commit: 56e9da22d0c8d761f26d0cb6988f2b44bb61142c Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> AuthorDate: Mon Mar 7 21:04:01 2016 +0000 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org> CommitDate: Fri Mar 11 01:05:30 2016 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=56e9da22
repoman: Add docstrings to the final vcs and scan modules pym/repoman/modules/scan/arches/arches.py | 13 ++++ pym/repoman/modules/scan/depend/depend.py | 13 ++++ pym/repoman/modules/scan/depend/profile.py | 27 +++++++ pym/repoman/modules/scan/depend/unknown.py | 13 ++++ pym/repoman/modules/scan/directories/files.py | 1 + pym/repoman/modules/scan/directories/mtime.py | 8 ++ pym/repoman/modules/scan/eapi/eapi.py | 2 + pym/repoman/modules/scan/ebuild/ebuild.py | 22 +++++- pym/repoman/modules/scan/ebuild/isebuild.py | 3 +- pym/repoman/modules/scan/ebuild/multicheck.py | 16 ++++ pym/repoman/modules/scan/eclasses/live.py | 6 ++ pym/repoman/modules/scan/eclasses/ruby.py | 8 +- pym/repoman/modules/scan/fetch/fetches.py | 1 + pym/repoman/modules/scan/keywords/keywords.py | 1 + pym/repoman/modules/scan/manifest/manifests.py | 25 ++++++ pym/repoman/modules/scan/metadata/pkgmetadata.py | 1 + .../modules/scan/mirrors/thirdpartymirrors.py | 1 + pym/repoman/modules/scan/options/options.py | 9 +++ pym/repoman/modules/scan/status/vcsstatus.py | 1 + pym/repoman/modules/scan/use/use_flags.py | 1 + pym/repoman/modules/vcs/None/changes.py | 15 +++- pym/repoman/modules/vcs/bzr/changes.py | 13 +++- pym/repoman/modules/vcs/bzr/status.py | 2 +- pym/repoman/modules/vcs/changes.py | 90 +++++++++++++++------- pym/repoman/modules/vcs/cvs/changes.py | 54 +++++++++---- pym/repoman/modules/vcs/cvs/status.py | 2 +- pym/repoman/modules/vcs/git/changes.py | 24 +++++- pym/repoman/modules/vcs/git/status.py | 5 ++ pym/repoman/modules/vcs/hg/changes.py | 21 ++++- pym/repoman/modules/vcs/hg/status.py | 2 +- pym/repoman/modules/vcs/settings.py | 13 ++++ pym/repoman/modules/vcs/svn/changes.py | 42 ++++++---- pym/repoman/modules/vcs/svn/status.py | 2 +- pym/repoman/modules/vcs/vcs.py | 13 +++- 34 files changed, 397 insertions(+), 73 deletions(-) diff --git a/pym/repoman/modules/scan/arches/arches.py b/pym/repoman/modules/scan/arches/arches.py index 5a58d15..bb9e204 100644 --- a/pym/repoman/modules/scan/arches/arches.py +++ b/pym/repoman/modules/scan/arches/arches.py @@ -2,13 +2,25 @@ class ArchChecks(object): + '''Perform arch keyword checks''' def __init__(self, **kwargs): + '''Class init + + @param options: the run time cli options + @param repo_settings: repository settings instance + @param profiles: dictionary + ''' self.options = kwargs.get('options') self.repo_settings = kwargs.get('repo_settings') self.profiles = kwargs.get('profiles') def check(self, **kwargs): + '''Determines the arches for the ebuild following the profile rules + + @param ebuild: Ebuild which we check (object). + @returns: dictionary, including arches set + ''' ebuild = kwargs.get('ebuild') if self.options.ignore_arches: arches = [[ @@ -57,4 +69,5 @@ class ArchChecks(object): @property def runInEbuilds(self): + '''Ebuild level scans''' return (True, [self.check]) diff --git a/pym/repoman/modules/scan/depend/depend.py b/pym/repoman/modules/scan/depend/depend.py index 2f90eee..72438e9 100644 --- a/pym/repoman/modules/scan/depend/depend.py +++ b/pym/repoman/modules/scan/depend/depend.py @@ -10,12 +10,24 @@ from repoman.qa_data import suspect_virtual, suspect_rdepend class DependChecks(object): + '''Perform dependency checks''' def __init__(self, **kwargs): + ''' + @param portdb: portdb instance + @param qatracker: QATracker instance + ''' self.qatracker = kwargs.get('qatracker') self.portdb = kwargs.get('portdb') def check(self, **kwargs): + '''Checks the ebuild dependencies for errors + + @param pkg: Package in which we check (object). + @param ebuild: Ebuild which we check (object). + @returns: dictionary including {unknown_pkgs, type_list, + badlicsyntax, baddepsyntax} + ''' ebuild = kwargs.get('ebuild') pkg = kwargs.get('pkg') @@ -136,4 +148,5 @@ class DependChecks(object): @property def runInEbuilds(self): + '''Ebuild level scans''' return (True, [self.check]) diff --git a/pym/repoman/modules/scan/depend/profile.py b/pym/repoman/modules/scan/depend/profile.py index db63b1c..c202377 100644 --- a/pym/repoman/modules/scan/depend/profile.py +++ b/pym/repoman/modules/scan/depend/profile.py @@ -16,8 +16,25 @@ def sort_key(item): class ProfileDependsChecks(object): + '''Perform dependency checks for the different profiles''' def __init__(self, **kwargs): + '''Class init + + @param qatracker: QATracker instance + @param repo_settings: repository settings instance + @param vcs_settings: VCSSettings instance + @param changed: changes dictionary + @param checks: checks dictionary + @param portdb: portdb instance + @param profiles: dictionary + @param include_arches: set + @param caches: dictionary of our caches + @param repoman_incrementals: tuple + @param env: the environment + @param have: dictionary instance + @param dev_keywords: developer profile keywords + ''' self.qatracker = kwargs.get('qatracker') self.portdb = kwargs.get('portdb') self.profiles = kwargs.get('profiles') @@ -31,6 +48,15 @@ class ProfileDependsChecks(object): self.dev_keywords = kwargs.get('dev_keywords') def check(self, **kwargs): + '''Perform profile dependant dependancy checks + + @param arches: + @param pkg: Package in which we check (object). + @param ebuild: Ebuild which we check (object). + @param baddepsyntax: boolean + @param unknown_pkgs: set of tuples (type, atom.unevaluated_atom) + @returns: dictionary + ''' arches = kwargs.get('arches') ebuild = kwargs.get('ebuild') pkg = kwargs.get('pkg') @@ -204,4 +230,5 @@ class ProfileDependsChecks(object): @property def runInEbuilds(self): + '''Ebuild level scans''' return (True, [self.check]) diff --git a/pym/repoman/modules/scan/depend/unknown.py b/pym/repoman/modules/scan/depend/unknown.py index b61a6e2..88927ad 100644 --- a/pym/repoman/modules/scan/depend/unknown.py +++ b/pym/repoman/modules/scan/depend/unknown.py @@ -2,11 +2,23 @@ class DependUnknown(object): + '''Perform checks to determine unknown dependencies''' def __init__(self, **kwargs): + '''Class init + + @param qatracker: QATracker instance + ''' self.qatracker = kwargs.get('qatracker') def check(self, **kwargs): + '''Perform unknown dependancy checks + + @param ebuild: Ebuild which we check (object). + @param baddepsyntax: boolean + @param unknown_pkgs: set of tuples (type, atom.unevaluated_atom) + @returns: dictionary + ''' ebuild = kwargs.get('ebuild') baddepsyntax = kwargs.get('baddepsyntax') unknown_pkgs = kwargs.get('unknown_pkgs') @@ -23,4 +35,5 @@ class DependUnknown(object): @property def runInEbuilds(self): + '''Ebuild level scans''' return (True, [self.check]) diff --git a/pym/repoman/modules/scan/directories/files.py b/pym/repoman/modules/scan/directories/files.py index 8f23528..a394658 100644 --- a/pym/repoman/modules/scan/directories/files.py +++ b/pym/repoman/modules/scan/directories/files.py @@ -36,6 +36,7 @@ class FileChecks(ScanBase): @param checkdir: string, directory path @param checkdir_relative: repolevel determined path @param changed: dictionary instance + @returns: dictionary ''' checkdir = kwargs.get('checkdir') checkdirlist = kwargs.get('checkdirlist') diff --git a/pym/repoman/modules/scan/directories/mtime.py b/pym/repoman/modules/scan/directories/mtime.py index e25b553..c5ddbb3 100644 --- a/pym/repoman/modules/scan/directories/mtime.py +++ b/pym/repoman/modules/scan/directories/mtime.py @@ -6,6 +6,13 @@ class MtimeChecks(object): self.vcs_settings = kwargs.get('vcs_settings') def check(self, **kwargs): + '''Perform a changelog and untracked checks on the ebuild + + @param pkg: Package in which we check (object). + @param ebuild: Ebuild which we check (object). + @param changed: dictionary instance + @returns: dictionary + ''' ebuild = kwargs.get('ebuild') changed = kwargs.get('changed') pkg = kwargs.get('pkg') @@ -17,4 +24,5 @@ class MtimeChecks(object): @property def runInEbuilds(self): + '''Ebuild level scans''' return (True, [self.check]) diff --git a/pym/repoman/modules/scan/eapi/eapi.py b/pym/repoman/modules/scan/eapi/eapi.py index 1d0ab23..603e1f5 100644 --- a/pym/repoman/modules/scan/eapi/eapi.py +++ b/pym/repoman/modules/scan/eapi/eapi.py @@ -19,6 +19,7 @@ class EAPIChecks(object): ''' @param pkg: Package in which we check (object). @param ebuild: Ebuild which we check (object). + @returns: dictionary ''' ebuild = kwargs.get('ebuild') @@ -42,4 +43,5 @@ class EAPIChecks(object): @property def runInEbuilds(self): + '''Ebuild level scans''' return (True, [self.check]) diff --git a/pym/repoman/modules/scan/ebuild/ebuild.py b/pym/repoman/modules/scan/ebuild/ebuild.py index 2414028..0ae416b 100644 --- a/pym/repoman/modules/scan/ebuild/ebuild.py +++ b/pym/repoman/modules/scan/ebuild/ebuild.py @@ -16,7 +16,8 @@ class Ebuild(ScanBase): '''Class to run primary checks on ebuilds''' def __init__(self, **kwargs): - ''' + '''Class init + @param qatracker: QATracker instance @param repo_settings: repository settings instance @param vcs_settings: VCSSettings instance @@ -36,7 +37,6 @@ class Ebuild(ScanBase): self.eapi = None self.inherited = None self.keywords = None - self.archs = None def _set_paths(self, **kwargs): repolevel = kwargs.get('repolevel') @@ -51,6 +51,7 @@ class Ebuild(ScanBase): @property def untracked(self): + '''Determines and returns if the ebuild is not tracked by the vcs''' do_check = self.vcs_settings.vcs in ("cvs", "svn", "bzr") really_notadded = (self.checks['ebuild_notadded'] and self.y_ebuild not in self.vcs_settings.eadded) @@ -60,6 +61,16 @@ class Ebuild(ScanBase): return False def check(self, **kwargs): + '''Perform a changelog and untracked checks on the ebuild + + @param xpkg: Package in which we check (object). + @param y_ebuild: Ebuild which we check (string). + @param changed: dictionary instance + @param repolevel: The depth within the repository + @param catdir: The category directiory + @param pkgdir: the package directory + @returns: dictionary, including {ebuild object} + ''' self.xpkg = kwargs.get('xpkg') self.y_ebuild = kwargs.get('y_ebuild') self.changed = kwargs.get('changed') @@ -76,6 +87,11 @@ class Ebuild(ScanBase): return {'continue': False, 'ebuild': self} def set_pkg_data(self, **kwargs): + '''Sets some classwide data needed for some of the checks + + @param pkgs: the dynamic list of ebuilds + @returns: dictionary + ''' self.pkg = kwargs.get('pkgs')[self.y_ebuild] self.metadata = self.pkg._metadata self.eapi = self.metadata["EAPI"] @@ -88,6 +104,7 @@ class Ebuild(ScanBase): '''Checks for bad category/package splits. @param pkgdir: string: path + @returns: dictionary ''' pkgdir = kwargs.get('pkgdir') myesplit = portage.pkgsplit(self.y_ebuild) @@ -109,6 +126,7 @@ class Ebuild(ScanBase): def pkg_invalid(self, **kwargs): '''Sets some pkg info and checks for invalid packages + @returns: dictionary, including {pkg object, allvalid} ''' if self.pkg.invalid: for k, msgs in self.pkg.invalid.items(): diff --git a/pym/repoman/modules/scan/ebuild/isebuild.py b/pym/repoman/modules/scan/ebuild/isebuild.py index 56e0268..1dffc6a 100644 --- a/pym/repoman/modules/scan/ebuild/isebuild.py +++ b/pym/repoman/modules/scan/ebuild/isebuild.py @@ -32,9 +32,10 @@ class IsEbuild(ScanBase): def check(self, **kwargs): '''Test the file for qualifications that is is an ebuild - @param checkdirlist: list of files in teh current package directory + @param checkdirlist: list of files in the current package directory @param checkdir: current package directory path @param xpkg: current package directory being checked + @returns: dictionary, including {pkgs, allvalid, can_force} ''' checkdirlist = kwargs.get('checkdirlist') checkdir = kwargs.get('checkdir') diff --git a/pym/repoman/modules/scan/ebuild/multicheck.py b/pym/repoman/modules/scan/ebuild/multicheck.py index 8b85abf..a9d85f0 100644 --- a/pym/repoman/modules/scan/ebuild/multicheck.py +++ b/pym/repoman/modules/scan/ebuild/multicheck.py @@ -1,4 +1,8 @@ +'''multicheck.py +Perform multiple different checks on an ebuild +''' + import io from portage import _encodings, _unicode_encode @@ -10,11 +14,22 @@ class MultiCheck(object): '''Class to run multiple different checks on an ebuild''' def __init__(self, **kwargs): + '''Class init + + @param qatracker: QATracker instance + @param options: the run time cli options + ''' self.qatracker = kwargs.get('qatracker') self.options = kwargs.get('options') checks_init(self.options.experimental_inherit == 'y') def check(self, **kwargs): + '''Check the ebuild for utf-8 encoding + + @param pkg: Package in which we check (object). + @param ebuild: Ebuild which we check (object). + @returns: dictionary + ''' ebuild = kwargs.get('ebuild') pkg = kwargs.get('pkg') try: @@ -36,4 +51,5 @@ class MultiCheck(object): @property def runInEbuilds(self): + '''Ebuild level scans''' return (True, [self.check]) diff --git a/pym/repoman/modules/scan/eclasses/live.py b/pym/repoman/modules/scan/eclasses/live.py index 4a870df..cb43bc0 100644 --- a/pym/repoman/modules/scan/eclasses/live.py +++ b/pym/repoman/modules/scan/eclasses/live.py @@ -18,6 +18,10 @@ class LiveEclassChecks(object): self.repo_settings = kwargs.get('repo_settings') def is_live(self, **kwargs): + '''Test if the ebuild inherits a live eclass + + @returns: dictionary, including {live_ebuild} + ''' return {'continue': False, 'live_ebuild': LIVE_ECLASSES.intersection( kwargs.get('ebuild').inherited)} @@ -32,6 +36,7 @@ class LiveEclassChecks(object): @param y_ebuild: Ebuild which we check (string). @param keywords: The keywords of the ebuild. @param global_pmaskdict: A global dictionary of all the masks. + @returns: dictionary ''' pkg = kwargs.get("pkg") package = kwargs.get('xpkg') @@ -68,4 +73,5 @@ class LiveEclassChecks(object): @property def runInEbuilds(self): + '''Ebuild level scans''' return (True, [self.is_live, self.check]) diff --git a/pym/repoman/modules/scan/eclasses/ruby.py b/pym/repoman/modules/scan/eclasses/ruby.py index 4dc5d62..aa2232a 100644 --- a/pym/repoman/modules/scan/eclasses/ruby.py +++ b/pym/repoman/modules/scan/eclasses/ruby.py @@ -1,5 +1,5 @@ -'''live.py +'''ruby.py Performs Ruby eclass checks ''' @@ -19,6 +19,12 @@ class RubyEclassChecks(ScanBase): self.old_ruby_eclasses = ["ruby-ng", "ruby-fakegem", "ruby"] def check(self, **kwargs): + '''Check ebuilds that inherit the ruby eclasses + + @param pkg: Package in which we check (object). + @param ebuild: Ebuild which we check (object). + @returns: dictionary + ''' pkg = kwargs.get('pkg') ebuild = kwargs.get('ebuild') is_inherited = lambda eclass: eclass in pkg.inherited diff --git a/pym/repoman/modules/scan/fetch/fetches.py b/pym/repoman/modules/scan/fetch/fetches.py index 63677d0..6bdcf23 100644 --- a/pym/repoman/modules/scan/fetch/fetches.py +++ b/pym/repoman/modules/scan/fetch/fetches.py @@ -38,6 +38,7 @@ class FetchChecks(ScanBase): @param xpkg: the pacakge being checked @param checkdir: string, directory path @param checkdir_relative: repolevel determined path + @returns: dictionary, including {src_uri_error} ''' xpkg = kwargs.get('xpkg') checkdir = kwargs.get('checkdir') diff --git a/pym/repoman/modules/scan/keywords/keywords.py b/pym/repoman/modules/scan/keywords/keywords.py index e34c891..196feb4 100644 --- a/pym/repoman/modules/scan/keywords/keywords.py +++ b/pym/repoman/modules/scan/keywords/keywords.py @@ -38,6 +38,7 @@ class KeywordChecks(ScanBase): @param ebuild_archs: Just the architectures (no prefixes) of the ebuild. @param changed: Changes instance @param live_ebuild: A boolean that determines if this is a live ebuild. + @returns: dictionary ''' pkg = kwargs.get('pkg') xpkg =kwargs.get('xpkg') diff --git a/pym/repoman/modules/scan/manifest/manifests.py b/pym/repoman/modules/scan/manifest/manifests.py index a19d566..2262e3f 100644 --- a/pym/repoman/modules/scan/manifest/manifests.py +++ b/pym/repoman/modules/scan/manifest/manifests.py @@ -12,8 +12,16 @@ from portage.util import writemsg_level class Manifests(object): + '''Creates as well as checks pkg Manifest entries/files''' def __init__(self, **kwargs): + '''Class init + + @param options: the run time cli options + @param portdb: portdb instance + @param qatracker: QATracker instance + @param repo_settings: repository settings instance + ''' self.options = kwargs.get('options') self.portdb = kwargs.get('portdb') self.qatracker = kwargs.get('qatracker') @@ -21,6 +29,12 @@ class Manifests(object): self.generated_manifest = False def check(self, **kwargs): + '''Perform a changelog and untracked checks on the ebuild + + @param xpkg: Package in which we check (object). + @param checkdirlist: list of files in the current package directory + @returns: dictionary + ''' checkdir = kwargs.get('checkdir') xpkg = kwargs.get('xpkg') self.generated_manifest = False @@ -83,6 +97,12 @@ class Manifests(object): return {'continue': False} def create_manifest(self, checkdir, fetchlist_dict): + '''Creates a Manifest file + + @param checkdir: the directory to generate the Manifest in + @param fetchlist_dict: dictionary of files to fetch and/or include + in the manifest + ''' try: distdir = self.repoman_settings['DISTDIR'] mf = self.repoman_settings.repositories.get_repo_for_location( @@ -102,6 +122,10 @@ class Manifests(object): portage._doebuild_manifest_exempt_depend -= 1 def digest_check(self, xpkg, checkdir): + '''Check the manifest entries, report any Q/A errors + + @param xpkg: the cat/pkg name to check + @param checkdir: the directory path to check''' self.repoman_settings['O'] = checkdir self.repoman_settings['PORTAGE_QUIET'] = '1' if not portage.digestcheck([], self.repoman_settings, strict=1): @@ -110,4 +134,5 @@ class Manifests(object): @property def runInPkgs(self): + '''Package level scans''' return (True, [self.check]) diff --git a/pym/repoman/modules/scan/metadata/pkgmetadata.py b/pym/repoman/modules/scan/metadata/pkgmetadata.py index 8e93457..030cbca 100644 --- a/pym/repoman/modules/scan/metadata/pkgmetadata.py +++ b/pym/repoman/modules/scan/metadata/pkgmetadata.py @@ -64,6 +64,7 @@ class PkgMetadata(ScanBase): @param checkdir: string, directory path @param checkdirlist: list of checkdir's @param repolevel: integer + @returns: dictionary, including {muselist} ''' xpkg = kwargs.get('xpkg') checkdir = kwargs.get('checkdir') diff --git a/pym/repoman/modules/scan/mirrors/thirdpartymirrors.py b/pym/repoman/modules/scan/mirrors/thirdpartymirrors.py index 9404e28..f467ea4 100644 --- a/pym/repoman/modules/scan/mirrors/thirdpartymirrors.py +++ b/pym/repoman/modules/scan/mirrors/thirdpartymirrors.py @@ -31,6 +31,7 @@ class ThirdPartyMirrors(ScanBase): @param ebuild: Ebuild which we check (object). @param src_uri_error: boolean + @returns: dictionary ''' ebuild = kwargs.get('ebuild') if kwargs.get('src_uri_error'): diff --git a/pym/repoman/modules/scan/options/options.py b/pym/repoman/modules/scan/options/options.py index c2546d6..327b6d8 100644 --- a/pym/repoman/modules/scan/options/options.py +++ b/pym/repoman/modules/scan/options/options.py @@ -3,9 +3,17 @@ class Options(object): def __init__(self, **kwargs): + '''Class init function + + @param options: argparse options instance + ''' self.options = kwargs.get('options') def is_forced(self, **kwargs): + '''Simple boolean function to trigger a skip past some additional checks + + @returns: dictionary + ''' if self.options.force: # The dep_check() calls are the most expensive QA test. If --force # is enabled, there's no point in wasting time on these since the @@ -15,4 +23,5 @@ class Options(object): @property def runInEbuilds(self): + '''Ebuild level scans''' return (True, [self.is_forced]) diff --git a/pym/repoman/modules/scan/status/vcsstatus.py b/pym/repoman/modules/scan/status/vcsstatus.py index 1ece6c6..cf2298e 100644 --- a/pym/repoman/modules/scan/status/vcsstatus.py +++ b/pym/repoman/modules/scan/status/vcsstatus.py @@ -24,6 +24,7 @@ class VCSStatus(ScanBase): @param checkdir: string, directory path @param checkdir_relative: repolevel determined path @param xpkg: the current package being checked + @returns: dictionary including {eadded} ''' checkdir = kwargs.get('checkdir') checkdir_relative = kwargs.get('checkdir_relative') diff --git a/pym/repoman/modules/scan/use/use_flags.py b/pym/repoman/modules/scan/use/use_flags.py index acc7dd3..b76ed70 100644 --- a/pym/repoman/modules/scan/use/use_flags.py +++ b/pym/repoman/modules/scan/use/use_flags.py @@ -36,6 +36,7 @@ class USEFlagChecks(ScanBase): @param ebuild: Ebuild which we check (object). @param y_ebuild: Ebuild which we check (string). @param muselist: Local USE flags of the package + @returns: dictionary, including {ebuild_UsedUseFlags, used_useflags} ''' pkg = kwargs.get('pkg') package = kwargs.get('xpkg') diff --git a/pym/repoman/modules/vcs/None/changes.py b/pym/repoman/modules/vcs/None/changes.py index 7f46177..46c38e2 100644 --- a/pym/repoman/modules/vcs/None/changes.py +++ b/pym/repoman/modules/vcs/None/changes.py @@ -15,7 +15,8 @@ class Changes(ChangesBase): def __init__(self, options, repo_settings): '''Class init - @param options: commandline options + @param options: the run time cli options + @param repo_settings: RepoSettings instance ''' super(Changes, self).__init__(options, repo_settings) @@ -23,11 +24,19 @@ class Changes(ChangesBase): '''VCS type scan function, looks for all detectable changes''' pass - def add_items(self, myautoadd): - '''Nothing to add them to''' + def add_items(self, autoadd): + '''Add files to the vcs's modified or new index + + @param autoadd: the files to add to the vcs modified index''' pass def commit(self, myfiles, commitmessagefile): + '''None commit function + + @param commitfiles: list of files to commit + @param commitmessagefile: file containing the commit message + @returns: The sub-command exit value or 0 + ''' commit_cmd = [] # substitute a bogus vcs value for pretend output commit_cmd.append("pretend") diff --git a/pym/repoman/modules/vcs/bzr/changes.py b/pym/repoman/modules/vcs/bzr/changes.py index e5e61ff..4d4808c 100644 --- a/pym/repoman/modules/vcs/bzr/changes.py +++ b/pym/repoman/modules/vcs/bzr/changes.py @@ -18,7 +18,8 @@ class Changes(ChangesBase): def __init__(self, options, repo_settings): '''Class init - @param options: commandline options + @param options: the run time cli options + @param repo_settings: RepoSettings instance ''' super(Changes, self).__init__(options, repo_settings) @@ -52,7 +53,15 @@ class Changes(ChangesBase): if elem.startswith("?") or elem[0:2] == " D"] return self._unadded - def digest_regen(self, myupdates, myremoved, mymanifests, scanner, broken_changelog_manifests): + def digest_regen(self, updates, removed, manifests, scanner, broken_changelog_manifests): + '''Regenerate manifests + + @param updates: updated files + @param removed: removed files + @param manifests: Manifest files + @param scanner: The repoman.scanner.Scanner instance + @param broken_changelog_manifests: broken changelog manifests + ''' if broken_changelog_manifests: for x in broken_changelog_manifests: self.repoman_settings["O"] = os.path.join(self.repo_settings.repodir, x) diff --git a/pym/repoman/modules/vcs/bzr/status.py b/pym/repoman/modules/vcs/bzr/status.py index d5f3326..199e7f3 100644 --- a/pym/repoman/modules/vcs/bzr/status.py +++ b/pym/repoman/modules/vcs/bzr/status.py @@ -62,7 +62,7 @@ class Status(object): @staticmethod def isVcsDir(dirname): - '''Is the directory belong to the vcs system + '''Does the directory belong to the vcs system @param dirname: string, directory name @returns: Boolean diff --git a/pym/repoman/modules/vcs/changes.py b/pym/repoman/modules/vcs/changes.py index f322cb1..aa4923f 100644 --- a/pym/repoman/modules/vcs/changes.py +++ b/pym/repoman/modules/vcs/changes.py @@ -21,6 +21,11 @@ class ChangesBase(object): vcs = 'None' def __init__(self, options, repo_settings): + '''Class init function + + @param options: the run time cli options + @param repo_settings: RepoSettings instance + ''' self.options = options self.repo_settings = repo_settings self.repoman_settings = repo_settings.repoman_settings @@ -28,6 +33,7 @@ class ChangesBase(object): self._reset() def _reset(self): + '''Reset the class variables for a new run''' self.new_ebuilds = set() self.ebuilds = set() self.changelogs = set() @@ -40,6 +46,11 @@ class ChangesBase(object): self._unadded = None def scan(self): + '''Scan the vcs for detectable changes. + + base method which calls the subclassing VCS module's _scan() + then updates some classwide variables. + ''' self._reset() if self.vcs: @@ -80,52 +91,79 @@ class ChangesBase(object): '''Override this function as needed''' return {} - def thick_manifest(self, myupdates, myheaders, no_expansion, expansion): - '''Create a thick manifest''' + def thick_manifest(self, updates, headers, no_expansion, expansion): + '''Create a thick manifest + + @param updates: + @param headers: + @param no_expansion: + @param expansion: + ''' pass - def digest_regen(self, myupdates, myremoved, mymanifests, scanner, + def digest_regen(self, updates, removed, manifests, scanner, broken_changelog_manifests): - '''Regenerate manifests''' + '''Regenerate manifests + + @param updates: updated files + @param removed: removed files + @param manifests: Manifest files + @param scanner: The repoman.scanner.Scanner instance + @param broken_changelog_manifests: broken changelog manifests + ''' pass @staticmethod - def clear_attic(myheaders): - '''Old CVS leftover''' + def clear_attic(headers): + '''Old CVS leftover + + @param headers: file headers''' pass def update_index(self, mymanifests, myupdates): - '''Update the vcs's modified index if it is needed''' + '''Update the vcs's modified index if it is needed + + @param mymanifests: manifest files updated + @param myupdates: other files updated''' pass - def add_items(self, myautoadd): - add_cmd = [self.vcs, "add"] - add_cmd += myautoadd - if self.options.pretend: - portage.writemsg_stdout( - "(%s)\n" % " ".join(add_cmd), - noiselevel=-1) - else: - add_cmd = [_unicode_encode(arg) for arg in add_cmd] - retcode = subprocess.call(add_cmd) - if retcode != os.EX_OK: - logging.error( - "Exiting on %s error code: %s\n" % (self.vcs_settings.vcs, retcode)) - sys.exit(retcode) - - - def commit(self, myfiles, commitmessagefile): - '''Common generic commit function''' + def add_items(self, autoadd): + '''Add files to the vcs's modified or new index + + @param autoadd: the files to add to the vcs modified index''' + add_cmd = [self.vcs, "add"] + add_cmd += autoadd + if self.options.pretend: + portage.writemsg_stdout( + "(%s)\n" % " ".join(add_cmd), + noiselevel=-1) + else: + add_cmd = [_unicode_encode(arg) for arg in add_cmd] + retcode = subprocess.call(add_cmd) + if retcode != os.EX_OK: + logging.error( + "Exiting on %s error code: %s\n", self.vcs_settings.vcs, retcode) + sys.exit(retcode) + + + def commit(self, commitfiles, commitmessagefile): + '''Common generic commit function + + @param commitfiles: list of files to commit + @param commitmessagefile: file containing the commit message + @returns: The sub-command exit value or 0 + ''' commit_cmd = [] commit_cmd.append(self.vcs) commit_cmd.extend(self.vcs_settings.vcs_global_opts) commit_cmd.append("commit") commit_cmd.extend(self.vcs_settings.vcs_local_opts) commit_cmd.extend(["-F", commitmessagefile]) - commit_cmd.extend(f.lstrip("./") for f in myfiles) + commit_cmd.extend(f.lstrip("./") for f in commitfiles) if self.options.pretend: print("(%s)" % (" ".join(commit_cmd),)) + return 0 else: retval = spawn(commit_cmd, env=self.repo_settings.commit_env) return retval diff --git a/pym/repoman/modules/vcs/cvs/changes.py b/pym/repoman/modules/vcs/cvs/changes.py index f5c622b..3e2f97a 100644 --- a/pym/repoman/modules/vcs/cvs/changes.py +++ b/pym/repoman/modules/vcs/cvs/changes.py @@ -7,9 +7,15 @@ from itertools import chain from repoman._portage import portage from repoman.modules.vcs.changes import ChangesBase +from repoman.modules.vcs.vcs import vcs_files_to_cps +from repoman._subprocess import repoman_getstatusoutput + +from portage import _encodings, _unicode_encode from portage import cvstree, os +from portage.output import green from portage.package.ebuild.digestgen import digestgen + class Changes(ChangesBase): '''Class object to scan and hold the resultant data for all changes to process. @@ -20,7 +26,8 @@ class Changes(ChangesBase): def __init__(self, options, repo_settings): '''Class init - @param options: commandline options + @param options: the run time cli options + @param repo_settings: RepoSettings instance ''' super(Changes, self).__init__(options, repo_settings) self._tree = None @@ -44,11 +51,15 @@ class Changes(ChangesBase): return self._unadded @staticmethod - def clear_attic(myheaders): + def clear_attic(headers): + '''Clear the attic (inactive files) + + @param headers: file headers + ''' cvs_header_re = re.compile(br'^#\s*\$Header.*\$$') attic_str = b'/Attic/' attic_replace = b'/' - for x in myheaders: + for x in headers: f = open( _unicode_encode(x, encoding=_encodings['fs'], errors='strict'), mode='rb') @@ -63,29 +74,44 @@ class Changes(ChangesBase): if modified: portage.util.write_atomic(x, b''.join(mylines), mode='wb') - def thick_manifest(self, myupdates, myheaders, no_expansion, expansion): + def thick_manifest(self, updates, headers, no_expansion, expansion): + '''Create a thick manifest + + @param updates: + @param headers: + @param no_expansion: + @param expansion: + ''' headerstring = "'\$(Header|Id).*\$'" - for myfile in myupdates: + for _file in updates: # for CVS, no_expansion contains files that are excluded from expansion - if myfile in no_expansion: + if _file in no_expansion: continue - myout = repoman_getstatusoutput( - "egrep -q %s %s" % (headerstring, portage._shell_quote(myfile))) - if myout[0] == 0: - myheaders.append(myfile) + _out = repoman_getstatusoutput( + "egrep -q %s %s" % (headerstring, portage._shell_quote(_file))) + if _out[0] == 0: + headers.append(_file) - print("%s have headers that will change." % green(str(len(myheaders)))) + print("%s have headers that will change." % green(str(len(headers)))) print( "* Files with headers will" " cause the manifests to be changed and committed separately.") - def digest_regen(self, myupdates, myremoved, mymanifests, scanner, broken_changelog_manifests): - if myupdates or myremoved: + def digest_regen(self, updates, removed, manifests, scanner, broken_changelog_manifests): + '''Regenerate manifests + + @param updates: updated files + @param removed: removed files + @param manifests: Manifest files + @param scanner: The repoman.scanner.Scanner instance + @param broken_changelog_manifests: broken changelog manifests + ''' + if updates or removed: for x in sorted(vcs_files_to_cps( - chain(myupdates, myremoved, mymanifests), + chain(updates, removed, manifests), scanner.repolevel, scanner.reposplit, scanner.categories)): self.repoman_settings["O"] = os.path.join(self.repo_settings.repodir, x) digestgen(mysettings=self.repoman_settings, myportdb=self.repo_settings.portdb) diff --git a/pym/repoman/modules/vcs/cvs/status.py b/pym/repoman/modules/vcs/cvs/status.py index 1917bde..b936aa7 100644 --- a/pym/repoman/modules/vcs/cvs/status.py +++ b/pym/repoman/modules/vcs/cvs/status.py @@ -123,7 +123,7 @@ class Status(object): @staticmethod def isVcsDir(dirname): - '''Is the directory belong to the vcs system + '''Does the directory belong to the vcs system @param dirname: string, directory name @returns: Boolean diff --git a/pym/repoman/modules/vcs/git/changes.py b/pym/repoman/modules/vcs/git/changes.py index a0b836e..7e9ac1e 100644 --- a/pym/repoman/modules/vcs/git/changes.py +++ b/pym/repoman/modules/vcs/git/changes.py @@ -24,7 +24,8 @@ class Changes(ChangesBase): def __init__(self, options, repo_settings): '''Class init - @param options: commandline options + @param options: the run time cli options + @param repo_settings: RepoSettings instance ''' super(Changes, self).__init__(options, repo_settings) @@ -63,13 +64,25 @@ class Changes(ChangesBase): del unadded return self._unadded - def digest_regen(self, myupdates, myremoved, mymanifests, scanner, broken_changelog_manifests): + def digest_regen(self, updates, removed, manifests, scanner, broken_changelog_manifests): + '''Regenerate manifests + + @param updates: updated files + @param removed: removed files + @param manifests: Manifest files + @param scanner: The repoman.scanner.Scanner instance + @param broken_changelog_manifests: broken changelog manifests + ''' if broken_changelog_manifests: for x in broken_changelog_manifests: self.repoman_settings["O"] = os.path.join(self.repo_settings.repodir, x) digestgen(mysettings=self.repoman_settings, myportdb=self.repo_settings.portdb) def update_index(self, mymanifests, myupdates): + '''Update the vcs's modified index if it is needed + + @param mymanifests: manifest files updated + @param myupdates: other files updated''' # It's not safe to use the git commit -a option since there might # be some modified files elsewhere in the working tree that the # user doesn't want to commit. Therefore, call git update-index @@ -92,7 +105,12 @@ class Changes(ChangesBase): sys.exit(retval) def commit(self, myfiles, commitmessagefile): - '''Git commit the changes''' + '''Git commit function + + @param commitfiles: list of files to commit + @param commitmessagefile: file containing the commit message + @returns: The sub-command exit value or 0 + ''' retval = super(Changes, self).commit(myfiles, commitmessagefile) if retval != os.EX_OK: if self.repo_settings.repo_config.sign_commit and not self.vcs_settings.status.supports_gpg_sign(): diff --git a/pym/repoman/modules/vcs/git/status.py b/pym/repoman/modules/vcs/git/status.py index 963abf6..48a73be 100644 --- a/pym/repoman/modules/vcs/git/status.py +++ b/pym/repoman/modules/vcs/git/status.py @@ -70,5 +70,10 @@ class Status(object): @staticmethod def isVcsDir(dirname): + '''Does the directory belong to the vcs system + + @param dirname: string, directory name + @returns: Boolean + ''' return dirname in [".git"] diff --git a/pym/repoman/modules/vcs/hg/changes.py b/pym/repoman/modules/vcs/hg/changes.py index c8b0c5f..8670575 100644 --- a/pym/repoman/modules/vcs/hg/changes.py +++ b/pym/repoman/modules/vcs/hg/changes.py @@ -20,7 +20,8 @@ class Changes(ChangesBase): def __init__(self, options, repo_settings): '''Class init - @param options: commandline options + @param options: the run time cli options + @param repo_settings: RepoSettings instance ''' super(Changes, self).__init__(options, repo_settings) @@ -67,14 +68,27 @@ class Changes(ChangesBase): return self._deleted - def digest_regen(self, myupdates, myremoved, mymanifests, scanner, broken_changelog_manifests): + def digest_regen(self, updates, removed, manifests, scanner, broken_changelog_manifests): + '''Regenerate manifests + + @param updates: updated files + @param removed: removed files + @param manifests: Manifest files + @param scanner: The repoman.scanner.Scanner instance + @param broken_changelog_manifests: broken changelog manifests + ''' if broken_changelog_manifests: for x in broken_changelog_manifests: self.repoman_settings["O"] = os.path.join(self.repo_settings.repodir, x) digestgen(mysettings=self.repoman_settings, myportdb=self.repo_settings.portdb) def commit(self, myfiles, commitmessagefile): - '''Hg commit the changes''' + '''Hg commit function + + @param commitfiles: list of files to commit + @param commitmessagefile: file containing the commit message + @returns: The sub-command exit value or 0 + ''' commit_cmd = [] commit_cmd.append(self.vcs) commit_cmd.extend(self.vcs_settings.vcs_global_opts) @@ -85,6 +99,7 @@ class Changes(ChangesBase): if self.options.pretend: print("(%s)" % (" ".join(commit_cmd),)) + return 0 else: retval = spawn(commit_cmd, env=self.repo_settings.commit_env) return retval diff --git a/pym/repoman/modules/vcs/hg/status.py b/pym/repoman/modules/vcs/hg/status.py index a3081cb..8443554 100644 --- a/pym/repoman/modules/vcs/hg/status.py +++ b/pym/repoman/modules/vcs/hg/status.py @@ -57,7 +57,7 @@ class Status(object): @staticmethod def isVcsDir(dirname): - '''Is the directory belong to the vcs system + '''Does the directory belong to the vcs system @param dirname: string, directory name @returns: Boolean diff --git a/pym/repoman/modules/vcs/settings.py b/pym/repoman/modules/vcs/settings.py index 9338a81..a8e91dd 100644 --- a/pym/repoman/modules/vcs/settings.py +++ b/pym/repoman/modules/vcs/settings.py @@ -1,3 +1,6 @@ +''' +Repoman VCSSettings modules +''' from __future__ import print_function, unicode_literals @@ -14,6 +17,12 @@ class VCSSettings(object): '''Holds various VCS settings''' def __init__(self, options=None, repoman_settings=None, repo_settings=None): + '''Class init function + + @param options: the run time cli options + @param repoman_settings: portage.config settings instance + @param repo_settings: RepoSettings instance + ''' self.options = options self.repoman_settings = repoman_settings self.repo_settings = repo_settings @@ -82,6 +91,8 @@ class VCSSettings(object): @property def status(self): + '''Initializes and returns the class instance + of the vcs's Status class''' if not self._status: status = self.module_controller.get_class('%s_status' % self.vcs) self._status = status(self.qatracker, self.eadded) @@ -89,6 +100,8 @@ class VCSSettings(object): @property def changes(self): + '''Initializes and returns the class instance + of the vcs's Changes class''' if not self._changes: changes = self.module_controller.get_class('%s_changes' % self.vcs) self._changes = changes(self.options, self.repo_settings) diff --git a/pym/repoman/modules/vcs/svn/changes.py b/pym/repoman/modules/vcs/svn/changes.py index f22c97d..d83c7c4 100644 --- a/pym/repoman/modules/vcs/svn/changes.py +++ b/pym/repoman/modules/vcs/svn/changes.py @@ -24,7 +24,8 @@ class Changes(ChangesBase): def __init__(self, options, repo_settings): '''Class init - @param options: commandline options + @param options: the run time cli options + @param repo_settings: RepoSettings instance ''' super(Changes, self).__init__(options, repo_settings) @@ -73,7 +74,14 @@ class Changes(ChangesBase): del svnstatus return self._unadded - def thick_manifest(self, myupdates, myheaders, no_expansion, expansion): + def thick_manifest(self, updates, headers, no_expansion, expansion): + '''Create a thick manifest + + @param updates: + @param headers: + @param no_expansion: + @param expansion: + ''' svn_keywords = dict((k.lower(), k) for k in [ "Rev", "Revision", @@ -88,36 +96,44 @@ class Changes(ChangesBase): "Header", ]) - for myfile in myupdates: + for _file in updates: # for SVN, expansion contains files that are included in expansion - if myfile not in expansion: + if _file not in expansion: continue # Subversion keywords are case-insensitive # in svn:keywords properties, # but case-sensitive in contents of files. enabled_keywords = [] - for k in expansion[myfile]: + for k in expansion[_file]: keyword = svn_keywords.get(k.lower()) if keyword is not None: enabled_keywords.append(keyword) headerstring = "'\$(%s).*\$'" % "|".join(enabled_keywords) - myout = repoman_getstatusoutput( - "egrep -q %s %s" % (headerstring, portage._shell_quote(myfile))) - if myout[0] == 0: - myheaders.append(myfile) + _out = repoman_getstatusoutput( + "egrep -q %s %s" % (headerstring, portage._shell_quote(_file))) + if _out[0] == 0: + headers.append(_file) - print("%s have headers that will change." % green(str(len(myheaders)))) + print("%s have headers that will change." % green(str(len(headers)))) print( "* Files with headers will" " cause the manifests to be changed and committed separately.") - def digest_regen(self, myupdates, myremoved, mymanifests, scanner, broken_changelog_manifests): - if myupdates or myremoved: + def digest_regen(self, updates, removed, manifests, scanner, broken_changelog_manifests): + '''Regenerate manifests + + @param updates: updated files + @param removed: removed files + @param manifests: Manifest files + @param scanner: The repoman.scanner.Scanner instance + @param broken_changelog_manifests: broken changelog manifests + ''' + if updates or removed: for x in sorted(vcs_files_to_cps( - chain(myupdates, myremoved, mymanifests), + chain(updates, removed, manifests), scanner.repolevel, scanner.reposplit, scanner.categories)): self.repoman_settings["O"] = os.path.join(self.repo_settings.repodir, x) digestgen(mysettings=self.repoman_settings, myportdb=self.repo_settings.portdb) diff --git a/pym/repoman/modules/vcs/svn/status.py b/pym/repoman/modules/vcs/svn/status.py index 3b57149..6575fe0 100644 --- a/pym/repoman/modules/vcs/svn/status.py +++ b/pym/repoman/modules/vcs/svn/status.py @@ -142,7 +142,7 @@ class Status(object): @staticmethod def isVcsDir(dirname): - '''Is the directory belong to the vcs system + '''Does the directory belong to the vcs system @param dirname: string, directory name @returns: Boolean diff --git a/pym/repoman/modules/vcs/vcs.py b/pym/repoman/modules/vcs/vcs.py index 8ec7270..c8cb55d 100644 --- a/pym/repoman/modules/vcs/vcs.py +++ b/pym/repoman/modules/vcs/vcs.py @@ -47,7 +47,11 @@ def FindVCS(cwd=None): outvcs = [] def seek(depth=None): - """ Seek for VCSes that have a top-level data directory only. """ + '''Seek for VCSes that have a top-level data directory only. + + @param depth: integer + @returns: list of strings + ''' retvcs = [] pathprep = cwd @@ -127,6 +131,13 @@ def vcs_files_to_cps(vcs_file_iter, repolevel, reposplit, categories): def vcs_new_changed(relative_path, mychanged, mynew): + '''Check if any vcs tracked file have been modified + + @param relative_path: + @param mychanged: iterable of changed files + @param mynew: iterable of new files + @returns boolean + ''' for x in chain(mychanged, mynew): if x == relative_path: return True