ewa.rules

Package ewa :: Module rules |
[hide private]
[frames] | no frames]

# Module rules

source code

a rule system for ewa, used to determine what files should appear before or after a main mp3 file in a composite mp3.

Rules are callables that take a single "filename" parameter and return None or a generator that yields mp3 filenames (or equivalent designations) in sequence.

A RuleList is a rule with a list of subrules, optionally with a condition (matched against the filename). When the RuleList is called, if the condition does not exist, or if it matches, each subrule is called on the filename until one returns something, which is the return value.

Rules can be marshalled to and from JSON, and from (but currently not to) the ewa rule configuration format implemented in ewa.ruleparser.

Classes | [hide private]
| _template
| OriginalName
| _jsonable
| RuleList
| DefaultRule this may be useful as the last rule in a rule-list; it yields the filename passed and nothing else
| MatchRule
| And
| Or
| Not
| RegexMatcher
| GlobMatcher
| CurrentTimeMatch returns true if the current time falls within a datetime range
| FileTimeMatch returns true if a date encoded in a string falls within a date range
| FileRule

Functions | [hide private]
to_jsondata(obj) | source code
extract_datetime(target, regex=`'``\\d{6}``'`, format=`'``%m%d%y``'`) | source code
RegexRule(pattern, pre=None, post=None, flags=0) | source code
GlobMatchRule(pattern, pre=None, post=None, casesensitive=True) | source code
from_jsondata(data) | source code
from_json(json) | source code
to_json(data) | source code
_parse_ewaconf(filename) | source code

Variables | [hide private]
| _json_registry = ``{``'``And``'``:` <class 'ewa.rules.And'>`,` `'``CurrentTime``...``
| __package__ = ``'``ewa``'``

Variables Details | [hide private]

  ### _json_registry Value:
      {'And': <class 'ewa.rules.And'>,
       'CurrentTimeMatch': <class 'ewa.rules.CurrentTimeMatch'>,
       'DefaultRule': <class 'ewa.rules.DefaultRule'>,
       'FileTimeMatch': <class 'ewa.rules.FileTimeMatch'>,
       'GlobMatcher': <class 'ewa.rules.GlobMatcher'>,
       'MatchRule': <class 'ewa.rules.MatchRule'>,
       'Not': <class 'ewa.rules.Not'>,
       'Or': <class 'ewa.rules.Or'>,
      ...