libs5-python 1.0.8__tar.gz → 1.0.10__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.8 → libs5_python-1.0.10}/.gitignore +5 -1
  2. {libs5_python-1.0.8 → libs5_python-1.0.10}/PKG-INFO +1 -1
  3. {libs5_python-1.0.8 → libs5_python-1.0.10}/pyproject.toml +1 -1
  4. {libs5_python-1.0.8 → libs5_python-1.0.10}/src/net/hypki/Ini.py +70 -5
  5. {libs5_python-1.0.8 → libs5_python-1.0.10}/src/net/hypki/args.py +14 -1
  6. {libs5_python-1.0.8 → libs5_python-1.0.10}/LICENSE +0 -0
  7. {libs5_python-1.0.8 → libs5_python-1.0.10}/MANIFEST.in +0 -0
  8. {libs5_python-1.0.8 → libs5_python-1.0.10}/README.md +0 -0
  9. {libs5_python-1.0.8 → libs5_python-1.0.10}/install.sh +0 -0
  10. {libs5_python-1.0.8 → libs5_python-1.0.10}/requirements.txt +0 -0
  11. {libs5_python-1.0.8 → libs5_python-1.0.10}/setup.py +0 -0
  12. {libs5_python-1.0.8 → libs5_python-1.0.10}/src/net/__init__.py +0 -0
  13. {libs5_python-1.0.8 → libs5_python-1.0.10}/src/net/hypki/File.py +0 -0
  14. {libs5_python-1.0.8 → libs5_python-1.0.10}/src/net/hypki/Logger.py +0 -0
  15. {libs5_python-1.0.8 → libs5_python-1.0.10}/src/net/hypki/StringUtils.py +0 -0
  16. {libs5_python-1.0.8 → libs5_python-1.0.10}/src/net/hypki/__init__.py +0 -0
  17. {libs5_python-1.0.8 → libs5_python-1.0.10}/src/net/hypki/apiutils.py +0 -0
  18. {libs5_python-1.0.8 → libs5_python-1.0.10}/src/net/hypki/asserts.py +0 -0
  19. {libs5_python-1.0.8 → libs5_python-1.0.10}/src/net/hypki/io.py +0 -0
  20. {libs5_python-1.0.8 → libs5_python-1.0.10}/src/net/hypki/log.py +0 -0
  21. {libs5_python-1.0.8 → libs5_python-1.0.10}/src/net/hypki/math.py +0 -0
  22. {libs5_python-1.0.8 → libs5_python-1.0.10}/src/net/hypki/random.py +0 -0
  23. {libs5_python-1.0.8 → libs5_python-1.0.10}/src/net/hypki/regex.py +0 -0
  24. {libs5_python-1.0.8 → libs5_python-1.0.10}/src/net/hypki/system.py +0 -0
  25. {libs5_python-1.0.8 → libs5_python-1.0.10}/src/net/hypki/tests/__init__.py +0 -0
  26. {libs5_python-1.0.8 → libs5_python-1.0.10}/src/net/hypki/tests/kepler.py +0 -0
  27. {libs5_python-1.0.8 → libs5_python-1.0.10}/src/net/hypki/tests/numpytest.py +0 -0
@@ -43,4 +43,8 @@ dist/libs5_python-1.0.5.tar.gz
43
43
  dist/libs5_python-1.0.6-py3-none-any.whl
44
44
  dist/libs5_python-1.0.6.tar.gz
45
45
  dist/libs5_python-1.0.7-py3-none-any.whl
46
- dist/libs5_python-1.0.7.tar.gz
46
+ dist/libs5_python-1.0.7.tar.gz
47
+ dist/libs5_python-1.0.8-py3-none-any.whl
48
+ dist/libs5_python-1.0.8.tar.gz
49
+ dist/libs5_python-1.0.9-py3-none-any.whl
50
+ dist/libs5_python-1.0.9.tar.gz
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: libs5-python
3
- Version: 1.0.8
3
+ Version: 1.0.10
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.8"
7
+ version = "1.0.10"
8
8
  authors = [
9
9
  { name="Arkadiusz Hypki" },
10
10
  ]
@@ -63,6 +63,29 @@ class Ini(object):
63
63
  keys.append(self.__getKey(line))
64
64
  return keys
65
65
 
66
+ def remove(self, section, key):
67
+ v = self.get(section, key)
68
+ if v is None:
69
+ return
70
+
71
+ newLines = []
72
+ currentSection = None
73
+ for line in self.__getIni():
74
+ if self.__isSection(line):
75
+ currentSection = self.__getSection(line)
76
+
77
+ currentKey = None
78
+ if self.__isKey(line):
79
+ currentKey = self.__getKey(line)
80
+
81
+ if currentSection is not None and currentSection == section and currentKey is not None and currentKey == key:
82
+ # not adding this line
83
+ pass
84
+ else:
85
+ newLines.append(line)
86
+
87
+ self.__iniLines = newLines
88
+
66
89
  def add(self, section, key, value):
67
90
  v = self.get(section, key)
68
91
  forceAdd = True
@@ -73,28 +96,58 @@ class Ini(object):
73
96
  def set(self, section, key, value, forceAdd = False):
74
97
  newLines = []
75
98
  currentSection = None
99
+ newKeyAdded = False
76
100
  for line in self.__getIni():
77
101
  lineAdded = False
78
102
 
79
103
  if self.__isSection(line):
80
104
  currentSection = self.__getSection(line)
81
105
 
82
- if forceAdd and currentSection is not None and currentSection == section:
106
+ if newKeyAdded is False and forceAdd and currentSection is not None and currentSection == section:
107
+ newLines.append(line)
83
108
  newLines.append(key + " = " + value)
84
109
  lineAdded = True
110
+ newKeyAdded = True
85
111
  else:
86
112
  if self.__isKey(line):
87
113
  currentKey = self.__getKey(line)
88
114
  if currentSection is not None and currentSection == section and currentKey == key:
89
115
  newLines.append(key + " = " + value)
90
116
  lineAdded = True
117
+ newKeyAdded = True
91
118
 
92
119
  if not lineAdded:
93
120
  newLines.append(line)
94
121
 
122
+ if newKeyAdded is False:
123
+ if forceAdd:
124
+ newLines.append(f"")
125
+ newLines.append(f"[{section}]")
126
+ newLines.append(f"{key} = {value}")
127
+
95
128
  self.__iniLines = newLines
96
129
 
97
- def get(self, section, key):
130
+ def getFloat(self, section, key, defaultValue = 0.0):
131
+ g = self.get(section, key, defaultValue = None)
132
+ if g is None:
133
+ return defaultValue
134
+ elif isinstance(g, str):
135
+ return float(g)
136
+ else:
137
+ return defaultValue
138
+
139
+ def getInt(self, section, key, defaultValue = 0):
140
+ g = self.get(section, key, defaultValue = None)
141
+ if g is None:
142
+ return defaultValue
143
+ elif isinstance(g, str):
144
+ return int(g)
145
+ elif isinstance(g, int):
146
+ return g
147
+ else:
148
+ return defaultValue
149
+
150
+ def get(self, section, key, defaultValue = None):
98
151
  currentSection = None
99
152
  for line in self.__getIni():
100
153
  if self.__isSection(line):
@@ -104,10 +157,22 @@ class Ini(object):
104
157
  currentKey = self.__getKey(line)
105
158
  if currentSection is not None and currentSection == section and currentKey == key:
106
159
  return line[(line.index("=") + 1):].strip()
107
- return None
160
+ return defaultValue
161
+
162
+ # names: this is list of strings in a format section.key e.g.: ['Mcluster.n', 'Mcluster.rh_mcl']
163
+ # values: tuple with values e.g.: ('50000', '1.0')
164
+ def updateValues(self, names, values):
165
+ i = 0
166
+ for oneCarth in values:
167
+ sec = names[i].split(".")[0]
168
+ key = names[i].split(".")[1]
169
+ value = oneCarth
170
+
171
+ self.set(sec, key, value)
172
+ i += 1
108
173
 
109
- def save(self):
174
+ def save(self, newPath = None):
110
175
  if self.__iniLines is not None:
111
- with open(self.__path, 'w') as f:
176
+ with open(self.__path if newPath is None else newPath, 'w') as f:
112
177
  for line in self.__iniLines:
113
178
  f.write(f"{line.strip()}\n")
@@ -7,6 +7,13 @@ Created on 15-06-2013
7
7
  import sys
8
8
 
9
9
  class ArgUtils:
10
+
11
+ def getStrings(name): # @NoSelf
12
+ v = []
13
+ for i in range(len(sys.argv)):
14
+ if sys.argv[i] == "--" + name or sys.argv[i] == "-" + name:
15
+ v.append(sys.argv[i + 1].strip())
16
+ return v
10
17
 
11
18
  def getString(name, defaultvalue): # @NoSelf
12
19
  for i in range(len(sys.argv)):
@@ -18,4 +25,10 @@ class ArgUtils:
18
25
  for i in range(len(sys.argv)):
19
26
  if sys.argv[i] == "--" + name or sys.argv[i] == "-" + name:
20
27
  return True
21
- return False
28
+ return False
29
+
30
+ def getArgsCount(): # @NoSelf
31
+ return len(sys.argv)
32
+
33
+ def getArg(idx): # @NoSelf
34
+ return sys.argv[idx]
File without changes
File without changes
File without changes
File without changes
File without changes