From 17d40c6057c88f4c432b0d7bac88e1b84cb7e67f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:03:36 +0200 Subject: Adding upstream version 1.65.0+dfsg1. Signed-off-by: Daniel Baumann --- src/etc/htmldocck.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/etc/htmldocck.py') diff --git a/src/etc/htmldocck.py b/src/etc/htmldocck.py index d02ac9d9c..c97fb4b80 100644 --- a/src/etc/htmldocck.py +++ b/src/etc/htmldocck.py @@ -41,15 +41,15 @@ There are a number of supported commands: `PATH` is relative to the output directory. It can be given as `-` which repeats the most recently used `PATH`. -* `@has PATH PATTERN` and `@matches PATH PATTERN` checks for - the occurrence of the given pattern `PATTERN` in the specified file. +* `@hasraw PATH PATTERN` and `@matchesraw PATH PATTERN` checks + for the occurrence of the given pattern `PATTERN` in the specified file. Only one occurrence of the pattern is enough. - For `@has`, `PATTERN` is a whitespace-normalized (every consecutive + For `@hasraw`, `PATTERN` is a whitespace-normalized (every consecutive whitespace being replaced by one single space character) string. The entire file is also whitespace-normalized including newlines. - For `@matches`, `PATTERN` is a Python-supported regular expression. + For `@matchesraw`, `PATTERN` is a Python-supported regular expression. The file remains intact but the regexp is matched without the `MULTILINE` and `IGNORECASE` options. You can still use a prefix `(?m)` or `(?i)` to override them, and `\A` and `\Z` for definitely matching @@ -386,7 +386,7 @@ def check_tree_attr(tree, path, attr, pat, regexp): return ret -# Returns the number of occurences matching the regex (`regexp`) and the text (`pat`). +# Returns the number of occurrences matching the regex (`regexp`) and the text (`pat`). def check_tree_text(tree, path, pat, regexp, stop_at_first): path = normalize_xpath(path) match_count = 0 @@ -542,19 +542,23 @@ ERR_COUNT = 0 def check_command(c, cache): try: cerr = "" - if c.cmd == 'has' or c.cmd == 'matches': # string test - regexp = (c.cmd == 'matches') - if len(c.args) == 1 and not regexp: # @has = file existence + if c.cmd in ['has', 'hasraw', 'matches', 'matchesraw']: # string test + regexp = c.cmd.startswith('matches') + + # @has = file existence + if len(c.args) == 1 and not regexp and 'raw' not in c.cmd: try: cache.get_file(c.args[0]) ret = True except FailedCheck as err: cerr = str(err) ret = False - elif len(c.args) == 2: # @has/matches = string test + # @hasraw/matchesraw = string test + elif len(c.args) == 2 and 'raw' in c.cmd: cerr = "`PATTERN` did not match" ret = check_string(cache.get_file(c.args[0]), c.args[1], regexp) - elif len(c.args) == 3: # @has/matches = XML tree test + # @has/matches = XML tree test + elif len(c.args) == 3 and 'raw' not in c.cmd: cerr = "`XPATH PATTERN` did not match" ret = get_nb_matching_elements(cache, c, regexp, True) != 0 else: -- cgit v1.2.3