From fdf73dadf06052dcbe105a7cadbbeea724a03819 Mon Sep 17 00:00:00 2001 From: jevans Date: Mon, 17 Jun 2013 18:23:28 -0400 Subject: [PATCH] Added 'glymur.data.nemo()'. Closes #20 --- docs/source/how_do_i.rst | 9 +++------ glymur/__init__.py | 2 +- glymur/jp2k.py | 12 ++++-------- setup.py | 2 +- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/docs/source/how_do_i.rst b/docs/source/how_do_i.rst index d4a91bf..355ff14 100644 --- a/docs/source/how_do_i.rst +++ b/docs/source/how_do_i.rst @@ -9,9 +9,8 @@ Printing the Jp2k object should reveal the number of resolutions (look in the COD segment section), but you can take a shortcut by supplying -1 as the reduce level. :: - >>> import pkg_resources >>> import glymur - >>> file = pkg_resources.resource_filename(glymur.__name__, "data/nemo.jp2") + >>> file = glymur.data.nemo() >>> j = glymur.Jp2k(file) >>> thumbnail = j.read(reduce=-1) @@ -24,9 +23,8 @@ available. :: From within Python, it is as simple as printing the Jp2k object, i.e. :: - >>> import pkg_resources >>> from glymur import Jp2k - >>> file = pkg_resources.resource_filename(glymur.__name__, "data/nemo.jp2") + >>> file = glymur.data.nemo() >>> j = Jp2k(file) >>> print(j) @@ -40,9 +38,8 @@ Work with XMP UUIDs? ==================== The example JP2 file shipped with glymur has an XMP UUID. :: - >>> import pkg_resources >>> from glymur import Jp2k - >>> file = pkg_resources.resource_filename(glymur.__name__, "data/nemo.jp2") + >>> file = glymur.data.nemo() >>> j = Jp2k(file) >>> print(j.box[4]) UUID Box (uuid) @ (715, 2412) diff --git a/glymur/__init__.py b/glymur/__init__.py index cc8297d..6a7574e 100644 --- a/glymur/__init__.py +++ b/glymur/__init__.py @@ -1,7 +1,6 @@ """glymur - read, write, and interrogate JPEG 2000 files """ - def _glymurrc_fname(): """Return the path to the configuration file. @@ -88,4 +87,5 @@ _OPENJP2 = _config() from .jp2k import Jp2k from .jp2dump import jp2dump +from . import data from . import test diff --git a/glymur/jp2k.py b/glymur/jp2k.py index 2845cf3..af08c2b 100644 --- a/glymur/jp2k.py +++ b/glymur/jp2k.py @@ -197,8 +197,7 @@ class Jp2k(Jp2kBox): Examples -------- >>> import glymur - >>> import pkg_resources as pkg - >>> jfile = pkg.resource_filename(glymur.__name__, "data/nemo.jp2") + >>> jfile = glymur.data.nemo() >>> jp2 = glymur.Jp2k(jfile) >>> data = jp2.read(reduce=3) >>> from tempfile import NamedTemporaryFile @@ -430,8 +429,7 @@ class Jp2k(Jp2kBox): Examples -------- >>> import glymur - >>> import pkg_resources as pkg - >>> jfile = pkg.resource_filename(glymur.__name__, "data/nemo.jp2") + >>> jfile = glymur.data.nemo() >>> jp = glymur.Jp2k(jfile) >>> image = jp.read() >>> image.shape @@ -633,8 +631,7 @@ class Jp2k(Jp2kBox): Examples -------- >>> import glymur - >>> import pkg_resources as pkg - >>> jfile = pkg.resource_filename(glymur.__name__, "data/nemo.jp2") + >>> jfile = glymur.data.nemo() >>> jp = glymur.Jp2k(jfile) >>> components_lst = jp.read_bands(reduce=1) """ @@ -663,8 +660,7 @@ class Jp2k(Jp2kBox): Examples -------- >>> import glymur - >>> import pkg_resources as pkg - >>> jfile = pkg.resource_filename(glymur.__name__, "data/nemo.jp2") + >>> jfile = glymur.data.nemo() >>> jp = glymur.Jp2k(jfile) >>> codestream = jp.get_codestream() >>> print(codestream.segment[1]) diff --git a/setup.py b/setup.py index 4f32597..55d6668 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ kwargs = {'name': 'Glymur', 'author': 'John Evans', 'author_email': 'johnevans938 at gmail dot com', 'url': 'https://github.com/quintusdias/glymur', - 'packages': ['glymur', 'glymur.test', 'glymur.lib', + 'packages': ['glymur', 'glymur.data', 'glymur.test', 'glymur.lib', 'glymur.lib.test'], 'package_data': {'glymur': ['data/*.jp2']}, 'scripts': ['bin/jp2dump'],