PythonExtensionsCollection 0.14.0__py3-none-any.whl → 0.15.1__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.
@@ -1,6 +1,6 @@
1
1
  # **************************************************************************************************************
2
2
  #
3
- # Copyright 2020-2022 Robert Bosch GmbH
3
+ # Copyright 2020-2023 Robert Bosch GmbH
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020-2022 Robert Bosch GmbH
1
+ # Copyright 2020-2023 Robert Bosch GmbH
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # **************************************************************************************************************
2
2
  #
3
- # Copyright 2020-2022 Robert Bosch GmbH
3
+ # Copyright 2020-2023 Robert Bosch GmbH
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020-2022 Robert Bosch GmbH
1
+ # Copyright 2020-2023 Robert Bosch GmbH
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # **************************************************************************************************************
2
2
  #
3
- # Copyright 2020-2022 Robert Bosch GmbH
3
+ # Copyright 2020-2023 Robert Bosch GmbH
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020-2022 Robert Bosch GmbH
1
+ # Copyright 2020-2023 Robert Bosch GmbH
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # **************************************************************************************************************
2
2
  #
3
- # Copyright 2020-2022 Robert Bosch GmbH
3
+ # Copyright 2020-2023 Robert Bosch GmbH
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -20,12 +20,12 @@
20
20
  #
21
21
  # XC-CT/ECA3-Queckenstedt
22
22
  #
23
- # 14.11.2022
23
+ # 19.10.2023
24
24
  #
25
25
  # **************************************************************************************************************
26
26
 
27
27
  # -- import standard Python modules
28
- import os, ntpath, re
28
+ import os, ntpath, platform, re
29
29
 
30
30
  # **************************************************************************************************************
31
31
 
@@ -47,7 +47,8 @@ Normalizes local paths, paths to local network resources and internet addresses
47
47
 
48
48
  / *Condition*: required / *Type*: str /
49
49
 
50
- The path to be normalized
50
+ The path to be normalized. Paths can start with environment variables. Accepted are notations for both Windows
51
+ (``%ENVVAR%``) and Linux (``${ENVVAR}``). Under Windows also the Linux notation will be resolved.
51
52
 
52
53
  * ``bWin``
53
54
 
@@ -94,10 +95,6 @@ Normalizes local paths, paths to local network resources and internet addresses
94
95
 
95
96
  if sPath is not None:
96
97
 
97
- # -- expand Windows environment variables
98
- if bExpandEnvVars is True:
99
- sPath = os.path.expandvars(sPath)
100
-
101
98
  # - remove leading and trailing horizontal space
102
99
  sPath = sPath.strip(" \t\r\n")
103
100
 
@@ -115,6 +112,20 @@ Normalizes local paths, paths to local network resources and internet addresses
115
112
  # - remove trailing slash or backslash (maybe at end of path to folder)
116
113
  sPath = sPath.rstrip("/\\")
117
114
 
115
+ # -- expand environment variables
116
+ if bExpandEnvVars is True:
117
+ sPattern_envvar = r"^\$\{(\w+?)\}" # check for Linux notation (shall be usable also under Windows)
118
+ regex_envvar = re.compile(sPattern_envvar)
119
+ sPlatformSystem = platform.system()
120
+ sPathModified = sPath
121
+ for sEnvVar in regex_envvar.findall(sPath):
122
+ sSearch = "${" + sEnvVar + "}"
123
+ if sPlatformSystem == "Windows":
124
+ sReplace = "%" + sEnvVar + "%"
125
+ sPathModified = sPathModified.replace(sSearch, sReplace)
126
+ # eof for sEnvVar in regex_envvar.findall(sPath):
127
+ sPath = os.path.expandvars(sPathModified)
128
+
118
129
  # --------------------------------------------------------------------------------------------------------------
119
130
  # consider internet addresses and local network resources
120
131
  # --------------------------------------------------------------------------------------------------------------
@@ -480,7 +491,7 @@ while walking through the file system.
480
491
 
481
492
  / *Condition*: required / *Type*: str /
482
493
 
483
- The input string that has to be investigated.
494
+ The input string that has to be investigated.
484
495
 
485
496
  * ``bCaseSensitive``
486
497
 
@@ -1,4 +1,4 @@
1
- # Copyright 2020-2022 Robert Bosch GmbH
1
+ # Copyright 2020-2023 Robert Bosch GmbH
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # **************************************************************************************************************
2
2
  #
3
- # Copyright 2020-2022 Robert Bosch GmbH
3
+ # Copyright 2020-2023 Robert Bosch GmbH
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -20,13 +20,18 @@
20
20
  #
21
21
  # XC-CT/ECA3-Queckenstedt
22
22
  #
23
- # 29.03.2023
23
+ # 30.05.2023
24
24
  #
25
25
  # **************************************************************************************************************
26
26
 
27
27
  # -- import standard Python modules
28
+ import os, sys, subprocess
28
29
  from dotdict import dotdict
29
30
 
31
+ from PythonExtensionsCollection.String.CString import CString
32
+ from PythonExtensionsCollection.File.CFile import CFile
33
+
34
+
30
35
  # **************************************************************************************************************
31
36
  # wrapper
32
37
  # **************************************************************************************************************
@@ -288,7 +293,7 @@ The method ``TypePrint`` computes details about the input variable ``oData``.
288
293
  del self.listGlobalPrefixes[-1] # remove prefix count
289
294
  del self.listGlobalPrefixes[-1] # remove prefix name
290
295
 
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'>") ):
296
+ elif ( (type(oData) is dotdict) or (str(type(oData)) == "<class 'robot.utils.dotdict.DotDict'>") ):
292
297
  nNrOfElements = len(oData)
293
298
  if nNrOfElements == 0:
294
299
  # -- indicate empty dot dictionary
@@ -325,5 +330,121 @@ The method ``TypePrint`` computes details about the input variable ``oData``.
325
330
 
326
331
  # eof class CTypePrint():
327
332
 
333
+
334
+ # --------------------------------------------------------------------------------------------------------------
335
+ # TM***
336
+
337
+ class CUtils(object):
338
+ """The class ``CUtils`` contains useful methods.
339
+ """
340
+
341
+ def GetInstalledPackages(sOutputFile=None):
342
+ """The method ``GetInstalledPackages`` computes a list of all installed Python packages.
343
+ The list is returned as list of tuples containing the name and the version of the package.
344
+
345
+ It is also possible to let the method dump the list to a text file.
346
+
347
+ **Arguments:**
348
+
349
+ * ``sOutputFile``
350
+
351
+ / *Condition*: optional / *Type*: string / *Default*: None /
352
+
353
+ Path and name of a file to dump the package list to.
354
+
355
+ **Returns:**
356
+
357
+ * ``listofTuplesPackages``
358
+
359
+ / *Type*: list /
360
+
361
+ List of tuples containing the name and the version of the package.
362
+
363
+ * ``bSuccess``
364
+
365
+ / *Type*: bool /
366
+
367
+ Indicates if the computation of the method was successful or not.
368
+
369
+ * ``sResult``
370
+
371
+ / *Type*: str /
372
+
373
+ The result of the computation of the method.
374
+ """
375
+
376
+ sMethod = "GetInstalledPackages"
377
+ bSuccess = None
378
+ sResult = "UNKNOWN"
379
+
380
+ listofTuplesPackages = []
381
+
382
+ sFreezeData = None
383
+ try:
384
+ sFreezeData = subprocess.check_output([sys.executable, '-m', 'pip', 'freeze'], encoding="utf-8", text=True)
385
+ except Exception as reason:
386
+ bSuccess = None
387
+ sResult = str(reason)
388
+ sResult = CString.FormatResult(sMethod, bSuccess, sResult)
389
+ return listofTuplesPackages, bSuccess, sResult
390
+
391
+ if sFreezeData is None:
392
+ bSuccess = None
393
+ sResult = "sFreezeData is None"
394
+ sResult = CString.FormatResult(sMethod, bSuccess, sResult)
395
+ return listofTuplesPackages, bSuccess, sResult
396
+
397
+ sFreezeData = str(sFreezeData) # to make the content 'split()' save
398
+
399
+ for sPackage in sFreezeData.split():
400
+ sName = None
401
+ sVersion = None
402
+ listParts = sPackage.split('==')
403
+ if len(listParts) != 2:
404
+ sName = sPackage
405
+ sVersion = "UNKNOWN"
406
+ # but I really would not expect this
407
+ else:
408
+ sName = listParts[0]
409
+ sVersion = listParts[1]
410
+ listofTuplesPackages.append((sName, sVersion))
411
+ # eof for sPackage in sFreezeData.split():
412
+
413
+ nNrOfPackages = len(listofTuplesPackages)
414
+
415
+ if sOutputFile is not None:
416
+ sOutputFile = CString.NormalizePath(sOutputFile)
417
+ sParentDirectory = os.path.dirname(sOutputFile)
418
+ if not os.path.isdir(sParentDirectory):
419
+ bSuccess = False
420
+ sResult = f"The folder to store the output file does not exist: '{sParentDirectory}'"
421
+ return listofTuplesPackages, bSuccess, sResult
422
+
423
+ oFile = CFile(sOutputFile)
424
+ for tuplePackage in listofTuplesPackages:
425
+ sName = tuplePackage[0]
426
+ sVersion = tuplePackage[1]
427
+ sOut = sName.rjust(40) + " = " + sVersion
428
+ bSuccess, sResult = oFile.Write(sOut)
429
+ del oFile
430
+
431
+ # eof if sOutputFile is not None:
432
+
433
+ bSuccess = True
434
+ sResult = f"Identified {nNrOfPackages} packages."
435
+
436
+ return listofTuplesPackages, bSuccess, sResult
437
+
438
+ # eof def GetInstalledPackages(sOutputFile=None):
439
+
440
+ # --------------------------------------------------------------------------------------------------------------
441
+ #TM***
442
+
443
+ # - make the methods static
444
+
445
+ GetInstalledPackages = staticmethod(GetInstalledPackages)
446
+
447
+ # eof class CUtils(object):
448
+
328
449
  # **************************************************************************************************************
329
450
 
@@ -1,4 +1,4 @@
1
- # Copyright 2020-2022 Robert Bosch GmbH
1
+ # Copyright 2020-2023 Robert Bosch GmbH
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020-2022 Robert Bosch GmbH
1
+ # Copyright 2020-2023 Robert Bosch GmbH
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # **************************************************************************************************************
2
2
  #
3
- # Copyright 2020-2022 Robert Bosch GmbH
3
+ # Copyright 2020-2023 Robert Bosch GmbH
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -18,6 +18,6 @@
18
18
  #
19
19
  # Version and date of PythonExtensionsCollection
20
20
  #
21
- VERSION = "0.14.0"
22
- VERSION_DATE = "05.05.2023"
21
+ VERSION = "0.15.1"
22
+ VERSION_DATE = "19.10.2023"
23
23
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PythonExtensionsCollection
3
- Version: 0.14.0
3
+ Version: 0.15.1
4
4
  Summary: Additional Python functions
5
5
  Home-page: https://github.com/test-fullautomation/python-extensions-collection
6
6
  Author: Holger Queckenstedt
@@ -21,9 +21,8 @@ Requires-Dist: dotdict
21
21
  Package Description
22
22
  ===================
23
23
 
24
- The **PythonExtensionsCollection** package extends the functionality of
25
- Python by some useful functions that are not available in Python
26
- immediately.
24
+ The **PythonExtensionsCollection** extends the functionality of Python
25
+ by some useful functions that are not available in Python immediately.
27
26
 
28
27
  How to install
29
28
  --------------
@@ -42,22 +41,59 @@ ways.
42
41
 
43
42
  2. Installation via GitHub (recommended for developers)
44
43
 
45
- Clone the **python-extensions-collection** repository to your
46
- machine.
44
+ - Clone the **python-extensions-collection** repository to your
45
+ machine.
47
46
 
48
- ``` {.}
49
- git clone https://github.com/test-fullautomation/python-extensions-collection.git
50
- ```
47
+ ``` {.}
48
+ git clone https://github.com/test-fullautomation/python-extensions-collection.git
49
+ ```
51
50
 
52
- [PythonExtensionsCollection in
53
- GitHub](https://github.com/test-fullautomation/python-extensions-collection)
51
+ [PythonExtensionsCollection in
52
+ GitHub](https://github.com/test-fullautomation/python-extensions-collection)
54
53
 
55
- Use the following command to install the
56
- **PythonExtensionsCollection**:
54
+ - Install dependencies
57
55
 
58
- ``` {.}
59
- setup.py install
60
- ```
56
+ **PythonExtensionsCollection** requires some additional Python
57
+ libraries. Before you install the cloned repository sources you
58
+ have to install the dependencies manually. The names of all
59
+ related packages you can find in the file `requirements.txt` in
60
+ the repository root folder. Use pip to install them:
61
+
62
+ ``` {.}
63
+ pip install -r ./requirements.txt
64
+ ```
65
+
66
+ Additionally install **LaTeX** (recommended: TeX Live). This is
67
+ used to render the documentation.
68
+
69
+ - Configure dependencies
70
+
71
+ The installation of **PythonExtensionsCollection** includes to
72
+ generate the documentation in PDF format. This is done by an
73
+ application called **GenPackageDoc**, that is part of the
74
+ installation dependencies (see `requirements.txt`).
75
+
76
+ **GenPackageDoc** uses **LaTeX** to generate the documentation
77
+ in PDF format. Therefore **GenPackageDoc** needs to know where
78
+ to find **LaTeX**. This is defined in the **GenPackageDoc**
79
+ configuration file
80
+
81
+ ``` {.}
82
+ packagedoc\packagedoc_config.json
83
+ ```
84
+
85
+ Before you start the installation you have to introduce the
86
+ following environment variable, that is used in
87
+ `packagedoc_config.json`:
88
+
89
+ - `GENDOC_LATEXPATH` : path to `pdflatex` executable
90
+
91
+ - Use the following command to install the
92
+ **PythonExtensionsCollection**:
93
+
94
+ ``` {.}
95
+ setup.py install
96
+ ```
61
97
 
62
98
  Package Documentation
63
99
  ---------------------
@@ -92,7 +128,7 @@ Contributors
92
128
  License
93
129
  -------
94
130
 
95
- Copyright 2020-2022 Robert Bosch GmbH
131
+ Copyright 2020-2023 Robert Bosch GmbH
96
132
 
97
133
  Licensed under the Apache License, Version 2.0 (the \"License\"); you
98
134
  may not use this file except in compliance with the License. You may
@@ -0,0 +1,18 @@
1
+ PythonExtensionsCollection/PythonExtensionsCollection.pdf,sha256=jX_yZLHxyixRqoUkmBAZilWhwc4aeGpJB8rSzOw-fJ8,286711
2
+ PythonExtensionsCollection/__init__.py,sha256=YKDTJjDsnQkr5X-gjjO8opwKUVKm6kc8sIUpURYMk48,596
3
+ PythonExtensionsCollection/version.py,sha256=mCVk09gvDXhYgM4Cn5luDuiWWMpD2aqVA7ZjYKdA7kk,932
4
+ PythonExtensionsCollection/Comparison/CComparison.py,sha256=MfA1JX7DVUtPPyFNINGmcG5c_euB1foW5X1CSXGJwZM,12552
5
+ PythonExtensionsCollection/Comparison/__init__.py,sha256=YKDTJjDsnQkr5X-gjjO8opwKUVKm6kc8sIUpURYMk48,596
6
+ PythonExtensionsCollection/File/CFile.py,sha256=5idGq3H35azgmB-lFHNDFmdUKUzSln0J7narq7u6fJw,36382
7
+ PythonExtensionsCollection/File/__init__.py,sha256=YKDTJjDsnQkr5X-gjjO8opwKUVKm6kc8sIUpURYMk48,596
8
+ PythonExtensionsCollection/Folder/CFolder.py,sha256=3a-KXyUoeUwVtH4Bhb9EMP1r3btUI1cnbtQAd5bFNfQ,15985
9
+ PythonExtensionsCollection/Folder/__init__.py,sha256=YKDTJjDsnQkr5X-gjjO8opwKUVKm6kc8sIUpURYMk48,596
10
+ PythonExtensionsCollection/String/CString.py,sha256=oIb8MeZoEdF8KrDPNhnj0o3K4HR6lO9ZEN9gVv8FwzU,38423
11
+ PythonExtensionsCollection/String/__init__.py,sha256=YKDTJjDsnQkr5X-gjjO8opwKUVKm6kc8sIUpURYMk48,596
12
+ PythonExtensionsCollection/Utils/CUtils.py,sha256=l8u_MYKLAwFvA9jQnoKSiMwDJ2JeJAZj76MzmoT4bQ4,15438
13
+ PythonExtensionsCollection/Utils/__init__.py,sha256=YKDTJjDsnQkr5X-gjjO8opwKUVKm6kc8sIUpURYMk48,596
14
+ PythonExtensionsCollection-0.15.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
15
+ PythonExtensionsCollection-0.15.1.dist-info/METADATA,sha256=22ftGaKHI_KoqZsB864pFyUuBTGim1w1g7sQZNnKnW8,4643
16
+ PythonExtensionsCollection-0.15.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
17
+ PythonExtensionsCollection-0.15.1.dist-info/top_level.txt,sha256=xv5w-C3GQkdbxctBNzEqPfWvpJ1kpAaHBe3TEdGcozQ,27
18
+ PythonExtensionsCollection-0.15.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.40.0)
2
+ Generator: bdist_wheel (0.42.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,18 +0,0 @@
1
- PythonExtensionsCollection/PythonExtensionsCollection.pdf,sha256=ngU8amGGVFTc1RfGYzPsZJjlrTnujpwZaTRKPkVxO9c,275407
2
- PythonExtensionsCollection/__init__.py,sha256=hr5YI0Et3k8uubFLR_hLILpLtqgnJvEYil0neGoKXhA,596
3
- PythonExtensionsCollection/version.py,sha256=H0-uXWqTQ2z-mHvg5TRWv7LPKCLGJJNQwtHRDlDXVec,932
4
- PythonExtensionsCollection/Comparison/CComparison.py,sha256=QS9ianplFbS8aN1oT8ax2kgh1TT6lE1djQhljJqloCQ,12552
5
- PythonExtensionsCollection/Comparison/__init__.py,sha256=hr5YI0Et3k8uubFLR_hLILpLtqgnJvEYil0neGoKXhA,596
6
- PythonExtensionsCollection/File/CFile.py,sha256=vLEmVnYowxqLilEtQmPuomUBiyABEtnUu5XFZW27skU,36382
7
- PythonExtensionsCollection/File/__init__.py,sha256=hr5YI0Et3k8uubFLR_hLILpLtqgnJvEYil0neGoKXhA,596
8
- PythonExtensionsCollection/Folder/CFolder.py,sha256=WUMITkZnpPNdxGPZraPsmxe0IzGmlZBbeEwiKv4AR7o,15985
9
- PythonExtensionsCollection/Folder/__init__.py,sha256=hr5YI0Et3k8uubFLR_hLILpLtqgnJvEYil0neGoKXhA,596
10
- PythonExtensionsCollection/String/CString.py,sha256=iJxfMW5NwJ5Mc9sFqHMWrNMTfH2KgAzPj19Mask4cig,37642
11
- PythonExtensionsCollection/String/__init__.py,sha256=hr5YI0Et3k8uubFLR_hLILpLtqgnJvEYil0neGoKXhA,596
12
- PythonExtensionsCollection/Utils/CUtils.py,sha256=bwYFsIMC-kwlrzPutmqTd7C4XoQXiKLLxI7vD_TXIgk,11926
13
- PythonExtensionsCollection/Utils/__init__.py,sha256=hr5YI0Et3k8uubFLR_hLILpLtqgnJvEYil0neGoKXhA,596
14
- PythonExtensionsCollection-0.14.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
15
- PythonExtensionsCollection-0.14.0.dist-info/METADATA,sha256=wiAELBSU0MJfR8tupyjK1mvaozcecrYFFJcIg4eaaXE,3211
16
- PythonExtensionsCollection-0.14.0.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
17
- PythonExtensionsCollection-0.14.0.dist-info/top_level.txt,sha256=xv5w-C3GQkdbxctBNzEqPfWvpJ1kpAaHBe3TEdGcozQ,27
18
- PythonExtensionsCollection-0.14.0.dist-info/RECORD,,