diff --git a/.travis.yml b/.travis.yml index 95cd240dc7f2891c7835458b3f9a81f93110dacb..022c6626ec1e10c3ace5799f1fc65b24c06286e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,13 +20,13 @@ install: # We do this conditionally because it saves us some downloading if the # version is the same. - if [ "$TRAVIS_OS_NAME" == "linux" ]; then - if [ "$PYTHON_VERSION" == "2.7" ]; then + if [ "$PYTHON_VERSION" == 2.7 ]; then wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh; else wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; fi else - if ["$PYTHON_VERSION" == "2.7"]; then + if ["$PYTHON_VERSION" == 2.7]; then curl -o miniconda.sh https://repo.continuum.io/miniconda/Miniconda-latest-MacOSX-x86_64.sh; else curl -o miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh; diff --git a/conda/meta.yaml b/conda/meta.yaml index c0f1d40f06d8ad73a9b009bc9805f48e7493327c..08523fa178075ebb9be9e4e9e21319cab176a844 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -12,6 +12,7 @@ requirements: - pvl - protobuf 3.0.0b2 - gdal >=2 + - icu - h5py - pandas - sqlalchemy @@ -22,6 +23,7 @@ requirements: - pvl - protobuf 3.0.0b2 - gdal >=2 + - icu - h5py - pandas - sqlalchemy diff --git a/plio/examples/Apollo15/pngs.lis b/plio/examples/Apollo15/pngs.lis new file mode 100644 index 0000000000000000000000000000000000000000..6ab84beba5fdba22cd4764d9ff8cc7081885264d --- /dev/null +++ b/plio/examples/Apollo15/pngs.lis @@ -0,0 +1,6 @@ +AS15-M-0295_SML.png +AS15-M-0296_SML.png +AS15-M-0297_SML.png +AS15-M-0298_SML.png +AS15-M-0299_SML.png +AS15-M-0300_SML.png \ No newline at end of file diff --git a/plio/io_utils.py b/plio/io_utils.py deleted file mode 100644 index 5ec884bad549a38095a66f4bbaddfeb9998e0321..0000000000000000000000000000000000000000 --- a/plio/io_utils.py +++ /dev/null @@ -1,35 +0,0 @@ -import shutil -import tempfile - - -def create_dir(basedir=''): - """ - Create a unique, temporary directory in /tmp where processing will occur - - Parameters - ---------- - basedir : str - The PATH to create the temporary directory in. - """ - return tempfile.mkdtemp(dir=basedir) - - -def delete_dir(dir): - """ - Delete a directory - - Parameters - ---------- - dir : str - Remove a directory - """ - shutil.rmtree(dir) - - -def file_to_list(file): - with open(file, 'r') as f: - file_list = f.readlines() - file_list = map(str.rstrip, file_list) - file_list = filter(None, file_list) - - return file_list diff --git a/plio/tests/test_io_utils.py b/plio/tests/test_io_utils.py deleted file mode 100644 index e9105a6f4cc6b82c80889fc52a717708ee8cba63..0000000000000000000000000000000000000000 --- a/plio/tests/test_io_utils.py +++ /dev/null @@ -1,16 +0,0 @@ -import os -import unittest - -from .. import io_utils - -class TestIoUtils(unittest.TestCase): - - def setUp(self): - pass - - def test_create_and_destroy_directory(self): - path = io_utils.create_dir() - self.assertTrue(os.path.exists(path)) - io_utils.delete_dir(path) - self.assertFalse(os.path.exists(path)) - diff --git a/plio/tests/test_utils.py b/plio/tests/test_utils.py index 1f999c61c83cead16b502ca55b24c0492a8f2e71..0098c5ecabbd12eb5bb2af779f840c08a7917c8f 100644 --- a/plio/tests/test_utils.py +++ b/plio/tests/test_utils.py @@ -1,8 +1,9 @@ +import os import unittest +from ..examples import get_path from .. import utils - class TestUtils(unittest.TestCase): def test_find_in_dict(self): @@ -36,4 +37,19 @@ class TestUtils(unittest.TestCase): } self.assertEqual(utils.find_nested_in_dict(d, 'a'), 1) - self.assertEqual(utils.find_nested_in_dict(d, ['c', 'f', 'g']), 5) \ No newline at end of file + self.assertEqual(utils.find_nested_in_dict(d, ['c', 'f', 'g']), 5) + + + + def test_create_and_destroy_directory(self): + path = utils.create_dir() + self.assertTrue(os.path.exists(path)) + utils.delete_dir(path) + self.assertFalse(os.path.exists(path)) + + def test_file_to_list(self): + truth = ['AS15-M-0295_SML.png', 'AS15-M-0296_SML.png', + 'AS15-M-0297_SML.png', 'AS15-M-0298_SML.png', + 'AS15-M-0299_SML.png', 'AS15-M-0300_SML.png'] + + self.assertEqual(utils.file_to_list(get_path('pngs.lis')), truth) \ No newline at end of file diff --git a/plio/utils.py b/plio/utils.py index 365af3894684430db2de3fc2ccae89d1a1fbab85..1b97f2407fdb156262c44b39d2454890d793d4ea 100644 --- a/plio/utils.py +++ b/plio/utils.py @@ -3,6 +3,42 @@ import shutil import tempfile import os import fnmatch +import shutil +import tempfile + + +def create_dir(basedir=''): + """ + Create a unique, temporary directory in /tmp where processing will occur + + Parameters + ---------- + basedir : str + The PATH to create the temporary directory in. + """ + return tempfile.mkdtemp(dir=basedir) + + +def delete_dir(dir): + """ + Delete a directory + + Parameters + ---------- + dir : str + Remove a directory + """ + shutil.rmtree(dir) + + +def file_to_list(file): + with open(file, 'r') as f: + file_list = f.readlines() + file_list = map(str.rstrip, file_list) + file_list = filter(None, file_list) + + return list(file_list) + def create_dir(basedir=''): """ @@ -53,6 +89,7 @@ def file_search(searchdir,searchstring): return filelist + def find_in_dict(obj, key): """ Recursively find an entry in a dictionary @@ -98,6 +135,7 @@ def find_nested_in_dict(data, key_list): """ return reduce(lambda d, k: d[k], key_list, data) + def xstr(s): """ Return an empty string if the input is a NoneType. Otherwise