summaryrefslogtreecommitdiffstats
path: root/utils.py
Commit message (Collapse)AuthorAgeFilesLines
* utils: new "hybridmethod" decoratorJan Pokorný2015-08-111-0/+8
| | | | | | | | | | | Similar to hybridproperty: first parameter of the decorated method is flexibly bound to either the instance or the class depending on the context of invokation. Effectively, the only difference is that hybridmethod is expected to be passed arguments, unlike with property where it is called directly (w/o parameters) upon access. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: try avoiding clash of special keys in kwargsJan Pokorný2015-08-111-7/+7
| | | | | | | | ...in filterdict_* lambdas where (now) _fn_ is a special key. Also adjust the callers where needed. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: add lazystring decorator/wrapper over eval'd stringJan Pokorný2015-02-261-0/+26
| | | | | | | | Caching of the value is implicit, can be disabled by the respective flag, e.g., if the value depends on some condition that may change in a repeated string yielding. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* ext-plugins/lib-general: string_{list,set} + conversion filterJan Pokorný2015-01-091-1/+1
| | | | | | | + start respective unit tests + fix faulty format passing logic as observed with the new plugins Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: properly rehash filterdict_* functionsJan Pokorný2014-11-141-11/+57
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: arg2wrapped: make sure list on input is on outputJan Pokorný2014-11-141-2/+3
| | | | | | Previously, the list was deconstructed and reconstructed as a tuple. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* format (+utils): make format compatibility check more liberalJan Pokorný2014-10-211-1/+8
| | | | | | | ... so as to fix a regression introduced with more explicit format declarations in the filter "signatures". Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* plugin_registry: fix issue with non-discoverable pluginsJan Pokorný2014-09-171-1/+7
| | | | | | | | | | | | | | | | | | There are "native" plugins, such as XML under `format` module. The problem with these is that once they are dropped (`PluginRegistry.setup(reset=True)`), they cannot be re-discovered any more (the first discovery is usually implicit through the import + metaclass machinery). Now we can also remove a hack in `PluginRegistry.discovery()` that used to inject such "native" plugins implicitly (but till the whole registry got restarted!) if full search was requested. Thanks to Travis CI for exposing the issue because of the different ordering of the unit tests (subsequently reproduced at me with `./run-tests tests.{format_manager.Injection,command_manager.Default}`). Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: sanitize args2tuple (OMG)Jan Pokorný2014-09-051-1/+1
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: consider set a "tuplist" as wellJan Pokorný2014-09-051-1/+1
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* Solve a "read-only dict as API" question once foreverJan Pokorný2014-09-041-0/+4
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* command/format: pass declared cmd context subset to Format objectJan Pokorný2014-06-181-0/+21
| | | | | | | | | | | | | | This subset is declared with 'context_specs' and is being built on the metaclass level in the top-down, extending (additive/non-subtractive) manner (just like the set of methods is growing monotonously top-down the hierarchy). Currently, only 'validator_specs' (mapping protocols to the somewhat abstract "validator spec", '' key being used as a failback) is of interest this way, and can be used as an on-off validation toggle on user's request (by convence, '' value stands for off state). Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* command_context: restore common dict semantics + allow "bypass"Jan Pokorný2014-06-171-1/+5
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: reconcile forgotten "filter" funcs renamingJan Pokorný2014-06-171-6/+14
| | | | | | | This parallel refactoring tainted/affected several commits back, starting with f1a9f5e. This should be fine now. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: fix braino in naming: mutable -> immutableJan Pokorný2014-06-041-1/+1
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: fix braino in func_defaults_varnames + update unittestJan Pokorný2014-06-041-16/+5
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* Cleanup: move squote from utils to utils_xmlJan Pokorný2014-05-301-7/+0
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* format: refactor out some tuplist-realated normalizationsJan Pokorný2014-05-301-0/+4
| | | | | | ...to utils.py Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: XMLFilter/XSLT: expose system knowledge as paramsJan Pokorný2014-05-221-0/+7
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils_prog: new program-specific unit incl. some moves from utilsJan Pokorný2014-05-191-71/+12
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* Relicence GPLv2 -> GPLv2+Jan Pokorný2014-04-251-1/+1
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: further sanitize/simplify func_defaults_varnamesJan Pokorný2014-04-011-8/+6
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* Refactor "magic @DITIT+ files: allow repeated usage"Jan Pokorný2014-04-011-12/+0
| | | | | | Now, it is used implicitly for any 'file'-like IO declaration. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* Refactor: move functional-paradigm helpers utils -> utils_funcJan Pokorný2014-04-011-76/+0
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: func_defaults_varnames: one more fixJan Pokorný2014-03-281-0/+3
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: func_defaults_varnames: fix previous commitJan Pokorný2014-03-281-1/+5
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: fix implicit function argument when making a generatorJan Pokorný2014-03-281-4/+12
| | | | | | ...which happened with the previous commit re: magic @DITIT+ files Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* re magic @DITIT+ files: allow repeated usageJan Pokorný2014-03-281-0/+12
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* Formalize s/_/-/g + inverse transformation as functionsJan Pokorný2014-03-061-0/+14
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: add a note wrt. longopt_letters_reprio (uppercasing)Jan Pokorný2014-03-041-1/+2
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* command: fix short-option assignment algorithmJan Pokorný2014-03-041-2/+4
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* command: automagically figure out the short opts for long onesJan Pokorný2014-02-261-0/+8
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* command-related: postpone creating Option instancesJan Pokorný2014-02-261-0/+3
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* command+utils: adjust commentsJan Pokorný2014-02-261-1/+1
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* format + simpleconfig: prevent unneeded deepcopy (of tuple)Jan Pokorný2014-02-191-0/+3
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* Allow more convenient way of specifying command parametersJan Pokorný2014-02-191-3/+8
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* command: make this top-layer work as per the design, yayJan Pokorný2014-02-131-0/+27
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: add decorator mainly for recursive staticmethodJan Pokorný2014-02-111-0/+8
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: fix args2... enforcing lists + extra spaceJan Pokorný2014-02-111-6/+9
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: add any2iter always having some "iterable" at outputJan Pokorný2014-02-101-0/+5
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: tuple-or-list = tuplist + function to detect itJan Pokorný2014-02-101-15/+14
| | | | | | Also apply/substitute the verbatim detection where suitable. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: adjust head_tail and add args2{sgpl,tuple} helpersJan Pokorný2014-02-091-4/+9
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* command: fine-tune "shapes" match for filter/format chainJan Pokorný2014-01-281-10/+20
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* command: implement "shapes" match for filter/format chainJan Pokorný2014-01-271-0/+17
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* Move base exceptions and exit codes to separate error.pyJan Pokorný2014-01-271-25/+1
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: apply_aggregation_preserving_passing_depth: new helperJan Pokorný2014-01-241-0/+6
| | | | | | | Sometimes it's handy if the aggregation function knows about the current depth (e.g., structured list/tuple pretty-printer). Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: func_defaults_varnames: new fnc instrospection helperJan Pokorný2014-01-241-0/+10
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: which: add docstringJan Pokorný2014-01-241-0/+1
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: fix issues with Clufter{,plain}Error robustnessJan Pokorný2014-01-231-4/+8
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* utils: add mappings of tuples/list with variable depthJan Pokorný2014-01-201-1/+20
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>