Skip to content
Snippets Groups Projects
Commit c340a5a7 authored by Adam Fekete's avatar Adam Fekete
Browse files

backward compatibility for python 2

parent a7875b3e
Branches
Tags
No related merge requests found
......@@ -5,6 +5,8 @@ import os
import sys
import operator
# Python 2 compability
from io import open
from LammpsCommon import get_metaInfo
from nomadcore.caching_backend import CachingLevel
......@@ -608,7 +610,11 @@ class LammpsDataParserContext(object):
xyz_file.append(xyz_line)
atomLabelling.append(xyz_line)
with open(os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(sys.argv[1])), 'generated_from_data_file.xyz')), 'w', encoding = 'latin-1') as xyz:
mode = 'w'
if sys.version_info.major < 3:
mode += 'b'
with open(os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(sys.argv[1])), 'generated_from_data_file.xyz')), mode) as xyz:
xyz.writelines(' '.join(str(j) for j in i) + '\n' for i in xyz_file) # WRITE XYZ ATOMIC NUMBER AND COORDINATES
......@@ -689,7 +695,11 @@ class LammpsDataParserContext(object):
xyz_file.append(xyz_line)
atomLabelling.append(xyz_line)
with open(os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(sys.argv[1])), 'generated_from_data_file.xyz')), 'w', encoding = 'latin-1') as xyz:
mode = 'w'
if sys.version_info.major < 3:
mode += 'b'
with open(os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(sys.argv[1])), 'generated_from_data_file.xyz')), mode) as xyz:
xyz.writelines(' '.join(str(j) for j in i) + '\n' for i in xyz_file) # WRITE XYZ ATOMIC NUMBER AND COORDINATES
return charge_dict, charge_list, mass_dict, mass_list, mass_xyz, new_mass_list, atomLabelling
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment