Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nomad-lab
python-common
Commits
62c6d3d8
Commit
62c6d3d8
authored
7 years ago
by
Lauri Himanen
Browse files
Options
Downloads
Patches
Plain Diff
Modified classes to take in the filepath in the parse()-function instead of the constructor.
parent
299ecfdd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/python/nomadcore/baseclasses.py
+7
-8
7 additions, 8 deletions
common/python/nomadcore/baseclasses.py
with
7 additions
and
8 deletions
common/python/nomadcore/baseclasses.py
+
7
−
8
View file @
62c6d3d8
...
...
@@ -182,7 +182,7 @@ class ParserInterface(with_metaclass(ABCMeta, object)):
if
not
self
.
main_parser
:
logger
.
error
(
"
The main parser has not been set up.
"
)
self
.
main_parser
.
parse
()
self
.
main_parser
.
parse
(
main_file
)
# If using a local backend, the results will have been saved to a
# separate results dictionary which should be returned.
...
...
@@ -310,8 +310,7 @@ class AbstractBaseParser(with_metaclass(ABCMeta, object)):
caching backend.
"""
def
__init__
(
self
,
file_path
,
parser_context
):
self
.
file_path
=
file_path
def
__init__
(
self
,
parser_context
):
self
.
parser_context
=
parser_context
self
.
backend
=
parser_context
.
caching_backend
self
.
super_backend
=
parser_context
.
super_backend
...
...
@@ -366,7 +365,7 @@ class AbstractBaseParser(with_metaclass(ABCMeta, object)):
self
.
super_backend
.
fileOut
.
write
(
"
]
\n
"
)
@abstractmethod
def
parse
(
self
):
def
parse
(
self
,
filepath
):
"""
Used to do the actual parsing. Inside this function you should push
the parsing results into the Caching backend, or directly to the
superBackend. You will also have to open new sections, but remember
...
...
@@ -398,20 +397,20 @@ class MainHierarchicalParser(AbstractBaseParser):
onClose triggers, SimpleMatchers, caching levels, etc.
"""
def
__init__
(
self
,
file_path
,
parser_context
):
def
__init__
(
self
,
parser_context
):
"""
Args:
file_path: Path to the main file as a string.
parser_context: The ParserContext object that contains various
in-depth information about the parsing environment.
"""
super
(
MainHierarchicalParser
,
self
).
__init__
(
file_path
,
parser_context
)
super
(
MainHierarchicalParser
,
self
).
__init__
(
parser_context
)
self
.
root_matcher
=
None
self
.
regexs
=
RegexService
()
self
.
cm
=
None
self
.
super_context
=
self
def
parse
(
self
):
def
parse
(
self
,
filepath
):
"""
Starts the parsing. By default uses the SimpleParser scheme, if you
want to use something else or customize the process just override this
method in the subclass.
...
...
@@ -429,7 +428,7 @@ class MainHierarchicalParser(AbstractBaseParser):
metainfo_units
=
self
.
parser_context
.
metainfo_units
,
superBackend
=
self
.
parser_context
.
super_backend
,
metaInfoToKeep
=
self
.
parser_context
.
metainfo_to_keep
,
mainFile
=
self
.
parser_context
.
main_
file
)
mainFile
=
file
path
)
def
startedParsing
(
self
,
fInName
,
parser
):
"""
Function is called when the parsing starts.
...
...
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