csvpath 0.0.470__tar.gz → 0.0.472__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {csvpath-0.0.470 → csvpath-0.0.472}/PKG-INFO +1 -1
- {csvpath-0.0.470 → csvpath-0.0.472}/config/config.ini +3 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/csvpath.py +27 -29
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/csvpaths.py +58 -23
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/managers/file_manager.py +34 -3
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/managers/result.py +21 -2
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/managers/results_manager.py +1 -1
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/boolean/notf.py +0 -1
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/counting/increment.py +0 -1
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/headers/empty_stack.py +0 -2
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/lines/advance.py +1 -1
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/lines/stop.py +2 -37
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/lark_transformer.py +0 -1
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/productions/header.py +0 -2
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/productions/matchable.py +10 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/productions/qualified.py +0 -9
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/productions/reference.py +0 -3
- csvpath-0.0.472/csvpath/util/cache.py +49 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/util/config.py +33 -8
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/util/error.py +1 -1
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/util/line_monitor.py +26 -1
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/advance.md +1 -1
- csvpath-0.0.472/docs/functions/has_matches.md +17 -0
- csvpath-0.0.472/docs/functions/implementing_functions.md +107 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/import.md +1 -1
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/metaphone.md +1 -1
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions.md +1 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/paths.md +2 -2
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/references.md +1 -1
- {csvpath-0.0.470 → csvpath-0.0.472}/pyproject.toml +1 -1
- csvpath-0.0.470/docs/functions/implementing_functions.md +0 -85
- {csvpath-0.0.470 → csvpath-0.0.472}/LICENSE +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/README.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/__init__.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/managers/__init__.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/managers/csvpaths_manager.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/__init__.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/__init__.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/boolean/all.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/boolean/andf.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/boolean/any.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/boolean/between.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/boolean/empty.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/boolean/exists.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/boolean/inf.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/boolean/no.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/boolean/orf.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/boolean/yes.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/counting/count.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/counting/count_headers.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/counting/count_lines.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/counting/count_scans.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/counting/every.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/counting/has_matches.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/counting/tally.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/counting/total_lines.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/dates/datef.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/dates/now.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/function.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/function_factory.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/function_focus.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/headers/collect.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/headers/end.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/headers/header_name.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/headers/header_names_mismatch.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/headers/headers.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/headers/mismatch.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/headers/replace.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/headers/reset_headers.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/lines/after_blank.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/lines/dups.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/lines/first.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/lines/first_line.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/lines/last.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/math/above.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/math/add.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/math/divide.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/math/equals.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/math/mod.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/math/multiply.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/math/round.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/math/subtract.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/math/sum.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/misc/importf.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/misc/intf.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/misc/nonef.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/misc/random.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/print/jinjaf.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/print/print_line.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/print/print_queue.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/print/printf.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/print/table.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/stats/correlate.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/stats/minf.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/stats/percent.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/stats/percent_unique.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/stats/stdev.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/strings/concat.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/strings/length.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/strings/lower.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/strings/metaphone.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/strings/num.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/strings/regex.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/strings/starts_with.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/strings/strip.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/strings/substring.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/strings/upper.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/testing/debug.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/validation.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/validity/fail.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/validity/failed.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/variables/get.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/variables/pushpop.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/variables/put.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/variables/track.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/functions/variables/variables.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/lark_parser.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/matcher.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/productions/__init__.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/productions/equality.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/productions/expression.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/productions/term.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/productions/variable.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/util/exceptions.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/util/expression_encoder.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/util/expression_utility.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/util/lark_print_parser.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/matching/util/print_parser.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/scanning/__init__.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/scanning/exceptions.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/scanning/parser.out +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/scanning/parsetab.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/scanning/scanner.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/scanning/scanning_lexer.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/util/config_exception.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/util/exceptions.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/util/last_line_stats.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/util/line_counter.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/util/log_utility.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/util/metadata_parser.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/csvpath/util/printer.py +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/asbool.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/assignment.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/config.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/examples.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/files.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/above.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/after_blank.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/all.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/andor.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/any.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/average.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/between.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/collect.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/correlate.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/count.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/count_headers.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/date.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/empty.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/empty_stack.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/end.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/every.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/fail.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/first.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/get.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/has_dups.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/header.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/header_name.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/header_names_mismatch.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/in.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/increment.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/jinja.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/last.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/line_number.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/max.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/mismatch.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/no.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/not.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/now.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/percent_unique.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/pop.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/print.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/print_line.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/print_queue.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/regex.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/replace.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/reset_headers.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/stdev.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/stop.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/string_functions.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/subtract.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/sum.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/tally.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/total_lines.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/track.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/variables.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/functions/variables_and_headers.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/grammar.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/headers.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/images/logo-wordmark-white-on-black-trimmed-padded.png +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/images/logo-wordmark-white-trimmed.png +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/qualifiers.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/terms.md +0 -0
- {csvpath-0.0.470 → csvpath-0.0.472}/docs/variables.md +0 -0
|
@@ -8,7 +8,7 @@ import hashlib
|
|
|
8
8
|
from typing import List, Dict, Any
|
|
9
9
|
from collections.abc import Iterator
|
|
10
10
|
from abc import ABC, abstractmethod
|
|
11
|
-
from csvpath.util.config import
|
|
11
|
+
from csvpath.util.config import Config
|
|
12
12
|
from csvpath.util.line_monitor import LineMonitor
|
|
13
13
|
from csvpath.util.log_utility import LogUtility
|
|
14
14
|
from .matching.matcher import Matcher
|
|
@@ -55,11 +55,7 @@ class CsvPathPublic(ABC):
|
|
|
55
55
|
|
|
56
56
|
@abstractmethod
|
|
57
57
|
def advance(self, ff: int = -1) -> None: # pragma: no cover
|
|
58
|
-
"""Advances the iteration by ff rows.
|
|
59
|
-
considered for match and variables and side effects will happen,
|
|
60
|
-
but no rows will be returned or stored. -1 means to the end of
|
|
61
|
-
the file.
|
|
62
|
-
"""
|
|
58
|
+
"""Advances the iteration by ff rows. -1 means to the end of the file."""
|
|
63
59
|
|
|
64
60
|
@abstractmethod
|
|
65
61
|
def fast_forward(self) -> None: # pragma: no cover
|
|
@@ -175,6 +171,7 @@ class CsvPath(CsvPathPublic, ErrorCollector): # pylint: disable=R0902, R0904
|
|
|
175
171
|
#
|
|
176
172
|
self.stopped = False
|
|
177
173
|
self._advance = 0
|
|
174
|
+
|
|
178
175
|
#
|
|
179
176
|
# set by fail()
|
|
180
177
|
#
|
|
@@ -249,6 +246,14 @@ class CsvPath(CsvPathPublic, ErrorCollector): # pylint: disable=R0902, R0904
|
|
|
249
246
|
self.logger = LogUtility.logger(self)
|
|
250
247
|
self.logger.info("initialized CsvPath")
|
|
251
248
|
|
|
249
|
+
@property
|
|
250
|
+
def advance_count(self) -> int: # pragma: no cover
|
|
251
|
+
return self._advance
|
|
252
|
+
|
|
253
|
+
@advance_count.setter
|
|
254
|
+
def advance_count(self, lines: int) -> None:
|
|
255
|
+
self._advance = lines
|
|
256
|
+
|
|
252
257
|
@property
|
|
253
258
|
def headers(self) -> List[str]:
|
|
254
259
|
if self._headers is None:
|
|
@@ -311,9 +316,9 @@ class CsvPath(CsvPathPublic, ErrorCollector): # pylint: disable=R0902, R0904
|
|
|
311
316
|
return ""
|
|
312
317
|
|
|
313
318
|
@property
|
|
314
|
-
def config(self) ->
|
|
319
|
+
def config(self) -> Config: # pylint: disable=C0116
|
|
315
320
|
if not self._config:
|
|
316
|
-
self._config =
|
|
321
|
+
self._config = Config(self)
|
|
317
322
|
return self._config
|
|
318
323
|
|
|
319
324
|
def has_errors(self) -> bool: # pylint: disable=C0116
|
|
@@ -345,7 +350,7 @@ class CsvPath(CsvPathPublic, ErrorCollector): # pylint: disable=R0902, R0904
|
|
|
345
350
|
# here we're just collecting them if collect is
|
|
346
351
|
# selected by our configuration
|
|
347
352
|
#
|
|
348
|
-
if self._error_collector:
|
|
353
|
+
if self._error_collector is not None:
|
|
349
354
|
self._error_collector.collect_error(e)
|
|
350
355
|
else:
|
|
351
356
|
if self._errors is None:
|
|
@@ -374,8 +379,7 @@ class CsvPath(CsvPathPublic, ErrorCollector): # pylint: disable=R0902, R0904
|
|
|
374
379
|
@property
|
|
375
380
|
def collect_when_not_matched(self) -> bool:
|
|
376
381
|
"""when this property is True CsvPath returns the lines that do not
|
|
377
|
-
match the
|
|
378
|
-
"""
|
|
382
|
+
match the matchers match components"""
|
|
379
383
|
return self._when_not_matched
|
|
380
384
|
|
|
381
385
|
@collect_when_not_matched.setter
|
|
@@ -551,14 +555,6 @@ class CsvPath(CsvPathPublic, ErrorCollector): # pylint: disable=R0902, R0904
|
|
|
551
555
|
metadata: {len(self.metadata)}
|
|
552
556
|
"""
|
|
553
557
|
|
|
554
|
-
@property
|
|
555
|
-
def advance(self) -> bool: # pragma: no cover
|
|
556
|
-
return self._advance
|
|
557
|
-
|
|
558
|
-
@advance.setter
|
|
559
|
-
def advance(self, lines: int) -> None:
|
|
560
|
-
self._advance = lines
|
|
561
|
-
|
|
562
558
|
@property
|
|
563
559
|
def is_valid(self) -> bool: # pragma: no cover
|
|
564
560
|
return self._is_valid
|
|
@@ -745,11 +741,11 @@ class CsvPath(CsvPathPublic, ErrorCollector): # pylint: disable=R0902, R0904
|
|
|
745
741
|
self.scan_count = self.scan_count + 1
|
|
746
742
|
matches = None
|
|
747
743
|
self._current_match_count = self.match_count
|
|
748
|
-
if self.
|
|
749
|
-
self.
|
|
744
|
+
if self.advance_count > 0:
|
|
745
|
+
self.advance_count -= 1
|
|
750
746
|
matches = False
|
|
751
747
|
self.logger.debug(
|
|
752
|
-
"Advancing one line with {self.
|
|
748
|
+
"Advancing one line with {self.advance_count} more skips to go"
|
|
753
749
|
)
|
|
754
750
|
else:
|
|
755
751
|
self.logger.debug("Starting matching")
|
|
@@ -809,9 +805,7 @@ class CsvPath(CsvPathPublic, ErrorCollector): # pylint: disable=R0902, R0904
|
|
|
809
805
|
return ls
|
|
810
806
|
|
|
811
807
|
def advance(self, ff: int = -1) -> None:
|
|
812
|
-
"""Advances the iteration by ff rows. The rows will be seen
|
|
813
|
-
variables and side effects will happen.
|
|
814
|
-
"""
|
|
808
|
+
"""Advances the iteration by ff rows. The rows will be seen but not matched."""
|
|
815
809
|
if ff is None:
|
|
816
810
|
raise InputException("Input to advance must not be None")
|
|
817
811
|
if self.line_monitor.physical_end_line_number is None:
|
|
@@ -819,14 +813,18 @@ class CsvPath(CsvPathPublic, ErrorCollector): # pylint: disable=R0902, R0904
|
|
|
819
813
|
"The last line number must be known (physical_end_line_number)"
|
|
820
814
|
)
|
|
821
815
|
if ff == -1:
|
|
822
|
-
|
|
816
|
+
a = self.advance_count
|
|
817
|
+
a = (
|
|
823
818
|
self.line_monitor.physical_end_line_number
|
|
824
819
|
- self.line_monitor.physical_line_number
|
|
825
|
-
-
|
|
820
|
+
- a
|
|
826
821
|
)
|
|
822
|
+
self.advance_count = a
|
|
827
823
|
else:
|
|
828
|
-
self.
|
|
829
|
-
self.
|
|
824
|
+
self.advance_count += ff
|
|
825
|
+
self.advance_count = min(
|
|
826
|
+
self.advance_count, self.line_monitor.physical_end_line_number
|
|
827
|
+
)
|
|
830
828
|
|
|
831
829
|
def get_total_lines(self) -> int: # pylint: disable=C0116
|
|
832
830
|
if (
|
|
@@ -6,7 +6,7 @@ from typing import List, Any, Tuple
|
|
|
6
6
|
import csv
|
|
7
7
|
import traceback
|
|
8
8
|
from .util.error import ErrorHandler, ErrorCollector, Error
|
|
9
|
-
from .util.config import
|
|
9
|
+
from .util.config import Config
|
|
10
10
|
from .util.log_utility import LogUtility
|
|
11
11
|
from .util.line_monitor import LineMonitor
|
|
12
12
|
from .util.metadata_parser import MetadataParser
|
|
@@ -107,11 +107,11 @@ class CsvPathsCoordinator(ABC):
|
|
|
107
107
|
|
|
108
108
|
@abstractmethod
|
|
109
109
|
def skip_all(self) -> None: # pragma: no cover
|
|
110
|
-
"""
|
|
110
|
+
"""skips the line for every CsvPath instance in a run"""
|
|
111
111
|
|
|
112
112
|
@abstractmethod
|
|
113
113
|
def advance_all(self, lines: int) -> None: # pragma: no cover
|
|
114
|
-
"""
|
|
114
|
+
"""advances every CsvPath instance in a run"""
|
|
115
115
|
|
|
116
116
|
|
|
117
117
|
class CsvPaths(CsvPathsPublic, CsvPathsCoordinator):
|
|
@@ -132,7 +132,7 @@ class CsvPaths(CsvPathsPublic, CsvPathsCoordinator):
|
|
|
132
132
|
self.quotechar = quotechar
|
|
133
133
|
self.skip_blank_lines = skip_blank_lines
|
|
134
134
|
self.current_matcher: CsvPath = None
|
|
135
|
-
self._config =
|
|
135
|
+
self._config = Config(self)
|
|
136
136
|
self.logger = LogUtility.logger(self)
|
|
137
137
|
self.logger.info("initialized CsvPaths")
|
|
138
138
|
self._errors = []
|
|
@@ -183,9 +183,9 @@ class CsvPaths(CsvPathsPublic, CsvPathsCoordinator):
|
|
|
183
183
|
return len(self._errors) > 0
|
|
184
184
|
|
|
185
185
|
@property
|
|
186
|
-
def config(self) ->
|
|
186
|
+
def config(self) -> Config: # pylint: disable=C0116
|
|
187
187
|
if not self._config:
|
|
188
|
-
self._config =
|
|
188
|
+
self._config = Config() # pragma: no cover
|
|
189
189
|
return self._config
|
|
190
190
|
|
|
191
191
|
def clean(self, *, paths) -> None:
|
|
@@ -287,7 +287,7 @@ class CsvPaths(CsvPathsPublic, CsvPathsCoordinator):
|
|
|
287
287
|
"Completed fast_forward_paths %s with %s paths", pathsname, len(paths)
|
|
288
288
|
)
|
|
289
289
|
|
|
290
|
-
def next_paths(self, *, pathsname, filename):
|
|
290
|
+
def next_paths(self, *, pathsname, filename, collect: bool = False):
|
|
291
291
|
"""appends the Result for each CsvPath to the end of
|
|
292
292
|
each line it produces. this is so that the caller can easily
|
|
293
293
|
interrogate the CsvPath for its path parts, file, etc."""
|
|
@@ -303,13 +303,27 @@ class CsvPaths(CsvPathsPublic, CsvPathsCoordinator):
|
|
|
303
303
|
self.clean(paths=pathsname)
|
|
304
304
|
self.logger.info("Beginning next_paths with %s paths", len(paths))
|
|
305
305
|
for path in paths:
|
|
306
|
+
if self._skip_all:
|
|
307
|
+
skip_err = "Found the skip-all signal set. skip_all() is"
|
|
308
|
+
skip_err = f"{skip_err} only for breadth-first runs using the"
|
|
309
|
+
skip_err = f"{skip_err} '_by_line' methods. It has the same"
|
|
310
|
+
skip_err = f"{skip_err} effect as skip() in a"
|
|
311
|
+
skip_err = f"{skip_err} serial run like this one."
|
|
312
|
+
self.logger.error(skip_err)
|
|
306
313
|
if self._stop_all:
|
|
307
|
-
self.logger.
|
|
314
|
+
self.logger.warning("Stop-all set. Shutting down run.")
|
|
308
315
|
break
|
|
316
|
+
if self._advance_all > 0:
|
|
317
|
+
advance_err = "Found the advance-all signal set. advance_all() is"
|
|
318
|
+
advance_err = f"{advance_err} only for breadth-first runs using the"
|
|
319
|
+
advance_err = f"{advance_err} '_by_line' methods. It has the same"
|
|
320
|
+
advance_err = f"{advance_err} effect as advance() in a"
|
|
321
|
+
advance_err = f"{advance_err} serial run like this one."
|
|
322
|
+
self.logger.error(advance_err)
|
|
309
323
|
csvpath = self.csvpath()
|
|
310
324
|
result = Result(csvpath=csvpath, file_name=filename, paths_name=pathsname)
|
|
311
325
|
if self._fail_all:
|
|
312
|
-
self.logger.
|
|
326
|
+
self.logger.warning(
|
|
313
327
|
"Fail-all set. Failing all remaining CsvPath instances in the run."
|
|
314
328
|
)
|
|
315
329
|
csvpath.is_valid = False
|
|
@@ -318,6 +332,8 @@ class CsvPaths(CsvPathsPublic, CsvPathsCoordinator):
|
|
|
318
332
|
self._load_csvpath(csvpath, path=path, file=file)
|
|
319
333
|
for line in csvpath.next():
|
|
320
334
|
line.append(result)
|
|
335
|
+
if collect:
|
|
336
|
+
result.append(line)
|
|
321
337
|
yield line
|
|
322
338
|
except Exception as ex: # pylint: disable=W0718
|
|
323
339
|
ex.trace = traceback.format_exc()
|
|
@@ -387,7 +403,7 @@ class CsvPaths(CsvPathsPublic, CsvPathsCoordinator):
|
|
|
387
403
|
if_all_agree=False,
|
|
388
404
|
collect_when_not_matched=False,
|
|
389
405
|
) -> List[Any]:
|
|
390
|
-
# re: R0912 -- absolutely
|
|
406
|
+
# re: R0912 -- absolutely. plan to refactor.
|
|
391
407
|
self.logger.info("Cleaning out any %s and %s results", filename, pathsname)
|
|
392
408
|
self.clean(paths=pathsname)
|
|
393
409
|
fn = self.file_manager.get_named_file(filename)
|
|
@@ -435,22 +451,40 @@ class CsvPaths(CsvPathsPublic, CsvPathsCoordinator):
|
|
|
435
451
|
for p in csvpath_objects:
|
|
436
452
|
self.current_matcher = p[0]
|
|
437
453
|
if self._fail_all:
|
|
438
|
-
self.logger.
|
|
454
|
+
self.logger.warning(
|
|
439
455
|
"Fail-all set. Setting CsvPath is_valid to False."
|
|
440
456
|
)
|
|
441
457
|
self.current_matcher.is_valid = False
|
|
442
458
|
if self._stop_all:
|
|
443
|
-
self.logger.
|
|
459
|
+
self.logger.warning("Stop-all set. Shutting down run.")
|
|
444
460
|
self.current_matcher.stopped = True
|
|
445
461
|
continue
|
|
446
462
|
if self._skip_all:
|
|
447
|
-
self.logger.
|
|
463
|
+
self.logger.warning("Skip-all set. Continuing to next.")
|
|
464
|
+
#
|
|
465
|
+
# all following CsvPaths must have their
|
|
466
|
+
# line_monitors incremented
|
|
467
|
+
#
|
|
468
|
+
self.current_matcher.track_line(line)
|
|
448
469
|
continue
|
|
449
470
|
if self._advance_all > 0:
|
|
450
|
-
self.logger.
|
|
471
|
+
self.logger.info(
|
|
451
472
|
"Advance-all set. Setting advance. CsvPath and its Matcher will handle the advancing."
|
|
452
473
|
)
|
|
453
|
-
|
|
474
|
+
#
|
|
475
|
+
# CsvPath will handle advancing so we don't need to do
|
|
476
|
+
# anything, including track_line(line). we just need to
|
|
477
|
+
# see if we're setting advance or increasing it.
|
|
478
|
+
#
|
|
479
|
+
a = self.current_matcher.advance_count
|
|
480
|
+
if self._advance_all > a:
|
|
481
|
+
self.current_matcher.advance_count = self._advance_all
|
|
482
|
+
#
|
|
483
|
+
# all following CsvPaths must have their
|
|
484
|
+
# advance incremented -- with the advance not being simply
|
|
485
|
+
# additive, have to be mindful of any existing advance
|
|
486
|
+
# count!
|
|
487
|
+
#
|
|
454
488
|
if self.current_matcher.stopped: # pylint: disable=R1724
|
|
455
489
|
continue
|
|
456
490
|
|
|
@@ -497,26 +531,24 @@ class CsvPaths(CsvPathsPublic, CsvPathsCoordinator):
|
|
|
497
531
|
# we yield even if we stopped in this iteration.
|
|
498
532
|
# caller needs to see what we stopped on.
|
|
499
533
|
#
|
|
500
|
-
#
|
|
534
|
+
# ! we only yield if keep is True
|
|
501
535
|
#
|
|
502
536
|
if keep:
|
|
503
537
|
yield line
|
|
504
538
|
if sum(stopped_count) == len(csvpath_objects):
|
|
505
539
|
break
|
|
506
|
-
# note to self: we have the lines in p[1]. we could, optionally, iteratively
|
|
507
|
-
# move them to the results here. probably a future requirement.
|
|
508
540
|
self.clear_run_coordination()
|
|
509
541
|
|
|
510
542
|
def _load_csvpath_objects(
|
|
511
543
|
self, *, paths: List[str], named_file: str, collect_when_not_matched=False
|
|
512
|
-
)
|
|
544
|
+
):
|
|
513
545
|
csvpath_objects = []
|
|
514
546
|
for path in paths:
|
|
515
547
|
csvpath = self.csvpath()
|
|
516
548
|
csvpath.collect_when_not_matched = collect_when_not_matched
|
|
517
549
|
try:
|
|
518
550
|
self._load_csvpath(csvpath, path=path, file=named_file)
|
|
519
|
-
csvpath_objects.append(
|
|
551
|
+
csvpath_objects.append([csvpath, []])
|
|
520
552
|
except Exception as ex: # pylint: disable=W0718
|
|
521
553
|
ex.trace = traceback.format_exc()
|
|
522
554
|
ex.source = self
|
|
@@ -532,18 +564,21 @@ class CsvPaths(CsvPathsPublic, CsvPathsCoordinator):
|
|
|
532
564
|
for csvpath in csvpath_objects:
|
|
533
565
|
try:
|
|
534
566
|
#
|
|
535
|
-
# lines object is a shared reference between path and results.
|
|
536
567
|
# Result will set itself into its CsvPath as error collector
|
|
537
568
|
# printer, etc.
|
|
538
569
|
#
|
|
539
570
|
result = Result(
|
|
540
|
-
csvpath=csvpath[0],
|
|
571
|
+
csvpath=csvpath[0],
|
|
572
|
+
file_name=filename,
|
|
573
|
+
paths_name=pathsname,
|
|
574
|
+
lines=csvpath[1],
|
|
541
575
|
)
|
|
576
|
+
csvpath[1] = result
|
|
542
577
|
self.results_manager.add_named_result(result)
|
|
543
578
|
except Exception as ex: # pylint: disable=W0718
|
|
544
579
|
ex.trace = traceback.format_exc()
|
|
545
580
|
ex.source = self
|
|
546
581
|
ErrorHandler(csvpaths=self, error_collector=csvpath).handle_error(ex)
|
|
547
582
|
#
|
|
548
|
-
# keep for modelines avoidance
|
|
583
|
+
# keep this comment for modelines avoidance
|
|
549
584
|
#
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
# pylint: disable=C0114
|
|
2
2
|
import os
|
|
3
3
|
import json
|
|
4
|
+
import csv
|
|
5
|
+
import hashlib
|
|
4
6
|
from json import JSONDecodeError
|
|
5
|
-
from typing import Dict, List
|
|
7
|
+
from typing import Dict, List, Tuple
|
|
6
8
|
from abc import ABC, abstractmethod
|
|
7
9
|
from ..util.line_counter import LineCounter
|
|
8
10
|
from ..util.line_monitor import LineMonitor
|
|
9
11
|
from ..util.error import ErrorHandler
|
|
12
|
+
from ..util.cache import Cache
|
|
10
13
|
|
|
11
14
|
|
|
12
15
|
class CsvPathsFileManager(ABC):
|
|
@@ -56,6 +59,7 @@ class FileManager(CsvPathsFileManager): # pylint: disable=C0115
|
|
|
56
59
|
self.named_files: Dict[str, str] = named_files
|
|
57
60
|
self.csvpaths = csvpaths
|
|
58
61
|
self.pathed_lines_and_headers = {}
|
|
62
|
+
self.cache = Cache(self.csvpaths)
|
|
59
63
|
|
|
60
64
|
def get_new_line_monitor(self, filename: str) -> LineMonitor:
|
|
61
65
|
if filename not in self.pathed_lines_and_headers:
|
|
@@ -70,10 +74,37 @@ class FileManager(CsvPathsFileManager): # pylint: disable=C0115
|
|
|
70
74
|
return self.pathed_lines_and_headers[filename][1][:]
|
|
71
75
|
|
|
72
76
|
def _find_lines_and_headers(self, filename: str) -> None:
|
|
73
|
-
|
|
74
|
-
lm
|
|
77
|
+
lm, headers = self._cached_lines_and_headers(filename)
|
|
78
|
+
if lm is None or headers is None:
|
|
79
|
+
lc = LineCounter(self.csvpaths)
|
|
80
|
+
lm, headers = lc.get_lines_and_headers(filename)
|
|
81
|
+
self._cache_lines_and_headers(filename, lm, headers)
|
|
75
82
|
self.pathed_lines_and_headers[filename] = (lm, headers)
|
|
76
83
|
|
|
84
|
+
# ========================================
|
|
85
|
+
# cache related
|
|
86
|
+
#
|
|
87
|
+
|
|
88
|
+
def _cached_lines_and_headers(self, filename: str) -> Tuple[LineMonitor, List[str]]:
|
|
89
|
+
lm = LineMonitor()
|
|
90
|
+
json = self.cache.cached_text(filename, "json")
|
|
91
|
+
if json is not None and not json.strip() == "":
|
|
92
|
+
lm.load(json)
|
|
93
|
+
else:
|
|
94
|
+
return (None, None)
|
|
95
|
+
headers = self.cache.cached_text(filename, "csv")
|
|
96
|
+
return (lm, headers)
|
|
97
|
+
|
|
98
|
+
def _cache_lines_and_headers(
|
|
99
|
+
self, filename, lm: LineMonitor, headers: List[str]
|
|
100
|
+
) -> None:
|
|
101
|
+
jstr = lm.dump()
|
|
102
|
+
self.cache.cache_text(filename, "json", jstr)
|
|
103
|
+
self.cache.cache_text(filename, "csv", ",".join(headers))
|
|
104
|
+
|
|
105
|
+
#
|
|
106
|
+
# ========================================
|
|
107
|
+
|
|
77
108
|
def set_named_files(self, nf: Dict[str, str]) -> None:
|
|
78
109
|
self.named_files = nf
|
|
79
110
|
|
|
@@ -57,6 +57,10 @@ class Result(ErrorCollector, Printer): # pylint: disable=R0902
|
|
|
57
57
|
def file_name(self, file_name: str) -> None:
|
|
58
58
|
self._file_name = file_name
|
|
59
59
|
|
|
60
|
+
# ==========================
|
|
61
|
+
# lines collecting methods
|
|
62
|
+
#
|
|
63
|
+
|
|
60
64
|
@property
|
|
61
65
|
def lines(self) -> List[List[Any]]: # pylint: disable=C0116
|
|
62
66
|
return self._lines
|
|
@@ -65,6 +69,18 @@ class Result(ErrorCollector, Printer): # pylint: disable=R0902
|
|
|
65
69
|
def lines(self, ls: List[List[Any]]) -> None:
|
|
66
70
|
self._lines = ls
|
|
67
71
|
|
|
72
|
+
def append(self, line: List[Any]) -> None:
|
|
73
|
+
if self._lines is None:
|
|
74
|
+
self._lines = []
|
|
75
|
+
self._lines.append(line)
|
|
76
|
+
|
|
77
|
+
def __len__(self) -> int:
|
|
78
|
+
if self._lines is None:
|
|
79
|
+
self._lines = []
|
|
80
|
+
return len(self._lines)
|
|
81
|
+
|
|
82
|
+
# ==========================
|
|
83
|
+
|
|
68
84
|
@property
|
|
69
85
|
def csvpath(self) -> CsvPath: # pylint: disable=C0116
|
|
70
86
|
return self._csvpath
|
|
@@ -79,15 +95,18 @@ class Result(ErrorCollector, Printer): # pylint: disable=R0902
|
|
|
79
95
|
def errors(self) -> List[Error]: # pylint: disable=C0116
|
|
80
96
|
return self._errors
|
|
81
97
|
|
|
98
|
+
@property
|
|
82
99
|
def errors_count(self) -> int: # pylint: disable=C0116
|
|
83
100
|
return len(self._errors) if self._errors else 0
|
|
84
101
|
|
|
85
102
|
def collect_error(self, error: Error) -> None: # pylint: disable=C0116
|
|
86
103
|
self._errors.append(error)
|
|
87
104
|
|
|
105
|
+
@property
|
|
88
106
|
def has_errors(self) -> bool: # pylint: disable=C0116
|
|
89
|
-
return len(self.
|
|
107
|
+
return len(self._errors) > 0
|
|
90
108
|
|
|
109
|
+
@property
|
|
91
110
|
def is_valid(self) -> bool: # pylint: disable=C0116
|
|
92
111
|
if self._csvpath:
|
|
93
112
|
return self._csvpath.is_valid
|
|
@@ -140,7 +159,7 @@ class Result(ErrorCollector, Printer): # pylint: disable=R0902
|
|
|
140
159
|
return i
|
|
141
160
|
|
|
142
161
|
def __str__(self) -> str:
|
|
143
|
-
return f"""
|
|
162
|
+
return f"""Result
|
|
144
163
|
file:{self.csvpath.scanner.filename if self.csvpath.scanner else None};
|
|
145
164
|
name of paths:{self.paths_name};
|
|
146
165
|
name of file:{self.file_name};
|
|
@@ -141,7 +141,7 @@ class ResultsManager(CsvPathsResultsManager): # pylint: disable=C0115
|
|
|
141
141
|
def is_valid(self, name: str) -> bool:
|
|
142
142
|
results = self.get_named_results(name)
|
|
143
143
|
for r in results:
|
|
144
|
-
if not r.is_valid
|
|
144
|
+
if not r.is_valid:
|
|
145
145
|
return False
|
|
146
146
|
return True
|
|
147
147
|
|
|
@@ -36,14 +36,12 @@ class EmptyStack(ValueProducer):
|
|
|
36
36
|
|
|
37
37
|
def _do_some(self, skip=None):
|
|
38
38
|
siblings = self.children[0].commas_to_list()
|
|
39
|
-
print(f"emmpty_stack: do_some: sibs: {siblings}")
|
|
40
39
|
self.value = []
|
|
41
40
|
for s in siblings:
|
|
42
41
|
v = s.to_value(skip=skip)
|
|
43
42
|
b = ExpressionUtility.is_empty(v)
|
|
44
43
|
if b:
|
|
45
44
|
self.value.append(s.name)
|
|
46
|
-
print(f"sib: {s}: {v} = {b}")
|
|
47
45
|
|
|
48
46
|
def _do_one(self, child, skip=None):
|
|
49
47
|
v = child.to_value(skip=skip)
|
|
@@ -15,7 +15,7 @@ class Advance(SideEffect):
|
|
|
15
15
|
v = child.to_value(skip=skip)
|
|
16
16
|
try:
|
|
17
17
|
v = int(v)
|
|
18
|
-
self.matcher.csvpath.
|
|
18
|
+
self.matcher.csvpath.advance_count = v
|
|
19
19
|
except (TypeError, ValueError) as e:
|
|
20
20
|
raise ChildrenException(
|
|
21
21
|
f"Advance must contain an int, not {type(v)}"
|
|
@@ -38,25 +38,6 @@ class Stop(Stopper):
|
|
|
38
38
|
def _decide_match(self, skip=None) -> None:
|
|
39
39
|
self.match = True
|
|
40
40
|
self._stop_me(skip=skip)
|
|
41
|
-
"""
|
|
42
|
-
if len(self.children) == 1:
|
|
43
|
-
b = self.children[0].matches(skip=skip)
|
|
44
|
-
if b is True:
|
|
45
|
-
self.matcher.csvpath.stop()
|
|
46
|
-
pln = self.matcher.csvpath.line_monitor.physical_line_number
|
|
47
|
-
self.matcher.csvpath.logger.info(
|
|
48
|
-
f"stopping at {pln}. contained child matches."
|
|
49
|
-
)
|
|
50
|
-
stopped = True
|
|
51
|
-
else:
|
|
52
|
-
self.matcher.csvpath.stop()
|
|
53
|
-
pln = self.matcher.csvpath.line_monitor.physical_line_number
|
|
54
|
-
self.matcher.csvpath.logger.info(f"stopping at {pln}")
|
|
55
|
-
stopped = True
|
|
56
|
-
if stopped and self.name == "fail_and_stop":
|
|
57
|
-
self.matcher.csvpath.logger.info("setting invalid")
|
|
58
|
-
self.matcher.csvpath.is_valid = False
|
|
59
|
-
"""
|
|
60
41
|
|
|
61
42
|
|
|
62
43
|
class StopAll(Stopper):
|
|
@@ -103,30 +84,14 @@ class Skip(Skipper):
|
|
|
103
84
|
def _decide_match(self, skip=None) -> None:
|
|
104
85
|
if self.do_once():
|
|
105
86
|
self._skip_me(skip=skip)
|
|
106
|
-
"""
|
|
107
|
-
if len(self.children) == 1:
|
|
108
|
-
b = self.children[0].matches(skip=skip)
|
|
109
|
-
if b is True:
|
|
110
|
-
self.matcher.skip = True
|
|
111
|
-
if self.once:
|
|
112
|
-
self._set_has_happened()
|
|
113
|
-
pln = self.matcher.csvpath.line_monitor.physical_line_number
|
|
114
|
-
self.matcher.csvpath.logger.info(
|
|
115
|
-
f"skipping physical line {pln}. contained child matches."
|
|
116
|
-
)
|
|
117
|
-
else:
|
|
118
|
-
self.matcher.skip = True
|
|
119
|
-
if self.once:
|
|
120
|
-
self._set_has_happened()
|
|
121
|
-
pln = self.matcher.csvpath.line_monitor.physical_line_number
|
|
122
|
-
self.matcher.csvpath.logger.info(f"skipping line {pln}")
|
|
123
|
-
"""
|
|
124
87
|
self.match = self.default_match()
|
|
125
88
|
|
|
126
89
|
|
|
127
90
|
class SkipAll(Skipper):
|
|
128
91
|
"""skips to the next line. tells the CsvPaths instance, if any,
|
|
129
92
|
to skip all the following CsvPath instances as well.
|
|
93
|
+
Note: skip_all() is only for the parallel/breadth-first methods.
|
|
94
|
+
for the serial/paths methods skip_all() works the same as skip().
|
|
130
95
|
"""
|
|
131
96
|
|
|
132
97
|
def check_valid(self) -> None:
|
|
@@ -31,7 +31,6 @@ class LarkTransformer(Transformer): # pylint: disable=C0115
|
|
|
31
31
|
# assignment
|
|
32
32
|
# COMMENT
|
|
33
33
|
def expression(self, acted_on, when=None, action=None): # pylint: disable=C0116
|
|
34
|
-
# print(f"expression: acted_on: {acted_on}, when: {when}, action: {action}")
|
|
35
34
|
if acted_on is None and when is None and action is None:
|
|
36
35
|
# this is a comment
|
|
37
36
|
return None
|
|
@@ -50,7 +50,6 @@ class Header(Matchable):
|
|
|
50
50
|
self.value = ExpressionUtility.asbool(ret)
|
|
51
51
|
else:
|
|
52
52
|
self.value = ret
|
|
53
|
-
# print(f"header.to_value: self.value: {self.value}<<<")
|
|
54
53
|
return self.value
|
|
55
54
|
|
|
56
55
|
def matches(self, *, skip=None) -> bool:
|
|
@@ -63,5 +62,4 @@ class Header(Matchable):
|
|
|
63
62
|
self.match = ExpressionUtility.asbool(v)
|
|
64
63
|
else:
|
|
65
64
|
self.match = not ExpressionUtility.is_none(v) # v is not None
|
|
66
|
-
# print(f"Header.matches: match? {self.match}")
|
|
67
65
|
return self.match
|
|
@@ -38,6 +38,7 @@ class Matchable(Qualified):
|
|
|
38
38
|
return name
|
|
39
39
|
|
|
40
40
|
def _noop_match(self) -> bool:
|
|
41
|
+
"""deprecated. use self.default_match()"""
|
|
41
42
|
return self.match if self.match is not None else True
|
|
42
43
|
|
|
43
44
|
def _noop_value(self) -> bool:
|
|
@@ -122,5 +123,14 @@ class Matchable(Qualified):
|
|
|
122
123
|
# with the current parse tree this shouldn't happen
|
|
123
124
|
return None
|
|
124
125
|
|
|
126
|
+
def _siblings(self) -> list:
|
|
127
|
+
if len(self.children) and hasattr(self.children[0], "op"):
|
|
128
|
+
return self.children[0].commas_to_list()
|
|
129
|
+
else:
|
|
130
|
+
self.matcher.csvpath.error(
|
|
131
|
+
"Cannot get siblings. children[0] is not an Equality"
|
|
132
|
+
)
|
|
133
|
+
return None
|
|
134
|
+
|
|
125
135
|
def default_match(self) -> bool:
|
|
126
136
|
return self.matcher._AND
|
|
@@ -259,15 +259,6 @@ class Qualified:
|
|
|
259
259
|
by adding self to the skip list."""
|
|
260
260
|
es = self.matcher.expressions # pylint: disable=E1101
|
|
261
261
|
for e in es:
|
|
262
|
-
#
|
|
263
|
-
# this fix for 1 test (test_function_last1) is blowing 11 other tests!
|
|
264
|
-
#
|
|
265
|
-
# me = ExpressionUtility.get_my_expression(self)
|
|
266
|
-
# print(f"my expression: me: {me}")
|
|
267
|
-
# if e[0] == me: # added experiment
|
|
268
|
-
# print(f"found my expression!")
|
|
269
|
-
# continue
|
|
270
|
-
# print(f"not my expression: {e[0]}")
|
|
271
262
|
m = e[1] is self.default_match() or e[0].matches(
|
|
272
263
|
skip=[self]
|
|
273
264
|
) # pylint: disable=E1101
|
|
@@ -75,9 +75,6 @@ class Reference(Matchable):
|
|
|
75
75
|
"""
|
|
76
76
|
# else:
|
|
77
77
|
self.match = self.value is not None
|
|
78
|
-
print(
|
|
79
|
-
f"\nReference.matches: self.match: {self.match}, self.value: {self.value}\n"
|
|
80
|
-
)
|
|
81
78
|
return self.match # pragma: no cover
|
|
82
79
|
|
|
83
80
|
def to_value(self, *, skip=None) -> Any:
|