From 546d094e7a0a759a2ff77ae1a3ac0f4cf3476da2 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Wed, 13 Dec 2023 11:34:12 +0000 Subject: [PATCH] style: format code with Autopep8 This commit fixes the style issues introduced in 14062d4 according to the output from Autopep8. Details: None --- cogs/_Example.py | 6 ++++-- cogs/skyeval.py | 28 +++++++++++++++------------ cogs/skyfun.py | 30 +++++++++++++++-------------- cogs/skyhelp.py | 28 +++++++++++++++------------ cogs/skyloader.py | 21 +++++++++++--------- skySB.py | 13 +++++++------ utils.py | 49 +++++++++++++++++++++++++++-------------------- 7 files changed, 99 insertions(+), 76 deletions(-) diff --git a/cogs/_Example.py b/cogs/_Example.py index ffe8aa6..0affc3f 100644 --- a/cogs/_Example.py +++ b/cogs/_Example.py @@ -3,13 +3,15 @@ import utils from discord.ext import commands as skySB + class Example(skySB.Cog): def __init__(self, bot) -> None: self.bot = bot - + @skySB.command(description='hi') async def example(self, ctx) -> None: await utils.answer(ctx, 'Hello!') + async def setup(bot) -> None: - await bot.add_cog(Example(bot)) \ No newline at end of file + await bot.add_cog(Example(bot)) diff --git a/cogs/skyeval.py b/cogs/skyeval.py index 01726e9..d3b72e9 100644 --- a/cogs/skyeval.py +++ b/cogs/skyeval.py @@ -1,9 +1,9 @@ -# ______ __ __ __ __ ______ ______ -# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \ -# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __< +# ______ __ __ __ __ ______ ______ +# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \ +# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __< # \/\_____\ \ \_\ \_\ \/\_____\ \/\_____\ \ \_____\ # \/_____/ \/_/\/_/ \/_____/ \/_____/ \/_____/ -# +# # AGPL-3.0 license import ast @@ -11,6 +11,7 @@ from discord.ext import commands as skySB + def insert_returns(body): if isinstance(body[-1], ast.Expr): body[-1] = ast.Return(body[-1].value) @@ -21,6 +22,7 @@ def insert_returns(body): if isinstance(body[-1], ast.With): insert_returns(body[-1].body) + async def execute_python_code(code, env={}): try: fn_name = "_eval_expr" @@ -35,11 +37,12 @@ async def execute_python_code(code, env={}): except Exception as error: return error + class Eval(skySB.Cog): def __init__(self, bot): self.bot = bot self.langpack = utils.Langs.getcurrent()['eval'] - + @skySB.command( aliases=["eval", "py3", "python", "py"], description=utils.Langs.getcurrent()['eval']['e']['description'], @@ -49,7 +52,7 @@ async def e(self, ctx, *, code: str = None) -> None: if code: if code.startswith("```") and code.endswith("```"): code = "\n".join(code.split("\n")[1:])[:-3] - + result = await execute_python_code( code, { @@ -66,10 +69,10 @@ async def e(self, ctx, *, code: str = None) -> None: } ) if getattr(result, 'stringify', ''): - try: - result = str(result.stringify()) - except: - pass + try: + result = str(result.stringify()) + except: + pass await utils.answer( ctx, @@ -77,9 +80,10 @@ async def e(self, ctx, *, code: str = None) -> None: f"```py\n{code}\n```\n" f"{self.langpack['e']['result']}" f"```py\n{result}\n```" - ) + ) else: await utils.answer(ctx, utils.Langs.getcurrent()['argRequired'].format('code')) + async def setup(bot) -> None: - await bot.add_cog(Eval(bot)) \ No newline at end of file + await bot.add_cog(Eval(bot)) diff --git a/cogs/skyfun.py b/cogs/skyfun.py index 6b9e5a8..7b9611e 100644 --- a/cogs/skyfun.py +++ b/cogs/skyfun.py @@ -1,9 +1,9 @@ -# ______ __ __ __ __ ______ ______ -# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \ -# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __< +# ______ __ __ __ __ ______ ______ +# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \ +# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __< # \/\_____\ \ \_\ \_\ \/\_____\ \/\_____\ \ \_____\ # \/_____/ \/_/\/_/ \/_____/ \/_____/ \/_____/ -# +# # AGPL-3.0 license import random @@ -13,11 +13,12 @@ from discord.ext import commands as skySB import utils + class Fun(skySB.Cog): def __init__(self, bot): self.bot = bot self.langpack = utils.Langs.getcurrent()['fun'] - + @skySB.command( description=utils.Langs.getcurrent()['fun']['dick']['description'] ) @@ -26,10 +27,10 @@ async def dick(self, ctx, user: discord.User = None): mention = user.mention else: mention = self.bot.user - + size = random.randint(1, 1000) await utils.answer( - ctx, + ctx, self.langpack['dick']['text'].format(mention, size)) @skySB.command( @@ -40,12 +41,12 @@ async def iq(self, ctx, user: discord.User = None): mention = user.mention else: mention = self.bot.user - + iq = random.randint(1, 1000) await utils.answer( - ctx, + ctx, self.langpack['iq']['text'].format(mention, iq)) - + @skySB.command( description=utils.Langs.getcurrent()['fun']['gay']['description'] ) @@ -54,11 +55,12 @@ async def gay(self, ctx, user: discord.User = None): mention = user.mention else: mention = self.bot.user - + percent = random.randint(0, 101) await utils.answer( - ctx, + ctx, self.langpack['gay']['text'].format(mention, percent)) - + + async def setup(bot): - await bot.add_cog(Fun(bot)) \ No newline at end of file + await bot.add_cog(Fun(bot)) diff --git a/cogs/skyhelp.py b/cogs/skyhelp.py index e5ffdfd..830b3c9 100644 --- a/cogs/skyhelp.py +++ b/cogs/skyhelp.py @@ -1,20 +1,21 @@ -# ______ __ __ __ __ ______ ______ -# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \ -# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __< +# ______ __ __ __ __ ______ ______ +# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \ +# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __< # \/\_____\ \ \_\ \_\ \/\_____\ \/\_____\ \ \_____\ # \/_____/ \/_/\/_/ \/_____/ \/_____/ \/_____/ -# +# # AGPL-3.0 license import utils from discord.ext import commands as skySB + class Help(skySB.Cog): def __init__(self, bot): self.bot = bot self.langpack = utils.Langs.getcurrent()['help'] - + @skySB.command( aliases=["h", "commands"], description=utils.Langs.getcurrent()['help']['help']['description'] @@ -22,15 +23,18 @@ def __init__(self, bot): async def help(self, ctx, cmd: str = None): msg = '' msg += self.langpack['help']['title'] - msg += self.langpack['help']['prefix'].format(utils.config.get('prefix')) - + msg += self.langpack['help']['prefix'].format( + utils.config.get('prefix')) + for cog in self.bot.cogs: cog_commands = self.bot.get_cog(cog).get_commands() - + for command in cog_commands: - msg += self.langpack['help']['cmdformat'].format(command.name, command.description) - + msg += self.langpack['help']['cmdformat'].format( + command.name, command.description) + await utils.answer(ctx, msg) - + + async def setup(bot): - await bot.add_cog(Help(bot)) \ No newline at end of file + await bot.add_cog(Help(bot)) diff --git a/cogs/skyloader.py b/cogs/skyloader.py index 40def88..e24c84f 100644 --- a/cogs/skyloader.py +++ b/cogs/skyloader.py @@ -1,9 +1,9 @@ -# ______ __ __ __ __ ______ ______ -# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \ -# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __< +# ______ __ __ __ __ ______ ______ +# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \ +# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __< # \/\_____\ \ \_\ \_\ \/\_____\ \/\_____\ \ \_____\ # \/_____/ \/_/\/_/ \/_____/ \/_____/ \/_____/ -# +# # AGPL-3.0 license import aiohttp @@ -23,7 +23,8 @@ def __init__(self, bot): @skySB.command( aliases=["lm", "install", "le"], - description=utils.Langs.getcurrent()['loader']['loadExt']['description'] + description=utils.Langs.getcurrent( + )['loader']['loadExt']['description'] ) async def loadExt(self, ctx, *, url: str = None): await utils.answer(ctx, self.langpack['loadExt']['wait'].format(url)) @@ -62,7 +63,8 @@ async def loadExt(self, ctx, *, url: str = None): @skySB.command( aliases=["reload", "rl", "reloadcogs"], - description=utils.Langs.getcurrent()['loader']['reloadExt']['description'] + description=utils.Langs.getcurrent( + )['loader']['reloadExt']['description'] ) async def reloadExt(self, ctx): msg = '' @@ -72,12 +74,13 @@ async def reloadExt(self, ctx): extension = file[:-3] try: await self.bot.reload_extension(f"cogs.{extension}") - msg += self.langpack['reloadExt']['format'].format(extension) + msg += self.langpack['reloadExt']['format'].format( + extension) except: pass - + await utils.answer(ctx, msg) async def setup(bot): - await bot.add_cog(Loader(bot)) \ No newline at end of file + await bot.add_cog(Loader(bot)) diff --git a/skySB.py b/skySB.py index f405834..2c4cf14 100644 --- a/skySB.py +++ b/skySB.py @@ -1,9 +1,9 @@ -# ______ __ __ __ __ ______ ______ -# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \ -# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __< +# ______ __ __ __ __ ______ ______ +# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \ +# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __< # \/\_____\ \ \_\ \_\ \/\_____\ \/\_____\ \ \_____\ # \/_____/ \/_/\/_/ \/_____/ \/_____/ \/_____/ -# +# # AGPL-3.0 license import os @@ -15,6 +15,7 @@ print(motd) logger.warning(f'status: {Fore.YELLOW}loading...{Style.RESET}') + @bot.event async def on_ready(): os.system('clear') @@ -23,7 +24,7 @@ async def on_ready(): logger.warning(f'connected: {Style.BOLD}{bot.user}{Style.RESET}') logger.warning(f'prefix: {Style.BOLD}{config.get("prefix")}{Style.RESET}') print("-" * 45) - + for file in os.listdir(f"{os.path.realpath(os.path.dirname(__file__))}/cogs"): if file.startswith("_"): pass @@ -36,4 +37,4 @@ async def on_ready(): logger.error(f'{extension}: {exception}') while True: - bot.run(config.get('token'), log_handler=None) \ No newline at end of file + bot.run(config.get('token'), log_handler=None) diff --git a/utils.py b/utils.py index 5b778d1..d389e4e 100644 --- a/utils.py +++ b/utils.py @@ -1,9 +1,9 @@ -# ______ __ __ __ __ ______ ______ -# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \ -# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __< +# ______ __ __ __ __ ______ ______ +# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \ +# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __< # \/\_____\ \ \_\ \_\ \/\_____\ \/\_____\ \ \_____\ # \/_____/ \/_/\/_/ \/_____/ \/_____/ \/_____/ -# +# # AGPL-3.0 license import json @@ -19,7 +19,8 @@ from types import FunctionType # Logging -logging.basicConfig(format=f"%(asctime)s | [{Fore.CYAN}%(levelname)s{Style.RESET}] %(message)s", level=logging.WARNING, datefmt='%H:%M') +logging.basicConfig( + format=f"%(asctime)s | [{Fore.CYAN}%(levelname)s{Style.RESET}] %(message)s", level=logging.WARNING, datefmt='%H:%M') logger = logging.getLogger(__name__) @@ -34,34 +35,35 @@ ) bot.remove_command('help') + class Langs: @staticmethod def all() -> list: """ Get all langpacks - + Returns: List - list all langpacks in directory. """ return os.listdir('./langs/') - + @staticmethod def getcurrent() -> dict: """ Get current langpack - + Returns: Dict - langpack JSON data """ with open(config.get('language')) as f: langpack = json.load(f) return langpack - + @staticmethod def get(file: str) -> dict: """ Get langpack - + Parameters: file (String) - file path Returns: @@ -69,9 +71,10 @@ def get(file: str) -> dict: """ with open(file) as f: langpack = json.load(f) - + return langpack + # MOTD motd = """ ______ __ __ __ __ ______ ______ @@ -81,8 +84,9 @@ def get(file: str) -> dict: \/_____/ \/_/\/_/ \/_____/ \/_____/ \/_____/ """ + async def answer( - ctx, + ctx, message: str, photo: bool = False, document: bool = False, @@ -90,11 +94,11 @@ async def answer( ) -> str: """ Answer text - + Parameters: ctx (Content), message (String) - + Returns: String - message text """ @@ -108,19 +112,20 @@ async def answer( responses.append(await ctx.message.edit(message)) except: responses.append(await ctx.reply(message)) - + await asyncio.sleep(config.get('deletetimer')) - + for response in responses: await response.delete() return responses + def get_ram() -> float: """ ! from teagram - + Get your ram usage - + Returns: Float - ram usage """ @@ -134,10 +139,11 @@ def get_ram() -> float: except: return 0 + def get_cpu() -> float: """ ! from teagram - + Get CPU usage as a percentage Returns: @@ -157,10 +163,11 @@ def get_cpu() -> float: except: return 0 + def get_platform() -> str: """ ! from teagram - + Get the platform information Returns: @@ -190,4 +197,4 @@ def get_platform() -> str: elif IS_ZACHOST: return "❔ Zachem㉿Host" else: - return "🖥️ VDS" \ No newline at end of file + return "🖥️ VDS"