summaryrefslogtreecommitdiffstats
path: root/filter.py
Commit message (Collapse)AuthorAgeFilesLines
* filter: use new utils_lxml.etree_parser_safe_unblankingJan Pokorný2016-02-011-4/+4
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter+format: harden (+prepare grounds for) XML/XSLT usageJan Pokorný2016-02-011-6/+7
| | | | | | | | | | | | Forbid any direct network/disk side-effects for XSLT and make sure we are using XML parser without network access. In the future, there is an possibility to forbid also entities replacement should it be considered risky and unintrusive. The new lxml.etree wrappers are placed into new utils_lxml module. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: _try_edit: make "was file modified" test more robustJan Pokorný2016-02-011-26/+30
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: get along without /dev/tty that may not existJan Pokorný2016-02-011-4/+6
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: XMLFilter: proceed: allow walk post-processingJan Pokorný2015-12-171-1/+3
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: XMLFilter: commented out code actually helpfulJan Pokorný2015-12-171-2/+2
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: XMLFilter: offer optional libxslt-based profilingJan Pokorný2015-12-171-13/+31
| | | | | | | | | | When XSLT-based commands passed a --profile switch, files per xslt-profile-<filter name>-<hexa timestamp>.xml will be produced (in an accumulative manner when a filter was multi-stepped). Also add new ballast-prevention item to .gitignore accordingly. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* command: make "XSLT" subheaders in msgs (uniformly) lowercasedJan Pokorný2015-12-171-1/+1
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: proceed_xslt: fix a comment discrepancyJan Pokorný2015-12-171-1/+1
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: fix very fallback "svc_output" caseJan Pokorný2015-12-171-1/+1
| | | | | | `None` apparently doesn't support "in" access. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* command + filter: refactor/simplify "svc_output" usageJan Pokorný2015-12-171-8/+17
| | | | | | | | | Do not propagate "maxl" needed to set up a prefix as it is conveniently memoized into "svc_output" callable within the context, and make it (hopefully) clear that filters should complain about stuff via flt_ctxt.ctxt_svc_output(msg, **kwargs) for uniformity. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: XMLFilter: adapt highlighter to support `highlight`Jan Pokorný2015-12-171-0/+3
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: XMLFilter: adapt highlighter to support "NOTE:"Jan Pokorný2015-12-171-2/+8
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: XMLFilter: preserve "descent-mix" in both casesJan Pokorný2015-12-171-2/+3
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: make XML validation recovery suggest an inspection stepJan Pokorný2015-12-171-2/+4
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: make XML validation recovery preoccupied users friendlyJan Pokorný2015-12-171-5/+14
| | | | | | | | | | | Two subsequent attempts without a modification now lead to immediate termination, preventing indefinite looping if the user was confused enough (understandable). This also prevents any sort of infloop when editor is specified as something like "touch" for some mysterious reasons. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: XMLFilter: tweak further terminating xsl:message outputJan Pokorný2015-12-171-1/+3
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: XMLFilter: handle terminating xsl:message correctlyJan Pokorný2015-12-171-10/+17
| | | | | | | I.e., handle etree.XSLTApplyError being raised while executing the XSL transformation and terminate (as this is fatal) without a traceback. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: XMLFilter: memoize if message is "urgent"Jan Pokorný2015-12-171-2/+3
| | | | | | To make it apparent that the decision is the same at multiple places. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: XMLFilter: avoid re-emitting fatal errorsJan Pokorný2015-12-171-1/+1
| | | | | | Show (also repeatedly, but good for clarity) the failed filter instead. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: XMLFilter: avoid emitting bogus errorsJan Pokorný2015-12-171-0/+3
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: proceed_xslt: fix emitting NOOP xsl:templateJan Pokorný2015-12-171-2/+1
| | | | | | | | | | | | | | | | | | | This was the case with ccs-obfuscate-ids filter that could emit something like <xsl:template match="rm"> <xsl:variable name="failoverdomain" select="..."/> <xsl:variable name="service" select="..."/> </xsl:template> as part of the resulting XSL template while explicit <clufter:descent-mix preserve-rest="true"/> at the top-level would lead to "identity transform" by default (modulo targeted transformations explicitly requested) also for this erroneously shadowed <rm> tag, just because of this bug stripping <rm> completely as a result. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: when filter validates along, avoid revalidationJan Pokorný2015-08-111-1/+4
| | | | | | ... on output format instantiation (needless and unhelpful). Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: XMLFilter.deco_xslt's fnc can be parametrized directlyJan Pokorný2015-08-111-2/+4
| | | | | | In that case, these directly passed kwargs take the precedence. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: allow passing xml_root into Format's walk_schemaJan Pokorný2015-08-111-3/+6
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: fix ccs-obfuscate not working properlyJan Pokorný2015-06-191-0/+4
| | | | | | | Possibly related to changes around filter: fix issue possibly workarounded with text-only descent Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: add unified interface for filter defaultsJan Pokorný2015-06-191-5/+7
| | | | | | This will also serve an "in-command-parameter interpolation" purpose. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: _xslt_preprocess: ensure params from def_first propagatedJan Pokorný2015-05-291-1/+2
| | | | | | | | ...into root (~first) template (or more generally, any top-level XSLT instruction from def_first as prescribed by the respective filter definition). Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: XSLT: clufter:descent-mix vs. repeated referencesJan Pokorný2015-05-291-4/+5
| | | | | | | | | | | | ...for the same tag from previous commit: > ... should be only for clufter:descent-mix (seems really a bad idea > for clufter:descent) -> turn the exception just into info log message for clufter:descent-mix Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: XSLT: support repeated references for the same tagJan Pokorný2015-05-291-13/+19
| | | | | | | ... should be only for clufter:descent-mix (seems really a bad idea for clufter:descent). Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: do_proceed: consider <xsl:if><xsl:template> et al.Jan Pokorný2015-05-291-4/+14
| | | | | | | | | | IOW, shallow/flat examination is not enough in that case. Some other specialities, like xsl:variable, has to be taken into account as well. For "to XSLT" experimental output (_xslt_template), at least, add a comment explaining that situation is a little bit more complicated. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: allow passing extra arguments to filtersJan Pokorný2015-05-291-1/+7
| | | | | | | | ...standard way is to rely fully on flt_ctxt -- this is an injection vector for convenient unit-testing (only) as also indicated by a warning emitted when their presence is witnessed. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: XMLFilter/command_common: use a symbolic stringJan Pokorný2015-05-291-1/+5
| | | | | | (leverage previously defined docformat decorator) Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: proceed: do not interleave def_first + systemJan Pokorný2015-05-291-3/+4
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: _xslt_preprocess drop unused codeJan Pokorný2015-05-291-10/+1
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: fix issue possibly workarounded with text-only descentJan Pokorný2015-05-291-6/+6
| | | | | | | | | | | IIRC, this is related to "filters/cib2pcscmd[group]" case where usage of a parameter (presumably propagated from def_first) was attempted but did not really worked with original descent-mix (hence text-only descent was deemed a quick fix). This patch should be a much better solution to that very problem ... so flip these "clufter:descent" instructions as well. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: add a (self-reference) link wrt. in-place modificationJan Pokorný2015-05-191-2/+3
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* Better support of Composite format usage/passingJan Pokorný2015-04-151-4/+10
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: flip logical value in comparisonJan Pokorný2015-04-151-2/+2
| | | | | | | Seems not to break anything + fits in the upcoming filter. (fingers crossed) Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: inject virtual "just merge, preserve-rest" abs. parentJan Pokorný2015-04-081-2/+10
| | | | | | | | | | | | | This is needed so as to spread top level XSLT tags from implicit def_first ($system{,_1,_2} params, etc.). (Alternatively, we could somehow propagate the parameters Python-wise and then passed them to respective method: http://lxml.de/xpathxslt.html#stylesheet-parameters but this seems bit more systemic [although clunky]) Related: rhbz#1207345 Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: support also xsl:value-of based/dynamic XSL commentsJan Pokorný2015-03-041-3/+7
| | | | | | Related to "script" RA ccs2pcs conversion provided by Patrik Hagara. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: make XSLT filter aware of lazystring symbolsJan Pokorný2015-02-261-1/+3
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: propagate unrecognized call kws to CommandContextJan Pokorný2015-02-261-3/+4
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: do not trust editors to do real in-place editJan Pokorný2015-02-261-2/+5
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: do not info-log launching editor prematurelyJan Pokorný2015-02-261-2/+2
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter: fix _try_edit not expecting additional keywordJan Pokorný2015-02-261-5/+4
| | | | | | | TODO: a test, likely more-than-unit one, to exercise _try_edit Reported-by: Patrik Hagara <phagara@redhat.com> Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* Mass change: import logging -> from logging import getLoggerJan Pokorný2015-01-091-2/+2
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* ext-plugins/lib-general: string_{list,set} + conversion filterJan Pokorný2015-01-091-1/+2
| | | | | | | + start respective unit tests + fix faulty format passing logic as observed with the new plugins Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* Integrate FancyOutput helper classJan Pokorný2014-12-111-12/+13
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
* filter{,s/*}: simplify declaration of default xslt filterJan Pokorný2014-12-081-0/+10
| | | | Signed-off-by: Jan Pokorný <jpokorny@redhat.com>