From: "André Erdmann" <dywi@mailerd.de> To: gentoo-commits@lists.gentoo.org Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/interface/ Date: Tue, 23 Jul 2013 07:51:32 +0000 (UTC) [thread overview] Message-ID: <1374255894.8735cde4882262112c7adf46b1e55a390d920e28.dywi@gentoo> (raw) commit: 8735cde4882262112c7adf46b1e55a390d920e28 Author: André Erdmann <dywi <AT> mailerd <DOT> de> AuthorDate: Fri Jul 19 17:44:54 2013 +0000 Commit: André Erdmann <dywi <AT> mailerd <DOT> 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
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:gsoc13/next commit in: roverlay/interface/ Date: Fri, 19 Jul 2013 18:00:39 +0000 (UTC) [thread overview] Message-ID: <1374255894.8735cde4882262112c7adf46b1e55a390d920e28.dywi@gentoo> (raw) Message-ID: <20130719180039.8nCP3B353wilThUzE7jvmvfqp5FtIor--X8HLIe8jVU@z> (raw) commit: 8735cde4882262112c7adf46b1e55a390d920e28 Author: André Erdmann <dywi <AT> mailerd <DOT> de> AuthorDate: Fri Jul 19 17:44:54 2013 +0000 Commit: André Erdmann <dywi <AT> mailerd <DOT> 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
next reply other threads:[~2013-07-23 7:51 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-07-23 7:51 André Erdmann [this message] 2013-07-19 18:00 ` [gentoo-commits] proj/R_overlay:gsoc13/next commit in: roverlay/interface/ André Erdmann -- strict thread matches above, loose matches on Subject: below -- 2014-06-05 22:09 [gentoo-commits] proj/R_overlay:master " André Erdmann 2014-06-05 22:09 André Erdmann 2013-08-20 21:46 André Erdmann 2013-07-24 9:54 André Erdmann 2013-07-24 9:54 André Erdmann 2013-07-24 9:54 André Erdmann 2013-07-23 7:51 André Erdmann 2013-07-18 19:25 [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann 2013-07-23 7:51 ` [gentoo-commits] proj/R_overlay:master " André Erdmann 2013-07-16 16:36 André Erdmann 2013-07-03 10:05 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=1374255894.8735cde4882262112c7adf46b1e55a390d920e28.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