From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (unknown [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 0B0C4138200 for ; Tue, 9 Jul 2013 22:52:30 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5152AE0AD6; Tue, 9 Jul 2013 22:50:14 +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 B34A7E0A96 for ; Tue, 9 Jul 2013 22:50:09 +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 486BE33E96A for ; Mon, 8 Jul 2013 22:48:01 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 1F484E546A for ; Mon, 8 Jul 2013 22:47:59 +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: <1373323019.ef2b1bb33faa1ac49ca500fb8fa2bb210b933cdc.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:gsoc13/next 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: ef2b1bb33faa1ac49ca500fb8fa2bb210b933cdc X-VCS-Branch: gsoc13/next Date: Mon, 8 Jul 2013 22:47:59 +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: 30b79566-74f3-4fc6-8be7-d5efcf3ee73e X-Archives-Hash: 76fe5cf35d623513286e991e85e38e04 commit: ef2b1bb33faa1ac49ca500fb8fa2bb210b933cdc Author: André Erdmann mailerd de> AuthorDate: Mon Jul 8 22:36:59 2013 +0000 Commit: André Erdmann mailerd de> CommitDate: Mon Jul 8 22:36:59 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=ef2b1bb3 roverlay/depres/depresult: comments --- roverlay/depres/depresult.py | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/roverlay/depres/depresult.py b/roverlay/depres/depresult.py index 8b4fa0d..2049719 100644 --- a/roverlay/depres/depresult.py +++ b/roverlay/depres/depresult.py @@ -11,10 +11,20 @@ import roverlay.depres.depenv 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) + """ self.dep = dep self.score = score #assert hasattr ( matching_rule, 'is_selfdep' ) @@ -26,6 +36,7 @@ class DepResult ( object ): # --- end of DepResult --- 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 ): @@ -43,6 +54,7 @@ class DepResult ( object ): # --- 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__ (...) --- @@ -71,6 +83,9 @@ class DepResult ( object ): # --- end of __getitem__ (...) --- def prepare_selfdep_reduction ( self ): + """Prepares this dep result for selfdep validation by creating all + necessary variables. + """ cat, sepa, pkg = self.resolving_package.rpartition ( '/' ) self.category = cat self.package = pkg @@ -81,21 +96,40 @@ class DepResult ( object ): vmod = self.fuzzy ['vmod'] version = self.fuzzy ['version_tuple'] + # DEBUG bind + self.version = version + self.version_compare = version.get_package_comparator ( vmod ) return self # --- end of prepare_selfdep_reduction (...) --- def deps_satisfiable ( self ): + """Returns True if >this< selfdep is satisfiable, else False. + This method should only be called _during_ selfdep validation. + """ # should be renamed to selfdeps_satisfiable return bool ( self.candidates ) # --- end of deps_satisfiable (...) --- def is_valid ( self ): + """Returns True if this dependency is valid, i.e. it either is not + a selfdep or it is satisfiable. + This method should be called _after_ selfdep validation. + """ return ( not self.is_selfdep ) or bool ( self.candidates ) # --- end of is_valid (...) --- def link_if_version_matches ( self, p ): + """Tries to a link a given package info as selfdep candidate. + Returns True on success, else False. + + The link operation succeeds iff the package claims to be valid and + its version is compatible. + + arguments: + * p -- package info + """ if p.is_valid() and ( not self.fuzzy or self.version_compare ( p ) ): self.link ( p ) return True @@ -104,6 +138,12 @@ class DepResult ( object ): # --- end of link_if_version_matches (...) --- def linkall_if_version_matches ( self, p_iterable ): + """Tries to link several packages. + Returns True if at least one package could be linked, else False. + + arguments: + * p_iterable -- iterable that contains package info objects + """ any_added = False for p in p_iterable: if self.link_if_version_matches ( p ): @@ -112,6 +152,11 @@ class DepResult ( object ): # --- end of linkall_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 candiates (0 if nothing removed). + """ candidates = list ( p for p in self.candidates if p.has_valid_selfdeps() ) @@ -123,4 +168,5 @@ class DepResult ( object ): # --- end of DepResult --- +# static object for unresolvable dependencies DEP_NOT_RESOLVED = DepResult ( dep=None, score=-2, matching_rule=None )