Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added python 2.6 backward compatibility #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pexif.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def __init__(self, marker, fd, data, mode):
self.data = data
self.mode = mode
self.fd = fd
self.code = jpeg_markers.get(self.marker, ('Unknown-{}'.format(self.marker), None))[0]
self.code = jpeg_markers.get(self.marker, ('Unknown-{0}'.format(self.marker), None))[0]
assert mode in ["rw", "ro"]
if self.data is not None:
self.parse_data(data)
Expand Down Expand Up @@ -304,19 +304,19 @@ def __setattr__(self, name, value):
for key, entry in self.embedded_tags.items():
if entry[0] == name:
if not isinstance(value, entry[1]):
raise TypeError("Values assigned to '{}' must be instances of {}".format(entry[0], entry[1]))
raise TypeError("Values assigned to '{0}' must be instances of {1}".format(entry[0], entry[1]))
self[key] = value
return

raise AttributeError("Invalid attribute '{}'".format(name))
raise AttributeError("Invalid attribute '{0}'".format(name))

def __delattr__(self, name):
for key, entry in self.tags.items():
if entry[1] == name:
del self[key]
break
else:
raise AttributeError("Invalid attribute '{}'".format(name))
raise AttributeError("Invalid attribute '{0}'".format(name))

def __getattr__(self, name):
for key, entry in self.tags.items():
Expand Down Expand Up @@ -367,7 +367,7 @@ def __setitem__(self, key, value):
return self.__setattr__(key, value)
found = 0
if len(self.tags[key]) < 3:
msg = "Error: Tags aren't set up correctly. Tag: {:x}:{} should have tag type."
msg = "Error: Tags aren't set up correctly. Tag: {0:x}:{1} should have tag type."
raise Exception(msg.format(key, self.tags[key]))
if self.tags[key][2] == ASCII:
if value is not None and not value.endswith('\0'):
Expand Down