libs5-python 1.0.1__tar.gz → 1.0.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.
Files changed (27) hide show
  1. {libs5_python-1.0.1 → libs5_python-1.0.2}/PKG-INFO +1 -1
  2. {libs5_python-1.0.1 → libs5_python-1.0.2}/pyproject.toml +1 -1
  3. libs5_python-1.0.2/src/net/hypki/File.py +47 -0
  4. libs5_python-1.0.2/src/net/hypki/Ini.py +104 -0
  5. {libs5_python-1.0.1 → libs5_python-1.0.2}/src/net/hypki/args.py +1 -1
  6. libs5_python-1.0.1/src/net/hypki/File.py +0 -25
  7. {libs5_python-1.0.1 → libs5_python-1.0.2}/.gitignore +0 -0
  8. {libs5_python-1.0.1 → libs5_python-1.0.2}/LICENSE +0 -0
  9. {libs5_python-1.0.1 → libs5_python-1.0.2}/MANIFEST.in +0 -0
  10. {libs5_python-1.0.1 → libs5_python-1.0.2}/README.md +0 -0
  11. {libs5_python-1.0.1 → libs5_python-1.0.2}/install.sh +0 -0
  12. {libs5_python-1.0.1 → libs5_python-1.0.2}/setup.py +0 -0
  13. {libs5_python-1.0.1 → libs5_python-1.0.2}/src/net/__init__.py +0 -0
  14. {libs5_python-1.0.1 → libs5_python-1.0.2}/src/net/hypki/Logger.py +0 -0
  15. {libs5_python-1.0.1 → libs5_python-1.0.2}/src/net/hypki/StringUtils.py +0 -0
  16. {libs5_python-1.0.1 → libs5_python-1.0.2}/src/net/hypki/__init__.py +0 -0
  17. {libs5_python-1.0.1 → libs5_python-1.0.2}/src/net/hypki/apiutils.py +0 -0
  18. {libs5_python-1.0.1 → libs5_python-1.0.2}/src/net/hypki/asserts.py +0 -0
  19. {libs5_python-1.0.1 → libs5_python-1.0.2}/src/net/hypki/io.py +0 -0
  20. {libs5_python-1.0.1 → libs5_python-1.0.2}/src/net/hypki/log.py +0 -0
  21. {libs5_python-1.0.1 → libs5_python-1.0.2}/src/net/hypki/math.py +0 -0
  22. {libs5_python-1.0.1 → libs5_python-1.0.2}/src/net/hypki/random.py +0 -0
  23. {libs5_python-1.0.1 → libs5_python-1.0.2}/src/net/hypki/regex.py +0 -0
  24. {libs5_python-1.0.1 → libs5_python-1.0.2}/src/net/hypki/system.py +0 -0
  25. {libs5_python-1.0.1 → libs5_python-1.0.2}/src/net/hypki/tests/__init__.py +0 -0
  26. {libs5_python-1.0.1 → libs5_python-1.0.2}/src/net/hypki/tests/kepler.py +0 -0
  27. {libs5_python-1.0.1 → libs5_python-1.0.2}/src/net/hypki/tests/numpytest.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: libs5-python
3
- Version: 1.0.1
3
+ Version: 1.0.2
4
4
  Summary: libs5 python scripts, and helper classes (useg e.g. in BEANS software)
5
5
  Project-URL: Homepage, https://gitlab.com/ahypki/libs5-python
6
6
  Project-URL: Issues, https://gitlab.com/ahypki/libs5-python/-/issues/
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "libs5-python"
7
- version = "1.0.1"
7
+ version = "1.0.2"
8
8
  authors = [
9
9
  { name="Arkadiusz Hypki" },
10
10
  ]
@@ -0,0 +1,47 @@
1
+ '''
2
+ Created on Oct 14, 2025
3
+
4
+ @author: ahypki
5
+ '''
6
+ import os
7
+ import shutil
8
+ from pathlib import Path
9
+
10
+ class File(object):
11
+ '''
12
+ classdocs
13
+ '''
14
+ __absPath = None
15
+
16
+ def __init__(self, path):
17
+ '''
18
+ Constructor
19
+ '''
20
+ if isinstance(path, str):
21
+ self.setAbsPath(path)
22
+ elif len(path) == 1:
23
+ self.setAbsPath(path[0])
24
+ else:
25
+ self.setAbsPath("/".join(path))
26
+ # p2 = "/"
27
+ # for p1 in path:
28
+ # p1 +=
29
+
30
+ def getAbsPath(self):
31
+ return self.__absPath
32
+
33
+
34
+ def setAbsPath(self, path):
35
+ self.__absPath = Path(path).expanduser()# os.path.abspath(path)
36
+
37
+ def exists(self):
38
+ return os.path.exists(self.__absPath)
39
+
40
+ def mkdirs(self):
41
+ os.makedirs(self.__absPath, exist_ok=True)
42
+
43
+
44
+ def copy(self, destination):
45
+ shutil.copyfile(self.__absPath, destination)
46
+
47
+
@@ -0,0 +1,104 @@
1
+ '''
2
+ Created on Oct 15, 2025
3
+
4
+ @author: ahypki
5
+ '''
6
+ import ini
7
+ import re
8
+
9
+ class Ini(object):
10
+ '''
11
+ classdocs
12
+ https://pypi.org/project/ini-parser/
13
+ '''
14
+ __path = None
15
+ __iniLines = None
16
+
17
+ def __init__(self, path):
18
+ '''
19
+ Constructor
20
+ '''
21
+ self.__path = path
22
+
23
+ def __getIni(self):
24
+ if self.__iniLines is None:
25
+ self.__iniLines = open(self.__path, "r").readlines()
26
+
27
+ return self.__iniLines
28
+
29
+ def __isKey(self, line):
30
+ k = self.__getKey(line)
31
+ return False if k is None else True
32
+
33
+ def __getKey(self, line):
34
+ m = re.match("^[\s]*(\w[\w\d]*)[\s]*=[\s]*.*$", line)
35
+ if m:
36
+ return m.group(1)
37
+ return None
38
+
39
+ def __isSection(self, line):
40
+ sec = self.__getSection(line)
41
+ return False if sec is None else True
42
+
43
+ def __getSection(self, line):
44
+ m = re.match("^[\s]*\[(\w[\w\d]+)\][\s]*$", line)
45
+ if m:
46
+ return m.group(1)
47
+ return None
48
+
49
+ def getSections(self):
50
+ sections = []
51
+ for line in self.__getIni():
52
+ if self.__isSection(line):
53
+ sections.append(self.__getSection(line))
54
+ return sections
55
+
56
+ def getKeys(self, section):
57
+ keys = []
58
+ currentSection = None
59
+ for line in self.__getIni():
60
+ if self.__isSection(line):
61
+ currentSection = self.__getSection(line)
62
+ continue
63
+ if self.__isKey(line):
64
+ if currentSection is not None and currentSection == section:
65
+ keys.append(self.__getKey(line))
66
+ return keys
67
+
68
+ def set(self, section, key, value):
69
+ newLines = []
70
+ currentSection = None
71
+ for line in self.__getIni():
72
+ lineAdded = False
73
+
74
+ if self.__isSection(line):
75
+ currentSection = self.__getSection(line)
76
+
77
+ if self.__isKey(line):
78
+ currentKey = self.__getKey(line)
79
+ if currentSection is not None and currentSection == section and currentKey == key:
80
+ newLines.append(key + " = " + value)
81
+ lineAdded = True
82
+
83
+ if not lineAdded:
84
+ newLines.append(line)
85
+
86
+ self.__iniLines = newLines
87
+
88
+ def get(self, section, key):
89
+ currentSection = None
90
+ for line in self.__getIni():
91
+ if self.__isSection(line):
92
+ currentSection = self.__getSection(line)
93
+ continue
94
+ if self.__isKey(line):
95
+ currentKey = self.__getKey(line)
96
+ if currentSection is not None and currentSection == section and currentKey == key:
97
+ return line[(line.index("=") + 1):].strip()
98
+ return None
99
+
100
+ def save(self):
101
+ if self.__iniLines is not None:
102
+ with open(self.__path, 'w') as f:
103
+ for line in self.__iniLines:
104
+ f.write(f"{line.strip()}\n")
@@ -11,7 +11,7 @@ class ArgUtils:
11
11
  def getString(name, defaultvalue): # @NoSelf
12
12
  for i in range(len(sys.argv)):
13
13
  if sys.argv[i] == "--" + name or sys.argv[i] == "-" + name:
14
- return sys.argv[i + 1]
14
+ return sys.argv[i + 1].strip()
15
15
  return defaultvalue
16
16
 
17
17
  def isArgPresent(name): # @NoSelf
@@ -1,25 +0,0 @@
1
- '''
2
- Created on Oct 14, 2025
3
-
4
- @author: ahypki
5
- '''
6
- import os
7
-
8
- class File(object):
9
- '''
10
- classdocs
11
- '''
12
- __absPath = None
13
-
14
- def __init__(self, path):
15
- '''
16
- Constructor
17
- '''
18
- self.setAbsPath(path)
19
-
20
- def getAbsPath(self):
21
- return self.__absPath
22
-
23
-
24
- def setAbsPath(self, path):
25
- self.__absPath = os.path.abspath(path)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes