[py-svn] pytest-codecheckers commit e405fd961f23: update hgdistver to the pep8-silent one

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Jul 15 12:45:40 CEST 2010


# HG changeset patch -- Bitbucket.org
# Project pytest-codecheckers
# URL http://bitbucket.org/RonnyPfannschmidt/pytest-codecheckers/overview
# User Ronny Pfannschmidt <Ronny.Pfannschmidt at gmx.de>
# Date 1279190731 -7200
# Node ID e405fd961f231dfc10d029d49ac531c48e1083ac
# Parent  8bc5808df9f7f045daeb42cb8dc0773fd41dd718
update hgdistver to the pep8-silent one

--- a/hgdistver.py
+++ b/hgdistver.py
@@ -2,37 +2,44 @@ import os
 import commands
 import subprocess
 
+
 def version_from_cachefile(cachefile=None):
     if not cachefile:
         return
     #replaces 'with open()' from py2.6
     fd = open(cachefile)
-    fd.readline() # remove the comment
+    fd.readline()  # remove the comment
     version = None
     try:
         line = fd.readline()
         version_string = line.split(' = ')[1].strip()
         version = version_string[1:-1].decode('string-escape')
-    except: # any error means invalid cachefile
+    except:  # any error means invalid cachefile
         pass
     fd.close()
     return version
 
+
 def version_from_hg_id(cachefile=None):
     """stolen logic from mercurials setup.py as well"""
     if os.path.isdir('.hg'):
         l = commands.getoutput('hg id -i -t').strip().split()
-        while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags
+        while len(l) > 1 and l[-1][0].isalpha():  # remove non-numbered tags
             l.pop()
-        if len(l) > 1: # tag found
+        if len(l) > 1:  # tag found
             version = l[-1]
-            if l[0].endswith('+'): # propagate the dirty status to the tag
+            if l[0].endswith('+'):  # propagate the dirty status to the tag
                 version += '+'
             return version
 
+
 def version_from_hg15_parents(cachefile=None):
     if os.path.isdir('.hg'):
-        hgver = commands.getoutput('python -c "import mercurial.__version__;print mercurial.__version__.version"')
+        hgver = commands.getoutput(
+            'python -c '
+            '"import mercurial.__version__;'
+            'print mercurial.__version__.version"')
+
         if hgver < 1.5:
             return version_from_hg_log_with_tags()
         node = commands.getoutput('hg id -i')
@@ -43,11 +50,12 @@ def version_from_hg15_parents(cachefile=
         out = commands.getoutput(cmd)
         try:
             tag, dist = out.split()
-            if tag=='null':
+            if tag == 'null':
                 tag = '0.0'
             return '%s.dev%s-%s' % (tag, dist, node)
         except ValueError:
-            pass # unpacking failed, old hg
+            pass  # unpacking failed, old hg
+
 
 def version_from_hg_log_with_tags(cachefile=None):
     if os.path.isdir('.hg'):
@@ -55,14 +63,15 @@ def version_from_hg_log_with_tags(cachef
         cmd = r'hg log -r %s:0 --template "{tags}\n"'
         cmd = cmd % node.rstrip('+')
         proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
-        dist = -1 # no revs vs one rev is tricky
+        dist = -1  # no revs vs one rev is tricky
 
         for dist, line in enumerate(proc.stdout):
             tags = [t for t in line.split() if not t.isalpha()]
             if tags:
                 return '%s.dev%s-%s' % (tags[0], dist, node)
 
-        return  '0.0.dev%s-%s' % (dist+1, node)
+        return  '0.0.dev%s-%s' % (dist + 1, node)
+
 
 def _archival_to_version(data):
     """stolen logic from mercurials setup.py"""
@@ -73,17 +82,20 @@ def _archival_to_version(data):
     else:
         return data.get('node', '')[:12]
 
+
 def _data_from_archival(path):
     import email
     data = email.message_from_file(open(str(path)))
     return dict(data.items())
 
+
 def version_from_archival(cachefile=None):
     #XXX: asumes cwd is repo root
     if os.path.exists('.hg_archival.txt'):
         data = _data_from_archival('.hg_archival.txt')
         return _archival_to_version(data)
 
+
 def version_from_sdist_pkginfo(cachefile=None):
     if cachefile is None and os.path.exists('PKG-INFO'):
         data = _data_from_archival('PKG-INFO')
@@ -91,6 +103,7 @@ def version_from_sdist_pkginfo(cachefile
         if version != 'UNKNOWN':
             return version
 
+
 def write_cachefile(path, version):
     fd = open(path, 'w')
     try:
@@ -109,6 +122,7 @@ methods = [
     version_from_sdist_pkginfo,
 ]
 
+
 def get_version(cachefile=None):
     try:
         version = None



More information about the pytest-commit mailing list