Browse Source

Removed f-strings

fstring
Laurent Kislaire 9 months ago
parent
commit
13012e40ea
4 changed files with 17 additions and 17 deletions
  1. +3
    -3
      pyfbx/__main__.py
  2. +8
    -8
      pyfbx/client.py
  3. +2
    -2
      pyfbx/mdns.py
  4. +4
    -4
      pyfbx/utils.py

+ 3
- 3
pyfbx/__main__.py View File

@@ -43,13 +43,13 @@ def main():
with open(args.token[2:]) as tok_file:
token = tok_file.read().strip()
else:
log.warning(f"Registering app {__name__}, id {args.app_id}, Press button")
log.warning("Registering app {}, id {}, Press button".format(__name__, args.app_id))
token = myfb.register(app_id=args.app_id, app_name=__name__,
device=os.uname().nodename)
log.warning(f"Save your application token: {token}")
log.warning("Save your application token: {}".format(token))
myfb.mksession(app_id=args.app_id, token=token)
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(eval(f"myfb.{args.command}"))
pp.pprint(eval("myfb.{}".format(args.command)))
return 0
except BaseException as err:
print(err)

+ 8
- 8
pyfbx/client.py View File

@@ -66,14 +66,14 @@ class FbxTransport():
response = req_response.json()
if response['success']:
if 'result' in response:
self.log.debug(f"<< Got {response['result']}")
self.log.debug("<< Got {}".format(response['result']))
return response['result']
else:
raise FbxErrorResponse(response['error_code'], response['msg'])

def get_local_base(self, url=api._DISC_HTTP_URL):
response = self._session.get(f"{url}/api_version").json()
self.log.debug(f"<< Detected api {response['api_version']}")
response = self._session.get("{}/api_version".format(url)).json()
self.log.debug("<< Detected api {}".format(response['api_version']))
return "%s%sv%s" % (url, response['api_base_url'],
response['api_version'][0])

@@ -105,10 +105,10 @@ class Fbx():
s = "pending"
self.log.info("Press Ok on the freebox to register application")
while s == "pending":
s = self._trn.api_exec("GET", f"login/authorize/{trackid}")["status"]
s = self._trn.api_exec("GET", "login/authorize/{}".format(trackid))["status"]
if s == "pending":
time.sleep(1)
self.log.debug(f"Registration returned: {s}")
self.log.debug("Registration returned: {}".format(s))
return s == "granted" and self.token

def mksession(self, app_id=None, token=None):
@@ -128,7 +128,7 @@ class Fbx():
session_token = resp["session_token"]
self.app_id = app_id
self._trn.set_session_header(session_token)
self.log.info(f"Authenticated")
self.log.info("Authenticated".format())
return resp["permissions"]


@@ -138,13 +138,13 @@ class FbxErrorResponse(Exception):
self.msg = msg

def __str__(self):
return f'{self.msg} [{self.error_code}]'
return '{} [{}]'.format(self.msg, self.error_code)


log = logging.getLogger("pyfbx")

# All FB subsystems are classes deriving from FbxClass
for _classname in api.SYSTEMS:
log.debug(f"Adding class {_classname} to locals")
log.debug("Adding class {} to locals".format(_classname))
locals()[_classname] = type(_classname, (FbxClass, ), {})
__all__.append(_classname)

+ 2
- 2
pyfbx/mdns.py View File

@@ -45,9 +45,9 @@ class FbxMDNS():
prop = self.svc_prop
base = "%sv%s" % (prop['api_base_url'], prop['api_version'][0])
if int(prop['https_available']):
return f"https://{prop['api_domain']}:{prop['https_port']}{base}"
return "https://{}:{}{}".format(prop['api_domain'], prop['https_port'], base)
else:
return f"http://{prop['api_domain']}{base}"
return "http://{}{}".format(prop['api_domain'], base)

@property
def svc_info(self):

+ 4
- 4
pyfbx/utils.py View File

@@ -37,11 +37,11 @@ def add_class_func(cls, name, method):

params = (["post_data"] if method.args else []) + get_params(method.endpoint)
input_params = ", ".join(params)
passed_param = ", ".join([f"{e}={e}" for e in params])
passed_param = ", ".join(["{}={}".format(e, e) for e in params])
namespace = {}
code = (f"def func(self, {input_params}):\n"
f" return self._trn.api_exec(\n"
f" \"{method.http_method}\", \"{method.endpoint}\", {passed_param})")
code = ("def func(self, {}):\n"
" return self._trn.api_exec(\n"
" \"{}\", \"{}\", {})".format(input_params, method.http_method, method.endpoint, passed_param))
exec(code, namespace)
func = namespace['func']
func.__name__ = name

Loading…
Cancel
Save