PythonIota 0.0.1__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.
- pythoniota-0.0.1/LICENSE.txt +19 -0
- pythoniota-0.0.1/PKG-INFO +31 -0
- pythoniota-0.0.1/PythonIota/__init__.py +0 -0
- pythoniota-0.0.1/PythonIota/main.py +71 -0
- pythoniota-0.0.1/PythonIota.egg-info/PKG-INFO +31 -0
- pythoniota-0.0.1/PythonIota.egg-info/SOURCES.txt +9 -0
- pythoniota-0.0.1/PythonIota.egg-info/dependency_links.txt +1 -0
- pythoniota-0.0.1/PythonIota.egg-info/top_level.txt +1 -0
- pythoniota-0.0.1/README.md +19 -0
- pythoniota-0.0.1/setup.cfg +4 -0
- pythoniota-0.0.1/setup.py +20 -0
|
@@ -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)
|
|
File without changes
|
|
@@ -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,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 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
PythonIota
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Pyota may be an imitation of iota() function in Go,C++ etc.
|
|
2
|
+
|
|
3
|
+
# Use as follows:
|
|
4
|
+
|
|
5
|
+
``````
|
|
6
|
+
newiota = Iota()
|
|
7
|
+
|
|
8
|
+
newiota.__parseInput__('''
|
|
9
|
+
A
|
|
10
|
+
B = iota
|
|
11
|
+
C
|
|
12
|
+
_
|
|
13
|
+
D = 6*8
|
|
14
|
+
E
|
|
15
|
+
F = iota+100
|
|
16
|
+
''')
|
|
17
|
+
|
|
18
|
+
print(newiota.get_values())
|
|
19
|
+
print(newiota.F)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import setuptools
|
|
2
|
+
|
|
3
|
+
with open("README.md", "r", encoding="utf-8") as fh:
|
|
4
|
+
long_description = fh.read()
|
|
5
|
+
|
|
6
|
+
setuptools.setup(
|
|
7
|
+
name="PythonIota",
|
|
8
|
+
version="0.0.1",
|
|
9
|
+
author="Equinox",
|
|
10
|
+
description="PythonIota may be an imitation of iota() function in Go,C++ etc.",
|
|
11
|
+
long_description=long_description,
|
|
12
|
+
long_description_content_type="text/markdown",
|
|
13
|
+
packages=setuptools.find_packages(),
|
|
14
|
+
classifiers=[
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
],
|
|
19
|
+
python_requires='>=3.6',
|
|
20
|
+
)
|