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
Commits
6239a47b
Commit
6239a47b
authored
2 years ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Plain Diff
Merge branch 'dev' into f-cfood-scalars
parents
f441e42b
8f624c26
No related branches found
No related tags found
2 merge requests
!53
Release 0.1
,
!45
Scalars in cfood definitions
Pipeline
#28985
passed with warnings
2 years ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+2
-1
2 additions, 1 deletion
CHANGELOG.md
src/caoscrawler/crawl.py
+10
-14
10 additions, 14 deletions
src/caoscrawler/crawl.py
with
12 additions
and
15 deletions
CHANGELOG.md
+
2
−
1
View file @
6239a47b
...
@@ -20,7 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
...
@@ -20,7 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
### Changed
*
Renamed module from
`newcrawler`
to
`caoscrawler`
*
MAINT: Renamed module from
`newcrawler`
to
`caoscrawler`
*
MAINT: Removed global converters from
`crawl.py`
### Deprecated
### Deprecated
...
...
This diff is collapsed.
Click to expand it.
src/caoscrawler/crawl.py
+
10
−
14
View file @
6239a47b
...
@@ -165,7 +165,6 @@ class Crawler(object):
...
@@ -165,7 +165,6 @@ class Crawler(object):
"""
"""
def
__init__
(
self
,
def
__init__
(
self
,
converters
:
List
[
Converter
]
=
[],
generalStore
:
Optional
[
GeneralStore
]
=
None
,
generalStore
:
Optional
[
GeneralStore
]
=
None
,
debug
:
bool
=
False
,
debug
:
bool
=
False
,
identifiableAdapter
:
IdentifiableAdapter
=
None
,
identifiableAdapter
:
IdentifiableAdapter
=
None
,
...
@@ -176,8 +175,6 @@ class Crawler(object):
...
@@ -176,8 +175,6 @@ class Crawler(object):
Parameters
Parameters
----------
----------
converters : List[Converter]
The set of converters used for this crawler.
recordStore : GeneralStore
recordStore : GeneralStore
An initial GeneralStore which might store e.g. environment variables.
An initial GeneralStore which might store e.g. environment variables.
debug : bool
debug : bool
...
@@ -197,7 +194,6 @@ class Crawler(object):
...
@@ -197,7 +194,6 @@ class Crawler(object):
"""
"""
# TODO: check if this feature is really needed
# TODO: check if this feature is really needed
self
.
global_converters
=
converters
self
.
identified_cache
=
IdentifiedCache
()
self
.
identified_cache
=
IdentifiedCache
()
self
.
recordStore
=
RecordStore
()
self
.
recordStore
=
RecordStore
()
...
@@ -409,8 +405,7 @@ class Crawler(object):
...
@@ -409,8 +405,7 @@ class Crawler(object):
continue
continue
elif
key
==
"
Converters
"
:
elif
key
==
"
Converters
"
:
continue
continue
converters
.
append
(
Converter
.
converter_factory
(
converters
.
append
(
Converter
.
converter_factory
(
value
,
key
,
converter_registry
))
value
,
key
,
converter_registry
))
return
converters
return
converters
...
@@ -448,12 +443,11 @@ class Crawler(object):
...
@@ -448,12 +443,11 @@ class Crawler(object):
crawler_definition
,
converter_registry
)
crawler_definition
,
converter_registry
)
# This recursive crawling procedure generates the update list:
# This recursive crawling procedure generates the update list:
self
.
target_data
:
List
[
db
.
Record
]
=
[]
self
.
target_data
:
List
[
db
.
Record
]
=
[]
self
.
_crawl
(
items
,
self
.
_crawl
(
items
,
local_converters
,
self
.
generalStore
,
self
.
global_converters
,
local_converters
,
self
.
generalStore
,
self
.
recordStore
,
self
.
recordStore
,
[],
[])
[],
[])
if
self
.
debug
:
if
self
.
debug
:
self
.
debug_converters
=
self
.
global_converters
+
local_converters
self
.
debug_converters
=
local_converters
return
self
.
target_data
return
self
.
target_data
...
@@ -947,7 +941,6 @@ ____________________\n""".format(i + 1, len(pending_changes)) + str(el[3]))
...
@@ -947,7 +941,6 @@ ____________________\n""".format(i + 1, len(pending_changes)) + str(el[3]))
f
.
write
(
yaml
.
dump
(
paths
,
sort_keys
=
False
))
f
.
write
(
yaml
.
dump
(
paths
,
sort_keys
=
False
))
def
_crawl
(
self
,
items
:
List
[
StructureElement
],
def
_crawl
(
self
,
items
:
List
[
StructureElement
],
global_converters
:
List
[
Converter
],
local_converters
:
List
[
Converter
],
local_converters
:
List
[
Converter
],
generalStore
:
GeneralStore
,
generalStore
:
GeneralStore
,
recordStore
:
RecordStore
,
recordStore
:
RecordStore
,
...
@@ -956,7 +949,7 @@ ____________________\n""".format(i + 1, len(pending_changes)) + str(el[3]))
...
@@ -956,7 +949,7 @@ ____________________\n""".format(i + 1, len(pending_changes)) + str(el[3]))
Crawl a list of StructureElements and apply any matching converters.
Crawl a list of StructureElements and apply any matching converters.
items: structure_elements (e.g. files and folders on one level on the hierarchy)
items: structure_elements (e.g. files and folders on one level on the hierarchy)
global_converters and
local_converters:
globally or
locally defined converters for
local_converters: locally defined converters for
treating structure elements. A locally defined converter could be
treating structure elements. A locally defined converter could be
one that is only valid for a specific subtree of the originally
one that is only valid for a specific subtree of the originally
cralwed StructureElement structure.
cralwed StructureElement structure.
...
@@ -964,7 +957,8 @@ ____________________\n""".format(i + 1, len(pending_changes)) + str(el[3]))
...
@@ -964,7 +957,8 @@ ____________________\n""".format(i + 1, len(pending_changes)) + str(el[3]))
global stores of the Crawler object.
global stores of the Crawler object.
"""
"""
for
element
in
items
:
for
element
in
items
:
for
converter
in
global_converters
+
local_converters
:
for
converter
in
local_converters
:
# type is something like "matches files", replace isinstance with "type_matches"
# type is something like "matches files", replace isinstance with "type_matches"
# match function tests regexp for example
# match function tests regexp for example
if
(
converter
.
typecheck
(
element
)
and
if
(
converter
.
typecheck
(
element
)
and
...
@@ -1006,7 +1000,7 @@ ____________________\n""".format(i + 1, len(pending_changes)) + str(el[3]))
...
@@ -1006,7 +1000,7 @@ ____________________\n""".format(i + 1, len(pending_changes)) + str(el[3]))
structure_elements_path
+
[
element
.
get_name
()],
structure_elements_path
+
[
element
.
get_name
()],
converters_path
+
[
converter
.
name
])
converters_path
+
[
converter
.
name
])
self
.
_crawl
(
children
,
global_converters
,
converter
.
converters
,
self
.
_crawl
(
children
,
converter
.
converters
,
generalStore_copy
,
recordStore_copy
,
generalStore_copy
,
recordStore_copy
,
structure_elements_path
+
[
element
.
get_name
()],
structure_elements_path
+
[
element
.
get_name
()],
converters_path
+
[
converter
.
name
])
converters_path
+
[
converter
.
name
])
...
@@ -1094,6 +1088,8 @@ def crawler_main(crawled_directory_path: str,
...
@@ -1094,6 +1088,8 @@ def crawler_main(crawled_directory_path: str,
if
isinstance
(
elem
,
db
.
File
):
if
isinstance
(
elem
,
db
.
File
):
# correct the file path:
# correct the file path:
# elem.file = os.path.join(args.path, elem.file)
# elem.file = os.path.join(args.path, elem.file)
if
prefix
is
None
:
raise
RuntimeError
(
"
No prefix set. Prefix must be set if files are used.
"
)
if
elem
.
path
.
startswith
(
prefix
):
if
elem
.
path
.
startswith
(
prefix
):
elem
.
path
=
elem
.
path
[
len
(
prefix
):]
elem
.
path
=
elem
.
path
[
len
(
prefix
):]
elem
.
file
=
None
elem
.
file
=
None
...
...
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