|
|
|
@ -1,4 +1,8 @@ |
|
|
|
import re |
|
|
|
from dateutil.parser import parse as datetime_parse, ParserError |
|
|
|
import pytz |
|
|
|
|
|
|
|
tzinfos = {name: pytz.timezone(name) for name in pytz.all_timezones} |
|
|
|
|
|
|
|
|
|
|
|
def parse_property_text(text): |
|
|
|
@ -6,6 +10,12 @@ def parse_property_text(text): |
|
|
|
key_value_regex = re.compile(r"(?P<key>^[^=]+)=(?P<value>.*)") |
|
|
|
lines = text.split("\n") |
|
|
|
for line in lines: |
|
|
|
if line.startswith("#"): |
|
|
|
try: |
|
|
|
time = datetime_parse(line.lstrip("#"), tzinfos=tzinfos) |
|
|
|
properties["backup_time"] = time.astimezone(pytz.UTC).timestamp() |
|
|
|
except ParserError: |
|
|
|
pass |
|
|
|
match = key_value_regex.match(line) |
|
|
|
if match: |
|
|
|
key = match.group("key") |
|
|
|
|