Two patches attached, one basically shows the repoman help, modes/options, and QA related text removed; relevant references replaced by repohelp.<var> or repohelp.<var>.keys().
Second path shows basically that stuff being placed in a second file, with function calls replacing global code. IIRC I think the qahelp() function call is missing from repoman in these patches, but I'm too lazy atm to modify them ;) Mostly looking at yay or nay for the idea ;)
Index: repoman =================================================================== --- repoman (revision 3068) +++ repoman (working copy) @@ -11,7 +11,7 @@ exename=os.path.basename(sys.argv[0]) os.environ["PORTAGE_CALLER"]="repoman" sys.path = ["/usr/lib/portage/pym"]+sys.path -version="1.2" + allowed_filename_chars="a-zA-Z0-9._-+:" allowed_filename_chars_set = {} @@ -30,28 +30,26 @@ import cvstree import time import codecs - from portage_manifest import Manifest - from output import * -#bold, darkgreen, darkred, green, red, turquoise, yellow - from commands import getstatusoutput from fileinput import input from grp import getgrnam from stat import * +import repohelp if portage.settings["NOCOLOR"] in ("yes","true") or not sys.stdout.isatty(): nocolor() def warn(txt): print exename+": "+txt + def err(txt): warn(txt) sys.exit(1) def err_help(txt): - help(exitstatus=-1,helpfulness=0) + repohelp.help(exitstatus=-1,helpfulness=0) warn(txt) sys.exit(1) @@ -62,151 +60,11 @@ signal.signal(signal.SIGINT,exithandler) REPOROOTS=["gentoo-x86"] -shortmodes={"ci":"commit"} -modeshelp={ -"scan" : "Scan directory tree for QA issues (default)", -"fix" : "Fix simple QA issues (stray digests, missing digests)", -"full" : "Scan directory tree for QA issues (full listing)", -"help" : "Show this screen", -"commit" : "Scan directory tree for QA issues; if OK, commit via cvs", -"last" : "Remember report from last run", -"lfull" : "Remember report from last run (full listing)" -} -modes=modeshelp.keys() -repoman_options={ -"--commitmsg" : "Adds a commit message via the command line", -"--commitmsgfile" : "Adds a commit message from the specified file", -"--help" : "Show this screen", -"--ignore-arches" : "Ignore arch-specific failures (where arch != host)", -"--include-masked" : "Include masked packages in scans at category or tree level", -"--pretend" : "Don't commit or fix anything; just show what would be done", -"--quiet" : "Be less verbose about extraneous info", -"--verbose" : "Displays every package name while checking", -"--version" : "Show version info", -"--xmlparse" : "Forces the metadata.xml parse check to be carried out" -} -repoman_shortoptions={ -"-h" : "--help", -"-i" : "--include-masked", -"-I" : "--ignore-arches", -"-m" : "--commitmsg", -"-M" : "--commitmsgfile", -"-p" : "--pretend", -"-q" : "--quiet", -"-v" : "--verbose", -"-V" : "--version", -"-x" : "--xmlparse" -} -repoman_shortoptions_rev=dict([(v,k) for (k,v) in repoman_shortoptions.items()]) -options=repoman_options.keys() - -qahelp={ - "CVS/Entries.IO_error":"Attempting to commit, and an IO error was encountered access the Entries file", - "digest.partial":"Digest files do not contain all corresponding URI elements", - "digest.assumed":"Existing digest must be assumed correct (Package level only)", - "digestentry.unused":"Digest/Manifest entry has no matching SRC_URI entry", - "digest.fail":"Digest does not match the specified local file", - "digest.stray":"Digest files that do not have a corresponding ebuild", - "digest.missing":"Digest files that are missing (ebuild exists, digest doesn't)", - "digest.disjointed":"Digests not added to cvs when the matching ebuild has been added", - "digest.notadded":"Digests that exist but have not been added to cvs", - "digest.unmatch":"Digests which are incomplete (please check if your USE/ARCH includes all files)", - "ebuild.invalidname":"Ebuild files with a non-parseable or syntactically incorrect name (or using 2.1 versioning extensions)", - "ebuild.namenomatch":"Ebuild files that do not have the same name as their parent directory", - "changelog.missing":"Missing ChangeLog files", - "ebuild.disjointed":"Ebuilds not added to cvs when the matching digest has been added", - "ebuild.notadded":"Ebuilds that exist but have not been added to cvs", - "changelog.notadded":"ChangeLogs that exist but have not been added to cvs", - "filedir.missing":"Package lacks a files directory", - "file.executable":"Ebuilds, digests, metadata.xml, Manifest, and ChangeLog do note need the executable bit", - "file.size":"Files in the files directory must be under 20k", - "file.name":"File/dir name must be composed of only the following chars: %s " % allowed_filename_chars, - "file.UTF8":"File is not UTF8 compliant", - "KEYWORDS.missing":"Ebuilds that have a missing or empty KEYWORDS variable", - "KEYWORDS.stupid":"Ebuilds that use KEYWORDS=-* instead of package.mask", - "LICENSE.missing":"Ebuilds that have a missing or empty LICENSE variable", - "DESCRIPTION.missing":"Ebuilds that have a missing or empty DESCRIPTION variable", - "SLOT.missing":"Ebuilds that have a missing or empty SLOT variable", - "HOMEPAGE.missing":"Ebuilds that have a missing or empty HOMEPAGE variable", - "DEPEND.bad":"User-visible ebuilds with bad DEPEND settings (matched against *visible* ebuilds)", - "RDEPEND.bad":"User-visible ebuilds with bad RDEPEND settings (matched against *visible* ebuilds)", - "PDEPEND.bad":"User-visible ebuilds with bad PDEPEND settings (matched against *visible* ebuilds)", - "DEPEND.badmasked":"Masked ebuilds with bad DEPEND settings (matched against *all* ebuilds)", - "RDEPEND.badmasked":"Masked ebuilds with RDEPEND settings (matched against *all* ebuilds)", - "PDEPEND.badmasked":"Masked ebuilds with PDEPEND settings (matched against *all* ebuilds)", - "DEPEND.badindev":"User-visible ebuilds with bad DEPEND settings (matched against *visible* ebuilds) in developing arch", - "RDEPEND.badindev":"User-visible ebuilds with bad RDEPEND settings (matched against *visible* ebuilds) in developing arch", - "PDEPEND.badindev":"User-visible ebuilds with bad PDEPEND settings (matched against *visible* ebuilds) in developing arch", - "DEPEND.badmaskedindev":"Masked ebuilds with bad DEPEND settings (matched against *all* ebuilds) in developing arch", - "RDEPEND.badmaskedindev":"Masked ebuilds with RDEPEND settings (matched against *all* ebuilds) in developing arch", - "PDEPEND.badmaskedindev":"Masked ebuilds with PDEPEND settings (matched against *all* ebuilds) in developing arch", - "DEPEND.syntax":"Syntax error in DEPEND (usually an extra/missing space/parenthesis)", - "RDEPEND.syntax":"Syntax error in RDEPEND (usually an extra/missing space/parenthesis)", - "PDEPEND.syntax":"Syntax error in PDEPEND (usually an extra/missing space/parenthesis)", - "LICENSE.syntax":"Syntax error in LICENSE (usually an extra/missing space/parenthesis)", - "PROVIDE.syntax":"Syntax error in PROVIDE (usually an extra/missing space/parenthesis)", - "ebuild.syntax":"Error generating cache entry for ebuild; typically caused by ebuild syntax error", - "ebuild.output":"A simple sourcing of the ebuild produces output; this breaks ebuild policy.", - "ebuild.nesteddie":"Placing 'die' inside ( ) prints an error, but doesn't stop the ebuild.", - "variable.readonly":"Assigning a readonly variable", - "IUSE.invalid":"This build has a variable in IUSE that is not in the use.desc or use.local.desc file", - "LICENSE.invalid":"This ebuild is listing a license that doesnt exist in portages license/ dir.", - "KEYWORDS.invalid":"This ebuild contains KEYWORDS that are not listed in profiles/arch.list or for which no valid profile was found", - "ebuild.nostable":"There are no ebuilds that are marked as stable for your ARCH", - "ebuild.allmasked":"All ebuilds are masked for this package (Package level only)", - "ebuild.majorsyn":"This ebuild has a major syntax error that may cause the ebuild to fail partially or fully", - "ebuild.minorsyn":"This ebuild has a minor syntax error that contravenes gentoo coding style", - "ebuild.badheader":"This ebuild has a malformed header", - "metadata.missing":"Missing metadata.xml files", - "metadata.bad":"Bad metadata.xml files", - "virtual.versioned":"PROVIDE contains virtuals with versions", - "virtual.exists":"PROVIDE contains existing package names", - "virtual.unavailable":"PROVIDE contains a virtual which contains no profile default", - "usage.obsolete":"The ebuild makes use of an obsolete construct" -} - -qacats = qahelp.keys() -qacats.sort() - -qawarnings=[ -"changelog.missing", -"changelog.notadded", -"ebuild.notadded", -"ebuild.nostable", -"ebuild.allmasked", -"ebuild.nesteddie", -"digest.assumed", -"digest.notadded", -"digest.disjointed", -"digest.missing", -"digestentry.unused", -"DEPEND.badmasked","RDEPEND.badmasked","PDEPEND.badmasked", -"DEPEND.badindev","RDEPEND.badindev","PDEPEND.badindev", -"DEPEND.badmaskedindev","RDEPEND.badmaskedindev","PDEPEND.badmaskedindev", -"IUSE.invalid", -"KEYWORDS.stupid", -"ebuild.minorsyn", -"ebuild.badheader", -"file.size", -"metadata.missing", -"metadata.bad", -"virtual.versioned", -"virtual.exists", -"virtual.unavailable" -] - missingvars=["KEYWORDS","LICENSE","DESCRIPTION","HOMEPAGE","SLOT"] allvars=portage.auxdbkeys commitmessage=None commitmessagefile=None -for x in missingvars: - x += ".missing" - if x not in qacats: - print "* missingvars values need to be added to qahelp ("+x+")" - qacats.append(x) - qawarnings.append(x) - ven_cat = r'[\w0-9-]+' # Category ven_nam = r'([+a-z0-9-]+(?:[+_a-z0-9-]*[+a-z0-9-]+)*)' # Name ven_ver = r'((?:\d+\.)*\d+[a-z]?)' # Version @@ -238,45 +96,6 @@ print exename+" "+version sys.exit(0) -def help(exitstatus=1,helpfulness=1): - if quiet: - helpfulness=0 - if helpfulness: - print - print green(exename+" "+version) - print " \"Quality is job zero.\"" - print " Copyright 1999-2006 Gentoo Foundation" - print " Distributed under the terms of the GNU General Public License v2" - print - print bold(" Usage:"),turquoise(exename),"[",green("options"),"] [",green("mode"),"]" - if helpfulness: - print bold(" Modes:"),turquoise("scan (default)"), - for x in modes[1:]: - print "|",turquoise(x), - print - print - print " "+green(string.ljust("Options",20)+" Description") - for x in options: - if repoman_shortoptions_rev.has_key(x): - shopt=repoman_shortoptions_rev[x]+", "+x - else: - shopt=" "+x - print " "+string.ljust(shopt,20),repoman_options[x] - print - print " "+green(string.ljust("Modes",20)+" Description") - for x in modes: - print " "+string.ljust(x,20),modeshelp[x] - if helpfulness: - print - print " "+green(string.ljust("QA keyword",20)+" Description") - for x in qacats: - print " "+string.ljust(x,20),qahelp[x] - print - if (exitstatus != -1): - sys.exit(exitstatus) - else: - print - def last(): try: #Retrieve and unpickle stats and fails from saved files @@ -301,10 +120,10 @@ print print green("RepoMan remembers...") print - for x in qacats: + for x in repohelp.qahelp.keys(): if stats[x]: dowarn=1 - if x not in qawarnings: + if x not in repohelp.qawarnings: dofail=1 else: if mymode!="lfull": @@ -313,7 +132,7 @@ if stats[x]==0: print green(`stats[x]`) continue - elif x in qawarnings: + elif x in repohelp.qawarnings: print yellow(`stats[x]`) else: print red(`stats[x]`) @@ -342,16 +161,16 @@ if len(sys.argv)>1: x=1 while x < len(sys.argv): - if sys.argv[x] in shortmodes.keys(): - sys.argv[x]=shortmodes[sys.argv[x]] - elif sys.argv[x] in repoman_shortoptions.keys(): - sys.argv[x] = repoman_shortoptions[sys.argv[x]] - if sys.argv[x] in modes: + if sys.argv[x] in repohelp.shortmodes.keys(): + sys.argv[x]=repohelp.shortmodes[sys.argv[x]] + elif sys.argv[x] in repohelp.repoman_shortoptions.keys(): + sys.argv[x] = repohelp.repoman_shortoptions[sys.argv[x]] + if sys.argv[x] in repohelp.modeshelp.keys(): if mymode==None: mymode=sys.argv[x] else: err("Please specify either \""+mymode+"\" or \""+sys.argv[x]+"\", but not both.") - elif sys.argv[x] in options: + elif sys.argv[x] in repohelp.repoman_options.keys(): optionx=sys.argv[x] if (optionx=="--commitmsg") and (len(sys.argv)>=(x+1)): commitmessage=sys.argv[x+1] @@ -371,7 +190,7 @@ if mymode==None: mymode="scan" if mymode=="help" or ("--help" in myoptions): - help(exitstatus=0) + repohelp.help(exitstatus=0,quiet=quiet) if ("--version" in myoptions): show_version() if mymode=="last" or (mymode=="lfull"): @@ -652,7 +471,7 @@ fails={} #objsadded records all object being added to cvs objsadded=[] -for x in qacats: +for x in repohelp.qahelp.keys(): stats[x]=0 fails[x]=[] xmllint_capable = False @@ -1336,12 +1155,12 @@ dowarn=0 #dofull will be set if we should print a "repoman full" informational message dofull=0 -for x in qacats: +for x in repohelp.qahelp.keys(): if not isCvs and (string.find(x, "notadded") != -1): stats[x] = 0 if stats[x]: dowarn=1 - if x not in qawarnings: + if x not in repohelp.qawarnings: dofail=1 else: continue @@ -1349,7 +1168,7 @@ if stats[x]==0: print green(`stats[x]`) continue - elif x in qawarnings: + elif x in repohelp.qawarnings: print yellow(`stats[x]`) else: print red(`stats[x]`)
Index: repohelp.py =================================================================== --- repohelp.py (revision 0) +++ repohelp.py (revision 0) @@ -0,0 +1,201 @@ +# Repoman QA help similar in scope to emerge's emergehelp.py +# Alec Warner <[EMAIL PROTECTED]> 2006 + +from output import * +import string + +allowed_filename_chars="a-zA-Z0-9._-+:" +version="1.2" + +""" Repoman's short action modes """ +shortmodes={"ci":"commit"} + +""" Help for each of Repoman's action modes""" +modeshelp={ +"scan" : "Scan directory tree for QA issues (default)", +"fix" : "Fix simple QA issues (stray digests, missing digests)", +"full" : "Scan directory tree for QA issues (full listing)", +"help" : "Show this screen", +"commit" : "Scan directory tree for QA issues; if OK, commit via cvs", +"last" : "Remember report from last run", +"lfull" : "Remember report from last run (full listing)" +} + +""" Repoman options """ +repoman_options={ +"--commitmsg" : "Adds a commit message via the command line", +"--commitmsgfile" : "Adds a commit message from the specified file", +"--help" : "Show this screen", +"--ignore-arches" : "Ignore arch-specific failures (where arch != host)", +"--include-masked" : "Include masked packages in scans at category or tree level", +"--pretend" : "Don't commit or fix anything; just show what would be done", +"--quiet" : "Be less verbose about extraneous info", +"--verbose" : "Displays every package name while checking", +"--version" : "Show version info", +"--xmlparse" : "Forces the metadata.xml parse check to be carried out" +} + +""" Repoman Short Options """ +repoman_shortoptions={ +"-h" : "--help", +"-i" : "--include-masked", +"-I" : "--ignore-arches", +"-m" : "--commitmsg", +"-M" : "--commitmsgfile", +"-p" : "--pretend", +"-q" : "--quiet", +"-v" : "--verbose", +"-V" : "--version", +"-x" : "--xmlparse" +} + + +""" Map short QA Error messages to associated string objects """ +qahelp={ + "CVS/Entries.IO_error":"Attempting to commit, and an IO error was encountered access the Entries file", + "digest.partial":"Digest files do not contain all corresponding URI elements", + "digest.assumed":"Existing digest must be assumed correct (Package level only)", + "digestentry.unused":"Digest/Manifest entry has no matching SRC_URI entry", + "digest.fail":"Digest does not match the specified local file", + "digest.stray":"Digest files that do not have a corresponding ebuild", + "digest.missing":"Digest files that are missing (ebuild exists, digest doesn't)", + "digest.disjointed":"Digests not added to cvs when the matching ebuild has been added", + "digest.notadded":"Digests that exist but have not been added to cvs", + "digest.unmatch":"Digests which are incomplete (please check if your USE/ARCH includes all files)", + "ebuild.invalidname":"Ebuild files with a non-parseable or syntactically incorrect name (or using 2.1 versioning extensions)", + "ebuild.namenomatch":"Ebuild files that do not have the same name as their parent directory", + "changelog.missing":"Missing ChangeLog files", + "ebuild.disjointed":"Ebuilds not added to cvs when the matching digest has been added", + "ebuild.notadded":"Ebuilds that exist but have not been added to cvs", + "changelog.notadded":"ChangeLogs that exist but have not been added to cvs", + "filedir.missing":"Package lacks a files directory", + "file.executable":"Ebuilds, digests, metadata.xml, Manifest, and ChangeLog do note need the executable bit", + "file.size":"Files in the files directory must be under 20k", + "file.name":"File/dir name must be composed of only the following chars: %s " % allowed_filename_chars, + "file.UTF8":"File is not UTF8 compliant", + "KEYWORDS.missing":"Ebuilds that have a missing or empty KEYWORDS variable", + "KEYWORDS.stupid":"Ebuilds that use KEYWORDS=-* instead of package.mask", + "LICENSE.missing":"Ebuilds that have a missing or empty LICENSE variable", + "DESCRIPTION.missing":"Ebuilds that have a missing or empty DESCRIPTION variable", + "SLOT.missing":"Ebuilds that have a missing or empty SLOT variable", + "HOMEPAGE.missing":"Ebuilds that have a missing or empty HOMEPAGE variable", + "DEPEND.bad":"User-visible ebuilds with bad DEPEND settings (matched against *visible* ebuilds)", + "RDEPEND.bad":"User-visible ebuilds with bad RDEPEND settings (matched against *visible* ebuilds)", + "PDEPEND.bad":"User-visible ebuilds with bad PDEPEND settings (matched against *visible* ebuilds)", + "DEPEND.badmasked":"Masked ebuilds with bad DEPEND settings (matched against *all* ebuilds)", + "RDEPEND.badmasked":"Masked ebuilds with RDEPEND settings (matched against *all* ebuilds)", + "PDEPEND.badmasked":"Masked ebuilds with PDEPEND settings (matched against *all* ebuilds)", + "DEPEND.badindev":"User-visible ebuilds with bad DEPEND settings (matched against *visible* ebuilds) in developing arch", + "RDEPEND.badindev":"User-visible ebuilds with bad RDEPEND settings (matched against *visible* ebuilds) in developing arch", + "PDEPEND.badindev":"User-visible ebuilds with bad PDEPEND settings (matched against *visible* ebuilds) in developing arch", + "DEPEND.badmaskedindev":"Masked ebuilds with bad DEPEND settings (matched against *all* ebuilds) in developing arch", + "RDEPEND.badmaskedindev":"Masked ebuilds with RDEPEND settings (matched against *all* ebuilds) in developing arch", + "PDEPEND.badmaskedindev":"Masked ebuilds with PDEPEND settings (matched against *all* ebuilds) in developing arch", + "DEPEND.syntax":"Syntax error in DEPEND (usually an extra/missing space/parenthesis)", + "RDEPEND.syntax":"Syntax error in RDEPEND (usually an extra/missing space/parenthesis)", + "PDEPEND.syntax":"Syntax error in PDEPEND (usually an extra/missing space/parenthesis)", + "LICENSE.syntax":"Syntax error in LICENSE (usually an extra/missing space/parenthesis)", + "PROVIDE.syntax":"Syntax error in PROVIDE (usually an extra/missing space/parenthesis)", + "ebuild.syntax":"Error generating cache entry for ebuild; typically caused by ebuild syntax error", + "ebuild.output":"A simple sourcing of the ebuild produces output; this breaks ebuild policy.", + "ebuild.nesteddie":"Placing 'die' inside ( ) prints an error, but doesn't stop the ebuild.", + "variable.readonly":"Assigning a readonly variable", + "IUSE.invalid":"This build has a variable in IUSE that is not in the use.desc or use.local.desc file", + "LICENSE.invalid":"This ebuild is listing a license that doesnt exist in portages license/ dir.", + "KEYWORDS.invalid":"This ebuild contains KEYWORDS that are not listed in profiles/arch.list or for which no valid profile was found", + "ebuild.nostable":"There are no ebuilds that are marked as stable for your ARCH", + "ebuild.allmasked":"All ebuilds are masked for this package (Package level only)", + "ebuild.majorsyn":"This ebuild has a major syntax error that may cause the ebuild to fail partially or fully", + "ebuild.minorsyn":"This ebuild has a minor syntax error that contravenes gentoo coding style", + "ebuild.badheader":"This ebuild has a malformed header", + "metadata.missing":"Missing metadata.xml files", + "metadata.bad":"Bad metadata.xml files", + "virtual.versioned":"PROVIDE contains virtuals with versions", + "virtual.exists":"PROVIDE contains existing package names", + "virtual.unavailable":"PROVIDE contains a virtual which contains no profile default", + "usage.obsolete":"The ebuild makes use of an obsolete construct" +} + +""" A list of QA errors that are not fatal, as in they generate a warning only """ +qawarnings=[ +"changelog.missing", +"changelog.notadded", +"ebuild.notadded", +"ebuild.nostable", +"ebuild.allmasked", +"ebuild.nesteddie", +"digest.assumed", +"digest.notadded", +"digest.disjointed", +"digest.missing", +"digestentry.unused", +"DEPEND.badmasked","RDEPEND.badmasked","PDEPEND.badmasked", +"DEPEND.badindev","RDEPEND.badindev","PDEPEND.badindev", +"DEPEND.badmaskedindev","RDEPEND.badmaskedindev","PDEPEND.badmaskedindev", +"IUSE.invalid", +"KEYWORDS.stupid", +"ebuild.minorsyn", +"ebuild.badheader", +"file.size", +"metadata.missing", +"metadata.bad", +"usage.obsolete", +"virtual.versioned", +"virtual.exists", +"virtual.unavailable" +] + +""" This does some auxillary checks to compile the help and make sure nothing important +is missing from the help list.""" +def qahelp_check( missingvars ): + qacats = qahelp.keys() + qacats.sort() + for var in missingvars: + var += ".missing" + if var not in qacats: + print "* missingvars values need to be added to qahelp ("+var+")" + qacats.append(var) + qawarnings.append(var) + +""" Prints out helpful information about repoman usage""" +def help(exitstatus=1,helpfulness=1,quiet=0): + modes=modeshelp.keys() + repoman_shortoptions_rev=dict([(v,k) for (k,v) in repoman_shortoptions.items()]) + options=repoman_options.keys() + if quiet: + helpfulness=0 + if helpfulness: + print + print green("Repoman"+" "+version) + print " \"Quality is job zero.\"" + print " Copyright 1999-2006 Gentoo Foundation" + print " Distributed under the terms of the GNU General Public License v2" + print + print bold(" Usage:"),turquoise("Repoman"),"[",green("options"),"] [",green("mode"),"]" + if helpfulness: + print bold(" Modes:"),turquoise("scan (default)"), + for x in modes[1:]: + print "|",turquoise(x), + print + print + print " "+green(string.ljust("Options",20)+" Description") + for x in options: + if repoman_shortoptions_rev.has_key(x): + shopt=repoman_shortoptions_rev[x]+", "+x + else: + shopt=" "+x + print " "+string.ljust(shopt,20),repoman_options[x] + print + print " "+green(string.ljust("Modes",20)+" Description") + for x in modes: + print " "+string.ljust(x,20),modeshelp[x] + if helpfulness: + print + print " "+green(string.ljust("QA keyword",20)+" Description") + for x in qahelp.keys(): + print " "+string.ljust(x,20),qahelp[x] + print + if (exitstatus != -1): + sys.exit(exitstatus) + else: + print