Skip to content

Commit 18c2008

Browse files
committed
New sample file added
1 parent 730abf3 commit 18c2008

File tree

3 files changed

+1131
-14
lines changed

3 files changed

+1131
-14
lines changed

melkit/toolkit.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,35 @@ def _read_object(self, id_regex: str) -> List[Object]:
3636
ids, objs = [], []
3737
with open(self._filename, 'r') as file:
3838
for line in file:
39-
id = search(id_regex, line)
40-
if id and id not in ids:
41-
if 'CV' in id_regex:
42-
objs.append(self.get_cv(id.group()[:-2]))
43-
elif 'FL' in id_regex:
44-
objs.append(self.get_fl(id.group()[:-2]))
45-
elif 'CF' in id_regex:
46-
objs.append(self.get_cf(id.group()[:-2]))
39+
line = line.lstrip()
40+
if not line.startswith('*'):
41+
id = search(id_regex, line)
42+
if id and id not in ids:
43+
if 'CV' in id_regex:
44+
objs.append(self.get_cv(id.group()[:-2]))
45+
elif 'FL' in id_regex:
46+
objs.append(self.get_fl(id.group()[:-2]))
47+
elif 'CF' in id_regex:
48+
objs.append(self.get_cf(id.group()[:-2]))
4749
return objs
4850

4951
def _read_cvs(self) -> List[CV]:
5052
'''
5153
Looks for CVs in the input file and returns them as a list of CV objects.
5254
'''
53-
return self._read_object(r'\s*\bCV\d{3}00\b')
55+
return self._read_object(r'\bCV\d{3}00\b')
5456

5557
def _read_fls(self) -> List[FL]:
5658
'''
5759
Looks for FLs in the input file and returns them as a list of FL objects.
5860
'''
59-
return self._read_object(r'\s*\bFL\d{3}00\b')
61+
return self._read_object(r'\bFL\d{3}00\b')
6062

6163
def _read_cfs(self) -> List[CF]:
6264
'''
6365
Looks for CFs in the input file and returns them as a list of CF objects.
6466
'''
65-
return self._read_object(r'\s*\bCF\d{3,8}00\b')
67+
return self._read_object(r'\bCF\d{3,8}00\b')
6668

6769
def get_cv(self, cv_id: str) -> CV:
6870
'''
@@ -280,7 +282,7 @@ def remove_object(self, obj_id: str, overwrite: bool = False, new_file: str = No
280282

281283
with open(src_file, 'r') as f1, open(new_file, 'w') as f2:
282284
for line in f1:
283-
if not line.startswith(obj_id):
285+
if not line.lstrip().startswith(obj_id):
284286
f2.write(line)
285287

286288
if overwrite:
@@ -343,7 +345,7 @@ def get_edf_vars(self) -> List[str]:
343345
keys = ['TIME']
344346
with open(self._filename, 'r') as file:
345347
for line in file:
346-
if match(r'\s*\bEDF\d{3}[A-Z][A-Z0-9]', line):
348+
if match(r'\bEDF\d{3}[A-Z][A-Z0-9]', line.lstrip()):
347349
keys.append(line.split()[1])
348350
return keys
349351

melkit/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.1
1+
0.3.2

0 commit comments

Comments
 (0)