[Pkg-javascript-commits] [npm2deb] 01/04: Imported Upstream version 0.1.1

Leo Iannacone l3on-guest at moszumanska.debian.org
Wed May 7 07:41:43 UTC 2014


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

l3on-guest pushed a commit to branch master
in repository npm2deb.

commit d0c9de7c3c1dbdfd17201a630a6e9aad49cbffc5
Author: Leo Iannacone <l3on at ubuntu.com>
Date:   Wed May 7 09:34:37 2014 +0200

    Imported Upstream version 0.1.1
---
 Changelog.md           |   6 +++
 npm2deb/__init__.py    |  33 +++++++-------
 npm2deb/helper.py      |  48 ++++++++++++++-------
 npm2deb/mapper.py      |  15 ++++---
 npm2deb/scripts.py     | 114 ++++++++++++++++++++++++++++++++-----------------
 npm2deb/templates.py   |   5 +--
 npm2deb/utils.py       |  18 +++++---
 setup.py               |   9 ++--
 tests/npm_coherence.py |  22 +++++-----
 9 files changed, 168 insertions(+), 102 deletions(-)

diff --git a/Changelog.md b/Changelog.md
new file mode 100644
index 0000000..1ff743b
--- /dev/null
+++ b/Changelog.md
@@ -0,0 +1,6 @@
+## 0.1.1 (2014-05-07)
+
+ * [FIX] - prevent infinite loop looking for reverse dependencies
+
+## 0.1.0 
+Initial release
diff --git a/npm2deb/__init__.py b/npm2deb/__init__.py
index 149b2c4..100cedf 100644
--- a/npm2deb/__init__.py
+++ b/npm2deb/__init__.py
@@ -5,7 +5,6 @@ from datetime import datetime
 from dateutil import tz
 from shutil import rmtree
 import os
-import stat
 import re
 
 # python 3 import
@@ -17,10 +16,11 @@ except ImportError:
 from npm2deb import utils, templates
 from npm2deb.mapper import Mapper
 
-VERSION = '0.1.0'
+VERSION = '0.1.1'
 DEBHELPER = 8
 STANDARDS_VERSION = '3.9.5'
 
+
 class Npm2Deb(object):
 
     def __init__(self, module_name=None, args={}):
@@ -58,8 +58,8 @@ class Npm2Deb(object):
         self.debian_author = 'FIX_ME debian author'
         if 'DEBFULLNAME' in os.environ and 'DEBEMAIL' in os.environ:
             self.debian_author = "%s <%s>" % \
-                (os.environ['DEBFULLNAME'].decode('utf-8')
-                    , os.environ['DEBEMAIL'].decode('utf-8'))
+                (os.environ['DEBFULLNAME'].decode('utf-8'),
+                    os.environ['DEBEMAIL'].decode('utf-8'))
         elif 'DEBFULLNAME' in os.environ and 'EMAIL' in os.environ:
             self.debian_author = "%s <%s>" % \
                 (os.environ['DEBFULLNAME'].decode('utf-8'),
@@ -137,8 +137,8 @@ class Npm2Deb(object):
         dest = self.debian_dest
         if os.path.isdir('bin'):
             for script in os.listdir('bin'):
-                links.append("%s/bin/%s usr/bin/%s" % \
-                    (dest, script, script.replace('.js', '')))
+                links.append("%s/bin/%s usr/bin/%s" %
+                            (dest, script, script.replace('.js', '')))
         if len(links) > 0:
             content = '\n'.join(links)
             utils.create_debian_file('links', content)
@@ -188,9 +188,10 @@ class Npm2Deb(object):
         args['Standards-Version'] = self.debian_standards
         args['Homepage'] = self.homepage
         args['Vcs-Git'] = 'git://anonscm.debian.org/pkg-javascript/%s.git' \
-           % self.debian_name
+                          % self.debian_name
         args['Vcs-Browser'] = 'http://anonscm.debian.org/' + \
-          'gitweb/?p=pkg-javascript/%s.git' % self.debian_name
+                              'gitweb/?p=pkg-javascript/%s.git' \
+                              % self.debian_name
         args['Package'] = self.debian_name
         args['Depends'] = self._get_Depends()
         args['Description'] = self.description
@@ -213,7 +214,7 @@ class Npm2Deb(object):
             args['upstream_license'] = "\nLicense: %s" % \
                 utils.get_license(self.upstream_license)
         else:
-            args['upstream_license'] = '' # do not insert same license twice
+            args['upstream_license'] = ''  # do not insert same license twice
         args['debian_date'] = self.date.year
         args['debian_author'] = self.debian_author
         args['debian_license_name'] = self.debian_license
@@ -236,9 +237,8 @@ class Npm2Deb(object):
         args['overrides'] = ''
         for filename in os.listdir('.'):
             if filename.lower().startswith('history'):
-                args['overrides'] += \
-                "override_dh_installchangelogs:\n" + \
-                "\tdh_installchangelogs -k %s\n" % filename
+                args['overrides'] += "override_dh_installchangelogs:\n" + \
+                                     "\tdh_installchangelogs -k %s\n" % filename
                 break
         content = utils.get_template('rules') % args
         utils.create_debian_file("rules", content)
@@ -337,7 +337,7 @@ class Npm2Deb(object):
                     license_name = "Expat"
                 self.upstream_license = license_name
         if self.debian_license is None or \
-            self.debian_license.find('FIX_ME') >= 0:
+           self.debian_license.find('FIX_ME') >= 0:
             self.debian_license = self.upstream_license
 
     def _get_json_version(self):
@@ -403,8 +403,8 @@ class Npm2Deb(object):
                 name = mapper.get_debian_package(dep)['name']
                 if not name:
                     name = 'node-%s' % dep
-                    mapper.append_warning('error', dep, 'dependency %s '\
-                        'not in debian' % (name))
+                    mapper.append_warning('error', dep, 'dependency %s '
+                                          'not in debian' % (name))
                 version = dependencies[dep].replace('~', '')
                 if version[0].isdigit():
                     version = '>= %s' % version
@@ -422,7 +422,8 @@ class Npm2Deb(object):
         return name.replace('_', '-')
 
     def _get_github_url_from_git(self, url):
-        result = getstatusoutput("nodejs -e "
+        result = getstatusoutput(
+            "nodejs -e "
             "\"console.log(require('github-url-from-git')"
             "('%s'));\"" % url)[1]
         if result == 'undefined':
diff --git a/npm2deb/helper.py b/npm2deb/helper.py
index af4aab1..c759832 100644
--- a/npm2deb/helper.py
+++ b/npm2deb/helper.py
@@ -9,10 +9,12 @@ from npm2deb.mapper import Mapper
 
 DO_PRINT = False
 
+
 def my_print(what):
     if DO_PRINT:
         print(what.encode('utf-8'))
 
+
 def search_for_repository(module):
     if isinstance(module, Npm2Deb):
         module = module.name
@@ -25,7 +27,7 @@ def search_for_repository(module):
         debug(1, "search for %s in %s" % (module, repo))
         url_base = "http://anonscm.debian.org/gitweb"
         data = urlopen("%s/?a=project_list&pf=%s&s=%s" %
-            (url_base, repo, module)).read()
+                      (url_base, repo, module)).read()
         dom = minidom.parseString(data)
         for row in dom.getElementsByTagName('tr')[1:]:
             try:
@@ -42,10 +44,11 @@ def search_for_repository(module):
         my_print("  None")
     return result
 
+
 def search_for_bug(module):
     if isinstance(module, Npm2Deb):
         module = module.name
-    url = 'http://wnpp.debian.net/' \
+    url = 'http://wnpp.debian.net/'
     '?type%5B%5D=ITA&type%5B%5D=ITP&type%5B%5D=O&type%5B%5D=RFA' \
     '&type%5B%5D=RFH&type%5B%5D=RFP&project=&description=&owner%5B%5D=yes' \
     '&owner%5B%5D=no&col%5B%5D=type&col%5B%5D=description&sort=project'
@@ -72,19 +75,22 @@ def search_for_bug(module):
                         bug["description"].find(module) >= 0:
                     found = True
                     result.append(bug)
-                    my_print(formatted.format(bug["num"], \
-                        bug["type"], bug["package"], bug["description"]))
+                    my_print(formatted.format(bug["num"],
+                                              bug["type"],
+                                              bug["package"],
+                                              bug["description"]))
             except:
                 continue
     if not found:
         my_print('  None')
     return result
 
+
 def search_for_reverse_dependencies(module):
     if isinstance(module, Npm2Deb):
         module = module.name
     url = "http://registry.npmjs.org/-/_view/dependedUpon?startkey=" \
-    + "[%%22%(name)s%%22]&endkey=[%%22%(name)s%%22,%%7B%%7D]&group_level=2"
+        + "[%%22%(name)s%%22]&endkey=[%%22%(name)s%%22,%%7B%%7D]&group_level=2"
     url = url % {'name': module}
     debug(1, "opening url %s" % url)
     data = urlopen(url).read()
@@ -100,12 +106,15 @@ def search_for_reverse_dependencies(module):
         my_print("Module %s has no reverse dependencies" % module)
     return result
 
-def search_for_dependencies(module, recursive=False,
-        force=False, prefix=u''):
+
+def search_for_dependencies(module, recursive=False, force=False,
+                            prefix=u'', expanded_dependencies=[]):
     try:
         if not isinstance(module, Npm2Deb):
-            dependencies = parseJSON(getstatusoutput('npm view "%s" '
-                'dependencies --json 2>/dev/null' % module)[1])
+            npm_out = getstatusoutput('npm view "%s" '
+                                      'dependencies --json 2>/dev/null'
+                                      % module)[1]
+            dependencies = parseJSON(npm_out)
         else:
             dependencies = module.json['dependencies']
             module = module.name
@@ -125,23 +134,29 @@ def search_for_dependencies(module, recursive=False,
         result[dep]['debian'] = mapper.get_debian_package(dep)['repr']
         dep_prefix = u'└─' if last_dep else u'├─'
         print_formatted_dependency(u"%s %s (%s)" % (dep_prefix, dep,
-            result[dep]['version']), result[dep]['debian'], prefix)
-        if recursive:
+                                   result[dep]['version']),
+                                   result[dep]['debian'], prefix)
+        if recursive and not dep in expanded_dependencies:
+            expanded_dependencies.append(dep)
             if (result[dep]['debian'] and force) or \
                     result[dep]['debian'] is None:
                 new_prefix = "%s%s " % (prefix, u"  " if last_dep else u"│ ")
-                result[dep]['dependencies'] = search_for_dependencies(dep, \
-                    recursive, force, new_prefix)
+                result[dep]['dependencies'] = \
+                    search_for_dependencies(dep, recursive, force, new_prefix,
+                                            expanded_dependencies)
         else:
             result[dep]['dependencies'] = None
 
     return result
 
+
 def search_for_builddep(module):
     try:
         if not isinstance(module, Npm2Deb):
-            builddeb = parseJSON(getstatusoutput('npm view "%s" '
-                'devDependencies --json 2>/dev/null' % module)[1])
+            npm_out = getstatusoutput('npm view "%s" '
+                                      'devDependencies --json 2>/dev/null'
+                                      % module)[1]
+            builddeb = parseJSON(npm_out)
         else:
             builddeb = module.json['devDependencies']
             module = module.name
@@ -156,10 +171,11 @@ def search_for_builddep(module):
         result[dep]['version'] = builddeb[dep]
         result[dep]['debian'] = mapper.get_debian_package(dep)['repr']
         print_formatted_dependency("%s (%s)" % (dep, result[dep]['version']),
-            result[dep]['debian'])
+                                   result[dep]['debian'])
 
     return result
 
+
 def print_formatted_dependency(npm, debian, prefix=u''):
     formatted = u"{0:50}{1}"
     my_print(formatted.format(u"%s%s" % (prefix, npm), debian))
diff --git a/npm2deb/mapper.py b/npm2deb/mapper.py
index cc1d6ea..3de2e90 100644
--- a/npm2deb/mapper.py
+++ b/npm2deb/mapper.py
@@ -6,16 +6,17 @@ from npm2deb.utils import debug
 
 DB_URL = 'https://wiki.debian.org/Javascript/Nodejs/Database'
 
+
 class Mapper(object):
     INSTANCE = None
 
     def __init__(self):
         if self.INSTANCE is not None:
-            raise ValueError("Mapper is a Singleton. " \
-                "Please use get_instance method.")
+            raise ValueError("Mapper is a Singleton. "
+                             "Please use get_instance method.")
         debug(2, 'loading database from %s' % DB_URL)
-        data = findall('{{{(.*)}}}', \
-            urlopen("%s?action=raw" % DB_URL).read().replace('\n', ''))[0]
+        data = findall('{{{(.*)}}}', urlopen("%s?action=raw"
+                       % DB_URL).read().replace('\n', ''))[0]
         self.json = parseJSON(data)
         self._warnings = {}
         self.reset_warnings()
@@ -42,8 +43,8 @@ class Mapper(object):
                 self.append_warning('info', node_module, db_package['info'])
             elif 'warning' in db_package:
                 result['info'] = ('warning', db_package['warning'])
-                self.append_warning('warning', node_module, \
-                    db_package['warning'])
+                self.append_warning('warning', node_module,
+                                    db_package['warning'])
             elif 'error' in db_package:
                 result['info'] = ('error', db_package['error'])
                 self.append_warning('error', node_module, db_package['error'])
@@ -53,7 +54,7 @@ class Mapper(object):
         if not result['name']:
             return result
 
-        madison = getstatusoutput( \
+        madison = getstatusoutput(
             'apt-cache madison "%s" | grep Sources' % result['name'])
 
         if madison[0] != 0:
diff --git a/npm2deb/scripts.py b/npm2deb/scripts.py
index 0ab2202..75c2128 100644
--- a/npm2deb/scripts.py
+++ b/npm2deb/scripts.py
@@ -18,74 +18,101 @@ def main(argv=None):
 
     subparsers = parser.add_subparsers(title='commands')
 
-    parser_create = subparsers.add_parser('create', \
+    parser_create = subparsers.add_parser(
+        'create',
         help='create the debian files')
-    parser_create.add_argument('-n', '--noclean', action="store_true", \
+    parser_create.add_argument(
+        '-n', '--noclean', action="store_true",
         default=False, help='do not remove files downloaded with npm')
-    parser_create.add_argument('--debhelper', default=DEBHELPER, \
+    parser_create.add_argument(
+        '--debhelper', default=DEBHELPER,
         help='specify debhelper version [default: %(default)s]')
-    parser_create.add_argument('--standards-version',
-        default=STANDARDS_VERSION, \
+    parser_create.add_argument(
+        '--standards-version', default=STANDARDS_VERSION,
         help='set standards-version [default: %(default)s]')
-    parser_create.add_argument('--upstream-license', default=None, \
+    parser_create.add_argument(
+        '--upstream-license', default=None,
         help='set upstream license if not automatically recognized')
-    parser_create.add_argument('--debian-license', default=None, \
+    parser_create.add_argument(
+        '--debian-license', default=None,
         help='license used for debian files [default: the same of upstream]')
-    parser_create.add_argument('node_module', \
+    parser_create.add_argument(
+        'node_module',
         help='node module available via npm')
     parser_create.set_defaults(func=create)
 
-    parser_view = subparsers.add_parser('view', \
+    parser_view = subparsers.add_parser(
+        'view',
         help="a summary view of a node module")
-    parser_view.add_argument('-j', '--json', action="store_true", \
+    parser_view.add_argument(
+        '-j', '--json', action="store_true",
         default=False, help='print verbose information in json format')
-    parser_view.add_argument('node_module', \
+    parser_view.add_argument(
+        'node_module',
         help='node module available via npm')
     parser_view.set_defaults(func=print_view)
 
-    parser_depends = subparsers.add_parser('depends', \
+    parser_depends = subparsers.add_parser(
+        'depends',
         help='show module dependencies in npm and debian')
-    parser_depends.add_argument('-r', '--recursive', action="store_true", \
+    parser_depends.add_argument(
+        '-r', '--recursive', action="store_true",
         default=False, help='look for binary dependencies recursively')
-    parser_depends.add_argument('-f', '--force', action="store_true", \
+    parser_depends.add_argument(
+        '-f', '--force', action="store_true",
         default=False, help='force inspection for modules already in debian')
-    parser_depends.add_argument('-b', '--binary', action="store_true", \
+    parser_depends.add_argument(
+        '-b', '--binary', action="store_true",
         default=False, help='show binary dependencies')
-    parser_depends.add_argument('-B', '--builddeb', action="store_true", \
+    parser_depends.add_argument(
+        '-B', '--builddeb', action="store_true",
         default=False, help='show build dependencies')
-    parser_depends.add_argument('node_module', \
+    parser_depends.add_argument(
+        'node_module',
         help='node module available via npm')
     parser_depends.set_defaults(func=show_dependencies)
 
-    parser_rdepends = subparsers.add_parser('rdepends', \
+    parser_rdepends = subparsers.add_parser(
+        'rdepends',
         help='show the reverse dependencies for module')
-    parser_rdepends.add_argument('node_module', \
+    parser_rdepends.add_argument(
+        'node_module',
         help='node module available via npm')
     parser_rdepends.set_defaults(func=show_reverse_dependencies)
 
-    parser_search = subparsers.add_parser('search', \
+    parser_search = subparsers.add_parser(
+        'search',
         help="look for module in debian project")
-    parser_search.add_argument('-b', '--bug', action="store_true", \
+    parser_search.add_argument(
+        '-b', '--bug', action="store_true",
         default=False, help='search for existing bug in wnpp')
-    parser_search.add_argument('-d', '--debian', action="store_true", \
+    parser_search.add_argument(
+        '-d', '--debian', action="store_true",
         default=False, help='search for existing package in debian')
-    parser_search.add_argument('-r', '--repository', action="store_true", \
+    parser_search.add_argument(
+        '-r', '--repository', action="store_true",
         default=False, help='search for existing repository in alioth')
-    parser_search.add_argument('node_module', \
+    parser_search.add_argument(
+        'node_module',
         help='node module available via npm')
     parser_search.set_defaults(func=search_for_module)
 
-    parser_itp = subparsers.add_parser('itp', \
+    parser_itp = subparsers.add_parser(
+        'itp',
         help="print a itp bug template")
-    parser_itp.add_argument('node_module', \
+    parser_itp.add_argument(
+        'node_module',
         help='node module available via npm')
     parser_itp.set_defaults(func=print_itp)
 
-    parser_license = subparsers.add_parser('license', \
+    parser_license = subparsers.add_parser(
+        'license',
         help='print license template and exit')
-    parser_license.add_argument('-l', '--list', action="store_true", \
+    parser_license.add_argument(
+        '-l', '--list', action="store_true",
         default=False, help='show the available licenses')
-    parser_license.add_argument('name', nargs='?', \
+    parser_license.add_argument(
+        'name', nargs='?',
         help='the license name to show')
     parser_license.set_defaults(func=print_license)
 
@@ -96,6 +123,7 @@ def main(argv=None):
 
     args.func(args)
 
+
 def search_for_module(args):
     helper.DO_PRINT = True
     # enable all by default
@@ -118,15 +146,16 @@ def search_for_module(args):
 
     _show_mapper_warnings()
 
+
 def print_view(args):
     npm2deb_instance = get_npm2deb_instance(args)
     if args.json:
         from json import dumps
         # print a clean version of json module
         json = npm2deb_instance.json
-        for key in ['time', 'versions', 'dist-tags', 'component', \
-            'users', 'time', 'maintainers', 'readmeFilename', 'contributors', \
-            'keywords']:
+        for key in ['time', 'versions', 'dist-tags', 'component',
+                    'users', 'time', 'maintainers', 'readmeFilename',
+                    'contributors', 'keywords']:
             if key in json:
                 del json[key]
         print(dumps(json, indent=4, sort_keys=True))
@@ -138,11 +167,11 @@ def print_view(args):
             if key == 'license' or key == 'version':
                 attr_key = 'upstream_%s' % key
             print(formatted.format("%s:" % key.capitalize(),
-                getattr(npm2deb_instance, attr_key, None)))
+                  getattr(npm2deb_instance, attr_key, None)))
 
         mapper = Mapper.get_instance()
         print(formatted.format("Debian:", mapper
-            .get_debian_package(npm2deb_instance.name)['repr']))
+              .get_debian_package(npm2deb_instance.name)['repr']))
 
         if mapper.has_warnings():
             print("")
@@ -152,10 +181,11 @@ def print_view(args):
 def print_itp(args):
     get_npm2deb_instance(args).show_itp()
 
+
 def print_license(args, prefix=""):
     if args.list:
-        print("%s Available licenses are: %s." % \
-                (prefix, ', '.join(sorted(templates.LICENSES.keys())).lower()))
+        print("%s Available licenses are: %s." %
+              (prefix, ', '.join(sorted(templates.LICENSES.keys())).lower()))
     else:
         if args.name is None:
             print("You have to specify a license name")
@@ -170,6 +200,7 @@ def print_license(args, prefix=""):
                 args.list = True
                 print_license(args)
 
+
 def show_dependencies(args):
     helper.DO_PRINT = True
     # enable all by default
@@ -188,10 +219,12 @@ def show_dependencies(args):
             module_ver = npm2deb_instance.upstream_version
             module_deb = Mapper.get_instance()\
                 .get_debian_package(module_name)["repr"]
-            helper.print_formatted_dependency("%s (%s)" % \
-                (module_name, module_ver), module_deb)
+            helper.print_formatted_dependency("%s (%s)" %
+                                              (module_name, module_ver),
+                                              module_deb)
             helper.search_for_dependencies(npm2deb_instance,
-                args.recursive, args.force)
+                                           args.recursive,
+                                           args.force)
             print("")
         else:
             print("Module %s has no dependencies." % module_name)
@@ -207,11 +240,13 @@ def show_dependencies(args):
 
     _show_mapper_warnings()
 
+
 def show_reverse_dependencies(args):
     helper.DO_PRINT = True
     node_module = get_npm2deb_instance(args).name
     helper.search_for_reverse_dependencies(node_module)
 
+
 def create(args):
     npm2deb = get_npm2deb_instance(args)
     try:
@@ -246,6 +281,7 @@ def get_npm2deb_instance(args):
         print value_error
         exit(1)
 
+
 def _show_mapper_warnings():
     mapper = Mapper.get_instance()
     if mapper.has_warnings():
diff --git a/npm2deb/templates.py b/npm2deb/templates.py
index f0545e0..ac550e8 100644
--- a/npm2deb/templates.py
+++ b/npm2deb/templates.py
@@ -152,7 +152,7 @@ LICENSES['Artistic'] = """Artistic-1.0
  can be found in "/usr/share/common-licenses/Artistic".
 """
 
-LICENSES['BSD'] = """BSD-3-Clause
+LICENSES['BSD'] = """BSD-3-clause
  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions
  are met:
@@ -176,9 +176,6 @@ LICENSES['BSD'] = """BSD-3-Clause
  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- .
- On Debian systems, the complete text of the BSD License
- can be found in "/usr/share/common-licenses/BSD".
 """
 
 LICENSES['LGPL-2'] = """LGPL-2
diff --git a/npm2deb/utils.py b/npm2deb/utils.py
index 807043b..bf47f42 100644
--- a/npm2deb/utils.py
+++ b/npm2deb/utils.py
@@ -12,14 +12,17 @@ except ImportError:
 
 DEBUG_LEVEL = 0
 
+
 def debug(level, msg):
     if level <= DEBUG_LEVEL:
         print(" debug [%s] - %s" % (level, msg))
 
+
 def get_npm_version(module_name):
-    return getstatusoutput( \
+    return getstatusoutput(
         'npm view "%s" version' % module_name)[1].split('\n')[-2].strip()
 
+
 def get_template(filename):
     result = None
     if filename is 'control':
@@ -32,6 +35,7 @@ def get_template(filename):
         result = templates.WNPP
     return result
 
+
 def get_license(license):
     result = None
     name = license.lower().replace('-', '')
@@ -57,17 +61,20 @@ def get_license(license):
         result = 'FIX_ME please specify a license description'
     return result
 
+
 def change_dir(dir):
     debug(2, "moving to directory %s" % dir)
     try:
         os.chdir(dir)
     except OSError as oserror:
-        raise OSError("OSError [%d]: %s at %s" % \
-          (oserror.errno, oserror.strerror, oserror.filename))
+        raise OSError("OSError [%d]: %s at %s" %
+                      (oserror.errno, oserror.strerror, oserror.filename))
+
 
 def create_debian_file(filename, content):
     create_file("debian/%s" % filename, content)
 
+
 def create_file(filename, content):
     debug(2, "creating file %s" % filename)
     content = u'%s' % content
@@ -76,10 +83,11 @@ def create_file(filename, content):
     with codecs.open(filename, 'w', 'utf-8') as writer:
         writer.write(content)
 
+
 def create_dir(dir):
     debug(2, "creating directory %s" % dir)
     try:
         os.mkdir(dir)
     except OSError as oserror:
-        raise OSError("Error: directory %s already exists." % \
-            (oserror.filename))
+        raise OSError("Error: directory %s already exists." %
+                      oserror.filename)
diff --git a/setup.py b/setup.py
index 07f37e9..bac15e8 100755
--- a/setup.py
+++ b/setup.py
@@ -4,6 +4,7 @@ from distutils.command.install_scripts import install_scripts
 from npm2deb import VERSION
 import shutil
 
+
 class remove_extension(install_scripts):
     def run(self):
         install_scripts.run(self)
@@ -22,9 +23,9 @@ setup(name='npm2deb',
       packages=['npm2deb'],
       dependencies=['dateutil'],
       data_files=[
-        ('share/man/man1', ['man/npm2deb.1']),
-        ('share/doc/npm2deb', ['README.md', 'AUTHORS']),
-        ('/etc/bash_completion.d', ['etc/bash_completion.d/npm2deb'])
+          ('share/man/man1', ['man/npm2deb.1']),
+          ('share/doc/npm2deb', ['README.md', 'AUTHORS']),
+          ('/etc/bash_completion.d', ['etc/bash_completion.d/npm2deb'])
       ],
       cmdclass={"install_scripts": remove_extension},
-)
+      )
diff --git a/tests/npm_coherence.py b/tests/npm_coherence.py
index a983ca3..6449e09 100644
--- a/tests/npm_coherence.py
+++ b/tests/npm_coherence.py
@@ -2,11 +2,11 @@ import sys
 import os
 import inspect
 current = os.path.dirname(os.path.abspath(
-            inspect.getfile(inspect.currentframe()) + '/..'))
+                          inspect.getfile(
+                          inspect.currentframe()) + '/..'))
 sys.path.append(current)
 
 import unittest
-from commands import getstatusoutput
 from shutil import rmtree
 from npm2deb import Npm2Deb, DEBHELPER
 
@@ -14,7 +14,7 @@ from npm2deb import Npm2Deb, DEBHELPER
 class npm2deb_fails(unittest.TestCase):
     def test_init_no_npm_module(self):
         try:
-            n = Npm2Deb('MODULE_NOT_IN_NPM')
+            Npm2Deb('MODULE_NOT_IN_NPM')
             raise Exception
         except Exception as err:
             self.assertTrue(isinstance(err, ValueError))
@@ -23,13 +23,14 @@ class npm2deb_fails(unittest.TestCase):
 
     def test_init_module_multiple_version(self):
         try:
-            n = Npm2Deb('socket.io at 0.9.x')
+            Npm2Deb('socket.io at 0.9.x')
             raise Exception
         except Exception as err:
             self.assertTrue(isinstance(err, ValueError))
             # must suggest type of failure
-            self.assertTrue(str(err).find(\
-                'More than one version found. Please specify one of:') >= 0)
+            self.assertTrue(str(err)
+                .find('More than one version found. '
+                      'Please specify one of:') >= 0)
 
 
 class npm_coherences_license(unittest.TestCase):
@@ -65,7 +66,6 @@ class debian(unittest.TestCase):
         if os.path.isdir('debian'):
             rmtree('debian')
 
-
     def _get_compat(self):
         with open('debian/compat', 'r') as compat_fd:
             return compat_fd.read().strip('\n')
@@ -87,8 +87,8 @@ class debian(unittest.TestCase):
         n.create_base_debian()
         n.create_control()
         self.assertEqual(self._get_compat(), str(DEBHELPER))
-        self.assertEqual(self._get_debfile_line("control", " debhelper ("),\
-            ' debhelper (>= %s)' % DEBHELPER)
+        self.assertEqual(self._get_debfile_line("control",
+                         " debhelper ("), ' debhelper (>= %s)' % DEBHELPER)
 
     def test_debhelper_as_argument(self):
         MY_DEBHELPER = DEBHELPER + 1
@@ -96,8 +96,8 @@ class debian(unittest.TestCase):
         n.create_base_debian()
         n.create_control()
         self.assertEqual(self._get_compat(), str(MY_DEBHELPER))
-        self.assertEqual(self._get_debfile_line("control", " debhelper ("),\
-            ' debhelper (>= %s)' % MY_DEBHELPER)
+        self.assertEqual(self._get_debfile_line("control", " debhelper ("),
+                         ' debhelper (>= %s)' % MY_DEBHELPER)
 
     def test_manpages(self):
         n = Npm2Deb('jade')

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/npm2deb.git



More information about the Pkg-javascript-commits mailing list