diff options
author | Anthon van der Neut <anthon@mnt.org> | 2015-08-27 17:19:18 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2015-08-27 17:19:18 +0200 |
commit | 50ac90d1e4af4b1e6ff2472a84bacc2f45414414 (patch) | |
tree | 17af766f75ea2c04c35907d60ea3efb3612c793b | |
parent | 93e249469454df3c83e7bd29359d460baf29e9f6 (diff) | |
download | ruamel.base-50ac90d1e4af4b1e6ff2472a84bacc2f45414414.tar.gz |
- flake8 in tox
-rw-r--r-- | .hgignore | 1 | ||||
-rw-r--r-- | LICENSE | 21 | ||||
-rw-r--r-- | __init__.py | 3 | ||||
-rw-r--r-- | _test/test_base.py | 4 | ||||
-rw-r--r-- | setup.py | 45 | ||||
-rw-r--r-- | tox.ini | 13 |
6 files changed, 63 insertions, 24 deletions
@@ -9,3 +9,4 @@ dist build *.egg-info .tox +ruamel @@ -0,0 +1,21 @@ + + The MIT License (MIT) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + diff --git a/__init__.py b/__init__.py index e25444e..3339f76 100644 --- a/__init__.py +++ b/__init__.py @@ -4,13 +4,14 @@ from __future__ import print_function _package_data = dict( full_package_name="ruamel.base", - version_info = (1, 0, 0), + version_info=(1, 0, 0), author='Anthon van der Neut', author_email='a.van.der.neut@ruamel.eu', description="common routines for ruamel packages", entry_points=None, ) + def _convert_version(tup): """create a PEP 386 pseudo-format conformant string from tuple tup""" ret_val = str(tup[0]) # first is always digit diff --git a/_test/test_base.py b/_test/test_base.py index cd49d07..ef87b5d 100644 --- a/_test/test_base.py +++ b/_test/test_base.py @@ -2,11 +2,13 @@ from __future__ import print_function -import pytest +import pytest # QAOK + # default for tox stub is to Fail def test_base(): import ruamel with pytest.raises(ImportError): import ruamel.std + print(ruamel.std.__file__) # to suppress flake msg assert True @@ -1,4 +1,4 @@ -## header +# # header # coding: utf-8 from __future__ import print_function @@ -6,10 +6,11 @@ from __future__ import print_function if __name__ != '__main__': raise NotImplementedError('should never include setup.py') -## definitions +# # definitions full_package_name = None + def _package_data(fn): data = {} with open(fn) as fp: @@ -22,6 +23,8 @@ def _package_data(fn): continue if line.startswith(')'): break + if '# NOQA' in line: + line = line.split('# NOQA', 1)[0].rstrip() k, v = [x.strip() for x in line.split('=', 1)] if v[-1] == ',': v = v[:-1] @@ -34,10 +37,10 @@ def _package_data(fn): elif v == 'False': data[k] = False elif v[0] == '(' and v[-1] == ')': - data[k] = tuple([x.strip()[1:-1] if x[0] in '\'"' else int(x) \ - for x in v[1:-1].split(', ')]) + data[k] = tuple([x.strip()[1:-1] if x[0] in '\'"' else int(x) + for x in v[1:-1].split(', ')]) elif v[0] == '[' and v[-1] == ']': - data[k] = [x.strip()[1:-1] if x[0] in '\'"' else int(x) \ + data[k] = [x.strip()[1:-1] if x[0] in '\'"' else int(x) for x in v[1:-1].split(', ')] else: print('Unknown: >>>>> {0!r} {1!r}'.format(k, v)) @@ -49,16 +52,15 @@ exclude_files = [ 'setup.py', ] -## imports +# # imports import os import sys from setuptools import setup from setuptools.command import install_lib -## helper - +# # helper def _check_convert_version(tup): """Create a PEP 386 pseudo-format conformant string from tuple tup.""" ret_val = str(tup[0]) # first is always digit @@ -93,6 +95,7 @@ def _check_convert_version(tup): version_info = pkg_data['version_info'] version_str = _check_convert_version(version_info) + class MyInstallLib(install_lib.install_lib): def install(self): fpp = pkg_data['full_package_name'].split('.') # full package path @@ -119,7 +122,7 @@ class NameSpacePackager(object): self.depth = self.full_package_name.count('.') self.command = None if sys.argv[0] == 'setup.py' and sys.argv[1] == 'install' and \ - not '--single-version-externally-managed' in sys.argv: + '--single-version-externally-managed' not in sys.argv: print('error: have to install with "pip install ."') sys.exit(1) for x in sys.argv: @@ -191,7 +194,7 @@ class NameSpacePackager(object): for p in sys.path: if not p: continue # directory with setup.py - if os.path.exists(os.path.join(p, 'setup.py')) : + if os.path.exists(os.path.join(p, 'setup.py')): continue # some linked in stuff might not be hgi based if not os.path.isdir(p): continue @@ -220,7 +223,7 @@ class NameSpacePackager(object): if fn.startswith(pre): break else: - continue # hgiabc instead of hgi. + continue # hgiabc instead of hgi. if fn.endswith('-link') and self.command == 'install': raise InstallationError( 'Cannot mix non-develop with develop\n(pip install -e)' @@ -255,8 +258,8 @@ class NameSpacePackager(object): @property def license(self): - lic = self._pkg_data.get('license') - #if lic is None: + # lic = self._pkg_data.get('license') + # if lic is None: # lic_file_name = os.path.join(os.path.dirname(__file__), 'LICENSE') # assert os.path.exists(lic_file_name) return "MIT license" @@ -282,8 +285,8 @@ class NameSpacePackager(object): return [ 'Development Status :: {0} - {1}'.format(*self.status), 'Intended Audience :: Developers', - 'License :: ' + ('Other/Proprietary License' \ - if self._pkg_data.get('license') else \ + 'License :: ' + ('Other/Proprietary License' + if self._pkg_data.get('license') else 'OSI Approved :: MIT License'), 'Operating System :: OS Independent', 'Programming Language :: Python', @@ -300,7 +303,7 @@ class NameSpacePackager(object): df.append('LICENSE') if not df: return None - return [('.', df),] + return [('.', df), ] @property def package_data(self): @@ -314,7 +317,8 @@ class NameSpacePackager(object): return None return {self.full_package_name: df} -## call setup + +# # call setup def main(): nsp = NameSpacePackager(pkg_data) nsp.check() @@ -336,9 +340,10 @@ def main(): classifiers=nsp.classifiers, package_data=nsp.package_data, ) - for k in sorted(kw): - v = kw[k] - print(k, '->', v) + if '--version' not in sys.argv: + for k in sorted(kw): + v = kw[k] + print(k, '->', v) with open('README.rst') as fp: kw['long_description'] = fp.read() setup(**kw) @@ -1,8 +1,17 @@ [tox] -envlist = py26,py27,py33,py34 +envlist = pep8,py27,py34,py26,py33 [testenv] -commands = +commands = py.test _test deps = pytest + flake8 + +[testenv:pep8] +commands = + flake8 {posargs} + +[flake8] +show-source = True +exclude = .hg,.git,.tox,dist,.cache,__pycache__,ruamel.zip2tar.egg-info |