Skip to content

Commit

Permalink
Merge af72ef1 into d004ef7
Browse files Browse the repository at this point in the history
  • Loading branch information
avmarchenko committed Jul 6, 2020
2 parents d004ef7 + af72ef1 commit 4e572be
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 8 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ install:
script:
- export PYTHONDONTWRITEBYTECODE=1
- pytest --doctest-modules -v --cov coveralls --cov-report term --cov=exa --cov-report xml
- if [[ ${TRAVIS_OS_NAME} == "linux" ]] && [[ ${TRAVIS_PULL_REQUEST} == false ]] && [[ ${TRAVIS_PULL_REQUEST_BRANCH} == "" ]] && [[ ${TRAVIS_BRANCH} == "master" ]]; then
- if [[ ${TRAVIS_OS_NAME} == "linux" ]] && [[ ${TRAVIS_PULL_REQUEST} == false ]] && [[ ${TRAVIS_PULL_REQUEST_BRANCH} == "" ]] && [[ ${TRAVIS_BRANCH} == "master" ]] && [[ ${PYTHONVER} == "3.8" ]]; then
rm -rf docs/source/*.txt;
SPHINX_APIDOC_OPTIONS=members,undoc-members,show-inheritance sphinx-apidoc -eM -s txt -o docs/source/ exa *test*;
travis-sphinx build;
Expand All @@ -70,7 +70,7 @@ after_success:
- coveralls
- bash <(curl -Ls https://coverage.codacy.com/get.sh) report --language Python -r coverage.xml
- bash <(curl -Ls https://coverage.codacy.com/get.sh) final
- if [[ ${TRAVIS_OS_NAME} == "linux" ]] && [[ ${TRAVIS_PULL_REQUEST} == false ]] && [[ ${TRAVIS_PULL_REQUEST_BRANCH} == "" ]] && [[ ${TRAVIS_BRANCH} == "master" ]]; then
- if [[ ${TRAVIS_OS_NAME} == "linux" ]] && [[ ${TRAVIS_PULL_REQUEST} == false ]] && [[ ${TRAVIS_PULL_REQUEST_BRANCH} == "" ]] && [[ ${TRAVIS_BRANCH} == "master" ]] && [[ ${PYTHONVER} == "3.8" ]]; then
travis-sphinx deploy;
fi
- if [[ ${TRAVIS_OS_NAME} == "linux" ]] && [[ ${TRAVIS_PULL_REQUEST} == false ]] && [[ ${TRAVIS_PULL_REQUEST_BRANCH} == "" ]] && [[ ${TRAVIS_BRANCH} == "master" ]]; then
Expand All @@ -82,10 +82,10 @@ after_success:
sed -i "s/version = .* /version = \"${ver}\"/" meta.yaml;
cat meta.yaml;
printf "[distutils]\nindex-servers =\n pypi\n testpypi\n\n[pypi]\nrepository = https://upload.pypi.org/legacy/\nusername = __token__\npassword = ${pypi}\n\n[testpypi]\nrepository = https://test.pypi.org/legacy/\nusername = __token__\npassword = ${testpypi}" > ${HOME}/.pypirc;
python setup.py sdist bdist_wheel;
python setup.py sdist;
python -m twine upload --repository pypi dist/*;
conda build .;
conda convert -f --platform all ${HOME}/miniconda/envs/test/conda-bld/linux-64/exa-${ver}-${pyver}_0.tar.bz2 -o dist1/;
conda convert -f -p osx-64,linux-32,win-32,win-64 ${HOME}/miniconda/envs/test/conda-bld/linux-64/exa-${ver}-${pyver}_0.tar.bz2 -o dist1/;
ls -lisah dist1;
anaconda login --username ${anaconda_username} --password ${anaconda_password};
anaconda upload ${HOME}/miniconda/envs/test/conda-bld/linux-64/exa-${ver}-${pyver}_0.tar.bz2;
Expand Down
2 changes: 1 addition & 1 deletion exa/static/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.18
0.5.19
2 changes: 1 addition & 1 deletion exa/util/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ def read_tarball(path, shortkey=False, classes=Editor):
cls = classes(name)
else:
raise TypeError("Wrong type for classes argument (with type {})".format(type(classes)))
editors[name] = cls(f, name=name)
editors[name] = cls(f.read().decode(), name=name)
return editors

27 changes: 27 additions & 0 deletions exa/util/tests/test_io.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015-2020, Exa Analytics Development Team
# Distributed under the terms of the Apache License 2.0
import tarfile
from os import remove, rmdir, path, makedirs
from tempfile import mkdtemp
from exa.util.io import read_tarball


def test_tarball():
tmpdir = mkdtemp()
archive_dir = path.join(tmpdir, "tmp")
makedirs(archive_dir)
with open(path.join(archive_dir, "file.txt"), "w") as f:
f.write("hello {value}")
archive = path.join(tmpdir, "tmp.tar.gz")
with tarfile.open(archive, "w:gz") as tar:
tar.add(archive_dir)
eds = read_tarball(archive, shortkey=True)
assert len(eds) == 1
ed = eds["file.txt"]
assert ed.variables == ["{value}"]
assert str(ed) == "hello {value}"
remove(path.join(archive_dir, "file.txt"))
remove(archive)
rmdir(path.join(tmpdir, "tmp"))
rmdir(tmpdir)
44 changes: 44 additions & 0 deletions exa/util/tests/test_utility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015-2020, Exa Analytics Development Team
# Distributed under the terms of the Apache License 2.0
from os import path
from tempfile import mkdtemp
from exa.util.utility import datetime_header, mkp, convert_bytes, get_internal_modules


def test_get_internal_modules():
lst = get_internal_modules()
assert len(lst) > 0
assert lst[0].__name__.startswith("exa")


def test_convert_bytes():
a, b = convert_bytes(2049)
assert a >= 2.0
assert b == "KiB"
a, b = convert_bytes(10000000)
assert a >= 9.5367
assert b == "MiB"
a, b = convert_bytes(10000000000)
assert a >= 9.3132
assert b == "GiB"
a, b = convert_bytes(10000000000000)
assert a >= 9.0949
assert b == "TiB"
a, b = convert_bytes(1000000000000000000)
assert a >= 888.1784
assert b == "PiB"
a, b = convert_bytes(1000000000000000000000)
assert a >= 867.3617
assert b == "EiB"


def test_mkp():
dir_ = mkdtemp()
pth = path.join(dir_, "tmp")
mkp(pth)
assert path.exists(pth)


def test_datetime_header():
assert isinstance(datetime_header(), str)
3 changes: 1 addition & 2 deletions exa/util/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def datetime_header(title=''):
return '\n'.join(('=' * 80, title + ': ' + str(datetime.now()), '=' * 80))


def mkp(*args, **kwargs):
def mkp(*args, mk=True):
"""
Generate a directory path, and create it if requested.
Expand All @@ -40,7 +40,6 @@ def mkp(*args, **kwargs):
Returns:
path (str): File or directory path
"""
mk = kwargs.pop('mk', False)
path = os.sep.join(list(args))
if mk:
while sep2 in path:
Expand Down

0 comments on commit 4e572be

Please sign in to comment.