From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 929141381F3 for ; Fri, 23 Aug 2013 13:52:18 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4F5C5E0C2C; Fri, 23 Aug 2013 13:52:12 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A502AE0C2A for ; Fri, 23 Aug 2013 13:52:06 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 195A533EC6F for ; Fri, 23 Aug 2013 13:52:05 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id A6231E547A for ; Fri, 23 Aug 2013 13:52:02 +0000 (UTC) From: "André Erdmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "André Erdmann" Message-ID: <1377265175.958ea80e3999379df6ed269a7ef9d0d202626741.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/depres/ X-VCS-Repository: proj/R_overlay X-VCS-Files: roverlay/depres/depresult.py X-VCS-Directories: roverlay/depres/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: 958ea80e3999379df6ed269a7ef9d0d202626741 X-VCS-Branch: master Date: Fri, 23 Aug 2013 13:52:02 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: e3b3c633-26d3-46c0-b4c1-d97ee44b8635 X-Archives-Hash: c1880851b9fc468de94f0e131297011a commit: 958ea80e3999379df6ed269a7ef9d0d202626741 Author: André Erdmann mailerd de> AuthorDate: Fri Aug 23 13:39:35 2013 +0000 Commit: André Erdmann mailerd de> CommitDate: Fri Aug 23 13:39:35 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=958ea80e roverlay/depres/depresult: ConstantDepResult dep result class that cannot participate in selfdep validation. --- roverlay/depres/depresult.py | 81 ++++++++++++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 30 deletions(-) diff --git a/roverlay/depres/depresult.py b/roverlay/depres/depresult.py index d084ea0..9a320b6 100644 --- a/roverlay/depres/depresult.py +++ b/roverlay/depres/depresult.py @@ -17,37 +17,22 @@ DEBUG = False EMPTY_STR = "" -class _DepResult ( object ): - """dependency resolution result data container""" - - def __init__ ( self, - dep, score, matching_rule, dep_env=None, fuzzy=None - ): - """Initializes a dependency resolution result object. - - arguments: - * dep -- resolving dependency (string or None) - * score -- score (int) - * matching_rule -- (reference to) the rule that resolved dep - * 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' ) - self.is_selfdep = matching_rule.is_selfdep if matching_rule else 0 +class ConstantDepResult ( object ): + # COULDFIX: class name not really accurate, + # because all dep results are "constant" once they have been created - if self.is_selfdep: - self.fuzzy = fuzzy - self.resolving_package = matching_rule.resolving_package - # --- end of DepResult --- + def __init__ ( self, dep, score, is_selfdep=0 ): + super ( ConstantDepResult, self ).__init__() + self.dep = dep + self.score = score + self.is_selfdep = is_selfdep + # --- end of __init__ (...) --- def __eq__ ( self, other ): """Compares this dep result with another result or a string.""" if isinstance ( other, str ): return str ( self ) == other - elif isinstance ( other, DepResult ): + elif isinstance ( other, ConstantDepResult ): return ( self.score == other.score and self.is_selfdep == other.is_selfdep @@ -57,16 +42,16 @@ class _DepResult ( object ): return NotImplemented # --- end of __eq__ (...) --- - def __hash__ ( self ): - return id ( self ) - # --- end of __hash__ (...) --- - def __bool__ ( self ): """Returns True if this dep result has a valid score (>0).""" return self.score > 0 #and self.dep is not False # --- end of __bool__ (...) --- + def __hash__ ( self ): + return hash ( self.dep ) + # --- end of __hash__ (...) --- + def __repr__ ( self ): return "<{} object {!r} at 0x{:x}>".format ( self.__class__.__name__, self.dep, id ( self ) @@ -77,6 +62,42 @@ class _DepResult ( object ): return self.dep if self.dep is not None else EMPTY_STR # --- end of __str__ (...) --- + def is_valid ( self ): + return True + # --- end of is_valid (...) --- + +# --- end of ConstantDepResult --- + + +class _DepResult ( ConstantDepResult ): + """dependency resolution result data container""" + + def __init__ ( self, + dep, score, matching_rule, dep_env=None, fuzzy=None + ): + """Initializes a dependency resolution result object. + + arguments: + * dep -- resolving dependency (string or None) + * score -- score (int) + * matching_rule -- (reference to) the rule that resolved dep + * dep_env -- dependency environment (optional) + * fuzzy -- fuzzy dep (sub-)environment (optional) + """ + #assert hasattr ( matching_rule, 'is_selfdep' ) + super ( _DepResult, self ).__init__( + dep, score, ( matching_rule.is_selfdep if matching_rule else 0 ) + ) + + if self.is_selfdep: + self.fuzzy = fuzzy + self.resolving_package = matching_rule.resolving_package + # --- end of __init__ (...) --- + + def __hash__ ( self ): + return id ( self ) + # --- end of __hash__ (...) --- + def prepare_selfdep_reduction ( self ): """Prepares this dep result for selfdep validation by creating all necessary variables. @@ -258,4 +279,4 @@ class _DebuggedDepResult ( _DepResult ): 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 = ConstantDepResult ( None, -2 )