Minor code readablity enhancements:
authorZac Medico <zmedico@gentoo.org>
Fri, 28 Dec 2007 16:09:36 +0000 (16:09 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 28 Dec 2007 16:09:36 +0000 (16:09 -0000)
* Use relative_path and full_path variables for files being checked
  instead of spreading code like x+"/files/"+y all over the place.
* Use stat.S_IMODE with octal 0111 instead of hex 0x0248 in the
  file.executable checks.
(trunk r9060)

svn path=/main/branches/2.1.2/; revision=9074

bin/repoman

index 9935649fa8f6ced8f2e4ab4733f614bd20d84fb2..6e1a83b52590383a44b2868308714f5a15b9fe65 100755 (executable)
@@ -1261,9 +1261,11 @@ for x in scanlist:
                        for y in filesdirlist:
                                if not y.startswith("digest-"):
                                        continue
-                               if os.stat(checkdir+"/files/"+y)[0] & 0x0248:
+                               relative_path = os.path.join(x, "files", y)
+                               full_path = os.path.join(repodir, relative_path)
+                               if stat.S_IMODE(os.stat(full_path).st_mode) & 0111:
                                        stats["file.executable"] += 1
-                                       fails["file.executable"].append(x+"/files/"+y)
+                                       fails["file.executable"].append(relative_path)
                                
                                mykey = catdir + "/" + y[7:]
                                if y[7:] not in ebuildlist:
@@ -1395,9 +1397,11 @@ for x in scanlist:
        allmasked = True
 
        for y in ebuildlist:
-               if os.stat(checkdir+"/"+y+".ebuild")[0] & 0x0248:
+               relative_path = os.path.join(x, y + ".ebuild")
+               full_path = os.path.join(repodir, relative_path)
+               if stat.S_IMODE(os.stat(full_path).st_mode) & 0111:
                        stats["file.executable"] += 1
-                       fails["file.executable"].append(x+"/"+y+".ebuild")
+                       fails["file.executable"].append(relative_path)
                if isCvs and y not in eadded:
                        #ebuild not added to cvs
                        stats["ebuild.notadded"]=stats["ebuild.notadded"]+1
@@ -1677,8 +1681,6 @@ for x in scanlist:
                                for mybad in mybadrestrict:
                                        fails["RESTRICT.invalid"].append(x+"/"+y+".ebuild: %s" % mybad)
                # Syntax Checks
-               relative_path = os.path.join(x, y + ".ebuild")
-               full_path = os.path.join(repodir, relative_path)
                f = open(full_path, 'rb')
                try:
                        contents = f.readlines()