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
233b8267
Commit
233b8267
authored
9 years ago
by
Himanen, Lauri (himanel1)
Browse files
Options
Downloads
Patches
Plain Diff
Added support for printing the parsed structure.
parent
42007c6e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/python/nomadcore/local_backend.py
+15
-9
15 additions, 9 deletions
common/python/nomadcore/local_backend.py
with
15 additions
and
9 deletions
common/python/nomadcore/local_backend.py
+
15
−
9
View file @
233b8267
...
...
@@ -7,12 +7,7 @@ logger = logging.getLogger(__name__)
#===============================================================================
class
LocalBackend
(
object
):
"""
A backend that outputs results into a regular python dictionary. This
backend is set up by the Analyzer class which gives it to the parser to use
as a backend.
TODO: Currently uses the metaname as key in the dictionary. This will cause
values with the same metaname to be placed in the same array.
"""
A backend that outputs results into a regular python dictionary.
"""
def
__init__
(
self
,
metaInfoEnv
,
fileOut
=
StringIO
.
StringIO
()):
self
.
__metaInfoEnv
=
metaInfoEnv
...
...
@@ -83,6 +78,7 @@ class LocalBackend(object):
# also gathered so that an informative prompt may be shown if an
# ambiguous metaname is searched.
results
=
self
.
results
.
_results
shortnames
=
self
.
results
.
_shortnames
clash_dict
=
self
.
results
.
_clash_dict
# Gather the clashing names
...
...
@@ -95,7 +91,7 @@ class LocalBackend(object):
n_longs
=
len
(
longs
)
if
n_longs
==
1
:
long_path
=
longs
[
0
]
result
s
[
short
]
=
results
[
long_path
]
shortname
s
[
short
]
=
results
[
long_path
]
#===============================================================================
...
...
@@ -138,6 +134,7 @@ class Results(object):
"""
def
__init__
(
self
,
metaInfoEnv
):
self
.
_results
=
defaultdict
(
list
)
self
.
_shortnames
=
defaultdict
(
list
)
self
.
_clash_dict
=
defaultdict
(
list
)
self
.
_metaInfoEnv
=
metaInfoEnv
...
...
@@ -160,7 +157,9 @@ class Results(object):
raise
LookupError
(
message
)
# Provide a simplified object if only one entry found
value
=
self
.
_results
[
metaname
]
value
=
self
.
_results
.
get
(
metaname
)
if
value
is
None
:
value
=
self
.
_shortnames
.
get
(
metaname
)
if
len
(
value
)
==
1
:
return
value
[
0
]
else
:
...
...
@@ -191,6 +190,13 @@ class Results(object):
self
.
test_validity
(
metaname
)
return
self
.
_metaInfoEnv
.
infoKinds
[
metaname
]
def
print_summary
(
self
):
"""
Return a string representing the data contained in the results. This
is a summary that can be used for debugging.
"""
for
key
,
value
in
self
.
_results
.
iteritems
():
print
key
+
"
: {}
"
.
format
(
value
)
#===============================================================================
class
Section
(
object
):
...
...
@@ -278,7 +284,7 @@ class Section(object):
path_string
+=
metaname
+
"
/
"
paths
.
append
(
path_string
)
# Add all the value with the long
and the short
path
# Add all the value with the long path
for
path
in
paths
:
for
metaname
,
value
in
self
.
simpleValues
.
iteritems
():
long_path
=
path
+
metaname
...
...
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