diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100755 index 0000000..ad81546 --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,2 @@ +languages: + Python: true diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..2a132aa --- /dev/null +++ b/.coveragerc @@ -0,0 +1,28 @@ +[run] + +branch = True + +[report] + +exclude_lines = + pragma: no cover + def __repr__ + if self.debug: + raise NotImplementedError + if __name__ == .__main__.: + +ignore_errors = True + +include = + */zpl2/* + +omit = + */virtualenv/* + */tests/* + setup.py + */__init__.py + tests.py + +[xml] + +output = coverage.xml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..345d58a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,42 @@ +addons: + apt: + packages: + - expect-dev + +language: python + +python: + - "2.7" + +virtualenv: + system_site_packages: true + +env: + global: + - PROJECT="zpl2" + - VERSION="1.0.0" + - RELEASE="1.0.0" + - AUTHOR_NAME="Sylvain Garancher" + - PYPI_USER="syleam" + # Generate the below per repo with the following: + # travis encrypt 'PYPI_PASSWORD="$PYPI_PASSWORD"' -r LasLabs/repo-name + # - secure: "$PYPI_TOKEN" + # Generate the below per repo with the following: + # travis encrypt 'GH_TOKEN="$GITHUB_TOKEN"' -r LasLabs/repo-name + # - secure: "$GH_TOKEN" + matrix: + - TESTS="1" + - LINT_CHECK="1" + # - PYPI="1" + # - DOCS="1" + +install: + - git clone --depth=1 https://github.com/LasLabs/python-quality-tools.git ${HOME}/python-quality-tools + - export PATH=${HOME}/python-quality-tools/travis:${PATH} + - travis_install + +script: + - travis_run + +after_success: + - travis_after_success diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..5c32300 --- /dev/null +++ b/README.rst @@ -0,0 +1,38 @@ +|License MIT| | |Build Status| | |Coveralls Status| | |Codecov Status| | |Code Climate| + +====== +ZPL II +====== + +This library allows you to generate ZPL II labels. + +Usage +===== + +* `Read The API Documentation `_ + +Known Issues / Road Map +======================= + +- Add usage instructions + +Credits +======= + +Contributors +------------ + +* Sylvain Garancher +* Dave Lasley + +.. |Build Status| image:: https://api.travis-ci.org/syleam/python-zpl2.svg?branch=master + :target: https://travis-ci.org/syleam/python-zpl2 +.. |Coveralls Status| image:: https://coveralls.io/repos/syleam/python-zpl2/badge.svg?branch=master + :target: https://coveralls.io/r/syleam/python-zpl2?branch=master +.. |Codecov Status| image:: https://codecov.io/gh/syleam/python-zpl2/branch/master/graph/badge.svg + :target: https://codecov.io/gh/syleam/python-zpl2 +.. |Code Climate| image:: https://codeclimate.com/github/syleam/python-zpl2/badges/gpa.svg + :target: https://codeclimate.com/github/syleam/python-zpl2 +.. |License AGPL-3| image:: https://img.shields.io/badge/license-AGPL--3-blue.svg + :target: https://www.gnu.org/licenses/agpl-3.0 + :alt: License: AGPL-3 diff --git a/README.txt b/README.txt deleted file mode 100644 index 0984c87..0000000 --- a/README.txt +++ /dev/null @@ -1,5 +0,0 @@ -====== -ZPL II -====== - -This library allows you to generate ZPL II labels. diff --git a/setup.py b/setup.py index 99b759a..dc7f3d9 100644 --- a/setup.py +++ b/setup.py @@ -1,16 +1,88 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2016 SYLEAM () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from distutils.core import setup - -setup( - name='zpl2', - version='1.0', - author='Sylvain Garancher', - author_email='sylvain.garancher@syleam.fr', - py_modules=['zpl2'], - license='LICENSE.txt', - description='Python library that generates ZPL II labels', - long_description=open('README.txt').read(), -) +# Copyright 2016-TODAY LasLabs Inc. +# License MIT (https://opensource.org/licenses/MIT). + +from setuptools import Command, setup +from setuptools import find_packages +from unittest import TestLoader, TextTestRunner + +from os import environ, path + + +PROJECT = 'python-zpl2' +SHORT_DESC = 'Python library that generates ZPL II labels' +README_FILE = 'README.rst' + +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: AGPL-3 License', + 'Programming Language :: Python', + 'Topic :: Software Development :: Libraries :: Python Modules', +] + +version = environ.get('RELEASE') or environ.get('VERSION') or '0.0.0' + +if environ.get('TRAVIS_BUILD_NUMBER'): + version += 'b%s' % environ.get('TRAVIS_BUILD_NUMBER') + + +setup_vals = { + 'name': PROJECT, + 'author': 'Sylvain Garancher', + 'author_email': 'sylvain.garancher@syleam.fr', + 'description': SHORT_DESC, + 'url': 'https://laslabs.github.io/%s' % PROJECT, + 'download_url': 'https://github.com/LasLabs/%s' % PROJECT, + 'license': 'MIT', + 'classifiers': CLASSIFIERS, + 'version': version, +} + + +if path.exists(README_FILE): + with open(README_FILE) as fh: + setup_vals['long_description'] = fh.read() + + +install_requires = [] +if path.exists('requirements.txt'): + with open('requirements.txt') as fh: + install_requires = fh.read().splitlines() + + +class FailTestException(Exception): + """ It provides a failing build """ + pass + + +class Tests(Command): + + user_options = [] # < For Command API compatibility + + def initialize_options(self, ): + pass + + def finalize_options(self, ): + pass + + def run(self, ): + loader = TestLoader() + tests = loader.discover('.', 'test_*.py') + t = TextTestRunner(verbosity=1) + res = t.run(tests) + if not res.wasSuccessful(): + raise FailTestException() + + +if __name__ == "__main__": + setup( + packages=find_packages(exclude=('tests')), + cmdclass={'test': Tests}, + tests_require=[ + 'mock', + ], + install_requires=install_requires, + **setup_vals + ) diff --git a/zpl2.py b/zpl2/__init__.py similarity index 100% rename from zpl2.py rename to zpl2/__init__.py diff --git a/zpl2/tests/test_zpl2.py b/zpl2/tests/test_zpl2.py new file mode 100644 index 0000000..f57fe6e --- /dev/null +++ b/zpl2/tests/test_zpl2.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from zpl2 import Zpl2 + + +class TestZpl2(object): + + def setUp(self): + self.zpl = Zpl2() + + def test_init_encoding(self): + """ It should set encoding """ + self.assertEqual(self.zpl.encoding, 'utf-8') + + def test_init_buffer(self): + """ It should set the buffer. """ + self.assertEqual(self.zpl._buffer, [])