From: "André Erdmann" <dywi@mailerd.de> To: gentoo-commits@lists.gentoo.org Subject: [gentoo-commits] proj/R_overlay:gsoc13/next commit in: roverlay/depres/ Date: Wed, 17 Jul 2013 18:10:43 +0000 (UTC) [thread overview] Message-ID: <1374084397.3cae70d2b3df58af8957e2c49089eb9d835486f2.dywi@gentoo> (raw) commit: 3cae70d2b3df58af8957e2c49089eb9d835486f2 Author: André Erdmann <dywi <AT> mailerd <DOT> de> AuthorDate: Wed Jul 17 18:06:37 2013 +0000 Commit: André Erdmann <dywi <AT> mailerd <DOT> de> CommitDate: Wed Jul 17 18:06:37 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=3cae70d2 add debug capabilities to depresult --- roverlay/depres/depresult.py | 112 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 108 insertions(+), 4 deletions(-) diff --git a/roverlay/depres/depresult.py b/roverlay/depres/depresult.py index 2049719..2ad2488 100644 --- a/roverlay/depres/depresult.py +++ b/roverlay/depres/depresult.py @@ -4,13 +4,22 @@ # Distributed under the terms of the GNU General Public License; # either version 2 of the License, or (at your option) any later version. +from __future__ import print_function + __all__ = [ 'DepResult', 'DEP_NOT_RESOLVED', ] +import logging + import roverlay.depres.depenv +# two dep result classes are available +# they're identical, but the "debugged-" one produces a lot of output +# and calculates some operations twice +DEBUG = False + EMPTY_STR = "" -class DepResult ( object ): +class _DepResult ( object ): """dependency resolution result data container""" def __init__ ( self, @@ -25,6 +34,7 @@ class DepResult ( object ): * dep_env -- dependency environment (optional) * fuzzy -- fuzzy dep (sub-)environment (optional) """ + super ( _DepResult, self ).__init__() self.dep = dep self.score = score #assert hasattr ( matching_rule, 'is_selfdep' ) @@ -98,6 +108,7 @@ class DepResult ( object ): # DEBUG bind self.version = version + self.vmod = vmod self.version_compare = version.get_package_comparator ( vmod ) @@ -155,7 +166,7 @@ class DepResult ( object ): """'reduce' operation for selfdep validation. Eliminates candidates that are no longer valid and returns the number - of removed candiates (0 if nothing removed). + of removed candidates (0 if nothing removed). """ candidates = list ( p for p in self.candidates if p.has_valid_selfdeps() @@ -166,7 +177,100 @@ class DepResult ( object ): return num_removed # --- end of do_reduce (...) --- -# --- end of DepResult --- +# --- end of _DepResult --- + + +class _DebuggedDepResult ( _DepResult ): + LOGGER = logging.getLogger ( 'depresult' ) + + def __init__ ( self, *args, **kwargs ): + super ( _DebuggedDepResult, self ).__init__ ( *args, **kwargs ) + if self.is_selfdep: + self.logger = self.__class__.LOGGER.getChild ( self.dep ) + + def deps_satisfiable ( self ): + self.logger.debug ( + "deps satisfiable? {}, <{}>".format ( + ( "Yes" if self.candidates else "No" ), + ', '.join ( + ( + "{}::{}-{}".format ( + ( + p['origin'].name if p.has ( 'origin' ) else "<undef>" + ), + p['name'], p['ebuild_verstr'] + ) for p in self.candidates + ) + ) + ) + ) + return super ( DebuggedDepResult, self ).deps_satisfiable() + # --- end of deps_satisfiable (...) --- + + def link_if_version_matches ( self, p ): + ret = super ( DebuggedDepResult, self ).link_if_version_matches ( p ) + + pf = "{PN}-{PVR}".format ( + PN = p ['name'], + PVR = p ['ebuild_verstr'], + ) + + info_append = ' p\'valid={valid!r}'.format ( + valid = bool ( p.is_valid() ), + ) + + if self.fuzzy: + info_append += ( + 'this\'fuzzy={fuzzy!r}, vmatch={vmatch!r}, ' + 'this\'version={myver!r}, p\'version={pver}, ' + 'vcomp={vcomp!r} vmod={vmod:d}'.format ( + fuzzy = bool ( self.fuzzy ), + vmatch = self.version_compare ( p ), + myver = self.version, + pver = p ['version'], + vcomp = self.version_compare, + vmod = self.vmod, + ) + ) + else: + info_append += ', this\'fuzzy=False' + + + if ret: + self.logger.debug ( + "Added {PF} to candidate list.".format ( PF=pf ) + + info_append + ) + else: + # recalculate for logging + self.logger.debug ( + 'Rejected {PF} as candidate.'.format ( PF=pf ) + + info_append + ) + + return ret + # --- end of link_if_version_matches (...) --- + + def do_reduce ( self ): + """'reduce' operation for selfdep validation. + + Eliminates candidates that are no longer valid and returns the number + of removed candidates (0 if nothing removed). + """ + self.logger.debug ( "Checking candidates:" ) + for p in self.candidates: + "{}-{}: {}".format ( + p['name'], p['ebuild_verstr'], p.has_valid_selfdeps() + ) + ret = super ( DebuggedDepResult, self ).do_reduce() + self.logger.debug ( "Dropped {:d} candidates.".format ( ret ) ) + return ret + # --- end of do_reduce (...) --- + +# --- end of _DebuggedDepResult --- + +# DepResult <= _DepResult | _DebuggedDepResult +DepResult = _DebuggedDepResult if DEBUG else _DepResult # static object for unresolvable dependencies -DEP_NOT_RESOLVED = DepResult ( dep=None, score=-2, matching_rule=None ) +DEP_NOT_RESOLVED = _DepResult ( dep=None, score=-2, matching_rule=None )
WARNING: multiple messages have this Message-ID (diff)
From: "André Erdmann" <dywi@mailerd.de> To: gentoo-commits@lists.gentoo.org Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/depres/ Date: Wed, 17 Jul 2013 18:10:43 +0000 (UTC) [thread overview] Message-ID: <1374084397.3cae70d2b3df58af8957e2c49089eb9d835486f2.dywi@gentoo> (raw) Message-ID: <20130717181043.4PJqt7vNBpn_cwyV2PI4tt3kRAI8vEg0F_qe2QzsnHU@z> (raw) commit: 3cae70d2b3df58af8957e2c49089eb9d835486f2 Author: André Erdmann <dywi <AT> mailerd <DOT> de> AuthorDate: Wed Jul 17 18:06:37 2013 +0000 Commit: André Erdmann <dywi <AT> mailerd <DOT> de> CommitDate: Wed Jul 17 18:06:37 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=3cae70d2 add debug capabilities to depresult --- roverlay/depres/depresult.py | 112 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 108 insertions(+), 4 deletions(-) diff --git a/roverlay/depres/depresult.py b/roverlay/depres/depresult.py index 2049719..2ad2488 100644 --- a/roverlay/depres/depresult.py +++ b/roverlay/depres/depresult.py @@ -4,13 +4,22 @@ # Distributed under the terms of the GNU General Public License; # either version 2 of the License, or (at your option) any later version. +from __future__ import print_function + __all__ = [ 'DepResult', 'DEP_NOT_RESOLVED', ] +import logging + import roverlay.depres.depenv +# two dep result classes are available +# they're identical, but the "debugged-" one produces a lot of output +# and calculates some operations twice +DEBUG = False + EMPTY_STR = "" -class DepResult ( object ): +class _DepResult ( object ): """dependency resolution result data container""" def __init__ ( self, @@ -25,6 +34,7 @@ class DepResult ( object ): * dep_env -- dependency environment (optional) * fuzzy -- fuzzy dep (sub-)environment (optional) """ + super ( _DepResult, self ).__init__() self.dep = dep self.score = score #assert hasattr ( matching_rule, 'is_selfdep' ) @@ -98,6 +108,7 @@ class DepResult ( object ): # DEBUG bind self.version = version + self.vmod = vmod self.version_compare = version.get_package_comparator ( vmod ) @@ -155,7 +166,7 @@ class DepResult ( object ): """'reduce' operation for selfdep validation. Eliminates candidates that are no longer valid and returns the number - of removed candiates (0 if nothing removed). + of removed candidates (0 if nothing removed). """ candidates = list ( p for p in self.candidates if p.has_valid_selfdeps() @@ -166,7 +177,100 @@ class DepResult ( object ): return num_removed # --- end of do_reduce (...) --- -# --- end of DepResult --- +# --- end of _DepResult --- + + +class _DebuggedDepResult ( _DepResult ): + LOGGER = logging.getLogger ( 'depresult' ) + + def __init__ ( self, *args, **kwargs ): + super ( _DebuggedDepResult, self ).__init__ ( *args, **kwargs ) + if self.is_selfdep: + self.logger = self.__class__.LOGGER.getChild ( self.dep ) + + def deps_satisfiable ( self ): + self.logger.debug ( + "deps satisfiable? {}, <{}>".format ( + ( "Yes" if self.candidates else "No" ), + ', '.join ( + ( + "{}::{}-{}".format ( + ( + p['origin'].name if p.has ( 'origin' ) else "<undef>" + ), + p['name'], p['ebuild_verstr'] + ) for p in self.candidates + ) + ) + ) + ) + return super ( DebuggedDepResult, self ).deps_satisfiable() + # --- end of deps_satisfiable (...) --- + + def link_if_version_matches ( self, p ): + ret = super ( DebuggedDepResult, self ).link_if_version_matches ( p ) + + pf = "{PN}-{PVR}".format ( + PN = p ['name'], + PVR = p ['ebuild_verstr'], + ) + + info_append = ' p\'valid={valid!r}'.format ( + valid = bool ( p.is_valid() ), + ) + + if self.fuzzy: + info_append += ( + 'this\'fuzzy={fuzzy!r}, vmatch={vmatch!r}, ' + 'this\'version={myver!r}, p\'version={pver}, ' + 'vcomp={vcomp!r} vmod={vmod:d}'.format ( + fuzzy = bool ( self.fuzzy ), + vmatch = self.version_compare ( p ), + myver = self.version, + pver = p ['version'], + vcomp = self.version_compare, + vmod = self.vmod, + ) + ) + else: + info_append += ', this\'fuzzy=False' + + + if ret: + self.logger.debug ( + "Added {PF} to candidate list.".format ( PF=pf ) + + info_append + ) + else: + # recalculate for logging + self.logger.debug ( + 'Rejected {PF} as candidate.'.format ( PF=pf ) + + info_append + ) + + return ret + # --- end of link_if_version_matches (...) --- + + def do_reduce ( self ): + """'reduce' operation for selfdep validation. + + Eliminates candidates that are no longer valid and returns the number + of removed candidates (0 if nothing removed). + """ + self.logger.debug ( "Checking candidates:" ) + for p in self.candidates: + "{}-{}: {}".format ( + p['name'], p['ebuild_verstr'], p.has_valid_selfdeps() + ) + ret = super ( DebuggedDepResult, self ).do_reduce() + self.logger.debug ( "Dropped {:d} candidates.".format ( ret ) ) + return ret + # --- end of do_reduce (...) --- + +# --- end of _DebuggedDepResult --- + +# DepResult <= _DepResult | _DebuggedDepResult +DepResult = _DebuggedDepResult if DEBUG else _DepResult # static object for unresolvable dependencies -DEP_NOT_RESOLVED = DepResult ( dep=None, score=-2, matching_rule=None ) +DEP_NOT_RESOLVED = _DepResult ( dep=None, score=-2, matching_rule=None )
next reply other threads:[~2013-07-17 18:10 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-07-17 18:10 André Erdmann [this message] 2013-07-17 18:10 ` [gentoo-commits] proj/R_overlay:master commit in: roverlay/depres/ André Erdmann -- strict thread matches above, loose matches on Subject: below -- 2013-07-18 19:25 [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann 2013-07-16 16:36 [gentoo-commits] proj/R_overlay:master " André Erdmann 2013-07-15 22:31 ` [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann 2013-07-15 22:31 André Erdmann 2013-07-11 16:44 André Erdmann 2013-07-11 8:49 [gentoo-commits] proj/R_overlay:master " André Erdmann 2013-07-11 8:45 ` [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann 2013-07-08 22:47 André Erdmann 2013-07-05 16:55 André Erdmann 2013-07-05 16:55 André Erdmann 2013-06-13 16:34 [gentoo-commits] proj/R_overlay:master " André Erdmann 2013-06-13 16:34 ` [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1374084397.3cae70d2b3df58af8957e2c49089eb9d835486f2.dywi@gentoo \ --to=dywi@mailerd.de \ --cc=gentoo-commits@lists.gentoo.org \ --cc=gentoo-dev@lists.gentoo.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox