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 008761381F3 for ; Fri, 19 Jul 2013 18:00:52 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 50176E094F; Fri, 19 Jul 2013 18:00:44 +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 5D57CE094E for ; Fri, 19 Jul 2013 18:00:43 +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 330BB33E874 for ; Fri, 19 Jul 2013 18:00:42 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id DAB09E5467 for ; Fri, 19 Jul 2013 18:00:39 +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: <1374255894.8735cde4882262112c7adf46b1e55a390d920e28.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:gsoc13/next commit in: roverlay/interface/ X-VCS-Repository: proj/R_overlay X-VCS-Files: roverlay/interface/depres.py X-VCS-Directories: roverlay/interface/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: 8735cde4882262112c7adf46b1e55a390d920e28 X-VCS-Branch: gsoc13/next Date: Fri, 19 Jul 2013 18:00:39 +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: 80069dc4-a010-41e1-acae-0c6b31cce14f X-Archives-Hash: ecc99be6f57b95046164fd43a0632d69 Message-ID: <20130719180039.8nCP3B353wilThUzE7jvmvfqp5FtIor--X8HLIe8jVU@z> commit: 8735cde4882262112c7adf46b1e55a390d920e28 Author: André Erdmann mailerd de> AuthorDate: Fri Jul 19 17:44:54 2013 +0000 Commit: André Erdmann mailerd de> CommitDate: Fri Jul 19 17:44:54 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=8735cde4 depres interface: visualize pools, ignore_missing --- roverlay/interface/depres.py | 70 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 10 deletions(-) diff --git a/roverlay/interface/depres.py b/roverlay/interface/depres.py index 6e79bc5..ad292de 100644 --- a/roverlay/interface/depres.py +++ b/roverlay/interface/depres.py @@ -6,6 +6,8 @@ #import weakref +import errno + import roverlay.interface.generic @@ -245,6 +247,7 @@ class DepresInterface ( roverlay.interface.generic.RoverlaySubInterface ): if ignore_missing: rule_files = self.config.get ( "DEPRES.simple_rules.files", None ) if rule_files: + ##return self.load_rule_files ( rule_files, ignore_missing=True ) return self.load_rule_files ( rule_files ) else: return False @@ -254,12 +257,26 @@ class DepresInterface ( roverlay.interface.generic.RoverlaySubInterface ): ) # --- end of load_rules_from_config (...) --- - def load_rule_files ( self, files_or_dirs ): + def load_rule_files ( self, files_or_dirs, ignore_missing=False ): """Loads the given files into a new rule pool (or new pools). + arguments: + * ignore_missing -- suppress exceptions caused by missing files and + return False + Returns: True on success, else False """ - ret = self._resolver.get_reader().read ( files_or_dirs ) + if ignore_missing: + try: + ret = self._resolver.get_reader().read ( files_or_dirs ) + except IOError as ioerr: + if ioerr.errno == errno.ENOENT: + ret = False + else: + raise + else: + ret = self._resolver.get_reader().read ( files_or_dirs ) + self.fixup_pool_id() return True if ret is None else ret # --- end of load_rule_files (...) --- @@ -311,6 +328,13 @@ class DepresInterface ( roverlay.interface.generic.RoverlaySubInterface ): # --- end of add_rule_list (...) --- def try_compile_rules ( self, *args, **kwargs ): + """Tells the rule parser to 'compile' rules. Does nothing if the + rule parser has any active context (e.g. is inside a multi line rule). + See compile_rules() for details. + + Returns: False if rule compiling has been suppressed du to active + context, else True (=rules compiled) + """ if self._parser.has_context(): return False else: @@ -364,18 +388,44 @@ class DepresInterface ( roverlay.interface.generic.RoverlaySubInterface ): return self.add_rule ( rule_str ) and self.compile_rules() # --- end of add_immediate_rule (...) --- - def visualize_pool ( self ): - """Visualizes the topmost rule pool. This returns a string that contains - all rules of this pool in text form (in rule file syntax). + def visualize_pool ( self, pool_id=None ): + """Visualizes the topmost rule pool (or the specified one). + his returns a string that contains all rules of this pool + in text form (in rule file syntax). + + arguments: + * pool_id -- index of the pool that should be visualized + Defaults to 0 (-> use topmost pool). + + Returns: + visualized pool (str) if requested pool existed, else empty string """ - if self._poolstack: + try: + pool = self._poolstack [ -1 if pool_id is None else pool_id ] + except IndexError: + return "" + else: + return '\n'.join ( pool.export_rules() ) + # --- end of visualize_pool (...) --- + + def visualize_pools ( self, id_range=None ): + """Visualize multiple pools at once. + + arguments: + * id_range -- an iterable of indexes or None (-> visualize all) + Defaults to None. + + Returns: visualized pools (str) + """ + if id_range is None: return '\n'.join ( - '\n'.join ( rule.export_rule() ) - for rule in self._poolstack[-1].rules + '\n'.join ( pool.export_rules() ) for pool in self._poolstack ) else: - return "" - # --- end of visualize_pool (...) --- + return '\n'.join ( + self.visualize_pool ( pool_id ) for pool_id in id_range + ) + # --- end of visualize_pools (...) --- def get_channel ( self, channel_name="channel" ): """Creates, registers and returns an EbuildJobChannel suitable for