3
0
mirror of https://github.com/triqs/dft_tools synced 2024-10-31 11:13:46 +01:00

Update readElkfiles.py

During the Elk conversion process, two files, SYMCRYS.OUT and LATTICE.OUT, need to be read. However, after the Elk calculation is completed, there are some blank lines in these files, which leads to recognition failure of readElkfiles.py.  By using line.strip(), non-blank lines can be directly read.
This commit is contained in:
Xiao Jiang 2024-09-04 17:19:56 +08:00 committed by Alexander Hampel
parent f3a0d611ff
commit dcb47d6e27

View File

@ -98,20 +98,21 @@ class readElkfiles:
if not(os.path.exists(filename)): if not(os.path.exists(filename)):
raise IOError("File %s does not exist." % filename) raise IOError("File %s does not exist." % filename)
for line in open(filename, 'r'): for line in open(filename, 'r'):
for old, new in to_replace.items(): if line.strip():
line = line.replace(old, new) for old, new in to_replace.items():
# removes the substring after '(' character - if it exists line = line.replace(old, new)
if "(" in line: # removes the substring after '(' character - if it exists
line = self.split_string2(line,'(') if "(" in line:
# removes the substring after '+' character - if it exists line = self.split_string2(line,'(')
if "+" in line: # removes the substring after '+' character - if it exists
line = self.split_string2(line,'+') if "+" in line:
# removes the substring after '|' character - if it exists line = self.split_string2(line,'+')
if "|" in line: # removes the substring after '|' character - if it exists
line = self.split_string2(line,'|') if "|" in line:
#only include lines which have multiple characters line = self.split_string2(line,'|')
if(len(line)>1): #only include lines which have multiple characters
yield line.split() if(len(line)>1):
yield line.split()
def split_string(self,line): def split_string(self,line):
""" """