PythonIota 0.0.1__py2.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.
PythonIota/__init__.py ADDED
File without changes
PythonIota/main.py ADDED
@@ -0,0 +1,71 @@
1
+ import re
2
+
3
+
4
+ def is_expression(s):
5
+ pattern = r'^[\d+iota\s+\-*/()]+$'
6
+ return True if re.match(pattern, s) else False
7
+
8
+
9
+ class Iota:
10
+ def __init__(self, initial=0):
11
+ self.current = initial
12
+ self.values = {}
13
+
14
+ def __call__(self, **kwargs):
15
+ for key, value in kwargs.items():
16
+ if value == "iota":
17
+ self.values[key] = 0
18
+ self.current = 1
19
+
20
+ elif value == '':
21
+ self.values[key] = self.current
22
+ self.current += 1
23
+
24
+ elif value == "_":
25
+ self.current += 1
26
+
27
+ elif value.isdigit():
28
+ self.values[key] = int(value)
29
+ self.current = self.values[key]+1
30
+
31
+
32
+ elif is_expression(value):
33
+ if "iota" in value:
34
+ value = value.replace("iota", str(self.current))
35
+ self.values[key] = eval(value)
36
+ self.current = self.values[key] + 1
37
+ else:
38
+ self.values[key] = eval(value)
39
+ self.current = self.values[key] + 1
40
+
41
+ elif len(value) == 1 and value.isalpha():
42
+ # 如果值是单个字母,则赋值为上一个值加1
43
+ self.values[key] = self.values[list(kwargs.keys())[-2]] + 1
44
+ else:
45
+ raise ValueError("Invalid value for iota assignment.")
46
+ setattr(self, key, self.values[key])
47
+
48
+ def __parseInput__(self,input_str):
49
+ lines = input_str.strip().split("\n")
50
+ args = {}
51
+ for line in lines:
52
+ if '=' in line:
53
+ key, value = line.split('=',1)
54
+ key = key.strip()
55
+ value = value.strip()
56
+ else:
57
+ key = line.strip()
58
+ value = ''
59
+ args[key] = value
60
+ self(**args)
61
+
62
+ def get_values(self):
63
+ return self.values
64
+
65
+
66
+
67
+ #iota_instance(AA="iota", BB="2*3", _="_", ZZ="99", CC="(iota+1)*2", DD="")
68
+ #print(iota_instance.get_values())
69
+
70
+
71
+
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2021 The Python Packaging Authority
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,31 @@
1
+ Metadata-Version: 2.1
2
+ Name: PythonIota
3
+ Version: 0.0.1
4
+ Summary: PythonIota may be an imitation of iota() function in Go,C++ etc.
5
+ Author: Equinox
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.6
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE.txt
12
+
13
+ Pyota may be an imitation of iota() function in Go,C++ etc.
14
+
15
+ # Use as follows:
16
+
17
+ ``````
18
+ newiota = Iota()
19
+
20
+ newiota.__parseInput__('''
21
+ A
22
+ B = iota
23
+ C
24
+ _
25
+ D = 6*8
26
+ E
27
+ F = iota+100
28
+ ''')
29
+
30
+ print(newiota.get_values())
31
+ print(newiota.F)
@@ -0,0 +1,7 @@
1
+ PythonIota/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ PythonIota/main.py,sha256=HeXmmBdfXUbgmgKrXOphs6xSQ08UAtrru92VAaqXswM,2095
3
+ PythonIota-0.0.1.dist-info/LICENSE.txt,sha256=jDhAhcffq3QKkJPRsbQcAu7QgJnI1CEvw4xVaR2Ah9I,1094
4
+ PythonIota-0.0.1.dist-info/METADATA,sha256=rX9lIDS0Iz6izPlByosx6uiaRT53hTkkmoUeaKzoPXo,660
5
+ PythonIota-0.0.1.dist-info/WHEEL,sha256=pWvVuNuBTVmNV7Lp2jMAgt1NplTICeFdl1SW8U3MWN4,109
6
+ PythonIota-0.0.1.dist-info/top_level.txt,sha256=MjQgWV8gW1VJtbqpyUML_Gs-k3VhxU7z1XlHE00GqMg,11
7
+ PythonIota-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,6 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (70.3.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py2-none-any
5
+ Tag: py3-none-any
6
+
@@ -0,0 +1 @@
1
+ PythonIota