DataComparerLibrary 0.853__tar.gz → 0.855__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.
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/PKG-INFO +1 -1
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/pyproject.toml +1 -1
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary/datacomparer.py +2 -0
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary/datetimehandler.py +15 -17
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary/field.py +31 -30
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary.egg-info/PKG-INFO +1 -1
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/LICENSE.txt +0 -0
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/README.rst +0 -0
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/setup.cfg +0 -0
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary/__init__.py +0 -0
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary/datasorter.py +0 -0
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary/delimitertranslator.py +0 -0
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary/fileconverter.py +0 -0
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary/matchstatus.py +0 -0
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary/report.py +0 -0
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary/row.py +0 -0
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary/tools.py +0 -0
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary/twodarray.py +0 -0
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary.egg-info/SOURCES.txt +0 -0
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary.egg-info/dependency_links.txt +0 -0
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary.egg-info/requires.txt +0 -0
- {datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: DataComparerLibrary
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.855
|
|
4
4
|
Summary: For comparing csv-files, 2d-array with a csv-file or 2d-arrays. For comparing text-files, text variable with a text-file or text variables. Including a sorting module.
|
|
5
5
|
Author-email: René Philip Zuijderduijn <datacomparerlibrary@outlook.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
|
|
|
6
6
|
[project]
|
|
7
7
|
name = "DataComparerLibrary"
|
|
8
8
|
description = "For comparing csv-files, 2d-array with a csv-file or 2d-arrays. For comparing text-files, text variable with a text-file or text variables. Including a sorting module."
|
|
9
|
-
version = "0.
|
|
9
|
+
version = "0.855"
|
|
10
10
|
dependencies = ["python-dateutil"]
|
|
11
11
|
authors = [{ name = "René Philip Zuijderduijn", email = "datacomparerlibrary@outlook.com" }]
|
|
12
12
|
readme = "README.rst"
|
{datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary/datacomparer.py
RENAMED
|
@@ -87,6 +87,8 @@ class DataComparer:
|
|
|
87
87
|
|
|
88
88
|
@staticmethod
|
|
89
89
|
def compare_data(actual_data, expected_data, template_literals_dict=None):
|
|
90
|
+
if template_literals_dict is not None and not isinstance(template_literals_dict, dict):
|
|
91
|
+
raise Exception(f"The argument passed to parameter 'template_literals_dict' is not a dictionary. Value is: '{template_literals_dict}'.")
|
|
90
92
|
actual_data = DataComparer.__make_data_2d_compliant(actual_data)
|
|
91
93
|
expected_data = DataComparer.__make_data_2d_compliant(expected_data)
|
|
92
94
|
#
|
{datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary/datetimehandler.py
RENAMED
|
@@ -9,15 +9,15 @@ class DatetimeHandler:
|
|
|
9
9
|
position_open_brace_today_text = expected_data_field_including_date_template.find("{NOW()")
|
|
10
10
|
position_close_brace_today_text = expected_data_field_including_date_template.find("}", position_open_brace_today_text)
|
|
11
11
|
#
|
|
12
|
+
if position_open_brace_today_text == -1:
|
|
13
|
+
raise Exception("Open brace '{NOW()' not found.")
|
|
14
|
+
#
|
|
12
15
|
if position_close_brace_today_text == -1:
|
|
13
|
-
|
|
14
|
-
# Close brace of TODAY has been found.
|
|
16
|
+
raise Exception("Close brace '}' not found.")
|
|
15
17
|
#
|
|
16
18
|
expected_datetime_template_string = expected_data_field_including_date_template[position_open_brace_today_text:position_close_brace_today_text + 1]
|
|
17
19
|
expected_datetime_string = DatetimeHandler.__convert_datetime_template_to_datetime(self, expected_datetime_template_string)
|
|
18
20
|
#
|
|
19
|
-
if expected_datetime_string == -1:
|
|
20
|
-
return -1
|
|
21
21
|
# Datetime_template_string has been converted to datetime.
|
|
22
22
|
#
|
|
23
23
|
# Replace expected_datetime_template_string by expected_datetime_string in expected_data_field_including_template.
|
|
@@ -48,18 +48,16 @@ class DatetimeHandler:
|
|
|
48
48
|
# Adjust date time based on current date time.
|
|
49
49
|
relative_datetime_template_string = template_datetime_string_splitted[0].replace('{NOW()', '')
|
|
50
50
|
relative_datetime = DatetimeHandler.__convert_relative_datetime_template_to_relative_datetime(self, relative_datetime_template_string[1:len(relative_datetime_template_string)])
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
case _:
|
|
60
|
-
return -1
|
|
51
|
+
#
|
|
52
|
+
match relative_datetime_template_string[0]:
|
|
53
|
+
case "+":
|
|
54
|
+
expected_datetime = datetime.datetime.now() + relative_datetime
|
|
55
|
+
case "-":
|
|
56
|
+
expected_datetime = datetime.datetime.now() - relative_datetime
|
|
57
|
+
case _:
|
|
58
|
+
raise Exception("'+' or '-' sign not found in '{NOW() relative datetime template string'.")
|
|
61
59
|
case _:
|
|
62
|
-
|
|
60
|
+
raise Exception("Datetime template format in {NOW() datetime string is incorrect. Split sign ':' to separate expectation and format has been found more than once.")
|
|
63
61
|
#
|
|
64
62
|
year = expected_datetime.strftime("%Y")
|
|
65
63
|
year_2_digits = expected_datetime.strftime("%y")
|
|
@@ -80,7 +78,7 @@ class DatetimeHandler:
|
|
|
80
78
|
period = regex.match(relative_datetime_str)
|
|
81
79
|
|
|
82
80
|
if not period:
|
|
83
|
-
|
|
81
|
+
raise Exception("Relative datetime template format in '{NOW() datetime template string' " + relative_datetime_str + " is incorrect.")
|
|
84
82
|
|
|
85
83
|
period = period.groupdict()
|
|
86
84
|
kwargs = {}
|
|
@@ -97,4 +95,4 @@ class DatetimeHandler:
|
|
|
97
95
|
if kwargs:
|
|
98
96
|
return dateutil.relativedelta.relativedelta(**kwargs)
|
|
99
97
|
else:
|
|
100
|
-
|
|
98
|
+
raise Exception("Relative datetime template format in '{NOW() datetime template string' " + relative_datetime_str + " is incorrect.")
|
|
@@ -49,9 +49,12 @@ class Field:
|
|
|
49
49
|
|
|
50
50
|
@staticmethod
|
|
51
51
|
def __replace_template_literals_dict(data, template_literals_dict):
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
try:
|
|
53
|
+
if template_literals_dict:
|
|
54
|
+
for i in range(0, len(template_literals_dict)):
|
|
55
|
+
data = data.replace(list(template_literals_dict.keys())[i], str(list(template_literals_dict.values())[i]))
|
|
56
|
+
except Exception as exception_message:
|
|
57
|
+
raise Exception(f"Error during replacing literals. The argument passed to parameter 'template_literals_dict': {template_literals_dict}. Error message: {exception_message}.")
|
|
55
58
|
return data
|
|
56
59
|
|
|
57
60
|
|
|
@@ -115,21 +118,16 @@ class Field:
|
|
|
115
118
|
skip_exception_rule_used = False
|
|
116
119
|
|
|
117
120
|
if "{SKIP}" in other_field_data_including_templates.upper() or "{DATETIME_FORMAT():YYYYMMDDHHMMSSFF6}" in other_field_data_including_templates.upper():
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
expected_data_with_wildcard = compiled2.sub("*", compiled.sub("*", other_field_data_including_templates))
|
|
129
|
-
#
|
|
130
|
-
if fnmatch.fnmatch(self.field_data, expected_data_with_wildcard):
|
|
131
|
-
skip_exception_rule_used = True
|
|
132
|
-
# continue
|
|
121
|
+
# Part(s) of the actual data field will be skipped for verification.
|
|
122
|
+
# Replace {SKIP}, ignoring cases, by wildcard *.
|
|
123
|
+
# compiled = re.compile(re.escape("{SKIP}"), re.IGNORECASE)
|
|
124
|
+
# expected_data_with_wildcard = compiled.sub("*", other_field_data_including_templates)
|
|
125
|
+
compiled = re.compile(re.escape("{SKIP}"), re.IGNORECASE)
|
|
126
|
+
compiled2 = re.compile(re.escape("{DATETIME_FORMAT():YYYYMMDDHHMMSSFF6}"), re.IGNORECASE)
|
|
127
|
+
expected_data_with_wildcard = compiled2.sub("*", compiled.sub("*", other_field_data_including_templates))
|
|
128
|
+
#
|
|
129
|
+
if fnmatch.fnmatch(self.field_data, expected_data_with_wildcard):
|
|
130
|
+
skip_exception_rule_used = True
|
|
133
131
|
#
|
|
134
132
|
if expected_data_with_wildcard == None:
|
|
135
133
|
# Wildcards not used.
|
|
@@ -142,20 +140,23 @@ class Field:
|
|
|
142
140
|
if all([x not in other_field_data_including_templates.upper() for x in matches]):
|
|
143
141
|
equal = False
|
|
144
142
|
Report.show_differences_comparation_result(self.row_nr, self.column_nr, self.field_data, other_field_data_including_templates, "NOW() has been found in expected data field, but format is incorrect.")
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
expected_data = DatetimeHandler.replace_date_template_in_expected_data(self, expected_data_including_date_template)
|
|
143
|
+
Report.show_differences_comparation_result(self.row_nr, self.column_nr, self.field_data, other_field_data_including_templates, "Colon character ':', sign '+' or '-'' is missing behind NOW().")
|
|
144
|
+
return False
|
|
148
145
|
#
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
else:
|
|
146
|
+
try:
|
|
147
|
+
expected_data = DatetimeHandler.replace_date_template_in_expected_data(self, expected_data_including_date_template)
|
|
148
|
+
#
|
|
153
149
|
if not fnmatch.fnmatch(self.field_data, expected_data):
|
|
154
150
|
# No match despite using of wildcard(s).
|
|
155
151
|
equal = False
|
|
156
152
|
Report.show_differences_comparation_result(self.row_nr, self.column_nr, self.field_data, other_field_data_including_templates, "Date template format displayed. See also next message line.")
|
|
157
153
|
Report.show_differences_comparation_result(self.row_nr, self.column_nr, self.field_data, expected_data, "There is a difference between actual and expected data.")
|
|
158
|
-
|
|
154
|
+
#
|
|
155
|
+
except Exception as exception_message:
|
|
156
|
+
equal = False
|
|
157
|
+
Report.show_differences_comparation_result(self.row_nr, self.column_nr, self.field_data, other_field_data_including_templates, "NOW() has been found in expected data field, but format is incorrect.")
|
|
158
|
+
Report.show_differences_comparation_result(self.row_nr, self.column_nr, self.field_data, other_field_data_including_templates, exception_message)
|
|
159
|
+
|
|
159
160
|
#
|
|
160
161
|
elif "{NOT(" in other_field_data_including_templates.upper():
|
|
161
162
|
try:
|
|
@@ -165,11 +166,11 @@ class Field:
|
|
|
165
166
|
# Unwanted match.
|
|
166
167
|
equal = False
|
|
167
168
|
Report.show_differences_comparation_result(self.row_nr, self.column_nr, self.field_data, other_field_data_including_templates, "NOT() template format displayed. See also next message line.")
|
|
168
|
-
Report.show_differences_comparation_result(self.row_nr, self.column_nr, self.field_data, unwanted_expected_data, "Actual and expected data are equal. However actual data should NOT be equal to the expected data!!!")
|
|
169
|
+
Report.show_differences_comparation_result(self.row_nr, self.column_nr, self.field_data, "<> "+ str(unwanted_expected_data), "Actual and expected data are equal. However actual data should NOT be equal to the expected data!!!")
|
|
169
170
|
except Exception as exception_message:
|
|
170
|
-
# print(f"An exception occurred: {exception_message}")
|
|
171
171
|
equal = False
|
|
172
172
|
Report.show_differences_comparation_result(self.row_nr, self.column_nr, self.field_data, other_field_data_including_templates, "NOT() has been found in expected data field, but format is incorrect.")
|
|
173
|
+
Report.show_differences_comparation_result(self.row_nr, self.column_nr, self.field_data, other_field_data_including_templates, exception_message)
|
|
173
174
|
#
|
|
174
175
|
else:
|
|
175
176
|
if not skip_exception_rule_used:
|
|
@@ -187,11 +188,11 @@ class Field:
|
|
|
187
188
|
#
|
|
188
189
|
if position_open_brace == -1:
|
|
189
190
|
#print("position_open_brace:", position_open_brace)
|
|
190
|
-
raise Exception()
|
|
191
|
+
raise Exception("Open brace '{NOT(' not found.")
|
|
191
192
|
#
|
|
192
193
|
if position_close_brace == -1:
|
|
193
194
|
#print("position_close_brace:", position_close_brace)
|
|
194
|
-
raise Exception()
|
|
195
|
+
raise Exception("Close brace '}' not found.")
|
|
195
196
|
#
|
|
196
197
|
unwanted_expected_data = expected_data_field_including_date_template[position_open_brace+5:position_close_brace]
|
|
197
198
|
#
|
{datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: DataComparerLibrary
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.855
|
|
4
4
|
Summary: For comparing csv-files, 2d-array with a csv-file or 2d-arrays. For comparing text-files, text variable with a text-file or text variables. Including a sorting module.
|
|
5
5
|
Author-email: René Philip Zuijderduijn <datacomparerlibrary@outlook.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary/datasorter.py
RENAMED
|
File without changes
|
|
File without changes
|
{datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary/fileconverter.py
RENAMED
|
File without changes
|
{datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary/matchstatus.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary/twodarray.py
RENAMED
|
File without changes
|
{datacomparerlibrary-0.853 → datacomparerlibrary-0.855}/src/DataComparerLibrary.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|