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
388930ab
Commit
388930ab
authored
3 years ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
ENH: cleaned up deubg tree and streamlined unit testing
parent
da94b3d0
No related branches found
No related tags found
1 merge request
!53
Release 0.1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/newcrawler/crawl.py
+5
-3
5 additions, 3 deletions
src/newcrawler/crawl.py
tests/test_tool.py
+29
-5
29 additions, 5 deletions
tests/test_tool.py
with
34 additions
and
8 deletions
src/newcrawler/crawl.py
+
5
−
3
View file @
388930ab
...
@@ -79,7 +79,9 @@ class FileSystemStructureElement(StructureElement):
...
@@ -79,7 +79,9 @@ class FileSystemStructureElement(StructureElement):
self
.
path
=
path
self
.
path
=
path
def
__str__
(
self
):
def
__str__
(
self
):
return
"
{}: {}, {}
"
.
format
(
self
.
__class__
,
self
.
name
,
self
.
path
)
class_name_short
=
str
(
self
.
__class__
).
replace
(
"
<class
\'
"
,
""
)[:
-
2
]
return
"
{}: {}, {}
"
.
format
(
class_name_short
,
self
.
name
,
self
.
path
)
class
Directory
(
FileSystemStructureElement
):
class
Directory
(
FileSystemStructureElement
):
pass
pass
...
@@ -389,7 +391,7 @@ class Crawler(object):
...
@@ -389,7 +391,7 @@ class Crawler(object):
self
.
debug
=
debug
self
.
debug
=
debug
if
self
.
debug
:
if
self
.
debug
:
self
.
debug_tree
=
dict
()
self
.
debug_tree
:
dict
[
str
,
tuple
]
=
dict
()
def
crawl_directory
(
self
,
dirname
:
str
,
def
crawl_directory
(
self
,
dirname
:
str
,
cfood
:
str
):
cfood
:
str
):
...
@@ -466,7 +468,7 @@ class Crawler(object):
...
@@ -466,7 +468,7 @@ class Crawler(object):
children
=
converter
.
create_children
(
generalStore_copy
,
element
)
children
=
converter
.
create_children
(
generalStore_copy
,
element
)
if
self
.
debug
:
if
self
.
debug
:
self
.
debug_tree
[
str
(
element
)]
=
(
self
.
debug_tree
[
str
(
element
)]
=
(
generalStore_copy
,
recordStore_copy
)
generalStore_copy
.
storage
,
recordStore_copy
.
storage
)
self
.
crawl
(
children
,
global_converters
,
converter
.
converters
,
self
.
crawl
(
children
,
global_converters
,
converter
.
converters
,
generalStore_copy
,
recordStore_copy
)
generalStore_copy
,
recordStore_copy
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_tool.py
+
29
−
5
View file @
388930ab
...
@@ -4,12 +4,36 @@
...
@@ -4,12 +4,36 @@
# A. Schlemmer, 06/2021
# A. Schlemmer, 06/2021
from
newcrawler
import
Crawler
from
newcrawler
import
Crawler
from
os.path
import
join
,
dirname
from
os.path
import
join
,
dirname
,
basename
import
yaml
def
rfp
(
*
pathcomponents
):
"""
Return full path.
Shorthand convenience function.
"""
return
join
(
dirname
(
__file__
),
*
pathcomponents
)
def
dircheckstr
(
*
pathcomponents
):
"""
Return the debug tree identifier for a given path.
"""
return
"
newcrawler.crawl.Directory:
"
+
basename
(
join
(
*
pathcomponents
))
+
"
,
"
+
rfp
(
"
test_directories
"
,
"
examples_article
"
,
*
pathcomponents
)
def
test_crawler
():
def
test_crawler
():
crawler
=
Crawler
(
debug
=
True
)
crawler
=
Crawler
(
debug
=
True
)
crawler
.
crawl_directory
(
join
(
dirname
(
__file__
),
"
test_directories/examples_article
"
),
crawler
.
crawl_directory
(
rfp
(
"
test_directories
"
,
"
examples_article
"
),
join
(
dirname
(
__file__
),
"
scifolder_cfood.yml
"
))
rfp
(
"
scifolder_cfood.yml
"
))
# debug_variables = dict()
# for k, v in crawler.debug_tree.items():
# debug_variables[k] = v[0]
# print(yaml.dump(debug_variables))
print
(
crawler
.
debug_tree
)
subd
=
crawler
.
debug_tree
[
dircheckstr
(
"
DataAnalysis
"
)]
assert
crawler
.
generalStore
[
"
date
"
]
==
"
test
"
assert
len
(
subd
)
==
2
assert
len
(
subd
[
0
])
==
0
subd
=
crawler
.
debug_tree
[
dircheckstr
(
"
DataAnalysis
"
,
"
2020_climate-model-predict
"
)]
assert
len
(
subd
[
0
])
==
2
assert
subd
[
0
][
"
date
"
]
==
"
2020
"
assert
subd
[
0
][
"
identifier
"
]
==
"
climate-model-predict
"
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