Commit 3582b096 authored by Mohamed, Fawzi Roberto (fawzi)'s avatar Mohamed, Fawzi Roberto (fawzi)
Browse files

python3: futurize stage2

parent b1ef5b11
from builtins import str
from builtins import object
import numpy as np import numpy as np
import logging import logging
from collections import defaultdict from collections import defaultdict
......
from builtins import next
from builtins import range
import os import os
import re import re
import logging import logging
...@@ -31,7 +33,7 @@ class CP2KParser(ParserInterface): ...@@ -31,7 +33,7 @@ class CP2KParser(ParserInterface):
version_id = None version_id = None
run_type = None run_type = None
with open(self.parser_context.main_file, 'r') as outputfile: with open(self.parser_context.main_file, 'r') as outputfile:
for i_line in xrange(n_lines): for i_line in range(n_lines):
line = next(outputfile) line = next(outputfile)
result_version = regex_version.match(line) result_version = regex_version.match(line)
result_run_type = regex_run_type.match(line) result_run_type = regex_run_type.match(line)
......
...@@ -13,11 +13,13 @@ the object can be queried for the results, or the default values defined by the ...@@ -13,11 +13,13 @@ the object can be queried for the results, or the default values defined by the
cp2k_input.xml. cp2k_input.xml.
""" """
from __future__ import print_function from __future__ import print_function
from future import standard_library
standard_library.install_aliases()
import xml.etree.cElementTree as ET import xml.etree.cElementTree as ET
import logging import logging
import json import json
import cPickle as pickle import pickle
from cp2kparser.generic.inputparsing import * from cp2kparser.generic.inputparsing import *
logger = logging logger = logging
...@@ -217,9 +219,9 @@ def generate_metainfo_recursively(obj, parent, container, name_stack): ...@@ -217,9 +219,9 @@ def generate_metainfo_recursively(obj, parent, container, name_stack):
if isinstance(obj, Section): if isinstance(obj, Section):
name_stack.append(obj.name) name_stack.append(obj.name)
json = generate_section_metainfo_json(obj, parent, name_stack) json = generate_section_metainfo_json(obj, parent, name_stack)
for child in obj.sections.itervalues(): for child in obj.sections.values():
generate_metainfo_recursively(child[0], obj, container, name_stack) generate_metainfo_recursively(child[0], obj, container, name_stack)
for child in obj.keywords.itervalues(): for child in obj.keywords.values():
generate_metainfo_recursively(child[0], obj, container, name_stack) generate_metainfo_recursively(child[0], obj, container, name_stack)
if obj.section_parameter is not None: if obj.section_parameter is not None:
generate_metainfo_recursively(obj.section_parameter, obj, container, name_stack) generate_metainfo_recursively(obj.section_parameter, obj, container, name_stack)
......
from __future__ import absolute_import from __future__ import absolute_import
from builtins import str
from builtins import object
import re import re
import numpy as np import numpy as np
import logging import logging
......
from __future__ import print_function from __future__ import print_function
from __future__ import absolute_import from __future__ import absolute_import
from builtins import next
from builtins import range
from nomadcore.simple_parser import SimpleMatcher as SM from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.baseclasses import MainHierarchicalParser from nomadcore.baseclasses import MainHierarchicalParser
from .commonmatcher import CommonMatcher from .commonmatcher import CommonMatcher
......
from future import standard_library
standard_library.install_aliases()
from builtins import object
import os import os
import re import re
import logging import logging
import cPickle as pickle import pickle
import numpy as np import numpy as np
from nomadcore.baseclasses import BasicParser from nomadcore.baseclasses import BasicParser
from cp2kparser.generic.inputparsing import * from cp2kparser.generic.inputparsing import *
...@@ -435,7 +438,7 @@ class CP2KInputParser(BasicParser): ...@@ -435,7 +438,7 @@ class CP2KInputParser(BasicParser):
self.backend.addValue(name, default_keyword.value) self.backend.addValue(name, default_keyword.value)
# Subsections # Subsections
for name, subsections in section.sections.iteritems(): for name, subsections in section.sections.items():
for subsection in subsections: for subsection in subsections:
self.fill_metadata_recursively(subsection, name_stack) self.fill_metadata_recursively(subsection, name_stack)
......
from __future__ import absolute_import from __future__ import absolute_import
from builtins import next
from builtins import range
import numpy as np import numpy as np
from nomadcore.simple_parser import SimpleMatcher as SM from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.baseclasses import MainHierarchicalParser from nomadcore.baseclasses import MainHierarchicalParser
......
...@@ -672,7 +672,7 @@ class TestGeoOptTrajectory(unittest.TestCase): ...@@ -672,7 +672,7 @@ class TestGeoOptTrajectory(unittest.TestCase):
systems = results["section_system"] systems = results["section_system"]
i_conf = 0 i_conf = 0
for calc in single_conf.itervalues(): for calc in single_conf.values():
system_index = calc["single_configuration_calculation_to_system_ref"][0] system_index = calc["single_configuration_calculation_to_system_ref"][0]
system = systems[system_index] system = systems[system_index]
pos = system["atom_positions"] pos = system["atom_positions"]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment