Merge branch 'issue49' into devel

This commit is contained in:
jevans 2013-06-17 20:37:09 -04:00
commit b12f17d2f2
5 changed files with 29 additions and 9 deletions

View file

@ -1,6 +1,7 @@
"""glymur - read, write, and interrogate JPEG 2000 files
"""
def _glymurrc_fname():
"""Return the path to the configuration file.
@ -61,7 +62,7 @@ def _config():
def _get_configdir():
"""Return string representing the configuration directory.
Default is $HOME/.config/glymur. You can override this with the
Default is $HOME/.config/glymur. You can override this with the
XDG_CONFIG_HOME environment variable.
"""

View file

@ -226,7 +226,7 @@ class Codestream:
def __str__(self):
msg = 'Codestream:\n'
for segment in self.segment:
strs = segment.__str__()
strs = str(segment)
# Add indentation
strs = [(' ' + x + '\n') for x in strs.split('\n')]

19
glymur/data/__init__.py Normal file
View file

@ -0,0 +1,19 @@
"""Shipping JPEG 2000 files.
There is only one JP2 file at the moment, "nemo.jp2", converted from the
original JPEG photo of the aftermath of NEMO, the nor'easter that shutdown
Boston in February of 2013.
"""
import pkg_resources
def nemo():
"""Shortcut for specifying path to nemo.jp2.
Returns
-------
file : str
Platform-independent path to nemo.jp2.
"""
file = pkg_resources.resource_filename(__name__, "nemo.jp2")
return file

View file

@ -532,7 +532,7 @@ class ContiguousCodestreamBox(Jp2kBox):
msg = Jp2kBox.__str__(self)
msg += '\n Main header:'
for segment in self.main_header.segment:
segstr = segment.__str__()
segstr = str(segment)
# Add indentation.
strs = [('\n ' + x) for x in segstr.split('\n')]
@ -760,7 +760,7 @@ class AssociationBox(Jp2kBox):
def __str__(self):
msg = Jp2kBox.__str__(self)
for box in self.box:
boxstr = box.__str__()
boxstr = str(box)
# Add indentation.
strs = [('\n ' + x) for x in boxstr.split('\n')]
@ -824,7 +824,7 @@ class JP2HeaderBox(Jp2kBox):
def __str__(self):
msg = Jp2kBox.__str__(self)
for box in self.box:
boxstr = box.__str__()
boxstr = str(box)
# Add indentation.
strs = [('\n ' + x) for x in boxstr.split('\n')]
@ -1177,7 +1177,7 @@ class ResolutionBox(Jp2kBox):
def __str__(self):
msg = Jp2kBox.__str__(self)
for box in self.box:
boxstr = box.__str__()
boxstr = str(box)
# Add indentation.
strs = [('\n ' + x) for x in boxstr.split('\n')]
@ -1554,7 +1554,7 @@ class UUIDInfoBox(Jp2kBox):
msg = Jp2kBox.__str__(self)
for box in self.box:
box_str = box.__str__()
box_str = str(box)
# Add indentation.
lst = [('\n ' + x) for x in box_str.split('\n')]

View file

@ -87,10 +87,10 @@ class Jp2k(Jp2kBox):
metadata = ['File: ' + os.path.basename(self.filename)]
if len(self.box) > 0:
for box in self.box:
metadata.append(box.__str__())
metadata.append(str(box))
else:
c = self.get_codestream()
metadata.append(c.__str__())
metadata.append(str(c))
return '\n'.join(metadata)
def _parse(self):