Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
RKrahl committed May 9, 2020
2 parents a619807 + 5f324d5 commit 64e7f53
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 48 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
*.pyc
*~
__pycache__/
/.env
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ python:
- "3.6"
- "3.7"
- "3.8"
install: pip install 'PyYAML' 'python-dateutil' 'pytest >=3.6.0' 'distutils-pytest' 'pytest-dependency >=0.2'
install: pip install -r .travis_require
script: make test

# Local Variables:
Expand Down
6 changes: 6 additions & 0 deletions .travis_require
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PyYAML <=5.2 ; python_version == '3.4'
PyYAML ; python_version > '3.4'
distutils-pytest
pytest >=3.6.0
pytest-dependency >=0.2
python-dateutil
13 changes: 11 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
History of changes to archive-tools
===================================
Changelog
=========

0.5 (2020-05-09)
New features
+ #45: The files argument to `archive-tool check` defaults to
the archive's basedir.

Bug fixes and minor changes
+ Fix: some test data have not been included in the source
distribution.

0.4 (2019-12-26)
New features
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ include tests/conftest.py
include tests/data/.sha256
include tests/data/legacy-1_0.tar.gz
include tests/data/mails.tar.gz
include tests/data/manifest.yaml
include tests/data/msg.txt
include tests/data/rnd.dat
include tests/data/rnd2.dat
include tests/pytest.ini
include tests/test_*.py
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PYTHON = python3
PYTHON = python3


build:
Expand All @@ -15,7 +15,6 @@ clean:
rm -rf build

distclean: clean
rm -f archive/*.pyc scripts/*.pyc tests/*.pyc
rm -rf archive/__pycache__ scripts/__pycache__ tests/__pycache__
rm -rf tests/.cache tests/.pytest_cache
rm -f MANIFEST .version
Expand Down
30 changes: 15 additions & 15 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
|travis| |pypi|

.. |travis| image:: https://img.shields.io/travis/com/RKrahl/archive-tools/master.svg
.. |travis| image:: https://img.shields.io/travis/com/RKrahl/archive-tools
:target: https://travis-ci.com/RKrahl/archive-tools
:alt: travis build status
:alt: Travis build status

.. |pypi| image:: https://img.shields.io/pypi/v/archive-tools.svg
.. |pypi| image:: https://img.shields.io/pypi/v/archive-tools
:target: https://pypi.org/project/archive-tools/
:alt: pypi version
:alt: PyPI version

Tools for managing archives
===========================
Expand Down Expand Up @@ -39,8 +39,10 @@ reading through the compressed tar archive.
Download
--------

The latest release version is available on PyPI, see
https://pypi.org/project/archive-tools/
The latest release version is available on the
`Python Package Index (PyPI)`__.

.. __: `PyPI site`_


System requirements
Expand All @@ -67,8 +69,8 @@ Optional library packages:

- date strings will lack time zone indication.

- the date formats recognized in the `--mtime` argument to
`archive-tool.py find` are reduced.
- the `--mtime` argument to `archive-tool.py find` recognizes a
reduced set of date formats.

+ `setuptools_scm`_

Expand Down Expand Up @@ -120,13 +122,10 @@ the site-packages directory of your Python installation.
Copyright and License
---------------------

Copyright 2019 Rolf Krahl

Licensed under the Apache License, Version 2.0 (the "License"); you
may not use this file except in compliance with the License. You may
obtain a copy of the License at
Copyright 2019–2020 Rolf Krahl

http://www.apache.org/licenses/LICENSE-2.0
Licensed under the `Apache License`_, Version 2.0 (the "License"); you
may not use this file except in compliance with the License.

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -135,7 +134,7 @@ implied. See the License for the specific language governing
permissions and limitations under the License.



.. _PyPI site: https://pypi.org/project/archive-tools/
.. _PyYAML: http://pyyaml.org/wiki/PyYAML
.. _imapclient: https://github.com/mjs/imapclient/
.. _python-dateutil: https://dateutil.readthedocs.io/en/stable/
Expand All @@ -144,3 +143,4 @@ permissions and limitations under the License.
.. _distutils-pytest: https://github.com/RKrahl/distutils-pytest
.. _pytest-dependency: https://pypi.python.org/pypi/pytest_dependency/
.. _Installing Python Modules: https://docs.python.org/3.7/install/
.. _Apache License: https://www.apache.org/licenses/LICENSE-2.0
9 changes: 6 additions & 3 deletions archive/cli/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ def check(args):
raise ArgError("can't accept both, --stdin and the files argument")
files = [Path(l.strip()) for l in sys.stdin]
else:
if not args.files:
raise ArgError("either --stdin or the files argument is required")
files = args.files
if args.files:
files = args.files
else:
files = None
with Archive().open(args.archive) as archive:
if files is None:
files = [ archive.basedir ]
metadata = { Path(md) for md in archive.manifest.metadata }
FileInfo.Checksums = archive.manifest.checksums
file_iter = FileInfo.iterpaths(files, set())
Expand Down
15 changes: 11 additions & 4 deletions python-archive-tools.spec
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
%bcond_with tests
%global distname archive-tools

Name: python3-archive-tools
Name: python3-%{distname}
Version: $version
Release: 0
Url: $url
Summary: $description
License: Apache-2.0
Group: Development/Libraries/Python
Source: archive-tools-%{version}.tar.gz
Source: %{distname}-%{version}.tar.gz
BuildRequires: python3-base >= 3.4
%if %{with tests}
BuildRequires: python3-PyYAML
Expand All @@ -24,28 +25,34 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
$long_description


%prep
%setup -q -n archive-tools-%{version}
%setup -q -n %{distname}-%{version}


%build
python3 setup.py build


%install
python3 setup.py install --optimize=1 --prefix=%{_prefix} --root=%{buildroot}
for f in `ls %{buildroot}%{_bindir}`
do
mv %{buildroot}%{_bindir}/$$f %{buildroot}%{_bindir}/$${f%%.py}
done


%if %{with tests}
%check
python3 setup.py test
%endif

%files

%files
%defattr(-,root,root)
%doc README.rst
%{python3_sitelib}/*
%{_bindir}/*


%changelog
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ def run(self):
if pkgname not in self.packages:
raise DistutilsSetupError("Expected package '%s' not found"
% pkgname)
pkgdir = self.package_dir.get(pkgname, pkgname)
pkgdir = Path(self.package_dir.get(pkgname, pkgname))
ver = self.distribution.get_version()
with Path(pkgdir, "__init__.py").open("wt") as f:
with (pkgdir / "__init__.py").open("wt") as f:
print(self.init_template % (__doc__, ver), file=f)


Expand Down Expand Up @@ -121,7 +121,7 @@ def run(self):
packages = ["archive", "archive.cli"],
scripts = ["scripts/archive-tool.py", "scripts/imap-to-archive.py"],
classifiers = [
"Development Status :: 3 - Alpha",
"Development Status :: 4 - Beta",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
Expand Down
12 changes: 12 additions & 0 deletions tests/test_04_cli_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ def test_check_allmatch(test_dir, copy_data, monkeypatch):
f.seek(0)
assert set(get_output(f)) == set()

def test_check_allmatch_default_files(test_dir, copy_data, monkeypatch):
"""Same as test_check_allmatch(), but ommit the files argument.
Rely on the fact that the file argument defaults to the archives's
basedir. Ref. #45.
"""
monkeypatch.chdir(str(copy_data))
with TemporaryFile(mode="w+t", dir=str(test_dir)) as f:
args = ["check", str(test_dir / "archive.tar")]
callscript("archive-tool.py", args, stdout=f)
f.seek(0)
assert set(get_output(f)) == set()

def test_check_add_file(test_dir, copy_data, monkeypatch):
monkeypatch.chdir(str(copy_data))
fp = Path("base", "new_msg.txt")
Expand Down
17 changes: 0 additions & 17 deletions tests/test_04_cli_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,23 +188,6 @@ def test_cli_integrity_missing_file(test_dir, testname, monkeypatch):
line = f.readline()
assert "%s:%s: missing" % (name, missing) in line

def test_cli_check_missing_files(test_dir, testname, monkeypatch):
monkeypatch.chdir(str(test_dir))
name = archive_name(tags=[testname])
args = ["create", name, "base"]
callscript("archive-tool.py", args)
with TemporaryFile(mode="w+t", dir=str(test_dir)) as f:
args = ["check", name]
callscript("archive-tool.py", args, returncode=2, stderr=f)
f.seek(0)
line = f.readline()
assert line.startswith("usage: archive-tool.py ")
while True:
line = f.readline()
if not line.startswith(" "):
break
assert "either --stdin or the files argument is required" in line

def test_cli_check_stdin_and_files(test_dir, testname, monkeypatch):
monkeypatch.chdir(str(test_dir))
name = archive_name(tags=[testname])
Expand Down

0 comments on commit 64e7f53

Please sign in to comment.