Replace StringIO usage with a simple list of lines. The
authorZac Medico <zmedico@gentoo.org>
Mon, 5 Nov 2007 06:16:16 +0000 (06:16 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 5 Nov 2007 06:16:16 +0000 (06:16 -0000)
iteration interface is practically identical but the
list of lines if more efficient because the lines only
have to be split one time for each ebuild instead of
for each check.

svn path=/main/trunk/; revision=8428

bin/repoman

index 27e6dfb119d59c547caf0556b996d94b63d1724a..5a5455bbd6e2daad43a5bcb0c22080ef16981526 100755 (executable)
@@ -52,11 +52,6 @@ except ImportError:
        from repoman.checks import EbuildWhitespace, EbuildHeader, EbuildQuote, \
                EbuildAssignment, EbuildNestedDie, EbuildUselessDodoc, EbuildUselessCdS
 
-try:
-       import cStringIO as StringIO
-except ImportError:
-       import StringIO
-
 import portage.checksum
 import portage.const
 import portage.dep
@@ -1374,7 +1369,12 @@ for x in scanlist:
                # Syntax Checks
                path = checkdir + '/' + y + '.ebuild'
                myear = time.gmtime(os.stat(path)[ST_MTIME])[0]
-               contents = StringIO.StringIO(open(path, 'rb').read())
+               f = open(path, 'rb')
+               try:
+                       contents = f.readlines()
+               finally:
+                       f.close()
+                       del f
                for check in (EbuildWhitespace, EbuildQuote,
                        EbuildAssignment, EbuildUselessDodoc, EbuildUselessCdS):
                        c = check(contents)
@@ -1382,14 +1382,12 @@ for x in scanlist:
                        for e in errors:
                                stats[c.repoman_check_name] += 1
                                fails[c.repoman_check_name].append(x + '/' + y + '.ebuild: %s' % e[1] % e[0])
-                       contents.seek(0) # move fp to the beginning of the StringIO Object
                del check
                check = EbuildHeader(contents, str(myear))
                errors = check.Run()
                for e in errors:
                        stats[check.repoman_check_name] += 1
                        fails[check.repoman_check_name].append(x + '/' + y + '.ebuild: %s' % e[1] % e[0])
-               contents.seek(0)
                del check
                check = EbuildNestedDie(contents)
                errors = check.Run()