[Python-modules-commits] [python-requirements-detector] 01/07: Import python-requirements-detector_0.4.1.orig.tar.xz

Daniel Stender danstender-guest at moszumanska.debian.org
Mon Jan 18 20:31:41 UTC 2016


This is an automated email from the git hooks/post-receive script.

danstender-guest pushed a commit to branch master
in repository python-requirements-detector.

commit 34d2160d574d836a36e9983e4f9543582cef6614
Author: Daniel Stender <debian at danielstender.com>
Date:   Mon Jan 18 21:06:49 2016 +0100

    Import python-requirements-detector_0.4.1.orig.tar.xz
---
 .travis.yml                                            |  6 ++++--
 requirements_detector/detect.py                        | 13 ++++++++++---
 setup.py                                               | 17 +++++++++++++++--
 tests/detection/syntax_error/setup_multiline_string.py | 13 +++++++++++++
 tests/test_failure_cases.py                            |  4 ++++
 tox.ini                                                |  2 +-
 6 files changed, 47 insertions(+), 8 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 5e4e364..b4e7098 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,12 +1,14 @@
+sudo: false
 language: python
 python:
   - "2.6"
   - "2.7"
   - "3.3"
   - "3.4"
+  - "3.5"
 install:
-  - "pip install --use-mirrors nose coverage coveralls"
-  - "pip install --use-mirrors --editable ."
+  - "pip install nose coverage coveralls"
+  - "pip install --editable ."
 script: 
   nosetests -s --with-coverage --cover-package requirements_detector --cover-inclusive
 after_success:
diff --git a/requirements_detector/detect.py b/requirements_detector/detect.py
index e289497..426edb2 100644
--- a/requirements_detector/detect.py
+++ b/requirements_detector/detect.py
@@ -54,11 +54,11 @@ def _load_file_contents(filepath):
         for line in encoding_lines:
             match = _ENCODING_REGEXP.search(line)
             if match is None:
-                result.append(line)
+                result.append(line.strip())
             else:
                 encoding = match.group(1)
 
-        result += contents[2:]
+        result += [line.strip() for line in contents[2:]]
         result = '\n'.join(result)
         return result.decode(encoding)
 
@@ -197,9 +197,16 @@ class SetupWalker(object):
 
 def from_setup_py(setup_file):
     try:
+        from astroid import AstroidBuildingException
+    except ImportError:
+        syntax_exceptions = (SyntaxError,)
+    else:
+        syntax_exceptions = (SyntaxError, AstroidBuildingException)
+
+    try:
         contents = _load_file_contents(setup_file)
         ast = AstroidBuilder(MANAGER).string_build(contents)
-    except SyntaxError:
+    except syntax_exceptions:
         # if the setup file is broken, we can't do much about that...
         raise CouldNotParseRequirements
 
diff --git a/setup.py b/setup.py
index eeedd54..56a3d29 100644
--- a/setup.py
+++ b/setup.py
@@ -1,9 +1,10 @@
 # -*- coding: UTF-8 -*-
 from distutils.core import setup
 from setuptools import find_packages
+import sys
 
 
-_version = "0.4"
+_version = "0.4.1"
 _packages = find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"])
 
 _short_description = "Python tool to find and list requirements of a Python project"
@@ -17,11 +18,23 @@ _CLASSIFIERS = (
     'Programming Language :: Python :: 2.6',
     'Programming Language :: Python :: 2.7',
     'Programming Language :: Python :: 3.3',
+    'Programming Language :: Python :: 3.4',
+    'Programming Language :: Python :: 3.5',
     'License :: OSI Approved :: '
     'GNU General Public License v2 or later (GPLv2+)',
 )
 
 
+if sys.version_info < (2, 7):
+    # pylint 1.4 dropped support for Python 2.6
+    _install_requires = [
+        'astroid>=1.0,<1.3.0',
+    ]
+else:
+    _install_requires = [
+        'astroid>=1.4',
+    ]
+
 setup(
     name='requirements-detector',
     url='https://github.com/landscapeio/requirements-detector',
@@ -30,7 +43,7 @@ setup(
     description=_short_description,
     version=_version,
     scripts=['bin/detect-requirements'],
-    install_requires=['astroid>=1.0.0'],
+    install_requires=_install_requires,
     packages=_packages,
     license='MIT',
     keywords='python requirements detector',
diff --git a/tests/detection/syntax_error/setup_multiline_string.py b/tests/detection/syntax_error/setup_multiline_string.py
new file mode 100644
index 0000000..f485e43
--- /dev/null
+++ b/tests/detection/syntax_error/setup_multiline_string.py
@@ -0,0 +1,13 @@
+from distutils.core import setup
+
+comment = 'this is a long comment ' \
+          'on two lines'
+
+setup(
+    name='prospector-test-1',
+    version='0.0.1',
+    install_requires=[
+        'Django==1.5.0',
+        'django-gubbins==1.1.2'
+    ]
+)
\ No newline at end of file
diff --git a/tests/test_failure_cases.py b/tests/test_failure_cases.py
index f513381..f765674 100644
--- a/tests/test_failure_cases.py
+++ b/tests/test_failure_cases.py
@@ -8,3 +8,7 @@ class SyntaxErrorTest(TestCase):
     def test_setup_py_syntax_error(self):
         filepath = os.path.join(os.path.dirname(__file__), 'detection/syntax_error/setup.py')
         self.assertRaises(CouldNotParseRequirements, from_setup_py, filepath)
+
+    def test_setup_py_multiline_string(self):
+        filepath = os.path.join(os.path.dirname(__file__), 'detection/syntax_error/setup_multiline_string.py')
+        from_setup_py(filepath)
diff --git a/tox.ini b/tox.ini
index 6f43d08..a9fe1bc 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
 [tox]
-envlist = py26,py27,py33,py34
+envlist = py26,py27,py33,py34,py35
 
 [testenv]
 deps=nose

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-requirements-detector.git



More information about the Python-modules-commits mailing list