From e59b633a66d2670c24ad9373142a154e557ba416 Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Fri, 22 Nov 2024 22:32:53 +0100 Subject: [PATCH] Removed some debugging print statements --- bindings/python/dlite-collection.i | 4 ++++ bindings/python/dlite-jstore.i | 1 + bindings/python/dlite-misc-python.i | 4 ++-- src/tests/test_collection.c | 21 +-------------------- 4 files changed, 8 insertions(+), 22 deletions(-) diff --git a/bindings/python/dlite-collection.i b/bindings/python/dlite-collection.i index 771ea16f9..8fe5cef59 100644 --- a/bindings/python/dlite-collection.i +++ b/bindings/python/dlite-collection.i @@ -57,9 +57,13 @@ int dlite_collection_remove(struct _DLiteCollection *coll, const char *label); struct _DLiteInstance * dlite_collection_get_new(const struct _DLiteCollection *coll, const char *label, const char *metaid); + +// Although dlite_collection_get_id() returns a borrowed reference in C, +// we create a new object in Python that must be properly deallocated. %newobject dlite_collection_get_id; const struct _DLiteInstance * dlite_collection_get_id(const struct _DLiteCollection *coll, const char *id); + int dlite_collection_has(const struct _DLiteCollection *coll, const char *label); int dlite_collection_has_id(const struct _DLiteCollection *coll, diff --git a/bindings/python/dlite-jstore.i b/bindings/python/dlite-jstore.i index 155d03a1c..43bf05ef0 100644 --- a/bindings/python/dlite-jstore.i +++ b/bindings/python/dlite-jstore.i @@ -102,6 +102,7 @@ struct _JStore {}; } %feature("docstring", "Iterate over all id's matching pattern.") get_ids; + %newobject get_ids; struct _DLiteJStoreIter *get_ids(const char *pattern=NULL) { return dlite_jstore_iter_create($self, pattern); } diff --git a/bindings/python/dlite-misc-python.i b/bindings/python/dlite-misc-python.i index 5de269502..c93db9c54 100644 --- a/bindings/python/dlite-misc-python.i +++ b/bindings/python/dlite-misc-python.i @@ -81,8 +81,8 @@ class errctl(): return [_dlite._err_getcode(errname) for errname in errnames] -silent = errctl(filename="None") -"""Context manager for a silent code block. Same as `errctl(filename="None")`.""" +silent = errctl(hide=True) +"""Context manager for a silent code block. Same as `errctl(hide=True)`.""" # A set for keeping track of already issued deprecation warnings _deprecation_warning_record = set() diff --git a/src/tests/test_collection.c b/src/tests/test_collection.c index 19690f74a..0d02e7f78 100644 --- a/src/tests/test_collection.c +++ b/src/tests/test_collection.c @@ -238,30 +238,11 @@ MU_TEST(test_collection_load) { DLiteCollection *coll2; char *collpath = STRINGIFY(dlite_SOURCE_DIR) "/src/tests/coll.json"; - //DLiteStoragePathIter *iter; - //const char *path; - - dlite_storage_paths_append(STRINGIFY(dlite_SOURCE_DIR) "/src/tests/*.json"); - - //printf("\n\nStorage paths:\n"); - //iter = dlite_storage_paths_iter_start(); - //while ((path = dlite_storage_paths_iter_next(iter))) - // printf(" - %s\n", path); - //printf("\n"); - //dlite_storage_paths_iter_stop(iter); - FILE *fp = fopen(collpath, "r"); + dlite_storage_paths_append(STRINGIFY(dlite_SOURCE_DIR) "/src/tests/*.json"); coll2 = (DLiteCollection *) dlite_json_fscan(fp, NULL, "http://onto-ns.com/meta/0.1/Collection"); fclose(fp); - //printf("\n\n--- coll2: %p ---\n", (void *)coll2); - //dlite_json_print((DLiteInstance *)coll2); - //printf("----------------------\n"); - - const DLiteInstance *inst = dlite_collection_get(coll2, "inst"); - //printf("\n--- inst: %p ---\n", (void *)inst); - //dlite_json_print((DLiteInstance *)inst); - //printf("----------------------\n"); dlite_collection_decref(coll2); }