DataComparerLibrary 0.838__tar.gz → 0.840__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.
Files changed (18) hide show
  1. {DataComparerLibrary-0.838 → datacomparerlibrary-0.840}/PKG-INFO +68 -2
  2. {DataComparerLibrary-0.838 → datacomparerlibrary-0.840}/README.rst +67 -1
  3. {DataComparerLibrary-0.838 → datacomparerlibrary-0.840}/src/DataComparerLibrary/datacomparer.py +19 -11
  4. {DataComparerLibrary-0.838 → datacomparerlibrary-0.840}/src/DataComparerLibrary/fileconverter.py +2 -2
  5. datacomparerlibrary-0.840/src/DataComparerLibrary/tools.py +7 -0
  6. {DataComparerLibrary-0.838 → datacomparerlibrary-0.840}/src/DataComparerLibrary/version.py +1 -1
  7. {DataComparerLibrary-0.838 → datacomparerlibrary-0.840}/src/DataComparerLibrary.egg-info/PKG-INFO +68 -2
  8. {DataComparerLibrary-0.838 → datacomparerlibrary-0.840}/src/DataComparerLibrary.egg-info/SOURCES.txt +1 -0
  9. {DataComparerLibrary-0.838 → datacomparerlibrary-0.840}/LICENSE.txt +0 -0
  10. {DataComparerLibrary-0.838 → datacomparerlibrary-0.840}/pyproject.toml +0 -0
  11. {DataComparerLibrary-0.838 → datacomparerlibrary-0.840}/setup.cfg +0 -0
  12. {DataComparerLibrary-0.838 → datacomparerlibrary-0.840}/setup.py +0 -0
  13. {DataComparerLibrary-0.838 → datacomparerlibrary-0.840}/src/DataComparerLibrary/__init__.py +0 -0
  14. {DataComparerLibrary-0.838 → datacomparerlibrary-0.840}/src/DataComparerLibrary/datasorter.py +0 -0
  15. {DataComparerLibrary-0.838 → datacomparerlibrary-0.840}/src/DataComparerLibrary/delimitertranslator.py +0 -0
  16. {DataComparerLibrary-0.838 → datacomparerlibrary-0.840}/src/DataComparerLibrary.egg-info/dependency_links.txt +0 -0
  17. {DataComparerLibrary-0.838 → datacomparerlibrary-0.840}/src/DataComparerLibrary.egg-info/top_level.txt +0 -0
  18. {DataComparerLibrary-0.838 → datacomparerlibrary-0.840}/test/test1.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: DataComparerLibrary
3
- Version: 0.838
3
+ Version: 0.840
4
4
  Summary: For comparing csv-files or 2d-array with csv-file.
5
5
  Home-page:
6
6
  Author: René Philip Zuijderduijn
@@ -60,7 +60,7 @@ Introduction
60
60
  The DataComparerLibrary can be used for:
61
61
  - comparing csv-files or text-files
62
62
  - comparing a 2d-matrix with a csv-file or text-file
63
- - comparing a csv_file or text-file with a 2d-matrix
63
+ - comparing a csv-file or text-file with a 2d-matrix
64
64
  - comparing 2d-matrices
65
65
 
66
66
  | In case a difference between actual and expected data is found an exception wil be given. In Robot Framework
@@ -186,6 +186,72 @@ Based on current datetime = 2023-09-06 19:04:00 (example):
186
186
 
187
187
 
188
188
 
189
+ DataSorter
190
+ ==========
191
+
192
+ Introduction
193
+ ------------
194
+ The DataSorter can be used for sorting records in a csv file or text file.
195
+
196
+
197
+ Default sorting
198
+ ---------------
199
+ The default sorting is alphabetically based in ascending order on column 0 on all records.
200
+
201
+
202
+ Special sorting
203
+ ---------------
204
+
205
+ | With the DataSorter it is possible to tune the sorting of records.
206
+ |
207
+ | number_of_header_lines:
208
+ | Optional argument "number_of_header_lines" can be used to set the number of header records. These records will be excluded from sorting.
209
+ In case this optional argument is not present the default value is set to 0.
210
+ |
211
+ | number_of_trailer_lines:
212
+ | Optional argument "number_of_trailer_lines" can be used to set the number of trailer records. These records will be excluded from sorting.
213
+ In case this optional argument is not present the default value is set to 0.
214
+ |
215
+ | sort_on_columns_list:
216
+ | Optional argument "sort_on_columns_list" can be used to specify one or more columns on which should be sorted and in which order of columns.
217
+ Sorting of a column can be done in an alphabetic or numeric way.
218
+ |
219
+ | delimiter:
220
+ | Optional argument "delimiter" can be used to set the delimiter.
221
+ Default delimiter is "," in case of an input file. You can use the option "delimiter" to set another delimiter
222
+ like ";" or "\t" for tab. It is also possible to use a multi-character delimiter like "@#@".
223
+
224
+
225
+ Examples of using the DataComparerLibrary keywords for sorting data in Robot Framework
226
+ ----------------------------------------------------------------------------------------
227
+
228
+ Below there are some examples how to call the keywords of the DataComparerLibrary in Robot Framework::
229
+
230
+
231
+ *** Settings ***
232
+ Library DataComparerLibrary
233
+
234
+ *** Test Cases ***
235
+ Testcase_DataSorter
236
+ Examples
237
+
238
+ *** Keywords ***
239
+ Examples
240
+ # sorting examples
241
+ #
242
+ # Sorting alphabetic on column 0, 5 and 4
243
+ ${sorting_column_0_5_4} = create list 0 5 4
244
+ # Sorting alphabetic on column 4 and 1 and numeric on colum 3
245
+ ${sorting_column_4_3i_1} = create list 4 ${3} 1
246
+
247
+
248
+ Run Keyword And Continue On Failure DataComparerLibrary.Sort Csv Files C:\\Users\\unsorted.csv C:\\Users\\sorted.csv
249
+ DataComparerLibrary.Sort Csv Files C:\\Users\\unsorted.csv C:\\Users\\sorted.csv number_of_header_lines=5 sort_on_columns_list=${sorting_column_0_5_4} number_of_trailer_lines=5 delimiter=;
250
+ DataComparerLibrary.Sort Csv Files C:\\Users\\unsorted.csv C:\\Users\\sorted.csv number_of_header_lines=4 sort_on_columns_list=${sorting_column_4_3i_1} delimiter=@#@
251
+ DataComparerLibrary.Sort Csv Files C:\\Users\\unsorted.csv C:\\Users\\sorted.csv number_of_trailer_lines=2 delimiter=\t
252
+ DataComparerLibrary.Sort Csv Files C:\\Users\\unsorted.csv C:\\Users\\sorted.csv
253
+
254
+
189
255
  FileConverter
190
256
  =============
191
257
 
@@ -40,7 +40,7 @@ Introduction
40
40
  The DataComparerLibrary can be used for:
41
41
  - comparing csv-files or text-files
42
42
  - comparing a 2d-matrix with a csv-file or text-file
43
- - comparing a csv_file or text-file with a 2d-matrix
43
+ - comparing a csv-file or text-file with a 2d-matrix
44
44
  - comparing 2d-matrices
45
45
 
46
46
  | In case a difference between actual and expected data is found an exception wil be given. In Robot Framework
@@ -166,6 +166,72 @@ Based on current datetime = 2023-09-06 19:04:00 (example):
166
166
 
167
167
 
168
168
 
169
+ DataSorter
170
+ ==========
171
+
172
+ Introduction
173
+ ------------
174
+ The DataSorter can be used for sorting records in a csv file or text file.
175
+
176
+
177
+ Default sorting
178
+ ---------------
179
+ The default sorting is alphabetically based in ascending order on column 0 on all records.
180
+
181
+
182
+ Special sorting
183
+ ---------------
184
+
185
+ | With the DataSorter it is possible to tune the sorting of records.
186
+ |
187
+ | number_of_header_lines:
188
+ | Optional argument "number_of_header_lines" can be used to set the number of header records. These records will be excluded from sorting.
189
+ In case this optional argument is not present the default value is set to 0.
190
+ |
191
+ | number_of_trailer_lines:
192
+ | Optional argument "number_of_trailer_lines" can be used to set the number of trailer records. These records will be excluded from sorting.
193
+ In case this optional argument is not present the default value is set to 0.
194
+ |
195
+ | sort_on_columns_list:
196
+ | Optional argument "sort_on_columns_list" can be used to specify one or more columns on which should be sorted and in which order of columns.
197
+ Sorting of a column can be done in an alphabetic or numeric way.
198
+ |
199
+ | delimiter:
200
+ | Optional argument "delimiter" can be used to set the delimiter.
201
+ Default delimiter is "," in case of an input file. You can use the option "delimiter" to set another delimiter
202
+ like ";" or "\t" for tab. It is also possible to use a multi-character delimiter like "@#@".
203
+
204
+
205
+ Examples of using the DataComparerLibrary keywords for sorting data in Robot Framework
206
+ ----------------------------------------------------------------------------------------
207
+
208
+ Below there are some examples how to call the keywords of the DataComparerLibrary in Robot Framework::
209
+
210
+
211
+ *** Settings ***
212
+ Library DataComparerLibrary
213
+
214
+ *** Test Cases ***
215
+ Testcase_DataSorter
216
+ Examples
217
+
218
+ *** Keywords ***
219
+ Examples
220
+ # sorting examples
221
+ #
222
+ # Sorting alphabetic on column 0, 5 and 4
223
+ ${sorting_column_0_5_4} = create list 0 5 4
224
+ # Sorting alphabetic on column 4 and 1 and numeric on colum 3
225
+ ${sorting_column_4_3i_1} = create list 4 ${3} 1
226
+
227
+
228
+ Run Keyword And Continue On Failure DataComparerLibrary.Sort Csv Files C:\\Users\\unsorted.csv C:\\Users\\sorted.csv
229
+ DataComparerLibrary.Sort Csv Files C:\\Users\\unsorted.csv C:\\Users\\sorted.csv number_of_header_lines=5 sort_on_columns_list=${sorting_column_0_5_4} number_of_trailer_lines=5 delimiter=;
230
+ DataComparerLibrary.Sort Csv Files C:\\Users\\unsorted.csv C:\\Users\\sorted.csv number_of_header_lines=4 sort_on_columns_list=${sorting_column_4_3i_1} delimiter=@#@
231
+ DataComparerLibrary.Sort Csv Files C:\\Users\\unsorted.csv C:\\Users\\sorted.csv number_of_trailer_lines=2 delimiter=\t
232
+ DataComparerLibrary.Sort Csv Files C:\\Users\\unsorted.csv C:\\Users\\sorted.csv
233
+
234
+
169
235
  FileConverter
170
236
  =============
171
237
 
@@ -8,6 +8,8 @@ import re
8
8
 
9
9
  import dateutil.relativedelta
10
10
 
11
+ from DataComparerLibrary.tools import Tools
12
+
11
13
 
12
14
  class DataComparer:
13
15
  # Situations:
@@ -181,8 +183,8 @@ class DataComparer:
181
183
  else:
182
184
  # Part(s) of the actual data field will be skipped for verification.
183
185
  # Replace {SKIP}, ignoring cases, by wildcard *.
184
- #compiled = re.compile(re.escape("{SKIP}"), re.IGNORECASE)
185
- #expected_data_with_wildcard = compiled.sub("*", expected_data_including_templates[row_nr][column_nr])
186
+ # compiled = re.compile(re.escape("{SKIP}"), re.IGNORECASE)
187
+ # expected_data_with_wildcard = compiled.sub("*", expected_data_including_templates[row_nr][column_nr])
186
188
  compiled = re.compile(re.escape("{SKIP}"), re.IGNORECASE)
187
189
  compiled2 = re.compile(re.escape("{DATETIME_FORMAT():YYYYMMDDHHMMSSFF6}"), re.IGNORECASE)
188
190
  expected_data_with_wildcard = compiled2.sub("*", compiled.sub("*", expected_data_including_templates[row_nr][column_nr]))
@@ -190,12 +192,6 @@ class DataComparer:
190
192
  if fnmatch.fnmatch(actual_data[row_nr][column_nr], expected_data_with_wildcard):
191
193
  skip_exception_rule_used = True
192
194
  continue
193
- # This can probably be removed. It is verified further in the code
194
- # else:
195
- # # No match despite using of wildcard(s).
196
- # if "{NOW()" not in expected_data_including_templates[row_nr][column_nr].upper():
197
- # difference_found = True
198
- # DataComparer.__print_comparation_result(self, row_nr, column_nr, actual_data[row_nr][column_nr], expected_data_including_templates[row_nr][column_nr], "Actual data field has not been SKIPped.")
199
195
  #
200
196
  if expected_data_with_wildcard is None:
201
197
  # Wildcards not used.
@@ -223,16 +219,17 @@ class DataComparer:
223
219
  DataComparer.__print_comparation_result(self, row_nr, column_nr, actual_data[row_nr][column_nr], expected_data, "There is a difference between actual and expected data.")
224
220
  continue
225
221
  #
226
- if "{NOT(" in expected_data_including_templates[row_nr][column_nr].upper():
222
+ elif "{NOT(" in expected_data_including_templates[row_nr][column_nr].upper():
227
223
  try:
228
224
  unwanted_expected_data = DataComparer.__get_unwanted_expected_data(self, expected_data_including_date_template)
229
225
  #
230
- if fnmatch.fnmatch(actual_data[row_nr][column_nr], unwanted_expected_data):
226
+ if actual_data[row_nr][column_nr] == unwanted_expected_data:
231
227
  # Unwanted match.
232
228
  difference_found = True
233
229
  DataComparer.__print_comparation_result(self, row_nr, column_nr, actual_data[row_nr][column_nr], expected_data_including_templates[row_nr][column_nr], "NOT() template format displayed. See also next message line.")
234
230
  DataComparer.__print_comparation_result(self, row_nr, column_nr, actual_data[row_nr][column_nr], unwanted_expected_data, "Actual and expected data are equal. However actual data should NOT be equal to the expected data!!!")
235
- except:
231
+ except Exception as exception_message:
232
+ # print(f"An exception occurred: {exception_message}")
236
233
  difference_found = True
237
234
  DataComparer.__print_comparation_result(self, row_nr, column_nr, actual_data[row_nr][column_nr], expected_data_including_templates[row_nr][column_nr], "NOT() has been found in expected data field, but format is incorrect.")
238
235
  #
@@ -383,6 +380,17 @@ class DataComparer:
383
380
  raise Exception()
384
381
  #
385
382
  unwanted_expected_data = expected_data_field_including_date_template[position_open_brace+5:position_close_brace]
383
+ #
384
+ if DataComparer.is_integer(self, unwanted_expected_data):
385
+ unwanted_expected_data = int(unwanted_expected_data)
386
386
  return unwanted_expected_data
387
387
 
388
388
 
389
+
390
+ def is_integer(self, string):
391
+ if string[0] == '-':
392
+ # if a negative number
393
+ return string[1:].isdigit()
394
+ else:
395
+ return string.isdigit()
396
+
@@ -44,7 +44,7 @@ class FileConverter:
44
44
 
45
45
 
46
46
  def remove_cr_and_lf(self, input):
47
- # Remove carriage return and linefeed (LF) from input string.
47
+ # Remove carriage return (CR) and linefeed (LF) from input string.
48
48
  print("input: ", input)
49
49
  output = str(input).replace("\r", "").replace("\n", "")
50
50
  print("output: ", output)
@@ -53,7 +53,7 @@ class FileConverter:
53
53
 
54
54
 
55
55
  def replace_cr_and_lf(self, input, replacement_string):
56
- # Replace carriage return and linefeed (LF) from input string.
56
+ # Replace carriage return (CR) and linefeed (LF) from input string.
57
57
  print("input: ", input)
58
58
  output = str(input).replace("\r", replacement_string).replace("\n", replacement_string)
59
59
  print("output: ", output)
@@ -0,0 +1,7 @@
1
+ class Tools:
2
+ def is_integer(self, string):
3
+ if string[0] == '-':
4
+ # if a negative number
5
+ return string[1:].isdigit()
6
+ else:
7
+ return string.isdigit()
@@ -1,3 +1,3 @@
1
1
  # encoding=utf-8
2
2
 
3
- VERSION = '0.838'
3
+ VERSION = '0.840'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: DataComparerLibrary
3
- Version: 0.838
3
+ Version: 0.840
4
4
  Summary: For comparing csv-files or 2d-array with csv-file.
5
5
  Home-page:
6
6
  Author: René Philip Zuijderduijn
@@ -60,7 +60,7 @@ Introduction
60
60
  The DataComparerLibrary can be used for:
61
61
  - comparing csv-files or text-files
62
62
  - comparing a 2d-matrix with a csv-file or text-file
63
- - comparing a csv_file or text-file with a 2d-matrix
63
+ - comparing a csv-file or text-file with a 2d-matrix
64
64
  - comparing 2d-matrices
65
65
 
66
66
  | In case a difference between actual and expected data is found an exception wil be given. In Robot Framework
@@ -186,6 +186,72 @@ Based on current datetime = 2023-09-06 19:04:00 (example):
186
186
 
187
187
 
188
188
 
189
+ DataSorter
190
+ ==========
191
+
192
+ Introduction
193
+ ------------
194
+ The DataSorter can be used for sorting records in a csv file or text file.
195
+
196
+
197
+ Default sorting
198
+ ---------------
199
+ The default sorting is alphabetically based in ascending order on column 0 on all records.
200
+
201
+
202
+ Special sorting
203
+ ---------------
204
+
205
+ | With the DataSorter it is possible to tune the sorting of records.
206
+ |
207
+ | number_of_header_lines:
208
+ | Optional argument "number_of_header_lines" can be used to set the number of header records. These records will be excluded from sorting.
209
+ In case this optional argument is not present the default value is set to 0.
210
+ |
211
+ | number_of_trailer_lines:
212
+ | Optional argument "number_of_trailer_lines" can be used to set the number of trailer records. These records will be excluded from sorting.
213
+ In case this optional argument is not present the default value is set to 0.
214
+ |
215
+ | sort_on_columns_list:
216
+ | Optional argument "sort_on_columns_list" can be used to specify one or more columns on which should be sorted and in which order of columns.
217
+ Sorting of a column can be done in an alphabetic or numeric way.
218
+ |
219
+ | delimiter:
220
+ | Optional argument "delimiter" can be used to set the delimiter.
221
+ Default delimiter is "," in case of an input file. You can use the option "delimiter" to set another delimiter
222
+ like ";" or "\t" for tab. It is also possible to use a multi-character delimiter like "@#@".
223
+
224
+
225
+ Examples of using the DataComparerLibrary keywords for sorting data in Robot Framework
226
+ ----------------------------------------------------------------------------------------
227
+
228
+ Below there are some examples how to call the keywords of the DataComparerLibrary in Robot Framework::
229
+
230
+
231
+ *** Settings ***
232
+ Library DataComparerLibrary
233
+
234
+ *** Test Cases ***
235
+ Testcase_DataSorter
236
+ Examples
237
+
238
+ *** Keywords ***
239
+ Examples
240
+ # sorting examples
241
+ #
242
+ # Sorting alphabetic on column 0, 5 and 4
243
+ ${sorting_column_0_5_4} = create list 0 5 4
244
+ # Sorting alphabetic on column 4 and 1 and numeric on colum 3
245
+ ${sorting_column_4_3i_1} = create list 4 ${3} 1
246
+
247
+
248
+ Run Keyword And Continue On Failure DataComparerLibrary.Sort Csv Files C:\\Users\\unsorted.csv C:\\Users\\sorted.csv
249
+ DataComparerLibrary.Sort Csv Files C:\\Users\\unsorted.csv C:\\Users\\sorted.csv number_of_header_lines=5 sort_on_columns_list=${sorting_column_0_5_4} number_of_trailer_lines=5 delimiter=;
250
+ DataComparerLibrary.Sort Csv Files C:\\Users\\unsorted.csv C:\\Users\\sorted.csv number_of_header_lines=4 sort_on_columns_list=${sorting_column_4_3i_1} delimiter=@#@
251
+ DataComparerLibrary.Sort Csv Files C:\\Users\\unsorted.csv C:\\Users\\sorted.csv number_of_trailer_lines=2 delimiter=\t
252
+ DataComparerLibrary.Sort Csv Files C:\\Users\\unsorted.csv C:\\Users\\sorted.csv
253
+
254
+
189
255
  FileConverter
190
256
  =============
191
257
 
@@ -7,6 +7,7 @@ src/DataComparerLibrary/datacomparer.py
7
7
  src/DataComparerLibrary/datasorter.py
8
8
  src/DataComparerLibrary/delimitertranslator.py
9
9
  src/DataComparerLibrary/fileconverter.py
10
+ src/DataComparerLibrary/tools.py
10
11
  src/DataComparerLibrary/version.py
11
12
  src/DataComparerLibrary.egg-info/PKG-INFO
12
13
  src/DataComparerLibrary.egg-info/SOURCES.txt