Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
python-common
Commits
afdd0937
Commit
afdd0937
authored
Jul 22, 2020
by
Markus Scheidgen
Browse files
Removed smart parser dep on old metainfo.
parent
cf843eda
Changes
3
Hide whitespace changes
Inline
Side-by-side
common/python/nomadcore/md_data_access/MDDataAccess.py
View file @
afdd0937
...
...
@@ -26,7 +26,12 @@ import MDAnalysis.core.universe as mda_u
import
MDAnalysis.coordinates
as
mda_c
import
panedr
import
parmed
as
pmd
import
pymolfile
as
pym
# this might not be available on all development systems, we still want to pass the import
# eventhough not all code will work
try
:
import
pymolfile
as
pym
except
:
pass
from
nomadcore.md_data_access
import
GromosTopoObjects
as
gto
from
nomadcore.md_data_access.GromosTopoObjects
import
get_zipType
,
get_fileExtensions
import
io
...
...
common/python/nomadcore/metainfo_storage/MetaInfoStorage.py
View file @
afdd0937
...
...
@@ -7,16 +7,6 @@ import re
import
ast
from
collections
import
namedtuple
import
metainfo
COMMON_META_INFO_PATH
=
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
metainfo
.
__file__
)),
"common.nomadmetainfo.json"
))
PUBLIC_META_INFO_PATH
=
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
metainfo
.
__file__
)),
"public.nomadmetainfo.json"
))
NOTEXCEPT
=
re
.
compile
(
r
'[a-cf-zA-CF-Z!\?,{}\[\]]'
)
def
is_number
(
val
):
...
...
@@ -756,25 +746,8 @@ class JsonMetaInfo(object):
Loads data and extracts values of items
with specified superNames
"""
def
__init__
(
self
,
*
args
):
self
.
jsonList
=
None
for
filepath
in
args
:
try
:
with
open
(
filepath
,
encoding
=
"utf-8"
)
as
f
:
jsonDict
=
json
.
load
(
f
)
except
:
logging
.
exception
(
"Error while loading file %s"
%
filepath
)
raise
typeStr
=
jsonDict
.
get
(
"type"
,
"nomad_meta_info_1_0"
)
typeRe
=
re
.
compile
(
r
"nomad_meta_info_(?P<major>[0-9]+)_(?P<minor>[0-9]+)$"
)
m
=
typeRe
.
match
(
typeStr
)
if
not
m
:
raise
Exception
(
"unexpected type '%s', expected nomad_meta_info_1_0"
%
typeStr
)
newJsonList
=
jsonDict
.
get
(
"metaInfos"
,[])
if
self
.
jsonList
:
self
.
jsonList
=
self
.
jsonList
+
newJsonList
else
:
self
.
jsonList
=
newJsonList
def
__init__
(
self
,
metainfo_env
):
self
.
jsonList
=
metainfo_env
.
to_legacy_dict
(
metainfo_env
.
packages
)[
'metaInfos'
]
def
attributes
(
self
,
sectionname
):
attributes
=
{}
...
...
@@ -889,7 +862,8 @@ if __name__ == "__main__":
'section_repository_info'
]}
jsonmetadata
=
JsonMetaInfo
(
COMMON_META_INFO_PATH
,
PUBLIC_META_INFO_PATH
)
from
nomad.datamodel.metainfo
import
m_env
jsonmetadata
=
JsonMetaInfo
(
m_env
)
updateDict
=
{
'startSection'
:
[[
'section_topology'
]],
...
...
common/python/nomadcore/smart_parser/SmartParserCommon.py
View file @
afdd0937
...
...
@@ -3,7 +3,6 @@ from nomadcore.unit_conversion.unit_conversion import convert_unit
from
nomadcore.caching_backend
import
CachingLevel
from
nomadcore.simple_parser
import
mainFunction
from
nomadcore.simple_parser
import
SimpleMatcher
as
SM
from
nomadcore.metainfo_storage.MetaInfoStorage
import
COMMON_META_INFO_PATH
,
PUBLIC_META_INFO_PATH
from
nomadcore.metainfo_storage
import
MetaInfoStorage
as
mStore
from
nomadcore.metainfo_storage.MetaInfoStorage
import
strcleaner
,
strisinstance
,
literal_eval
from
nomadcore.smart_parser.SmartParserDictionary
import
getDict_MetaStrInDict
,
getList_MetaStrInDict
,
get_unitDict
...
...
@@ -14,6 +13,8 @@ import os
import
re
import
io
from
nomad.metainfo.legacy
import
LegacyMetainfoEnvironment
@
contextmanager
def
open_section
(
parser
,
name
):
gid
=
parser
.
openSection
(
name
)
...
...
@@ -45,10 +46,7 @@ def conv_float(n, default=None):
return
None
def
get_metaInfo
(
self
):
metaInfoEnv
,
warnings
=
loadJsonFile
(
filePath
=
self
.
META_INFO_PATH
,
dependencyLoader
=
None
,
extraArgsHandling
=
InfoKindEl
.
ADD_EXTRA_ARGS
,
uri
=
None
)
metaInfoEnv
=
LegacyMetainfoEnvironment
.
from_legacy_package_path
(
self
.
META_INFO_PATH
)
metaInfoEnv
=
set_section_metaInfoEnv
(
self
.
PARSERTAG
,
metaInfoEnv
,
self
.
sectionDict
)
metaInfoEnv
=
setDict_metaInfoEnv
(
metaInfoEnv
,
self
.
metaDicts
)
return
metaInfoEnv
...
...
@@ -170,11 +168,7 @@ class ParserBase(object):
]}
self
.
META_INFO_PATH
=
metainfopath
PARSER_INFO_DEFAULT
=
parserinfodef
jsonmetadata
=
mStore
.
JsonMetaInfo
(
COMMON_META_INFO_PATH
,
PUBLIC_META_INFO_PATH
,
self
.
META_INFO_PATH
)
jsonmetadata
=
mStore
.
JsonMetaInfo
(
LegacyMetainfoEnvironment
.
from_legacy_package_path
(
metainfopath
))
self
.
metaStorage
.
build
(
jsonmetadata
,
'section_run'
,
exclude_dict
)
self
.
metaStorageRestrict
.
build
(
jsonmetadata
,
'section_restricted_uri'
,
exclude_dict
)
self
.
re_program_name
=
re_program_name
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment