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
ab3f1431
Commit
ab3f1431
authored
1 year ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
DOC: improved docstring of the _for_each helper function
parent
3b50909a
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!178
FIX: #96 Better error output for crawl.py script.
,
!167
Sync Graph
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caoscrawler/sync_graph.py
+11
-3
11 additions, 3 deletions
src/caoscrawler/sync_graph.py
with
11 additions
and
3 deletions
src/caoscrawler/sync_graph.py
+
11
−
3
View file @
ab3f1431
...
@@ -44,16 +44,24 @@ logger = logging.getLogger(__name__)
...
@@ -44,16 +44,24 @@ logger = logging.getLogger(__name__)
def
_for_each_scalar_value
(
node
:
SyncNode
,
condition
:
Callable
[[
Any
],
bool
],
kind
:
str
,
def
_for_each_scalar_value
(
node
:
SyncNode
,
condition
:
Callable
[[
Any
],
bool
],
kind
:
str
,
value
:
Any
=
None
):
value
:
Callable
[[
Any
],
Any
]
=
None
):
"""
helper function that performs an action on each value element of each property of a node
"""
helper function that performs an action on each value element of each property of a node
The action (remove or set) is performed on each property value of each property: in case on
The argument
"
kind
"
determines which action is performed on each property value:
The action (remove or set) is performed on each property value of each property: in case of
lists, it is performed on each list element. The action is only performed if the condition that
lists, it is performed on each list element. The action is only performed if the condition that
is provided is fulfilled, i.e. the callable ``condition`` returns True. The callable
is provided is fulfilled, i.e. the callable ``condition`` returns True. The callable
``condition`` must take the property value (or list element) as the sole argument.
``condition`` must take the property value (or list element) as the sole argument.
Thus, with
"
remove
"
you can conditionally remove values and with
"
set
"
you can conditionally
Thus, with
"
remove
"
you can conditionally remove values and with
"
set
"
you can conditionally
replace values
replace values.
Args:
node (SyncNode): The node which provides the properties (and their values) to operate on.
condition (Callable): A function with one argument which is interpreted as a condition: Only if
it returns True for the property value, the action is executed.
kind (str): Either
"
remove
"
or
"
set
"
depending on whether you want to remove the property or replace the property.
value (Callable): A function returning a new value that is set as the property value. This function receives the old value as the single argument.
"""
"""
for
p
in
node
.
properties
:
for
p
in
node
.
properties
:
if
isinstance
(
p
.
value
,
list
):
if
isinstance
(
p
.
value
,
list
):
...
...
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