diff options
author | 2013-07-19 19:42:41 +0200 | |
---|---|---|
committer | 2013-07-19 19:42:41 +0200 | |
commit | e328ea22ba0d41c4ccab358ae3df49486e6e4e62 (patch) | |
tree | 5e6e40ee76a31875c80d44ad87cdef7a8ba7139c | |
parent | fix has_context() in mapreader/rulemaker (diff) | |
download | R_overlay-e328ea22ba0d41c4ccab358ae3df49486e6e4e62.tar.gz R_overlay-e328ea22ba0d41c4ccab358ae3df49486e6e4e62.tar.bz2 R_overlay-e328ea22ba0d41c4ccab358ae3df49486e6e4e62.zip |
roverlay/depres/: replace rule pool export_rules()
-rw-r--r-- | roverlay/depres/deprule.py | 23 | ||||
-rw-r--r-- | roverlay/depres/simpledeprule/pool.py | 14 |
2 files changed, 24 insertions, 13 deletions
diff --git a/roverlay/depres/deprule.py b/roverlay/depres/deprule.py index 1d36941..ed6084d 100644 --- a/roverlay/depres/deprule.py +++ b/roverlay/depres/deprule.py @@ -40,6 +40,10 @@ class DependencyRule ( object ): make_result = _make_result + def export_rule ( self ): + raise NotImplementedError() + # --- end of export_rule (...) --- + # --- end of DependencyRule --- @@ -149,3 +153,22 @@ class DependencyRulePool ( object ): # default return return None # --- end of matches (...) --- + + def export_rules ( self ): + """Exports all rules. Typically, this generates text lines.""" + for rule in self.rules: + for item in rule.export_rule(): + yield item + # --- end of export_rules (...) --- + + def export_rules_into ( self, fh ): + """Writes all rules into the given file handle. + + arguments: + * fh -- + """ + NL = '\n' + for item in self.export_rules(): + fh.write ( str ( item ) ) + fh.write ( NL ) +# --- end of DependencyRulePool --- diff --git a/roverlay/depres/simpledeprule/pool.py b/roverlay/depres/simpledeprule/pool.py index 6fcb714..677ad20 100644 --- a/roverlay/depres/simpledeprule/pool.py +++ b/roverlay/depres/simpledeprule/pool.py @@ -16,6 +16,7 @@ from roverlay.depres import deprule from roverlay.depres.simpledeprule.abstractrules import SimpleRule class SimpleDependencyRulePool ( deprule.DependencyRulePool ): + def __init__ ( self, name, priority=70, **kw ): """Initializes a SimpleDependencyRulePool, which is a DependencyRulePool specialized in simple dependency rules; @@ -43,16 +44,3 @@ class SimpleDependencyRulePool ( deprule.DependencyRulePool ): else: raise Exception ( "bad usage (simple dependency rule expected)." ) # --- end of add (...) --- - - def export_rules ( self, fh ): - """Exports all rules from this pool into the given file handle. - - arguments: - * fh -- object that has a writelines ( list ) method - - raises: IOError (fh) - """ - for rule in self.rules: - fh.write ( str ( rule ) ) - fh.write ( '\n' ) - # --- end of export_rules (...) --- |