diff --git a/CHANGELOG.md b/CHANGELOG.md index 312f1b1d9bf2d7e6fcc80fc2f2bc4c2ac10ac149..f88538c8b1d4bff0109f68847430aeb53e7a01e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,13 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ## ### Added ### -- caosdbignore; You can add one or more `.caosdbignore` files to the directory - structure that you want to make available in CaosDB and the run loadFiles. - The syntax is that of `.gitignore` files. For more information see `loadFiles` - section of the Crawler in the documentation. - Unauthorized inserts can now be cached. Note that the Crawler cannot postpone inserts but the Cache has the functionality now. +- caosdbignore; You can add one or more `.caosdbignore` files to the directory + structure that you want to make available in CaosDB and the run loadFiles. + The syntax is that of `.gitignore` files. For more information see `loadFiles` + section of the Crawler in the documentation. ### Changed ### diff --git a/src/caosadvancedtools/loadFiles.py b/src/caosadvancedtools/loadFiles.py index 982cb9f3de193a2bc31096a6832122b390c98832..210732aa2bd31b7f493af263df24cc3e7a56611b 100755 --- a/src/caosadvancedtools/loadFiles.py +++ b/src/caosadvancedtools/loadFiles.py @@ -51,10 +51,13 @@ def convert_size(size): def combine_ignore_files(caosdbignore, localignore, dirname=None): - """appends the contents of localignore to caosdbignore - and saves the result and returns the name + """appends the contents of localignore to caosdbignore and saves the result + and returns the name + """ - tmp = NamedTemporaryFile(delete=False, mode="w", dir=dirname, prefix=".caosdbignore") + + tmp = NamedTemporaryFile(delete=False, mode="w", + dir=dirname, prefix=".caosdbignore") with open(caosdbignore, "r") as base: tmp.write(base.read()) with open(localignore, "r") as local: @@ -64,9 +67,11 @@ def combine_ignore_files(caosdbignore, localignore, dirname=None): def compile_file_list(caosdbignore, localpath): - """creates a list of files - that contain all files under localpath except those excluded by caosdbignore + """creates a list of files that contain all files under localpath except + those excluded by caosdbignore + """ + from gitignore_parser import parse_gitignore matches = parse_gitignore(caosdbignore) current_ignore = caosdbignore @@ -89,7 +94,8 @@ def compile_file_list(caosdbignore, localpath): # create a new local ignore file if ".caosdbignore" in files: current_ignore = combine_ignore_files(current_ignore, - os.path.join(root, ".caosdbignore"), + os.path.join( + root, ".caosdbignore"), # due to the logic of gitignore_parser the file # has to be written to this folder dirname=root) @@ -105,9 +111,10 @@ def compile_file_list(caosdbignore, localpath): def create_re_for_file_list(files, localroot, remoteroot): - """creates a regular expression - that matches file paths contained in the files argument and all parent directories. - The prefix localroot is replaced by the prefix remoteroot. + """creates a regular expression that matches file paths contained in the + files argument and all parent directories. The prefix localroot is replaced + by the prefix remoteroot. + """ regexp = "" for fi in files: @@ -232,13 +239,15 @@ exclude is given preference over include. args = parser.parse_args() if args.caosdbignore and (args.exclude or args.include): - raise ValueError("Do not use a caosdbignore file and in- or exclude simultaneously!") + raise ValueError( + "Do not use a caosdbignore file and in- or exclude simultaneously!") if args.caosdbignore and not args.localpath: raise ValueError("To use caosdbignore you must supply a local path!") if args.localpath and (args.exclude or args.include): - raise ValueError("Do not use a localpath and in- or exclude simultaneously!") + raise ValueError( + "Do not use a localpath and in- or exclude simultaneously!") con = db.get_connection() con.timeout = float(args.timeout)