Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CaosDB Crawler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Crawler
Commits
ee62664e
Commit
ee62664e
authored
1 year ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
DOC: Documentation of add_prefix and remove_prefix added.
parent
7218f73c
No related branches found
No related tags found
2 merge requests
!160
STY: styling
,
!127
More documentation (docstrings) of parameters add/remove_prefix and restricted_path
Pipeline
#39817
passed with warnings
1 year ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caoscrawler/crawl.py
+24
-4
24 additions, 4 deletions
src/caoscrawler/crawl.py
with
24 additions
and
4 deletions
src/caoscrawler/crawl.py
+
24
−
4
View file @
ee62664e
...
...
@@ -1165,11 +1165,29 @@ def _treat_deprecated_prefix(prefix, remove_prefix):
return
remove_prefix
def
_fix_file_paths
(
crawled_data
,
add_prefix
,
remove_prefix
):
"""
adjust the path according to add_/remove_prefix
def
_fix_file_paths
(
crawled_data
:
list
[
db
.
Entity
],
add_prefix
:
Optional
[
str
],
remove_prefix
:
Optional
[
str
]):
"""
Adjust the path according to add_/remove_prefix
Also remove the `file` attribute from File entities (because inserts need currently be done
by loadfiles.
Arguments:
------------
crawled_data: list[db.Entity]
A list of entities. This list will be searched for instances of db.File.
add_prefix: Optional[str]
If add_prefix is not None, the given prefix will be added in front of elem.path.
remove_prefix: Optional[str]
If remove_prefix is not None the given prefix will be removed from the front of
elem.path. In this case a RuntimeError will be raised if any path of a file does
not begin with
"
remove_prefix
"
.
"""
for
elem
in
crawled_data
:
if
isinstance
(
elem
,
db
.
File
):
...
...
@@ -1267,9 +1285,11 @@ def crawler_main(crawled_directory_path: str,
Traverse the data tree only along the given path. When the end of the given path
is reached, traverse the full tree as normal.
remove_prefix : Optional[str]
remove the given prefix from file paths
Remove the given prefix from file paths.
See docstring of
'
_fix_file_paths
'
for more details.
add_prefix : Optional[str]
add the given prefix to file paths
Add the given prefix to file paths.
See docstring of
'
_fix_file_paths
'
for more details.
Returns
-------
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment