Skip to content

Commit 698667e

Browse files
authored
Upgrade to v0.1.1
Fixing CLI bugs: - Printing bitmasks - Parsing bitmasks as name
2 parents 72964a5 + cae3b52 commit 698667e

3 files changed

Lines changed: 23 additions & 12 deletions

File tree

feClient/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.1.0"
1+
__version__ = "0.1.1"
22
__doc__ = """
33
Python client for Fusion Explorer API v{}
44
Copyright (C) 2021 Fusion Solutions KFT <contact@fusionsolutions.io>

feClient/__main__.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
2222
Use optional environment keys {PUB_ENV_NAME} for public key and {SEC_ENV_NAME} for secret. If you use you need set both.
2323
For set:
24-
export {PUB_ENV_NAME}="YOUR_PUBLIC_KEY" {SEC_ENV_NAME}="YOUR_SECRET_KEY"
24+
export {PUB_ENV_NAME}="YOUR_PUBLIC_KEY" {SEC_ENV_NAME}="YOUR_SECRET_KEY"
2525
For unset:
26-
unset {PUB_ENV_NAME} {SEC_ENV_NAME}
26+
unset {PUB_ENV_NAME} {SEC_ENV_NAME}
2727
2828
All numbers will be converted into decimal string, but you can use {CONVERTHEX_ENV_NAME} enviroment if you want in hexadecimal:
2929
export {CONVERTHEX_ENV_NAME}="1"
@@ -60,7 +60,7 @@ class LevelBitmask:
6060
def parseByName(cls, data:str) -> int:
6161
r = 0
6262
for name in data.split(","):
63-
r |= cls.data[name][0]
63+
r |= toInt(cls.data[name][0])
6464
return r
6565

6666
class Parameters:
@@ -106,7 +106,7 @@ def parseType(cls, name:str, typ:str) -> Any:
106106
return {
107107
"str":str,
108108
"bytes":cls._bytes,
109-
"int":int,
109+
"int":toInt,
110110
"bool":cls._bool,
111111
"dict":cls._dict,
112112
"list":cls._dict,
@@ -139,6 +139,15 @@ def printResult(r:Any) -> None:
139139
else:
140140
print(r)
141141

142+
def toInt(input:Any) -> int:
143+
if type(input) is int:
144+
return input
145+
elif type(input) is str:
146+
if input[:2].lower() == "0x":
147+
return int(input, 16)
148+
return int(input)
149+
raise RuntimeError
150+
142151
def main() -> None:
143152
inputs:List[str] = []
144153
_inputs = sys.argv[:]
@@ -203,6 +212,13 @@ def main() -> None:
203212
pass
204213
#
205214
if method in ["", "help"] and not args and not kwargs:
215+
bitmaskLines:List[Tuple[str, str]] = [
216+
(
217+
"{0:>{stack}}{name}".format("", name=bid, stack=toInt(bdet[1])*2),
218+
bdet[2],
219+
) for bid, bdet in LevelBitmask.data.items()
220+
]
221+
optimalBitmaskIDColumnLength = max([ len(x[0]) for x in bitmaskLines]) if bitmaskLines else 0
206222
ret = [__doc__.format(
207223
version=__version__,
208224
PUB_ENV_NAME=PUB_ENV_NAME,
@@ -212,12 +228,7 @@ def main() -> None:
212228
CACHEPATH_ENV_NAME=CACHEPATH_ENV_NAME,
213229
CONVERTHEX_ENV_NAME=CONVERTHEX_ENV_NAME,
214230
selfName=selfName,
215-
bitmasks="\n".join(
216-
map(
217-
lambda x: "{:<32}{}".format(" {0:>{stack}}{name}".format("", name=x[0], stack=x[1][1]*4), x[1][2]),
218-
LevelBitmask.data.items(),
219-
)
220-
),
231+
bitmasks="\n".join([" {0:<{pad}} {1}".format(*x, pad=optimalBitmaskIDColumnLength) for x in bitmaskLines]),
221232
)]
222233
for name in sorted(methods.keys()):
223234
m = methods[name]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
setup(
1111
name = "python-feclient",
12-
version = "0.1.0",
12+
version = "0.1.1",
1313
description = "Client for Fusion Explorer",
1414
keywords = "explorer client fusion solutions fusionsolutions fusionexplorer",
1515
author = "Andor `iFA` Rajci - Fusions Solutions KFT",

0 commit comments

Comments
 (0)