]> thyrsus.com Git - sccs2rcs.git/commitdiff
pylint cleanup.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 6 Nov 2014 13:55:54 +0000 (08:55 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 6 Nov 2014 13:55:54 +0000 (08:55 -0500)
Makefile
sccs2rcs

index 33aac7d54a7eb82acac6761b0f150e4ac63b206f..27308dcbf3b8b3fd3d66d75dd169063a2e4a809b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -23,6 +23,13 @@ sccs2rcs-$(VERS).tar.gz: $(SOURCES) sccs2rcs.1
        (cd ..; tar -czvf sccs2rcs/sccs2rcs-$(VERS).tar.gz `cat sccs2rcs/MANIFEST`)
        @(cd ..; rm sccs2rcs-$(VERS))
 
+COMMON_PYLINT = --rcfile=/dev/null --reports=n \
+       --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
+       --dummy-variables-rgx='^_'
+PYLINTOPTS = "C0103,C0301,C0326,C0111,W0110,W0141,W0311,W0312,W0603"
+pylint:
+       @pylint $(COMMON_PYLINT) --disable=$(PYLINTOPTS) sccs2rcs
+
 version:
        @echo $(VERS)
 
index 44c62f6362ba42a60133b14d0c39ac2767ca9db1..214da1af19b325fc79e8350ca18798fdf85e1c50 100755 (executable)
--- a/sccs2rcs
+++ b/sccs2rcs
@@ -4,7 +4,7 @@
 #
 # sccs2rcs is a script to convert an existing SCCS history into an RCS
 # history without losing any of the information contained therein.
-# It requires that the SCCS and RCS tools be installed on your system. 
+# It requires that the SCCS and RCS tools be installed on your system.
 #
 # This code requires only get, unget, and prs from the SCCS tools.
 # If what you have installed is cssc, you may have to find where
@@ -28,7 +28,7 @@
 #
 # There is one option. With -c you can specify an initial-comments file.
 # Each line should consist of a filename followed by a colon, followed
-# by the RCS initial coment to set for that file.
+# by the RCS initial comment to set for that file.
 #
 # LICENSE:
 #
 #
 # HISTORY:
 #
-# This tool has a complicated history for its size.  It began life as a 
+# This tool has a complicated history for its size.  It began life as a
 # script in C-shell written by a hacker named Ken Cox in 1991.
 #
-# In 1993 I applied some minor fixes for newer RCS versions and it 
+# In 1993 I applied some minor fixes for newer RCS versions and it
 # shipped as part of one of Rich Morin's Prime Time Freeware releases.
 #
 # In 1994 Brian Berliner hacked Ken Cox's original in a slightly
@@ -51,7 +51,7 @@
 # In 2003 I folded in a minor bug fix from Roger Pilkey.
 # In 2007 I merged in the missing features from Brian Berliner's version
 # and sent it to the GNU RCS project hoping they'd take it off my hands.
-# 
+#
 # Then it started to bother me that I was casting the thing loose in a
 # dying language, so I decided to port it to Python and clean it up.
 # I added error checking, added the comments-file processing, added
@@ -62,7 +62,7 @@
 # Ken said:
 # "This file may be copied, processed, hacked, mutilated, and
 # even destroyed as long as you don't tell anyone you wrote it."
-# Those were more innocent days.  This version is released under MIT terms. 
+# Those were more innocent days.  This version is released under MIT terms.
 #
 # Ken also said:
 #   + If a particular module is hanging you up, consider
 # I removed the dependencies on the BSD/SV `sccs' utility; this script
 # will now work on any system that has the base SCCS/RCS tools available.
 #
-# 1.2: Merges in Roger Pilkey's fix for the case in which date spans 
-# cross the millenium boundary.  Use GNU tac instead of tail, which can't 
+# 1.2: Merges in Roger Pilkey's fix for the case in which date spans
+# cross the millenium boundary.  Use GNU tac instead of tail, which can't
 # reverse large files properly.
 #
 # 1.3: Merges in Brian Berliner's branch hack from the other fork
-# of this script, the one distributed with CVS.  That and four SCCS 
+# of this script, the one distributed with CVS.  That and four SCCS
 # keyword substitutions were the only thing it did that this didn't.
 #
 # 1.4: Python rewrite described above.  Interface cleanup.  Auto-checkout
@@ -139,7 +139,7 @@ def sccsmaster(f):
 
 def is_sccsmaster(f):
     return os.path.basename(f).startswith("s.")
-    
+
 def workfile(f):
     assert os.path.basename(f).startswith("s.")
     return os.path.basename(f)[2:]
@@ -161,16 +161,16 @@ def progress(msg):
 def do_it(command):
     global logtext
     logtext += "$ " + command + "\n"
-    (st, out) = commands.getstatusoutput(command)
+    (_, out) = commands.getstatusoutput(command)
     logtext += out + "\n"
     return out + "\n"
 
 def die(msg):
     print >>sys.stderr, "sccs2rcs: fatal error, ", msg
     record("error recovery begins")
-    for master in os.listdir("SCCS"):
-        if is_sccsmaster(master):
-            do_it("unget " + master)
+    for sccsfile in os.listdir("SCCS"):
+        if is_sccsmaster(sccsfile):
+            do_it("unget " + sccsfile)
     print >>sys.stderr, """\
 Danger!  Danger!
 Incomplete history in ./RCS -- remove it.
@@ -178,9 +178,9 @@ Original unchanged history in ./SCCS.
 """
     if logtext:
         if logfile:
-            wfp = open(logfile, "w")
-            wfp.write(logtext)
-            wfp.close()
+            lfp = open(logfile, "w")
+            lfp.write(logtext)
+            lfp.close()
         else:
             print "Log follows:"
             print logtext
@@ -190,7 +190,7 @@ Original unchanged history in ./SCCS.
 def warn(msg):
     global logtext
     msg = "sccs2rcs: warning, " + msg
-    logtext += msg + "\n" 
+    logtext += msg + "\n"
     print >>sys.stderr, msg
 
 def do_it_or_die(command):
@@ -213,7 +213,7 @@ if __name__ == '__main__':
             logfile = val
 
     # User may have supplied a comments file
-    initstrings = {} 
+    initstrings = {}
     if comments:
         for line in open(comments):
             try:
@@ -231,7 +231,7 @@ if __name__ == '__main__':
     # This assumption works under Debian/Ubuntu and will be harmless elsewhere.
     os.environ["PATH"] += ":/usr/lib/cssc:/usr/lib/x86_64-linux-gnu/cssc"
 
-    logtext = "" 
+    logtext = ""
 
     # Sanity checks on the directory
     if not writeable("."):
@@ -261,7 +261,7 @@ if __name__ == '__main__':
         if os.path.exists(stem):
             workfiles.append(stem)
 
-        # Extract a list of revisions from the master 
+        # Extract a list of revisions from the master
         revisions = []
         try:
             for line in os.popen("prs " + sccsmaster(stem), "r"):
@@ -281,7 +281,7 @@ if __name__ == '__main__':
             try:
                 (day, month, year, tod, author) = date.split()
             except ValueError:
-                die("prs output %s from '%s'was ill-formed" % (`date`, cmd))
+                die("prs output %s from '%s'was ill-formed" % (repr(date), cmd))
 
             # We assume here that no SCCS archives were made before 1970.
             # If you're converting an SCCS archive made after 2070, you lose.
@@ -292,7 +292,7 @@ if __name__ == '__main__':
 
             rcsdate = day + " " + months[int(month)-1] + " " + year + " " + tod
             progress("==> file %s, rev=%s, date=%s, author=%s" \
-                  % (stem, rev, rcsdate, author)) 
+                  % (stem, rev, rcsdate, author))
             do_it_or_die("get -e -r%s %s" % (rev, sccsmaster(stem)))
             record("checked out of SCCS")
 
@@ -325,7 +325,7 @@ if __name__ == '__main__':
                 do_it_or_die(cmd)
                 record("initial checkin successful")
             else:
-                # get RCS lock    
+                # get RCS lock
                 revparts = rev.split(".")
                 lckrev = ".".join(revparts[:-1])
                 if rev.count(".") > 1:
@@ -359,7 +359,7 @@ if __name__ == '__main__':
                         deltalines.pop(0)
                 deltamsg = "\n".join(deltalines)
                 cmd = 'ci -f -r%s -d"%s" -w%s %s' % (rev, rcsdate, author, stem)
-                # FIXME: output of this command isn't logged
+                # FIX-ME: output of this command isn't logged
                 record("$ " + cmd)
                 try:
                     cfp = os.popen(cmd, "w")