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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Crawler
Merge requests
!13
F refactor main
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
F refactor main
f-refactor-main
into
dev
Overview
0
Commits
1
Pipelines
0
Changes
1
Merged
Alexander Schlemmer
requested to merge
f-refactor-main
into
dev
3 years ago
Overview
0
Commits
1
Pipelines
0
Changes
1
This makes testing much easier. See also:
!11 (closed)
0
0
Merge request reports
Compare
dev
dev (base)
and
latest version
latest version
25f76a10
1 commit,
3 years ago
1 file
+
35
−
11
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
src/newcrawler/crawl.py
+
35
−
11
View file @ 25f76a10
Edit in single-file editor
Open in Web IDE
Show full file
@@ -893,15 +893,21 @@ class Crawler(object):
return
self
.
updateList
def
main
():
args
=
parse_args
()
crawler
=
Crawler
(
debug
=
args
.
debug
)
crawler
.
crawl_directory
(
args
.
path
,
args
.
cfood
)
if
args
.
provenance
is
not
None
:
crawler
.
save_debug_data
(
args
.
provenance
)
if
args
.
load_identifiables
is
not
None
:
with
open
(
args
.
load_identifiables
,
"
r
"
)
as
f
:
def
crawler_main
(
args_path
,
args_cfood
,
args_load_identifiables
,
args_debug
,
args_provenance
,
args_dry_sync
,
args_sync
,
args_prefix
):
crawler
=
Crawler
(
debug
=
args_debug
)
crawler
.
crawl_directory
(
args_path
,
args_cfood
)
if
args_provenance
is
not
None
:
crawler
.
save_debug_data
(
args_provenance
)
if
args_load_identifiables
is
not
None
:
with
open
(
args_load_identifiables
,
"
r
"
)
as
f
:
identifiable_data
=
yaml
.
safe_load
(
f
)
ident
=
CaosDBIdentifiableAdapter
()
@@ -914,7 +920,7 @@ def main():
rt
.
add_property
(
name
=
pn
)
ident
.
register_identifiable
(
k
,
rt
)
if
args
.
dry_sync
:
if
args
_
dry_sync
:
ins
,
upd
=
crawler
.
synchronize
(
commit_changes
=
False
)
inserts
=
[
str
(
i
)
for
i
in
ins
]
updates
=
[
str
(
i
)
for
i
in
upd
]
@@ -922,12 +928,14 @@ def main():
f
.
write
(
yaml
.
dump
({
"
insert
"
:
inserts
,
"
update
"
:
updates
}))
elif
args
.
sync
:
elif
args
_
sync
:
rtsfinder
=
dict
()
for
elem
in
crawler
.
updateList
:
if
isinstance
(
elem
,
db
.
File
):
# correct the file path:
# elem.file = os.path.join(args.path, elem.file)
if
elem
.
path
.
startswith
(
args_prefix
):
elem
.
path
=
elem
.
path
[
len
(
args_prefix
):]
elem
.
file
=
None
# TODO: as long as the new file backend is not finished
# we are using the loadFiles function to insert symlinks.
@@ -982,8 +990,24 @@ def parse_args():
help
=
"
Do the synchronization. This is probably the expected
"
"
standard behavior of the crawler.
"
)
parser
.
add_argument
(
"
-p
"
,
"
--prefix
"
,
help
=
"
Remove the given prefix from the paths
"
"
of all file objects.
"
)
return
parser
.
parse_args
()
def
main
():
args
=
parse_args
()
return
crawler_main
(
args
.
path
,
args
.
cfood
,
args
.
load_identifiables
,
args
.
debug
,
args
.
provenance
,
args
.
dry_sync
,
args
.
sync
,
args
.
prefix
)
if
__name__
==
"
__main__
"
:
sys
.
exit
(
main
())
Loading