commit:     4d370b84a917b351eaaa55f0d181909f42add18d
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 25 03:57:03 2016 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Apr 25 04:04:35 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=4d370b84

ProfileDependsChecks: convert ArchChecks to function

 pym/repoman/modules/scan/arches/__init__.py    | 30 ----------
 pym/repoman/modules/scan/arches/arches.py      | 78 --------------------------
 pym/repoman/modules/scan/depend/__init__.py    |  1 -
 pym/repoman/modules/scan/depend/_gen_arches.py | 57 +++++++++++++++++++
 pym/repoman/modules/scan/depend/profile.py     |  5 +-
 pym/repoman/scanner.py                         |  2 +-
 6 files changed, 61 insertions(+), 112 deletions(-)

diff --git a/pym/repoman/modules/scan/arches/__init__.py 
b/pym/repoman/modules/scan/arches/__init__.py
deleted file mode 100644
index d66be1e..0000000
--- a/pym/repoman/modules/scan/arches/__init__.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright 2015-2016 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-doc = """Arches plug-in module for repoman.
-Performs archs checks on ebuilds."""
-__doc__ = doc[:]
-
-
-module_spec = {
-       'name': 'arches',
-       'description': doc,
-       'provides':{
-               'archs-module': {
-                       'name': "arches",
-                       'sourcefile': "arches",
-                       'class': "ArchChecks",
-                       'description': doc,
-                       'functions': ['check'],
-                       'func_desc': {
-                       },
-                       'mod_kwargs': ['options', 'repo_settings', 'profiles'
-                       ],
-                       'func_kwargs': {
-                               'arches': ('Future', 'set'),
-                               'ebuild': (None, None),
-                       },
-               },
-       }
-}
-

diff --git a/pym/repoman/modules/scan/arches/arches.py 
b/pym/repoman/modules/scan/arches/arches.py
deleted file mode 100644
index b86848d..0000000
--- a/pym/repoman/modules/scan/arches/arches.py
+++ /dev/null
@@ -1,78 +0,0 @@
-# -*- coding:utf-8 -*-
-
-from repoman.modules.scan.scanbase import ScanBase
-
-
-class ArchChecks(ScanBase):
-       '''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').get()
-               if self.options.ignore_arches:
-                       arches = [[
-                               self.repo_settings.repoman_settings["ARCH"], 
self.repo_settings.repoman_settings["ARCH"],
-                               
self.repo_settings.repoman_settings["ACCEPT_KEYWORDS"].split()]]
-               else:
-                       arches = set()
-                       for keyword in ebuild.keywords:
-                               if keyword[0] == "-":
-                                       continue
-                               elif keyword[0] == "~":
-                                       arch = keyword[1:]
-                                       if arch == "*":
-                                               for expanded_arch in 
self.profiles:
-                                                       if expanded_arch == 
"**":
-                                                               continue
-                                                       arches.add(
-                                                               (keyword, 
expanded_arch, (
-                                                                       
expanded_arch, "~" + expanded_arch)))
-                                       else:
-                                               arches.add((keyword, arch, 
(arch, keyword)))
-                               else:
-                                       # For ebuilds with stable keywords, 
check if the
-                                       # dependencies are satisfiable for 
unstable
-                                       # configurations, since use.stable.mask 
is not
-                                       # applied for unstable configurations 
(see bug
-                                       # 563546).
-                                       if keyword == "*":
-                                               for expanded_arch in 
self.profiles:
-                                                       if expanded_arch == 
"**":
-                                                               continue
-                                                       arches.add(
-                                                               (keyword, 
expanded_arch, (expanded_arch,)))
-                                                       arches.add(
-                                                               (keyword, 
expanded_arch,
-                                                                       
(expanded_arch, "~" + expanded_arch)))
-                                       else:
-                                               arches.add((keyword, keyword, 
(keyword,)))
-                                               arches.add((keyword, keyword,
-                                                       (keyword, "~" + 
keyword)))
-                       if not arches:
-                               # Use an empty profile for checking 
dependencies of
-                               # packages that have empty KEYWORDS.
-                               arches.add(('**', '**', ('**',)))
-               # update the dynamic data
-               dyn_arches = kwargs.get('arches')
-               dyn_arches.set(arches)
-               return False
-
-       @property
-       def runInEbuilds(self):
-               '''Ebuild level scans'''
-               return (True, [self.check])

diff --git a/pym/repoman/modules/scan/depend/__init__.py 
b/pym/repoman/modules/scan/depend/__init__.py
index 27c803d..01bd116 100644
--- a/pym/repoman/modules/scan/depend/__init__.py
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -41,7 +41,6 @@ module_spec = {
                                'repoman_incrementals', 'env', 'have', 
'dev_keywords'
                        ],
                        'func_kwargs': {
-                               'arches': (None, None),
                                'baddepsyntax': (None, None),
                                'ebuild': (None, None),
                                'pkg': (None, None),

diff --git a/pym/repoman/modules/scan/depend/_gen_arches.py 
b/pym/repoman/modules/scan/depend/_gen_arches.py
new file mode 100644
index 0000000..16b8dac
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/_gen_arches.py
@@ -0,0 +1,57 @@
+# -*- coding:utf-8 -*-
+
+
+def _gen_arches(ebuild, options, repo_settings, profiles):
+       '''Determines the arches for the ebuild following the profile rules
+
+       @param ebuild: Ebuild which we check (object).
+       @param profiles: dictionary
+       @param options: cli options
+       @param repo_settings: repository settings instance
+       @returns: dictionary, including arches set
+       '''
+       if options.ignore_arches:
+               arches = [[
+                       repo_settings.repoman_settings["ARCH"], 
repo_settings.repoman_settings["ARCH"],
+                       
repo_settings.repoman_settings["ACCEPT_KEYWORDS"].split()]]
+       else:
+               arches = set()
+               for keyword in ebuild.keywords:
+                       if keyword[0] == "-":
+                               continue
+                       elif keyword[0] == "~":
+                               arch = keyword[1:]
+                               if arch == "*":
+                                       for expanded_arch in profiles:
+                                               if expanded_arch == "**":
+                                                       continue
+                                               arches.add(
+                                                       (keyword, 
expanded_arch, (
+                                                               expanded_arch, 
"~" + expanded_arch)))
+                               else:
+                                       arches.add((keyword, arch, (arch, 
keyword)))
+                       else:
+                               # For ebuilds with stable keywords, check if the
+                               # dependencies are satisfiable for unstable
+                               # configurations, since use.stable.mask is not
+                               # applied for unstable configurations (see bug
+                               # 563546).
+                               if keyword == "*":
+                                       for expanded_arch in profiles:
+                                               if expanded_arch == "**":
+                                                       continue
+                                               arches.add(
+                                                       (keyword, 
expanded_arch, (expanded_arch,)))
+                                               arches.add(
+                                               (keyword, expanded_arch,
+                                                       (expanded_arch, "~" + 
expanded_arch)))
+                               else:
+                                       arches.add((keyword, keyword, 
(keyword,)))
+                                       arches.add((keyword, keyword,
+                                               (keyword, "~" + keyword)))
+               if not arches:
+                       # Use an empty profile for checking dependencies of
+                       # packages that have empty KEYWORDS.
+                       arches.add(('**', '**', ('**',)))
+
+       return arches

diff --git a/pym/repoman/modules/scan/depend/profile.py 
b/pym/repoman/modules/scan/depend/profile.py
index 8fc7721..0388374 100644
--- a/pym/repoman/modules/scan/depend/profile.py
+++ b/pym/repoman/modules/scan/depend/profile.py
@@ -9,6 +9,7 @@ from _emerge.Package import Package
 # import our initialized portage instance
 from repoman._portage import portage
 from repoman.modules.scan.scanbase import ScanBase
+from repoman.modules.scan.depend._gen_arches import _gen_arches
 from portage.dep import Atom
 
 
@@ -56,14 +57,14 @@ class ProfileDependsChecks(ScanBase):
                @param unknown_pkgs: set of tuples (type, atom.unevaluated_atom)
                @returns: dictionary
                '''
-               arches = kwargs.get('arches').get()
                ebuild = kwargs.get('ebuild').get()
                pkg = kwargs.get('pkg').get()
                baddepsyntax = kwargs.get('baddepsyntax').get()
                unknown_pkgs = kwargs.get('unknown_pkgs').get()
 
                relevant_profiles = []
-               for keyword, arch, groups in arches:
+               for keyword, arch, groups in _gen_arches(ebuild, self.options,
+                       self.repo_settings, self.profiles):
                        if arch not in self.profiles:
                                # A missing profile will create an error 
further down
                                # during the KEYWORDS verification.

diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index c9b76a4..74bb7e3 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -378,7 +378,7 @@ class Scanner(object):
                                ('thirdpartymirrors', 'ThirdPartyMirrors'),
                                ('description', 'DescriptionChecks'),
                                ('keywords', 'KeywordChecks'),
-                               ('arches', 'ArchChecks'), ('depend', 
'DependChecks'),
+                               ('depend', 'DependChecks'),
                                ('use_flags', 'USEFlagChecks'), ('ruby', 
'RubyEclassChecks'),
                                ('license', 'LicenseChecks'), ('restrict', 
'RestrictChecks'),
                                ('mtime', 'MtimeChecks'), ('multicheck', 
'MultiCheck'),

Reply via email to