|
|
@ -61,13 +61,14 @@ def extract(txt, begin, end, pos=0):
|
|
|
|
except ValueError:
|
|
|
|
except ValueError:
|
|
|
|
return None, pos
|
|
|
|
return None, pos
|
|
|
|
|
|
|
|
|
|
|
|
def extract_all(txt, begin, end, pos=0):
|
|
|
|
def extract_all(txt, rules, pos=0):
|
|
|
|
try:
|
|
|
|
"""Calls extract for each rule and returns the result in a dict"""
|
|
|
|
first = txt.index(begin, pos)
|
|
|
|
values = {}
|
|
|
|
last = txt.index(end, first + len(begin)) + len(end)
|
|
|
|
for key, begin, end in rules:
|
|
|
|
return txt[first:last], last
|
|
|
|
result, pos = extract(txt, begin, end, pos)
|
|
|
|
except ValueError:
|
|
|
|
if key:
|
|
|
|
return None, pos
|
|
|
|
values[key] = result
|
|
|
|
|
|
|
|
return values, pos
|
|
|
|
|
|
|
|
|
|
|
|
if platform.system() == "Windows":
|
|
|
|
if platform.system() == "Windows":
|
|
|
|
clean_path = clean_path_windows
|
|
|
|
clean_path = clean_path_windows
|
|
|
|