Skip to content
Snippets Groups Projects
Commit eaa1e276 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

STY: docstrings and changelog

parent a61a52ab
No related branches found
No related tags found
2 merge requests!59FIX: if multiple updates for one entity exist, the retrieve would result in an...,!55ENH: include caosdbignore
......@@ -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 ###
......
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment