PythonExtensionsCollection 0.11.0__py3-none-any.whl → 0.13.0__py3-none-any.whl

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.
@@ -20,7 +20,7 @@
20
20
  #
21
21
  # XC-CT/ECA3-Queckenstedt
22
22
  #
23
- # 08.11.2022
23
+ # 03.04.2023
24
24
  #
25
25
  # **************************************************************************************************************
26
26
 
@@ -43,13 +43,11 @@ or based on an extract (made with regular expressions) to ensure that only relev
43
43
 
44
44
  def __init__(self):
45
45
  self.__bSkipBlankLines = True
46
- self.__bToScreen = False # content of files will be printed to screen (debug)
47
- # eof def __init__(self):
48
46
 
49
47
  # --------------------------------------------------------------------------------------------------------------
50
48
  #TM***
51
49
 
52
- def Compare(self, sFile_1=None, sFile_2=None, sPatternFile=None):
50
+ def Compare(self, sFile_1=None, sFile_2=None, sPatternFile=None, sIgnorePatternFile=None, bDebug=False):
53
51
  """
54
52
  Compares two files. While reading in all files empty lines are skipped.
55
53
 
@@ -74,13 +72,20 @@ Compares two files. While reading in all files empty lines are skipped.
74
72
  Pattern file containing a set of regular expressions (line by line). The regular expressions are used to make
75
73
  an extract of both input files. In this case the extracts are compared (instead of the original file content).
76
74
 
75
+ * ``sIgnorePatternFile``
76
+
77
+ / *Condition*: optional / *Type*: str / *Default*: None /
78
+
79
+ Pattern file containing a set of strings (**not** regular expressuions; line by line). Every line containing one
80
+ of the strings, is skipped.
81
+
77
82
  **Returns:**
78
83
 
79
84
  * ``bIdentical``
80
85
 
81
86
  / *Type*: bool /
82
87
 
83
- Indicates if the two input files have the same content or not.
88
+ Indicates if the two input files (or their extracts) have the same content or not.
84
89
 
85
90
  * ``bSuccess``
86
91
 
@@ -142,23 +147,44 @@ Compares two files. While reading in all files empty lines are skipped.
142
147
  sResult = f"The file '{sPatternFile}' does not exist"
143
148
  sResult = CString.FormatResult(sMethod, bSuccess, sResult)
144
149
  return bIdentical, bSuccess, sResult
150
+ # eof if sPatternFile is not None:
151
+
152
+ sIgnorePatterns = None
153
+ listIgnorePatterns = None
145
154
 
146
- if self.__bToScreen is True:
155
+ if sIgnorePatternFile is not None:
156
+ # (optional)
157
+ sIgnorePatternFile = CString.NormalizePath(sIgnorePatternFile)
158
+ if os.path.isfile(sIgnorePatternFile) is False:
159
+ bSuccess = False
160
+ sResult = f"The file '{sIgnorePatternFile}' does not exist"
161
+ sResult = CString.FormatResult(sMethod, bSuccess, sResult)
162
+ return bIdentical, bSuccess, sResult
163
+ oIgnorePatternFile = CFile(sIgnorePatternFile)
164
+ listIgnorePatterns, bSuccess, sResult = oIgnorePatternFile.ReadLines()
165
+ del oIgnorePatternFile
166
+ if bSuccess is not True:
167
+ return bIdentical, bSuccess, CString.FormatResult(sMethod, bSuccess, sResult)
168
+ if listIgnorePatterns is not None:
169
+ sIgnorePatterns = ";".join(listIgnorePatterns)
170
+ # eof if sIgnorePatternFile is not None:
171
+
172
+ if bDebug is True:
147
173
  print()
148
174
  print("[FILE 1]")
149
175
  oFile_1 = CFile(sFile_1)
150
- listLines_1, bSuccess, sResult = oFile_1.ReadLines(bSkipBlankLines=self.__bSkipBlankLines, bLStrip=True, bRStrip=True, bToScreen=self.__bToScreen)
176
+ listLines_1, bSuccess, sResult = oFile_1.ReadLines(bSkipBlankLines=self.__bSkipBlankLines, sContainsNot=sIgnorePatterns, bLStrip=True, bRStrip=True, bToScreen=bDebug)
151
177
  del oFile_1
152
178
  if bSuccess is False:
153
179
  del listLines_1
154
180
  sResult = CString.FormatResult(sMethod, bSuccess, sResult)
155
181
  return bIdentical, bSuccess, sResult
156
182
 
157
- if self.__bToScreen is True:
183
+ if bDebug is True:
158
184
  print()
159
185
  print("[FILE 2]")
160
186
  oFile_2 = CFile(sFile_2)
161
- listLines_2, bSuccess, sResult = oFile_2.ReadLines(bSkipBlankLines=self.__bSkipBlankLines, bLStrip=True, bRStrip=True, bToScreen=self.__bToScreen)
187
+ listLines_2, bSuccess, sResult = oFile_2.ReadLines(bSkipBlankLines=self.__bSkipBlankLines, sContainsNot=sIgnorePatterns, bLStrip=True, bRStrip=True, bToScreen=bDebug)
162
188
  del oFile_2
163
189
  if bSuccess is False:
164
190
  del listLines_1
@@ -166,19 +192,20 @@ Compares two files. While reading in all files empty lines are skipped.
166
192
  sResult = CString.FormatResult(sMethod, bSuccess, sResult)
167
193
  return bIdentical, bSuccess, sResult
168
194
 
169
- # -- check number of lines
170
- nNrOfLines_1 = len(listLines_1)
171
- nNrOfLines_2 = len(listLines_2)
172
- if nNrOfLines_1 != nNrOfLines_2:
173
- del listLines_1
174
- del listLines_2
175
- bIdentical = False
176
- bSuccess = True
177
- sResult = f"The files contain different number of lines (file 1: {nNrOfLines_1} lines, file 2: {nNrOfLines_2} lines"
178
- return bIdentical, bSuccess, sResult
179
-
180
195
  if sPatternFile is None:
181
196
  # no pattern given => compare the original version of the files
197
+
198
+ # -- check number of lines
199
+ nNrOfLines_1 = len(listLines_1)
200
+ nNrOfLines_2 = len(listLines_2)
201
+ if nNrOfLines_1 != nNrOfLines_2:
202
+ del listLines_1
203
+ del listLines_2
204
+ bIdentical = False
205
+ bSuccess = True
206
+ sResult = f"The files contain different number of lines (file 1: {nNrOfLines_1} lines, file 2: {nNrOfLines_2} lines"
207
+ return bIdentical, bSuccess, sResult
208
+
182
209
  for nIndex, sLine_1 in enumerate(listLines_1):
183
210
  sLine_2 = listLines_2[nIndex]
184
211
  if sLine_1 != sLine_2:
@@ -189,12 +216,12 @@ Compares two files. While reading in all files empty lines are skipped.
189
216
  sResult = f"Found deviating lines\n(1) '{sLine_1}'\n(2) '{sLine_2}'"
190
217
  return bIdentical, bSuccess, sResult
191
218
  else:
192
- if self.__bToScreen is True:
219
+ if bDebug is True:
193
220
  print()
194
221
  print("[PATTERN]")
195
222
  # -- read pattern for comparison of files
196
223
  oPatternFile = CFile(sPatternFile)
197
- listPatterns, bSuccess, sResult = oPatternFile.ReadLines(bSkipBlankLines=True, bLStrip=True, bRStrip=True, bToScreen=self.__bToScreen)
224
+ listPatterns, bSuccess, sResult = oPatternFile.ReadLines(bSkipBlankLines=True, bLStrip=True, bRStrip=True, bToScreen=bDebug)
198
225
  del oPatternFile
199
226
  if bSuccess is False:
200
227
  del listPatterns
@@ -208,20 +235,36 @@ Compares two files. While reading in all files empty lines are skipped.
208
235
  # -- apply pattern to content of file 1
209
236
  listSubsetLines_1 = []
210
237
  for sLine in listLines_1:
238
+ listLineParts_1 = []
211
239
  for RegEx in listRegEx:
212
240
  listPositions = RegEx.findall(sLine)
213
241
  if len(listPositions) > 0:
214
- listSubsetLines_1.append(listPositions[0])
242
+ for position in listPositions:
243
+ if isinstance(position, (tuple, list)):
244
+ for subposition in position:
245
+ listLineParts_1.append(subposition)
246
+ else:
247
+ listLineParts_1.append(position)
248
+ sLineNew_1 = " || ".join(listLineParts_1)
249
+ listSubsetLines_1.append(sLineNew_1)
215
250
  break # for RegEx in listRegEx:
216
251
  # eof for sLine in listLines_1:
217
252
  del listLines_1
218
253
  # -- apply pattern to content of file 2
219
254
  listSubsetLines_2 = []
220
255
  for sLine in listLines_2:
256
+ listLineParts_2 = []
221
257
  for RegEx in listRegEx:
222
258
  listPositions = RegEx.findall(sLine)
223
259
  if len(listPositions) > 0:
224
- listSubsetLines_2.append(listPositions[0])
260
+ for position in listPositions:
261
+ if isinstance(position, (tuple, list)):
262
+ for subposition in position:
263
+ listLineParts_2.append(subposition)
264
+ else:
265
+ listLineParts_2.append(position)
266
+ sLineNew_2 = " || ".join(listLineParts_2)
267
+ listSubsetLines_2.append(sLineNew_2)
225
268
  break # for RegEx in listRegEx:
226
269
  # eof for sLine in listLines_2:
227
270
  del listLines_2
@@ -231,6 +274,17 @@ Compares two files. While reading in all files empty lines are skipped.
231
274
  nNrOfSubsetLines_1 = len(listSubsetLines_1)
232
275
  nNrOfSubsetLines_2 = len(listSubsetLines_2)
233
276
  if nNrOfSubsetLines_1 != nNrOfSubsetLines_2:
277
+ print()
278
+ print(120*"-")
279
+ print("[SUBSET 1]")
280
+ sSubset1 = "\n".join(listSubsetLines_1)
281
+ print(f"{sSubset1}")
282
+ print(120*"-")
283
+ print("[SUBSET 2]")
284
+ sSubset2 = "\n".join(listSubsetLines_2)
285
+ print(f"{sSubset2}")
286
+ print(120*"-")
287
+ print()
234
288
  del listSubsetLines_1
235
289
  del listSubsetLines_2
236
290
  bIdentical = False
@@ -244,6 +298,18 @@ Compares two files. While reading in all files empty lines are skipped.
244
298
  if sLine_1 != sLine_2:
245
299
  del listSubsetLines_1
246
300
  del listSubsetLines_2
301
+ if bDebug is True:
302
+ print()
303
+ print(120*"-")
304
+ print("[SUBSET 1]")
305
+ sSubset1 = "\n".join(listSubsetLines_1)
306
+ print(f"{sSubset1}")
307
+ print(120*"-")
308
+ print("[SUBSET 2]")
309
+ sSubset2 = "\n".join(listSubsetLines_2)
310
+ print(f"{sSubset2}")
311
+ print(120*"-")
312
+ print()
247
313
  bIdentical = False
248
314
  bSuccess = True
249
315
  sResult = f"Found deviating lines\n(1) '{sLine_1}'\n(2) '{sLine_2}'"
@@ -20,7 +20,7 @@
20
20
  #
21
21
  # XC-CT/ECA3-Queckenstedt
22
22
  #
23
- # 15.11.2022
23
+ # 29.03.2023
24
24
  #
25
25
  # **************************************************************************************************************
26
26
 
@@ -179,25 +179,25 @@ The method ``TypePrint`` computes details about the input variable ``oData``.
179
179
  sOut = sGlobalPrefix + " " + sLocalPrefix + " : " + str(oData)
180
180
  self.listOutLines.append(sOut.strip())
181
181
 
182
- elif type(oData) == int:
182
+ elif type(oData) is int:
183
183
  sLocalPrefix = "[INT]"
184
184
  sGlobalPrefix = " ".join(self.listGlobalPrefixes)
185
185
  sOut = sGlobalPrefix + " " + sLocalPrefix + " : " + str(oData)
186
186
  self.listOutLines.append(sOut.strip())
187
187
 
188
- elif type(oData) == float:
188
+ elif type(oData) is float:
189
189
  sLocalPrefix = "[FLOAT]"
190
190
  sGlobalPrefix = " ".join(self.listGlobalPrefixes)
191
191
  sOut = sGlobalPrefix + " " + sLocalPrefix + " : " + str(oData)
192
192
  self.listOutLines.append(sOut.strip())
193
193
 
194
- elif type(oData) == bool:
194
+ elif type(oData) is bool:
195
195
  sLocalPrefix = "[BOOL]"
196
196
  sGlobalPrefix = " ".join(self.listGlobalPrefixes)
197
197
  sOut = sGlobalPrefix + " " + sLocalPrefix + " : " + str(oData)
198
198
  self.listOutLines.append(sOut.strip())
199
199
 
200
- elif type(oData) == str:
200
+ elif type(oData) is str:
201
201
  sLocalPrefix = "[STR]"
202
202
  sGlobalPrefix = " ".join(self.listGlobalPrefixes)
203
203
  sData = str(oData)
@@ -206,7 +206,7 @@ The method ``TypePrint`` computes details about the input variable ``oData``.
206
206
  sOut = sGlobalPrefix + " " + sLocalPrefix + " : '" + sData + "'"
207
207
  self.listOutLines.append(sOut.strip())
208
208
 
209
- elif type(oData) == list:
209
+ elif type(oData) is list:
210
210
  nNrOfElements = len(oData)
211
211
  if nNrOfElements == 0:
212
212
  # -- indicate empty list
@@ -226,7 +226,7 @@ The method ``TypePrint`` computes details about the input variable ``oData``.
226
226
  del self.listGlobalPrefixes[-1] # remove prefix count
227
227
  del self.listGlobalPrefixes[-1] # remove prefix name
228
228
 
229
- elif type(oData) == tuple:
229
+ elif type(oData) is tuple:
230
230
  nNrOfElements = len(oData)
231
231
  if nNrOfElements == 0:
232
232
  # -- indicate empty tuple
@@ -246,7 +246,7 @@ The method ``TypePrint`` computes details about the input variable ``oData``.
246
246
  del self.listGlobalPrefixes[-1] # remove prefix count
247
247
  del self.listGlobalPrefixes[-1] # remove prefix name
248
248
 
249
- elif type(oData) == set:
249
+ elif type(oData) is set:
250
250
  nNrOfElements = len(oData)
251
251
  if nNrOfElements == 0:
252
252
  # -- indicate empty set
@@ -266,7 +266,7 @@ The method ``TypePrint`` computes details about the input variable ``oData``.
266
266
  del self.listGlobalPrefixes[-1] # remove prefix count
267
267
  del self.listGlobalPrefixes[-1] # remove prefix name
268
268
 
269
- elif type(oData) == dict:
269
+ elif type(oData) is dict:
270
270
  nNrOfElements = len(oData)
271
271
  if nNrOfElements == 0:
272
272
  # -- indicate empty dictionary
@@ -288,8 +288,7 @@ The method ``TypePrint`` computes details about the input variable ``oData``.
288
288
  del self.listGlobalPrefixes[-1] # remove prefix count
289
289
  del self.listGlobalPrefixes[-1] # remove prefix name
290
290
 
291
- # elif type(oData) == dotdict:
292
- elif ( (type(oData) == dotdict) or (str(type(oData)) == "<class 'robot.utils.dotdict.DotDict'>") ):
291
+ elif ( (type(oData) is dotdict) or (str(type(oData)) == "<class 'robot.utils.dotdict.DotDict'>") or (str(type(oData)) == "<class 'RobotFramework_TestsuitesManagement.Config.CConfig.dotdict'>") ):
293
292
  nNrOfElements = len(oData)
294
293
  if nNrOfElements == 0:
295
294
  # -- indicate empty dot dictionary
@@ -18,6 +18,6 @@
18
18
  #
19
19
  # Version and date of PythonExtensionsCollection
20
20
  #
21
- VERSION = "0.11.0"
22
- VERSION_DATE = "15.11.2022"
21
+ VERSION = "0.13.0"
22
+ VERSION_DATE = "03.04.2023"
23
23
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PythonExtensionsCollection
3
- Version: 0.11.0
3
+ Version: 0.13.0
4
4
  Summary: Additional Python functions
5
5
  Home-page: https://github.com/test-fullautomation/python-extensions-collection
6
6
  Author: Holger Queckenstedt
@@ -16,38 +16,54 @@ Classifier: Topic :: Software Development
16
16
  Requires-Python: >=3.0
17
17
  Description-Content-Type: text/markdown
18
18
  License-File: LICENSE
19
- Requires-Dist: pypandoc
20
- Requires-Dist: colorama
21
- Requires-Dist: GenPackageDoc
19
+ Requires-Dist: dotdict
22
20
 
23
21
  Package Description
24
22
  ===================
25
23
 
26
- The *Python Extensions Collection* package extends the functionality of
24
+ The **PythonExtensionsCollection** package extends the functionality of
27
25
  Python by some useful functions that are not available in Python
28
26
  immediately.
29
27
 
30
28
  How to install
31
29
  --------------
32
30
 
33
- Firstly clone the **python-extensions-collection** repository to your
34
- machine.
31
+ The **PythonExtensionsCollection** can be installed in two different
32
+ ways.
35
33
 
36
- ``` {.sourceCode .}
37
- git clone https://github.com/test-fullautomation/python-extensions-collection.git
38
- ```
34
+ 1. Installation via PyPi (recommended for users)
39
35
 
40
- Use the following command to install this package:
36
+ ``` {.}
37
+ pip install PythonExtensionsCollection
38
+ ```
41
39
 
42
- ``` {.sourceCode .}
43
- setup.py install
44
- ```
40
+ [PythonExtensionsCollection in
41
+ PyPi](https://pypi.org/project/PythonExtensionsCollection/)
42
+
43
+ 2. Installation via GitHub (recommended for developers)
44
+
45
+ Clone the **python-extensions-collection** repository to your
46
+ machine.
47
+
48
+ ``` {.}
49
+ git clone https://github.com/test-fullautomation/python-extensions-collection.git
50
+ ```
51
+
52
+ [PythonExtensionsCollection in
53
+ GitHub](https://github.com/test-fullautomation/python-extensions-collection)
54
+
55
+ Use the following command to install the
56
+ **PythonExtensionsCollection**:
57
+
58
+ ``` {.}
59
+ setup.py install
60
+ ```
45
61
 
46
62
  Package Documentation
47
63
  ---------------------
48
64
 
49
- A detailed documentation of the *Python Extensions Collection* package
50
- can be found here:
65
+ A detailed documentation of the **PythonExtensionsCollection** can be
66
+ found here:
51
67
  [PythonExtensionsCollection.pdf](https://github.com/test-fullautomation/python-extensions-collection/blob/develop/PythonExtensionsCollection/PythonExtensionsCollection.pdf)
52
68
 
53
69
  Feedback
@@ -1,7 +1,7 @@
1
- PythonExtensionsCollection/PythonExtensionsCollection.pdf,sha256=qKC30ANLBnfa-yvs3HKaiM4UrfoeAJsFLA_d6TtHpuo,280861
1
+ PythonExtensionsCollection/PythonExtensionsCollection.pdf,sha256=H1EVoh3wU2adU7jFvtq0xCrac2Nik2FvMYNjBojLtE4,281523
2
2
  PythonExtensionsCollection/__init__.py,sha256=hr5YI0Et3k8uubFLR_hLILpLtqgnJvEYil0neGoKXhA,596
3
- PythonExtensionsCollection/version.py,sha256=7ZRtPov2AMZsawAtF4VQLqqefGQWaH_k2er1E7fwJWA,932
4
- PythonExtensionsCollection/Comparison/CComparison.py,sha256=6RVxbZ_IqxSDgu-TB1PpIunblgTv51yLToN18jspliM,9779
3
+ PythonExtensionsCollection/version.py,sha256=w9Xlc1o3uKY2FoynLeHuH5Ii8jBKW7c_eTtfPTThFTQ,932
4
+ PythonExtensionsCollection/Comparison/CComparison.py,sha256=QS9ianplFbS8aN1oT8ax2kgh1TT6lE1djQhljJqloCQ,12552
5
5
  PythonExtensionsCollection/Comparison/__init__.py,sha256=hr5YI0Et3k8uubFLR_hLILpLtqgnJvEYil0neGoKXhA,596
6
6
  PythonExtensionsCollection/File/CFile.py,sha256=vLEmVnYowxqLilEtQmPuomUBiyABEtnUu5XFZW27skU,36382
7
7
  PythonExtensionsCollection/File/__init__.py,sha256=hr5YI0Et3k8uubFLR_hLILpLtqgnJvEYil0neGoKXhA,596
@@ -9,10 +9,10 @@ PythonExtensionsCollection/Folder/CFolder.py,sha256=WUMITkZnpPNdxGPZraPsmxe0IzGm
9
9
  PythonExtensionsCollection/Folder/__init__.py,sha256=hr5YI0Et3k8uubFLR_hLILpLtqgnJvEYil0neGoKXhA,596
10
10
  PythonExtensionsCollection/String/CString.py,sha256=iJxfMW5NwJ5Mc9sFqHMWrNMTfH2KgAzPj19Mask4cig,37642
11
11
  PythonExtensionsCollection/String/__init__.py,sha256=hr5YI0Et3k8uubFLR_hLILpLtqgnJvEYil0neGoKXhA,596
12
- PythonExtensionsCollection/Utils/CUtils.py,sha256=EDJYc7h9c4U237IlfZNqJOss3EfJ4XS0AX9ydyrd-Ag,11867
12
+ PythonExtensionsCollection/Utils/CUtils.py,sha256=bwYFsIMC-kwlrzPutmqTd7C4XoQXiKLLxI7vD_TXIgk,11926
13
13
  PythonExtensionsCollection/Utils/__init__.py,sha256=hr5YI0Et3k8uubFLR_hLILpLtqgnJvEYil0neGoKXhA,596
14
- PythonExtensionsCollection-0.11.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
15
- PythonExtensionsCollection-0.11.0.dist-info/METADATA,sha256=IjLKpJpYTf69Jy7oAnD6e3QSUfjVE-ithjmWt8789rg,2777
16
- PythonExtensionsCollection-0.11.0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
17
- PythonExtensionsCollection-0.11.0.dist-info/top_level.txt,sha256=xv5w-C3GQkdbxctBNzEqPfWvpJ1kpAaHBe3TEdGcozQ,27
18
- PythonExtensionsCollection-0.11.0.dist-info/RECORD,,
14
+ PythonExtensionsCollection-0.13.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
15
+ PythonExtensionsCollection-0.13.0.dist-info/METADATA,sha256=WTzPez6NAEOSrtfnjKOrsw4YntvYx_duhi92EUQvYZQ,3211
16
+ PythonExtensionsCollection-0.13.0.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
17
+ PythonExtensionsCollection-0.13.0.dist-info/top_level.txt,sha256=xv5w-C3GQkdbxctBNzEqPfWvpJ1kpAaHBe3TEdGcozQ,27
18
+ PythonExtensionsCollection-0.13.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.38.4)
2
+ Generator: bdist_wheel (0.40.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5