diff --git a/metadata.py b/metadata.py index 4cfbbb4d10fcf40bea461d5fc5fd7d56c375ac52..262736f4fc5bda494670b9e55b100a923e4889fe 100644 --- a/metadata.py +++ b/metadata.py @@ -138,13 +138,15 @@ class MetaData: with open(batch_script,'r') as file: data = file.readlines() + nlines = len(data) matched_lines = [iline for iline in range(nlines) if any(str_id in data[iline] for str_id in paths_to_mod)] # list of line-number indices to be modified for i in matched_lines: data[i] = add_str_to_path(data[i],self.exp_dir) + with open(batch_script,'w') as file: - file.writeslines(data) + file.writelines(data) def write_metadata_to_file(self,dest_dir = None): @@ -241,7 +243,8 @@ class MetaData: raise ValueError("Could not find the above mentioned variables.") else: pass - + + # ----------------------------------- end of class MetaData ----------------------------------- @@ -254,8 +257,8 @@ def add_str_to_path(path_in,add_str): Function is also capable to handle carriage returns for handling input-strings obtained by reading a file. """ - l_linebreak = line_str.endswith("\n") # flag for carriage return at the end of input string - line_str = line_str.rstrip("\n") + l_linebreak = path_in.endswith("\n") # flag for carriage return at the end of input string + line_str = path_in.rstrip("\n") if (not line_str.endswith(add_str)) or \ (not line_str.endswith(add_str.rstrip("/"))):