PythonIota 0.0.1__py2.py3-none-any.whl → 0.0.2__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 CHANGED
@@ -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
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PythonIota
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: PythonIota may be an imitation of iota() function in Go,C++ etc.
5
5
  Author: Equinox
6
6
  Classifier: Programming Language :: Python :: 3
@@ -0,0 +1,6 @@
1
+ PythonIota/__init__.py,sha256=HeXmmBdfXUbgmgKrXOphs6xSQ08UAtrru92VAaqXswM,2095
2
+ PythonIota-0.0.2.dist-info/LICENSE.txt,sha256=jDhAhcffq3QKkJPRsbQcAu7QgJnI1CEvw4xVaR2Ah9I,1094
3
+ PythonIota-0.0.2.dist-info/METADATA,sha256=YeM2f1oILnEEJNPZDZJ_yqqXRfZ76DTdb7FeSvok7Cc,660
4
+ PythonIota-0.0.2.dist-info/WHEEL,sha256=pWvVuNuBTVmNV7Lp2jMAgt1NplTICeFdl1SW8U3MWN4,109
5
+ PythonIota-0.0.2.dist-info/top_level.txt,sha256=MjQgWV8gW1VJtbqpyUML_Gs-k3VhxU7z1XlHE00GqMg,11
6
+ PythonIota-0.0.2.dist-info/RECORD,,
PythonIota/main.py DELETED
@@ -1,71 +0,0 @@
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
-
@@ -1,7 +0,0 @@
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,,