diff --git a/tibi_hardlinks/backup_parser.py b/tibi_hardlinks/backup_parser.py index 966fd64..7f8bb25 100644 --- a/tibi_hardlinks/backup_parser.py +++ b/tibi_hardlinks/backup_parser.py @@ -1,6 +1,8 @@ import re from dateutil.parser import parse as datetime_parse, ParserError import pytz +from pathlib import Path +from tibi_hardlinks.cache import tibi_cache tzinfos = {name: pytz.timezone(name) for name in pytz.all_timezones} @@ -22,3 +24,14 @@ def parse_property_text(text): value = match.group("value") properties[key] = value return properties + + +def read_backup_properties(property_file: Path): + cached_result = tibi_cache.read(property_file.name) + if cached_result is None: + with open(property_file) as backup_properties: + data = parse_property_text(backup_properties.read()) + tibi_cache.write(property_file.name, data) + return data + else: + return cached_result