From aba5c321a5bbdaa9f47791b2aee456caa566cd98 Mon Sep 17 00:00:00 2001 From: ks123 Date: Sat, 28 Mar 2020 10:54:03 +0200 Subject: (PEP Command): Hard-coded PEP 0 --- bot/cogs/utils.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/bot/cogs/utils.py b/bot/cogs/utils.py index 024141d62..db8f63ff4 100644 --- a/bot/cogs/utils.py +++ b/bot/cogs/utils.py @@ -40,6 +40,14 @@ If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those! """ +PEP0_TITLE = "Index of Python Enhancement Proposals (PEPs)" +PEP0_INFO = { + "Status": "Active", + "Created": "13-Jul-2000", + "Type": "Informational" +} +PEP0_LINK = "https://www.python.org/dev/peps/" + class Utils(Cog): """A selection of utilities which don't have a clear category.""" @@ -59,6 +67,19 @@ class Utils(Cog): await ctx.invoke(self.bot.get_command("help"), "pep") return + # Handle PEP 0 directly due it's not available like other PEPs (use constants) + if pep_number == 0: + pep_embed = Embed( + title=f"**PEP 0 - {PEP0_TITLE}**", + description=f"[Link]({PEP0_LINK})" + ) + pep_embed.set_thumbnail(url="https://www.python.org/static/opengraph-icon-200x200.png") + for field, value in PEP0_INFO.items(): + pep_embed.add_field(name=field, value=value) + + await ctx.send(embed=pep_embed) + return + possible_extensions = ['.txt', '.rst'] found_pep = False for extension in possible_extensions: -- cgit v1.2.3 From e955b83784c91c0144334b744f1d5e139a1d957f Mon Sep 17 00:00:00 2001 From: ks123 Date: Sat, 28 Mar 2020 20:28:24 +0200 Subject: (PEP Command): Fixed comment of explanation of PEP 0 different processing. --- bot/cogs/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot/cogs/utils.py b/bot/cogs/utils.py index db8f63ff4..f35ff0f03 100644 --- a/bot/cogs/utils.py +++ b/bot/cogs/utils.py @@ -67,7 +67,8 @@ class Utils(Cog): await ctx.invoke(self.bot.get_command("help"), "pep") return - # Handle PEP 0 directly due it's not available like other PEPs (use constants) + # Handle PEP 0 directly due it's static constant in PEPs GitHub repo in Python file, not .rst or .txt so it + # can't be accessed like other PEPs. if pep_number == 0: pep_embed = Embed( title=f"**PEP 0 - {PEP0_TITLE}**", -- cgit v1.2.3 From 317b5db5585ae72adf112508165fc6e161792948 Mon Sep 17 00:00:00 2001 From: ks123 Date: Sun, 29 Mar 2020 08:55:22 +0300 Subject: (PEP Command): Moved icon URL to constant instead hard-coded string. --- bot/cogs/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bot/cogs/utils.py b/bot/cogs/utils.py index f35ff0f03..d15edd0a0 100644 --- a/bot/cogs/utils.py +++ b/bot/cogs/utils.py @@ -48,6 +48,8 @@ PEP0_INFO = { } PEP0_LINK = "https://www.python.org/dev/peps/" +ICON_URL = "https://www.python.org/static/opengraph-icon-200x200.png" + class Utils(Cog): """A selection of utilities which don't have a clear category.""" @@ -74,7 +76,7 @@ class Utils(Cog): title=f"**PEP 0 - {PEP0_TITLE}**", description=f"[Link]({PEP0_LINK})" ) - pep_embed.set_thumbnail(url="https://www.python.org/static/opengraph-icon-200x200.png") + pep_embed.set_thumbnail(url=ICON_URL) for field, value in PEP0_INFO.items(): pep_embed.add_field(name=field, value=value) @@ -104,7 +106,7 @@ class Utils(Cog): description=f"[Link]({self.base_pep_url}{pep_number:04})", ) - pep_embed.set_thumbnail(url="https://www.python.org/static/opengraph-icon-200x200.png") + pep_embed.set_thumbnail(url=ICON_URL) # Add the interesting information fields_to_check = ("Status", "Python-Version", "Created", "Type") -- cgit v1.2.3 From 3e819043ce0538682b4512382974b641dc6872c0 Mon Sep 17 00:00:00 2001 From: ks123 Date: Sun, 29 Mar 2020 09:03:27 +0300 Subject: (PEP Command): Moved PEP 0 information to hard-coded strings from constants, moved PEP 0 sending to function. --- bot/cogs/utils.py | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/bot/cogs/utils.py b/bot/cogs/utils.py index d15edd0a0..3cd259b35 100644 --- a/bot/cogs/utils.py +++ b/bot/cogs/utils.py @@ -40,14 +40,6 @@ If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those! """ -PEP0_TITLE = "Index of Python Enhancement Proposals (PEPs)" -PEP0_INFO = { - "Status": "Active", - "Created": "13-Jul-2000", - "Type": "Informational" -} -PEP0_LINK = "https://www.python.org/dev/peps/" - ICON_URL = "https://www.python.org/static/opengraph-icon-200x200.png" @@ -72,16 +64,7 @@ class Utils(Cog): # Handle PEP 0 directly due it's static constant in PEPs GitHub repo in Python file, not .rst or .txt so it # can't be accessed like other PEPs. if pep_number == 0: - pep_embed = Embed( - title=f"**PEP 0 - {PEP0_TITLE}**", - description=f"[Link]({PEP0_LINK})" - ) - pep_embed.set_thumbnail(url=ICON_URL) - for field, value in PEP0_INFO.items(): - pep_embed.add_field(name=field, value=value) - - await ctx.send(embed=pep_embed) - return + return await self.send_pep_zero(ctx) possible_extensions = ['.txt', '.rst'] found_pep = False @@ -302,6 +285,19 @@ class Utils(Cog): for reaction in options: await message.add_reaction(reaction) + async def send_pep_zero(self, ctx: Context) -> None: + """Send information about PEP 0.""" + pep_embed = Embed( + title=f"**PEP 0 - Index of Python Enhancement Proposals (PEPs)**", + description=f"[Link](https://www.python.org/dev/peps/)" + ) + pep_embed.set_thumbnail(url=ICON_URL) + pep_embed.add_field(name="Status", value="Active") + pep_embed.add_field(name="Created", value="13-Jul-2000") + pep_embed.add_field(name="Type", value="Informational") + + await ctx.send(embed=pep_embed) + def setup(bot: Bot) -> None: """Load the Utils cog.""" -- cgit v1.2.3 From 8bebc1e68dba2252a0a7abee456bf02512c1e60e Mon Sep 17 00:00:00 2001 From: ks123 Date: Sun, 29 Mar 2020 09:06:00 +0300 Subject: (PEP Command): Fixed comment about PEP 0 separately handling. --- bot/cogs/utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bot/cogs/utils.py b/bot/cogs/utils.py index 3cd259b35..f0b1172e3 100644 --- a/bot/cogs/utils.py +++ b/bot/cogs/utils.py @@ -61,8 +61,7 @@ class Utils(Cog): await ctx.invoke(self.bot.get_command("help"), "pep") return - # Handle PEP 0 directly due it's static constant in PEPs GitHub repo in Python file, not .rst or .txt so it - # can't be accessed like other PEPs. + # Handle PEP 0 directly because it's not in .rst or .txt so it can't be accessed like other PEPs. if pep_number == 0: return await self.send_pep_zero(ctx) -- cgit v1.2.3