protoerror 3.20.2__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.
- protoerror-3.20.2/PKG-INFO +21 -0
- protoerror-3.20.2/README +1 -0
- protoerror-3.20.2/protoerror/__init__.py +133 -0
- protoerror-3.20.2/protoerror/__patch__.py +8 -0
- protoerror-3.20.2/protoerror/checker.py +78 -0
- protoerror-3.20.2/protoerror/cli.py +88 -0
- protoerror-3.20.2/protoerror/config.py +78 -0
- protoerror-3.20.2/protoerror/control.py +330 -0
- protoerror-3.20.2/protoerror/finding.py +145 -0
- protoerror-3.20.2/protoerror/group.py +158 -0
- protoerror-3.20.2/protoerror/linter.py +428 -0
- protoerror-3.20.2/protoerror/merger.py +69 -0
- protoerror-3.20.2/protoerror/messages.py +95 -0
- protoerror-3.20.2/protoerror/paged.py +109 -0
- protoerror-3.20.2/protoerror/question.py +138 -0
- protoerror-3.20.2/protoerror/report.py +210 -0
- protoerror-3.20.2/protoerror/report_parser.py +58 -0
- protoerror-3.20.2/protoerror/simple.py +85 -0
- protoerror-3.20.2/protoerror/solution.py +300 -0
- protoerror-3.20.2/protoerror/utils.py +49 -0
- protoerror-3.20.2/protoerror.egg-info/PKG-INFO +21 -0
- protoerror-3.20.2/protoerror.egg-info/SOURCES.txt +39 -0
- protoerror-3.20.2/protoerror.egg-info/dependency_links.txt +1 -0
- protoerror-3.20.2/protoerror.egg-info/requires.txt +8 -0
- protoerror-3.20.2/protoerror.egg-info/top_level.txt +1 -0
- protoerror-3.20.2/pyproject.toml +66 -0
- protoerror-3.20.2/setup.cfg +4 -0
- protoerror-3.20.2/tests/test_checker.py +50 -0
- protoerror-3.20.2/tests/test_cli.py +23 -0
- protoerror-3.20.2/tests/test_config.py +27 -0
- protoerror-3.20.2/tests/test_control.py +69 -0
- protoerror-3.20.2/tests/test_finding.py +83 -0
- protoerror-3.20.2/tests/test_group.py +43 -0
- protoerror-3.20.2/tests/test_linter.py +151 -0
- protoerror-3.20.2/tests/test_messages.py +27 -0
- protoerror-3.20.2/tests/test_paged.py +31 -0
- protoerror-3.20.2/tests/test_question.py +43 -0
- protoerror-3.20.2/tests/test_report.py +50 -0
- protoerror-3.20.2/tests/test_report_parser.py +48 -0
- protoerror-3.20.2/tests/test_solution.py +48 -0
- protoerror-3.20.2/tests/test_template_replacement.py +32 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: protoerror
|
|
3
|
+
Version: 3.20.2
|
|
4
|
+
Author-email: Helmut Konrad Schewe <helmutus@outlook.com>
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/anaticulae/protoerro
|
|
7
|
+
Project-URL: Repository, https://github.com/anaticulae/protoerro
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
11
|
+
Requires-Python: >=3.12
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: utilo<3.0.0,>=2.107.4
|
|
14
|
+
Requires-Dist: iamraw<5.0.0,>=4.91.4
|
|
15
|
+
Requires-Dist: configos<2.0.0,>=1.0.4
|
|
16
|
+
Requires-Dist: Jinja2<4.0.0,>=3.1.6
|
|
17
|
+
Provides-Extra: dev
|
|
18
|
+
Requires-Dist: utilotest<2.0.0,>=1.0.2; extra == "dev"
|
|
19
|
+
Requires-Dist: utilosafe<2.0.0,>=1.0.0; extra == "dev"
|
|
20
|
+
|
|
21
|
+
# protoerror
|
protoerror-3.20.2/README
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# protoerror
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
#==============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
#------------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2019-2022 by Helmut Konrad Fahrendholz. All rights reserved.
|
|
5
|
+
# This file is property of Helmut Konrad Fahrendholz. Any unauthorized copy,
|
|
6
|
+
# use or distribution is an offensive act against international law and may
|
|
7
|
+
# be prosecuted under federal law. Its content is company confidential.
|
|
8
|
+
#==============================================================================
|
|
9
|
+
"""Protocol
|
|
10
|
+
========
|
|
11
|
+
|
|
12
|
+
The `protoerror` library supports logging errors and giving advices how
|
|
13
|
+
to solve this errors.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import os
|
|
17
|
+
|
|
18
|
+
import iamraw
|
|
19
|
+
|
|
20
|
+
import protoerror.__patch__
|
|
21
|
+
# checker
|
|
22
|
+
from protoerror.checker import Checker
|
|
23
|
+
from protoerror.checker import check_messages
|
|
24
|
+
# config
|
|
25
|
+
from protoerror.config import MessageStatus
|
|
26
|
+
from protoerror.config import load
|
|
27
|
+
from protoerror.config import save
|
|
28
|
+
# control
|
|
29
|
+
from protoerror.control import DOCINFO
|
|
30
|
+
from protoerror.control import bachelor
|
|
31
|
+
from protoerror.control import book
|
|
32
|
+
from protoerror.control import decorators
|
|
33
|
+
from protoerror.control import disable_perpage
|
|
34
|
+
from protoerror.control import diss
|
|
35
|
+
from protoerror.control import dissertation
|
|
36
|
+
from protoerror.control import enable_perpage
|
|
37
|
+
from protoerror.control import english
|
|
38
|
+
from protoerror.control import filter_checkers
|
|
39
|
+
from protoerror.control import german
|
|
40
|
+
from protoerror.control import homework
|
|
41
|
+
from protoerror.control import integrate_docinfo
|
|
42
|
+
from protoerror.control import is_disabled_perpage
|
|
43
|
+
from protoerror.control import master
|
|
44
|
+
from protoerror.control import nobachelor
|
|
45
|
+
from protoerror.control import nobook
|
|
46
|
+
from protoerror.control import nodiss
|
|
47
|
+
from protoerror.control import nohome
|
|
48
|
+
from protoerror.control import nolarge
|
|
49
|
+
from protoerror.control import nomaster
|
|
50
|
+
from protoerror.control import nomedium
|
|
51
|
+
from protoerror.control import nopaper
|
|
52
|
+
from protoerror.control import nosmall
|
|
53
|
+
from protoerror.control import parse_docinfo
|
|
54
|
+
from protoerror.control import section_only
|
|
55
|
+
from protoerror.control import section_skip
|
|
56
|
+
# finding
|
|
57
|
+
from protoerror.finding import finding_status
|
|
58
|
+
from protoerror.finding import finding_status_update
|
|
59
|
+
from protoerror.finding import findings_from_path
|
|
60
|
+
from protoerror.finding import hash_finding
|
|
61
|
+
from protoerror.finding import make_finding_number_unique
|
|
62
|
+
# group
|
|
63
|
+
from protoerror.group import byid
|
|
64
|
+
from protoerror.group import bypage
|
|
65
|
+
from protoerror.group import count_findings
|
|
66
|
+
from protoerror.group import filter_mark
|
|
67
|
+
from protoerror.group import flat
|
|
68
|
+
from protoerror.group import lines
|
|
69
|
+
from protoerror.group import ranged
|
|
70
|
+
from protoerror.group import select
|
|
71
|
+
from protoerror.group import select_findings
|
|
72
|
+
from protoerror.group import select_pages
|
|
73
|
+
from protoerror.group import sentences
|
|
74
|
+
from protoerror.group import words
|
|
75
|
+
# linter
|
|
76
|
+
from protoerror.linter import DEVELOPER_FILE
|
|
77
|
+
from protoerror.linter import USER_FILE
|
|
78
|
+
from protoerror.linter import DumpedLinterResult
|
|
79
|
+
from protoerror.linter import Linter
|
|
80
|
+
from protoerror.linter import dump_result
|
|
81
|
+
from protoerror.linter import from_file
|
|
82
|
+
from protoerror.linter import from_module
|
|
83
|
+
from protoerror.linter import from_modules
|
|
84
|
+
from protoerror.linter import from_solution
|
|
85
|
+
from protoerror.linter import write_result
|
|
86
|
+
# merge
|
|
87
|
+
from protoerror.merger import merge_findings
|
|
88
|
+
# messages
|
|
89
|
+
from protoerror.messages import TYPE_DEFAULT
|
|
90
|
+
# paged
|
|
91
|
+
from protoerror.paged import load_grouped
|
|
92
|
+
from protoerror.paged import write_grouped
|
|
93
|
+
# question
|
|
94
|
+
from protoerror.question import Answer
|
|
95
|
+
from protoerror.question import Question
|
|
96
|
+
from protoerror.question import Questions
|
|
97
|
+
from protoerror.question import answer_questions
|
|
98
|
+
from protoerror.question import documore
|
|
99
|
+
from protoerror.question import pagemore
|
|
100
|
+
from protoerror.question import parse_questions
|
|
101
|
+
# report
|
|
102
|
+
from protoerror.report import integrate
|
|
103
|
+
# report parser
|
|
104
|
+
from protoerror.report_parser import Feature
|
|
105
|
+
from protoerror.report_parser import Report
|
|
106
|
+
from protoerror.report_parser import Reports
|
|
107
|
+
from protoerror.report_parser import Step
|
|
108
|
+
from protoerror.report_parser import Steps
|
|
109
|
+
from protoerror.report_parser import parses
|
|
110
|
+
# run
|
|
111
|
+
from protoerror.simple import ResultDefault
|
|
112
|
+
from protoerror.simple import ResultType
|
|
113
|
+
from protoerror.simple import run
|
|
114
|
+
# solution
|
|
115
|
+
from protoerror.solution import Solver
|
|
116
|
+
from protoerror.solution import Validators
|
|
117
|
+
from protoerror.solution import confidence
|
|
118
|
+
from protoerror.solution import parse_checkers
|
|
119
|
+
from protoerror.solution import parse_msgid
|
|
120
|
+
from protoerror.solution import parse_solutions
|
|
121
|
+
# utils
|
|
122
|
+
from protoerror.utils import RESULT_EMPTY
|
|
123
|
+
from protoerror.utils import driver
|
|
124
|
+
from protoerror.utils import skip_method
|
|
125
|
+
|
|
126
|
+
__version__ = '3.20.1'
|
|
127
|
+
|
|
128
|
+
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
|
129
|
+
|
|
130
|
+
OVERVIEW = iamraw.Location.from_page(-1)
|
|
131
|
+
|
|
132
|
+
skip_check = skip_method
|
|
133
|
+
skip = skip_method
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2020-2022 by Helmut Konrad Fahrendholz. All rights reserved.
|
|
5
|
+
# This file is property of Helmut Konrad Fahrendholz. Any unauthorized copy,
|
|
6
|
+
# use or distribution is an offensive act against international law and may
|
|
7
|
+
# be prosecuted under federal law. Its content is company confidential.
|
|
8
|
+
# =============================================================================
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2019-2022 by Helmut Konrad Fahrendholz. All rights reserved.
|
|
5
|
+
# This file is property of Helmut Konrad Fahrendholz. Any unauthorized copy,
|
|
6
|
+
# use or distribution is an offensive act against international law and may
|
|
7
|
+
# be prosecuted under federal law. Its content is company confidential.
|
|
8
|
+
# =============================================================================
|
|
9
|
+
"""Checker
|
|
10
|
+
=======
|
|
11
|
+
|
|
12
|
+
How does the Checker work
|
|
13
|
+
-------------------------
|
|
14
|
+
|
|
15
|
+
Extracted data of different sources -> Checker[Judegement] -> Problem
|
|
16
|
+
with possible solution
|
|
17
|
+
|
|
18
|
+
Base id of standard checkers (used in msg and report ids):
|
|
19
|
+
01: base
|
|
20
|
+
02: classes
|
|
21
|
+
03: format
|
|
22
|
+
04: import
|
|
23
|
+
05: misc
|
|
24
|
+
06: variables
|
|
25
|
+
07: exceptions
|
|
26
|
+
08: similar
|
|
27
|
+
09: design_analysis
|
|
28
|
+
10: newstyle
|
|
29
|
+
11: typecheck
|
|
30
|
+
12: logging
|
|
31
|
+
13: string_format
|
|
32
|
+
14: string_constant
|
|
33
|
+
15: stdlib
|
|
34
|
+
16: python3
|
|
35
|
+
17: refactoring
|
|
36
|
+
18-50: not yet used: reserved for future internal checkers.
|
|
37
|
+
51-99: perhaps used: reserved for external checkers
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
import collections.abc
|
|
41
|
+
|
|
42
|
+
import iamraw
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class Checker:
|
|
46
|
+
|
|
47
|
+
def __init__(self, linter):
|
|
48
|
+
self.linter = linter
|
|
49
|
+
|
|
50
|
+
def problems(self) -> list[str]:
|
|
51
|
+
"""Return list of implemented problems"""
|
|
52
|
+
|
|
53
|
+
def add_finding(
|
|
54
|
+
self,
|
|
55
|
+
location: iamraw.Location = None,
|
|
56
|
+
msgid: str = None,
|
|
57
|
+
confidence: float = None,
|
|
58
|
+
):
|
|
59
|
+
self.linter.add_finding(location, msgid, confidence)
|
|
60
|
+
|
|
61
|
+
def open(self):
|
|
62
|
+
pass
|
|
63
|
+
|
|
64
|
+
def judge(self, *args) -> iamraw.Findings:
|
|
65
|
+
pass
|
|
66
|
+
|
|
67
|
+
def close(self):
|
|
68
|
+
pass
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def check_messages(*messages: str) -> collections.abc.Callable:
|
|
72
|
+
"""decorator to store messages that are handled by a checker method"""
|
|
73
|
+
|
|
74
|
+
def store_messages(func):
|
|
75
|
+
func.checks_msgs = messages
|
|
76
|
+
return func
|
|
77
|
+
|
|
78
|
+
return store_messages
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2021-2022 by Helmut Konrad Fahrendholz. All rights reserved.
|
|
5
|
+
# This file is property of Helmut Konrad Fahrendholz. Any unauthorized copy,
|
|
6
|
+
# use or distribution is an offensive act against international law and may
|
|
7
|
+
# be prosecuted under federal law. Its content is company confidential.
|
|
8
|
+
# =============================================================================
|
|
9
|
+
|
|
10
|
+
import os
|
|
11
|
+
import sys
|
|
12
|
+
|
|
13
|
+
import serializeraw
|
|
14
|
+
import utilo
|
|
15
|
+
|
|
16
|
+
import protoerror
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@utilo.saveme
|
|
20
|
+
def main():
|
|
21
|
+
inpath, outpath, pages, action = evaluate()
|
|
22
|
+
for path in inpath:
|
|
23
|
+
if not utilo.exists(path):
|
|
24
|
+
utilo.error(f'input does not exists: {path}')
|
|
25
|
+
return utilo.FAILURE
|
|
26
|
+
if not utilo.exists(outpath):
|
|
27
|
+
utilo.error(f'output does not exists: {outpath}')
|
|
28
|
+
return utilo.FAILURE
|
|
29
|
+
if action == 'optimize':
|
|
30
|
+
optimize(srcs=inpath, dest=outpath, pages=pages)
|
|
31
|
+
return utilo.SUCCESS
|
|
32
|
+
return utilo.INVALID_COMMAND
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def optimize(srcs: str, dest: str, pages: tuple = None, msgid: set = None):
|
|
36
|
+
findings = []
|
|
37
|
+
for src in srcs:
|
|
38
|
+
utilo.log(f'load findings from: {src}', preserve_newlines=False)
|
|
39
|
+
findings = serializeraw.findings_from_path(
|
|
40
|
+
path=srcs,
|
|
41
|
+
msgid=msgid,
|
|
42
|
+
pages=pages,
|
|
43
|
+
)
|
|
44
|
+
findings = utilo.flatten_content(findings)
|
|
45
|
+
dest = os.path.join(dest, '__optimized__')
|
|
46
|
+
os.makedirs(dest, exist_ok=True)
|
|
47
|
+
utilo.log(
|
|
48
|
+
f'write optimized findings to: {dest}',
|
|
49
|
+
preserve_newlines=False,
|
|
50
|
+
)
|
|
51
|
+
serializeraw.write_grouped(findings, dest=dest)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def evaluate() -> tuple:
|
|
55
|
+
parser = utilo.cli.create_parser(
|
|
56
|
+
todo=[
|
|
57
|
+
utilo.cli.Flag(
|
|
58
|
+
longcut='optimize',
|
|
59
|
+
message='read findings and write to page dependent structure',
|
|
60
|
+
),
|
|
61
|
+
],
|
|
62
|
+
config=utilo.ParserConfiguration(
|
|
63
|
+
inputparameter=True,
|
|
64
|
+
outputparameter=True,
|
|
65
|
+
multiprocessed=False,
|
|
66
|
+
pages=True,
|
|
67
|
+
prefix=False,
|
|
68
|
+
verboseflag=True,
|
|
69
|
+
waitingflag=False,
|
|
70
|
+
cacheflag=False,
|
|
71
|
+
),
|
|
72
|
+
version=protoerror.__version__,
|
|
73
|
+
prog='findings',
|
|
74
|
+
)
|
|
75
|
+
args = utilo.parse(parser)
|
|
76
|
+
action = ''
|
|
77
|
+
if args['optimize']:
|
|
78
|
+
action = 'optimize'
|
|
79
|
+
if not action:
|
|
80
|
+
utilo.error('nothing todo')
|
|
81
|
+
sys.exit(utilo.INVALID_COMMAND)
|
|
82
|
+
choice = (
|
|
83
|
+
args['input'],
|
|
84
|
+
args['output'],
|
|
85
|
+
utilo.parse_pages(','.join(args['pages'])), # DIRTY
|
|
86
|
+
action,
|
|
87
|
+
)
|
|
88
|
+
return choice
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2019-2022 by Helmut Konrad Fahrendholz. All rights reserved.
|
|
5
|
+
# This file is property of Helmut Konrad Fahrendholz. Any unauthorized copy,
|
|
6
|
+
# use or distribution is an offensive act against international law and may
|
|
7
|
+
# be prosecuted under federal law. Its content is company confidential.
|
|
8
|
+
# =============================================================================
|
|
9
|
+
"""Configuration
|
|
10
|
+
=============
|
|
11
|
+
|
|
12
|
+
.. code-block:: none
|
|
13
|
+
|
|
14
|
+
message:
|
|
15
|
+
id: str
|
|
16
|
+
active : bool
|
|
17
|
+
min_confidence: float
|
|
18
|
+
|
|
19
|
+
example:
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
import dataclasses
|
|
25
|
+
|
|
26
|
+
import utilo
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@dataclasses.dataclass # pylint:disable=R0903
|
|
30
|
+
class MessageStatus:
|
|
31
|
+
"""Configurate how and if the user see the message or it will
|
|
32
|
+
support the development only.
|
|
33
|
+
|
|
34
|
+
Example:
|
|
35
|
+
MessageStatus('F0000', True, 1.0)
|
|
36
|
+
|
|
37
|
+
The example above describe the pdf-read-error-message which is
|
|
38
|
+
raised if there is a problem with reading the document.
|
|
39
|
+
"""
|
|
40
|
+
msgid: str
|
|
41
|
+
# The MessageStatus is active, so it will be provided to the user if
|
|
42
|
+
# it occurs
|
|
43
|
+
active: bool = False
|
|
44
|
+
# The `confidence` of 1.0 means that the message always is displayed
|
|
45
|
+
# if it occurs.
|
|
46
|
+
confidence: float = 1.0
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
MessageStatusList = list[MessageStatus]
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def load(path: str) -> MessageStatusList:
|
|
53
|
+
loaded = utilo.yaml_load(path)
|
|
54
|
+
result = []
|
|
55
|
+
for item in loaded:
|
|
56
|
+
msgid = item.get('msgid')
|
|
57
|
+
active = item.get('active', False)
|
|
58
|
+
confidence = item.get('confidence', 0.0)
|
|
59
|
+
result.append(
|
|
60
|
+
MessageStatus(
|
|
61
|
+
msgid=msgid,
|
|
62
|
+
active=active,
|
|
63
|
+
confidence=confidence,
|
|
64
|
+
))
|
|
65
|
+
return result
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def save(messages: MessageStatusList, path: str):
|
|
69
|
+
result = []
|
|
70
|
+
for item in messages:
|
|
71
|
+
raw = {'msgid': item.msgid}
|
|
72
|
+
if item.active:
|
|
73
|
+
raw['active'] = True
|
|
74
|
+
if item.confidence:
|
|
75
|
+
raw['confidence'] = item.confidence
|
|
76
|
+
result.append(raw)
|
|
77
|
+
dumped = utilo.yaml_dump(result)
|
|
78
|
+
utilo.file_create(path, dumped)
|