diff --git a/lnt/formats/PlistFormat.py b/lnt/formats/PlistFormat.py --- a/lnt/formats/PlistFormat.py +++ b/lnt/formats/PlistFormat.py @@ -3,15 +3,27 @@ def _matches_format(path_or_file): try: - plistlib.load(path_or_file) + if isinstance(path_or_file, str): + with open(path_or_file, 'rb') as fp: + plistlib.load(fp) + else: + plistlib.load(path_or_file) return True except Exception: return False +def _load_format(path_or_file): + if isinstance(path_or_file, str): + with open(path_or_file, 'rb') as fp: + return plistlib.load(fp) + else: + return plistlib.load(path_or_file) + + format = { 'name': 'plist', 'predicate': _matches_format, - 'read': plistlib.load, + 'read': _load_format, 'write': plistlib.dump, }