diff --git a/CHANGELOG.md b/CHANGELOG.md index 3432054f48495d106afdd2d3b24222f0bebf354a..c611b771b8723898ae2d46557f45c7520c8c1d61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - the restricted_path argument allows to crawl only a subtree - You can now access the file system path of a structure element (if it has one) using the variable name "<converter name>\_path" +- added the arguments 'add-prefix' and 'remove-prefix' to the command line and `crawler_main` ### Changed ### diff --git a/integrationtests/test_data/extroot/use_case_simple_presentation/cfood.yml b/integrationtests/test_data/extroot/use_case_simple_presentation/cfood.yml index da3c2dfe8276325c26607239071da3ccaf41a40c..3cf6124dedf2300fe82265de36b0be2bb070e77d 100644 --- a/integrationtests/test_data/extroot/use_case_simple_presentation/cfood.yml +++ b/integrationtests/test_data/extroot/use_case_simple_presentation/cfood.yml @@ -68,8 +68,8 @@ extroot: parents: - mdfile role: File - path: $DataFile - file: $DataFile + path: $DataFile_path + file: $DataFile_path Experiment: {} diff --git a/integrationtests/test_use_case_simple_presentation.py b/integrationtests/test_use_case_simple_presentation.py index ff2f2a43c5f4f923202218f5cd4eb89b82db04a7..4b006bd6d6e9b2d707b979f666edbba0967fc7a3 100644 --- a/integrationtests/test_use_case_simple_presentation.py +++ b/integrationtests/test_use_case_simple_presentation.py @@ -63,7 +63,7 @@ def test_complete_crawler( True, os.path.join(DATADIR, "provenance.yml"), False, - remove_prefix="/use_case_simple_presentation") + remove_prefix=os.path.abspath(DATADIR)) res = db.execute_query("FIND Record Experiment") assert len(res) == 1 diff --git a/src/caoscrawler/crawl.py b/src/caoscrawler/crawl.py index 60face1706dabbe40b78026d637154f5c97e13c4..8929161046504cdbaee14d548ba51e6fe3474a1b 100644 --- a/src/caoscrawler/crawl.py +++ b/src/caoscrawler/crawl.py @@ -1308,7 +1308,8 @@ def crawler_main(crawled_directory_path: str, elem.path = elem.path[len(remove_prefix):] else: raise RuntimeError("Prefix shall be removed from file path but the path " - "does not start with the prefix") + "does not start with the prefix:" + f"\n{remove_prefix}\n{elem.path}") if add_prefix: elem.path = add_prefix + elem.path elem.file = None