aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Dolbec <dolsen@gentoo.org>2016-03-15 11:40:06 -0700
committerBrian Dolbec <dolsen@gentoo.org>2016-03-15 11:40:06 -0700
commit4ee48de5477bbbe299cdb43f8779a9c9a0388eac (patch)
tree0b4552ed30e3f8889693ffec6ada4a6c8c5f3313
parentrepoman: Move changelog_modified to dynamic_data for use in the scan/ebuild m... (diff)
downloadportage-4ee48de5477bbbe299cdb43f8779a9c9a0388eac.tar.gz
portage-4ee48de5477bbbe299cdb43f8779a9c9a0388eac.tar.bz2
portage-4ee48de5477bbbe299cdb43f8779a9c9a0388eac.zip
repoman: Create a new boolean Fuse type
Create a Fuse type which implememts a boolean as a one time fuse. The Fuse is initialized True, then is pop()'d to become False. Once the Fuse is blown, it can not be reset to True. Convert the use of the dynamic_data variable 'allvalid' to a Fuse instance.
-rw-r--r--pym/repoman/fuse.py68
-rw-r--r--pym/repoman/modules/scan/ebuild/ebuild.py7
-rw-r--r--pym/repoman/modules/scan/ebuild/isebuild.py13
-rw-r--r--pym/repoman/modules/scan/metadata/unused.py2
-rw-r--r--pym/repoman/scanner.py2
5 files changed, 83 insertions, 9 deletions
diff --git a/pym/repoman/fuse.py b/pym/repoman/fuse.py
new file mode 100644
index 000000000..ac864fda9
--- /dev/null
+++ b/pym/repoman/fuse.py
@@ -0,0 +1,68 @@
+
+'''
+fuse.py
+
+A tiny one-time-fuse class that uses a boolean to mimic the property of
+an electrical fuse. IT's good (True) until it is popped (bad, False).
+It is not resetable.
+'''
+
+
+class Fuse(object):
+ '''A One time fuse style boolean instance'''
+
+ __slots__ = ('_state')
+
+ def __init__(self):
+ self._state = True
+
+ def pop(self):
+ '''Blow's the fuse state (makes it False)'''
+ self._state = False
+
+ def __repr__(self):
+ '''x.__repr__() <==> repr(x)'''
+ return repr(self._state>0)
+
+ def __str__(self):
+ '''x.__str__() <==> str(x)'''
+ return ['False', 'True'][self._state]
+
+ def __bool__(self):
+ '''self != 0'''
+ return self._state != 0
+
+ def __nonzero__(self):
+ '''self != 0'''
+ return self._state != 0
+
+ def __abs__(self):
+ '''x.__abs__() <==> abs(x)'''
+ return [0, 1] [self._state]
+
+ def __int__(self):
+ '''int(self)'''
+ return [0, 1][self._state]
+
+ def __eq__(self, value):
+ '''Return self==value.'''
+ return self._state == value
+
+ def __ne__(self, value):
+ '''Return self!=value.'''
+ return self._state != value
+
+ def __ge__(self, value):
+ '''Return self>=value.'''
+ return self._state >= value
+
+ def __gt__(self, value):
+ return self._state > value
+
+ def __le__(self, value):
+ '''Return self<=value.'''
+ return self._state <= value
+
+ def __lt__(self, value):
+ '''Return self<value.'''
+ return self._state < value
diff --git a/pym/repoman/modules/scan/ebuild/ebuild.py b/pym/repoman/modules/scan/ebuild/ebuild.py
index e9a2cdd2f..540411f51 100644
--- a/pym/repoman/modules/scan/ebuild/ebuild.py
+++ b/pym/repoman/modules/scan/ebuild/ebuild.py
@@ -127,13 +127,16 @@ class Ebuild(ScanBase):
def pkg_invalid(self, **kwargs):
'''Sets some pkg info and checks for invalid packages
- @returns: dictionary, including {pkg object, allvalid}
+ @param validity_fuse: Fuse instance
+ @returns: dictionary, including {pkg object}
'''
+ fuse = kwargs.get('validity_fuse')
if self.pkg.invalid:
for k, msgs in self.pkg.invalid.items():
for msg in msgs:
self.qatracker.add_error(k, "%s: %s" % (self.relative_path, msg))
- return {'continue': True, 'allvalid': False, 'pkg': self.pkg}
+ fuse.pop()
+ return {'continue': True, 'pkg': self.pkg}
return {'continue': False, 'pkg': self.pkg}
@property
diff --git a/pym/repoman/modules/scan/ebuild/isebuild.py b/pym/repoman/modules/scan/ebuild/isebuild.py
index 1dffc6a91..474a874bb 100644
--- a/pym/repoman/modules/scan/ebuild/isebuild.py
+++ b/pym/repoman/modules/scan/ebuild/isebuild.py
@@ -35,15 +35,16 @@ class IsEbuild(ScanBase):
@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}
+ @param validity_fuse: Fuse instance
+ @returns: dictionary, including {pkgs, can_force}
'''
checkdirlist = kwargs.get('checkdirlist')
checkdir = kwargs.get('checkdir')
xpkg = kwargs.get('xpkg')
+ fuse = kwargs.get('validity_fuse')
self.continue_ = False
ebuildlist = []
pkgs = {}
- allvalid = True
for y in checkdirlist:
file_is_ebuild = y.endswith(".ebuild")
file_should_be_non_executable = y in no_exec or file_is_ebuild
@@ -62,15 +63,15 @@ class IsEbuild(ScanBase):
try:
myaux = dict(zip(allvars, self.portdb.aux_get(cpv, allvars)))
except KeyError:
- allvalid = False
+ fuse.pop()
self.qatracker.add_error("ebuild.syntax", os.path.join(xpkg, y))
continue
except IOError:
- allvalid = False
+ fuse.pop()
self.qatracker.add_error("ebuild.output", os.path.join(xpkg, y))
continue
if not portage.eapi_is_supported(myaux["EAPI"]):
- allvalid = False
+ fuse.pop()
self.qatracker.add_error("EAPI.unsupported", os.path.join(xpkg, y))
continue
pkgs[pf] = Package(
@@ -85,7 +86,7 @@ class IsEbuild(ScanBase):
# positives confuse users.
self.continue_ = True
- return {'continue': self.continue_, 'pkgs': pkgs, 'allvalid': allvalid,
+ return {'continue': self.continue_, 'pkgs': pkgs,
'can_force': not self.continue_}
@property
diff --git a/pym/repoman/modules/scan/metadata/unused.py b/pym/repoman/modules/scan/metadata/unused.py
index 5eb67160e..b3dc86336 100644
--- a/pym/repoman/modules/scan/metadata/unused.py
+++ b/pym/repoman/modules/scan/metadata/unused.py
@@ -11,7 +11,7 @@ class UnusedCheck(object):
used_useflags = kwargs.get('used_useflags')
# check if there are unused local USE-descriptions in metadata.xml
# (unless there are any invalids, to avoid noise)
- if kwargs.get('allvalid'):
+ if kwargs.get('validity_fuse'):
for myflag in muselist.difference(used_useflags):
self.qatracker.add_error(
"metadata.warning",
diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index 86e389a40..9c6f5acd0 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -9,6 +9,7 @@ import portage
from portage import normalize_path
from portage import os
from portage.output import green
+from repoman.fuse import Fuse
from repoman.modules.commit import repochecks
from repoman.profile import check_profiles, dev_profile_keywords, setup_profile
from repoman.repos import repo_metadata
@@ -232,6 +233,7 @@ class Scanner(object):
'repolevel': self.repolevel,
'catdir': catdir,
'pkgdir': pkgdir,
+ 'validity_fuse': Fuse()
}
# need to set it up for ==> self.modules or some other ordered list
for mod in ['Manifests', 'IsEbuild', 'KeywordChecks', 'FileChecks',