Skip to content

Commit

Permalink
Support Python 2.6, fixes #27
Browse files Browse the repository at this point in the history
  • Loading branch information
sbraz committed Jul 20, 2016
1 parent ac5a3c9 commit 8ee9c10
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: python
python:
- 2.6
- 2.7
- 3.4
- 3.5
Expand Down
7 changes: 4 additions & 3 deletions pymediainfo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def parse_xml_data_into_dom(xml_data):
@staticmethod
def parse(filename):
if os.name in ("nt", "dos", "os2", "ce"):
lib = windll.MediaInfo
lib = windll.MediaInfo
elif sys.platform == "darwin":
try:
lib = CDLL("libmediainfo.0.dylib")
Expand Down Expand Up @@ -96,7 +96,7 @@ def parse(filename):
# Fix for https://github.com/sbraz/pymediainfo/issues/22
# Python 2 does not change LC_CTYPE
# at startup: https://bugs.python.org/issue6203
if (sys.version_info.major < 3 and os.name == "posix"
if (sys.version_info < (3,) and os.name == "posix"
and locale.getlocale() == (None, None)):
locale.setlocale(locale.LC_CTYPE, locale.getdefaultlocale())
lib.MediaInfo_Option(None, "Inform", "XML")
Expand All @@ -110,7 +110,8 @@ def parse(filename):
def _populate_tracks(self):
if self.xml_dom is None:
return
for xml_track in self.xml_dom.iter("track"):
iterator = "getiterator" if sys.version_info < (2, 7) else "iter"
for xml_track in getattr(self.xml_dom, iterator)("track"):
self._tracks.append(Track(xml_track))
@property
def tracks(self):
Expand Down

0 comments on commit 8ee9c10

Please sign in to comment.