From 1ca192362a1e5a04e94daa7f97a988312f890e44 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 12 Dec 2023 17:33:54 +0000 Subject: [PATCH] style: format code with Autopep8, Black, isort and Yapf This commit fixes the style issues introduced in 7206365 according to the output from Autopep8, Black, isort and Yapf. Details: None --- setup.py | 36 ++++++++-------- trustauthx/cli.py | 106 ++++++++++++++++++++++++++-------------------- 2 files changed, 78 insertions(+), 64 deletions(-) diff --git a/setup.py b/setup.py index c268021..43fb60d 100644 --- a/setup.py +++ b/setup.py @@ -1,27 +1,27 @@ -from setuptools import setup, find_packages import os +from setuptools import find_packages, setup + this_directory = os.path.abspath(os.path.dirname(__file__)) -with open(os.path.join(this_directory, 'README.md'), encoding='utf-8') as f: +with open(os.path.join(this_directory, "README.md"), encoding="utf-8") as f: long_description = f.read() - setup( - name='trustauthx', - version='0.5.2', - description='Official connector SDK for TrustAuthx', + name="trustauthx", + version="0.5.2", + description="Official connector SDK for TrustAuthx", long_description=long_description, - long_description_content_type='text/markdown', # This is important! - author='moonlightnexus', - author_email='nexus@trustauthx.com', + long_description_content_type="text/markdown", # This is important! + author="moonlightnexus", + author_email="nexus@trustauthx.com", url="https://github.com/One-Click-Auth/TrustAuthx-Py-SDK.git", license="MIT", classifiers=[ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 3.9', - ], + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3.9", + ], packages=find_packages(), install_requires=[ "certifi>=2023.5.7", @@ -37,11 +37,11 @@ "urllib3<=3.0.0", "charset-normalizer>=3.2.0", "python-jose>=3.3.0", - "python-dotenv==1.0.0" - ], + "python-dotenv==1.0.0", + ], entry_points={ - 'console_scripts': [ - 'trustauthx = trustauthx.cli:main', + "console_scripts": [ + "trustauthx = trustauthx.cli:main", ], }, ) diff --git a/trustauthx/cli.py b/trustauthx/cli.py index 52425ec..516d1fd 100644 --- a/trustauthx/cli.py +++ b/trustauthx/cli.py @@ -1,28 +1,33 @@ import argparse -from .llmai import LLMAI_Inter +import os import subprocess -import sys, os, time +import sys +import time + from dotenv import load_dotenv +from .llmai import LLMAI_Inter + + def main(): - parser = argparse.ArgumentParser(prog='trustauthx') - load_dotenv(dotenv_path='./.env', override=True, verbose=True) - api_key = os.environ.get('API_KEY') - api_secret = os.environ.get('API_SECRET') - org_id = os.environ.get('ORG_ID') - - parser.add_argument('command') - parser.add_argument('framework') - - parser.add_argument('-k', required=not api_key, help='API key') - parser.add_argument('-s', required=not api_secret, help='API secret') - parser.add_argument('-o', required=not org_id, help='Organization ID') + parser = argparse.ArgumentParser(prog="trustauthx") + load_dotenv(dotenv_path="./.env", override=True, verbose=True) + api_key = os.environ.get("API_KEY") + api_secret = os.environ.get("API_SECRET") + org_id = os.environ.get("ORG_ID") + + parser.add_argument("command") + parser.add_argument("framework") + + parser.add_argument("-k", required=not api_key, help="API key") + parser.add_argument("-s", required=not api_secret, help="API secret") + parser.add_argument("-o", required=not org_id, help="Organization ID") args = parser.parse_args() # try: if args.k and args.s and args.o: if api_key or api_secret or org_id: - file_path = './.env' + file_path = "./.env" if os.path.isfile(file_path): os.remove(file_path) else: @@ -32,41 +37,46 @@ def main(): time.sleep(1) print("\nEverything Done Status 200, Successfully logged out") else: - env_vars = { - "API_KEY": args.k, - "API_SECRET": args.s, - "ORG_ID": args.o - } - with open('.env', 'w') as f: + env_vars = {"API_KEY": args.k, "API_SECRET": args.s, "ORG_ID": args.o} + with open(".env", "w") as f: for key, value in env_vars.items(): - f.write(f'{key}={value}\n') - load_dotenv(dotenv_path='./.env', override=True, verbose=True) - api_key = os.environ.get('API_KEY') - api_secret = os.environ.get('API_SECRET') - org_id = os.environ.get('ORG_ID') + f.write(f"{key}={value}\n") + load_dotenv(dotenv_path="./.env", override=True, verbose=True) + api_key = os.environ.get("API_KEY") + api_secret = os.environ.get("API_SECRET") + org_id = os.environ.get("ORG_ID") - if api_key or api_secret or org_id: pass - else: print(f"no .env found, api_key {not bool(api_key)}, api_secret {not bool(api_secret)}, org_id {not bool(org_id)}") + if api_key or api_secret or org_id: + pass + else: + print( + f"no .env found, api_key {not bool(api_key)}, api_secret {not bool(api_secret)}, org_id {not bool(org_id)}" + ) client = LLMAI_Inter(api_key, api_secret, org_id, "") - print("\ngetting auth status ...") - if not client.arb_login():raise ConnectionRefusedError("user not found, invalid credential") + print("\ngetting auth status ...") + if not client.arb_login(): + raise ConnectionRefusedError("user not found, invalid credential") print("\nauthorization success, credentials valid") - - if args.command == 'neuroform': - client.framework=args.framework + + if args.command == "neuroform": + client.framework = args.framework sdk = client print("\ngetting req. dependencies:") list_depends = sdk.Install_dependancies() print(list_depends) print("\nInstalling dependencies...") + def install(packages): if packages == "pip install fastapi['all']": subprocess.call("pip install fastapi['all']", shell=True) return if isinstance(packages, list): - for package in packages:subprocess.call(package, shell=True) - else:subprocess.call(packages, shell=True) + for package in packages: + subprocess.call(package, shell=True) + else: + subprocess.call(packages, shell=True) + install(list_depends) print("\nDependencies installed.") a = sdk.Create_App(path=os.getcwd()) @@ -74,26 +84,30 @@ def install(packages): print("\nApp named --> authx.py") print(f"\napp located at --> {os.path.join(os.getcwd(), 'authx.py')}") print("\nApp creation Successful...") - print(f"\nyou could start the server with command trustauthx start {args.framework}") - - if args.command == 'start': - client.framework=args.framework + print( + f"\nyou could start the server with command trustauthx start {args.framework}" + ) + + if args.command == "start": + client.framework = args.framework sdk = client print("\nTrying to start local server ...") - print("\nthis command might fail in case of few frameworks in such cases consider installing req. lib. and starting server manually") + print( + "\nthis command might fail in case of few frameworks in such cases consider installing req. lib. and starting server manually" + ) b = sdk.Start_server() process = subprocess.Popen(b, shell=True) process.wait() - if args.command == 'login': + if args.command == "login": time.sleep(0.5) print("\nattempt to Login TrustAuthx Build AI successful") print("\nExecuting Rate-Limit") time.sleep(1) print("\nEverything Done Status 200, Ready To Start") - if args.command == 'logout': - file_path = './.env' + if args.command == "logout": + file_path = "./.env" if os.path.isfile(file_path): os.remove(file_path) else: @@ -103,9 +117,9 @@ def install(packages): time.sleep(1) print("\nEverything Done Status 200, Successfully logged out") -if __name__ == '__main__': - main() +if __name__ == "__main__": + main() # if args.command == 'fabricate': # client.framework=args.framework @@ -120,4 +134,4 @@ def install(packages): # install(list_depends) # print("\nDependencies installed.") # a = sdk.Create_App(out=args.out) - # print(a) \ No newline at end of file + # print(a)