diff options
author | 2019-07-22 17:44:21 -0400 | |
---|---|---|
committer | 2019-07-22 17:44:21 -0400 | |
commit | 75585469ebef6e560c6650105c9e6b7a5521bd62 (patch) | |
tree | a5d63f518f8549179224496a0ea5a761b8379a87 | |
parent | Rename variables for clarity, fix extraneous whitespace from review (diff) |
Apply suggestions from code review
* Unify use of apostophes & quotes in JSON resources
* Sync use of pathlib to the rest of the codebase
* Remove unnecessary string conversions
* Remove unnecessary dictionary `.get()` call without specifying a default
* Other minor syntax modifications
Co-Authored-By: Mark <[email protected]>
-rw-r--r-- | bot/resources/easter/easter_egg_facts.json | 16 | ||||
-rw-r--r-- | bot/seasons/easter/bunny_name_generator.py | 4 | ||||
-rw-r--r-- | bot/seasons/easter/easter_riddle.py | 2 | ||||
-rw-r--r-- | bot/seasons/easter/egg_facts.py | 4 | ||||
-rw-r--r-- | bot/seasons/evergreen/issues.py | 6 |
5 files changed, 16 insertions, 16 deletions
diff --git a/bot/resources/easter/easter_egg_facts.json b/bot/resources/easter/easter_egg_facts.json index 7248045e..ee6d4678 100644 --- a/bot/resources/easter/easter_egg_facts.json +++ b/bot/resources/easter/easter_egg_facts.json @@ -1,20 +1,20 @@ [ "The first story of a rabbit (later named the \"Easter Bunny\") hiding eggs in a garden was published in 1680.", - "Rabbits are known to be prolific pro creators and are an ancient symbol of fertility and new life. The German immigrants brought the tale of Easter Bunny in the 1700s with the tradition of an egg-laying hare called ‘Osterhase\". The kids then would make nests in which the creature would lay coloured eggs. The tradition has been revolutionized in the form of candies and gifts instead of eggs.", + "Rabbits are known to be prolific pro creators and are an ancient symbol of fertility and new life. The German immigrants brought the tale of Easter Bunny in the 1700s with the tradition of an egg-laying hare called \"Osterhase\". The kids then would make nests in which the creature would lay coloured eggs. The tradition has been revolutionized in the form of candies and gifts instead of eggs.", "In earlier days, a festival of egg throwing was held in church, when the priest would throw a hard-boiled egg to one of the choirboys. It was then tossed from one choirboy to the next and whoever held the egg when the clock struck 12 on Easter, was the winner and could keep it.", "In medieval times, Easter eggs were boiled with onions to give them a golden sheen. Edward I went beyond this tradition in 1290 and ordered 450 eggs to be covered in gold leaf and given as Easter gifts.", "Decorating Easter eggs is an ancient tradition that dates back to 13th century. One of the explanations for this custom is that eggs were considered as a forbidden food during the Lenten season (40 days before Easter). Therefore, people would paint and decorate them to mark an end of the period of penance and fasting and later eat them on Easter. The tradition of decorating eggs is called Pysanka which is creating a traditional Ukrainian folk design using wax-resist method.", - "Members of the Greek Orthodox faith often paint their Easter eggs red, which symbolizes Jesus\" blood and his victory over death. The color red, symbolizes renewal of life, such as, Jesus\" resurrection.", - "Eggs rolling take place in many parts of the world which symbolizes stone which was rolled away from the tomb where Jesus\" body was laid after his death.", - "Easter eggs have been considered as a symbol of fertility, rebirth and new life. The custom of giving eggs has been derived from Egyptians, Persians, Gauls, Greeks and Romans.", - "The first chocolate Easter egg was made by Fry\"s in 1873. Before this, people would give hollow cardboard eggs, filled with gifts.", + "Members of the Greek Orthodox faith often paint their Easter eggs red, which symbolizes Jesus' blood and his victory over death. The color red, symbolizes renewal of life, such as, Jesus' resurrection.", + "Eggs rolling take place in many parts of the world which symbolizes stone which was rolled away from the tomb where Jesus' body was laid after his death.", + "Easter eggs have been considered as a symbol of fertility, rebirth and new life. The custom of giving eggs has been derived from Egyptians, Persians, Gauls, Greeks, and Romans.", + "The first chocolate Easter egg was made by Fry's in 1873. Before this, people would give hollow cardboard eggs, filled with gifts.", "The tallest chocolate Easter egg was made in Italy in 2011. Standing 10.39 metres tall and weighing 7,200 kg, it was taller than a giraffe and heavier than an elephant.", "The largest ever Easter egg hunt was in Florida, where 9,753 children searched for 501,000 eggs.", "In 2007, an Easter egg covered in diamonds sold for almost £9 million. Every hour, a cockerel made of jewels pops up from the top of the Faberge egg, flaps its wings four times, nods its head three times and makes a crowing noise. The gold-and-pink enamel egg was made by the Russian royal family as an engagement gift for French aristocrat Baron Edouard de Rothschild.", - "The White House held their first official egg roll in 1878 when Rutherford B. Hayes was the President. It is a race in which children push decorated, hard-boiled eggs across the White House lawn as an annual event held the Monday after Easter. In 2009, the Obamas hosted their first Easter egg roll with the theme, ‘Let\"s go play\" which was meant to encourage young people to lead healthy and active lives.", - "80 million chocolate Easter eggs are sold each year. This accounts for 10% of Britain\"s annual spending on chocolate!", + "The White House held their first official egg roll in 1878 when Rutherford B. Hayes was the President. It is a race in which children push decorated, hard-boiled eggs across the White House lawn as an annual event held the Monday after Easter. In 2009, the Obamas hosted their first Easter egg roll with the theme, \"Let's go play\" which was meant to encourage young people to lead healthy and active lives.", + "80 million chocolate Easter eggs are sold each year. This accounts for 10% of Britain's annual spending on chocolate!", "The tradition of giving eggs at Easter has been traced back to Egyptians, Persians, Gauls, Greeks and Romans, who saw the egg as a symbol of life.", "Medieval Easter eggs were boiled with onions to give them a golden sheen. Edward I, however, went one better and in 1290 he ordered 450 eggs to be covered in gold leaf and given as Easter gifts.", "The first chocolate Easter egg was produced in 1873 by Fry\"s. Before this, people would give hollow cardboard eggs, filled with gifts.", - "John Cadbury soon followed suit and made his first Cadbury Easter egg in 1875. By 1892 the company was producing 19 different lines, all made from dark chocolate." + "John Cadbury soon followed suit and made his first Cadbury Easter egg in 1875. By 1892 the company was producing 19 different lines, all made from dark chocolate." ] diff --git a/bot/seasons/easter/bunny_name_generator.py b/bot/seasons/easter/bunny_name_generator.py index 1fca3c20..76d5c478 100644 --- a/bot/seasons/easter/bunny_name_generator.py +++ b/bot/seasons/easter/bunny_name_generator.py @@ -8,7 +8,7 @@ from discord.ext import commands log = logging.getLogger(__name__) -with open(Path("bot", "resources", "easter", "bunny_names.json"), "r", encoding="utf8") as f: +with Path("bot/resources/easter/bunny_names.json").open("r", encoding="utf8") as f: BUNNY_NAMES = json.load(f) @@ -20,7 +20,7 @@ class BunnyNameGenerator(commands.Cog): def find_separators(self, displayname): """Check if Discord name contains spaces so we can bunnify an individual word in the name.""" - new_name = re.split(r'[_.\s]', str(displayname)) + new_name = re.split(r'[_.\s]', displayname) if displayname not in new_name: return new_name diff --git a/bot/seasons/easter/easter_riddle.py b/bot/seasons/easter/easter_riddle.py index 2d4d1265..d6e6c207 100644 --- a/bot/seasons/easter/easter_riddle.py +++ b/bot/seasons/easter/easter_riddle.py @@ -11,7 +11,7 @@ from bot.constants import Colours log = logging.getLogger(__name__) -with open(Path('bot', 'resources', 'easter', 'easter_riddle.json'), 'r', encoding="utf8") as f: +with Path("bot/resources/easter/easter_riddle.json").open("r", encoding="utf8") as f: RIDDLE_QUESTIONS = load(f) TIMELIMIT = 10 diff --git a/bot/seasons/easter/egg_facts.py b/bot/seasons/easter/egg_facts.py index 6155670e..6d70225a 100644 --- a/bot/seasons/easter/egg_facts.py +++ b/bot/seasons/easter/egg_facts.py @@ -28,7 +28,7 @@ class EasterFacts(commands.Cog): @staticmethod def load_json(): """Load a list of easter egg facts from the resource JSON file.""" - p = Path('bot', 'resources', 'easter', 'easter_egg_facts.json') + p = Path("bot/resources/easter/easter_egg_facts.json") with p.open(encoding="utf8") as f: facts = load(f) return facts @@ -39,7 +39,7 @@ class EasterFacts(commands.Cog): while True: embed = self.make_embed() await channel.send(embed=embed) - await asyncio.sleep(24*60*60) + await asyncio.sleep(24 * 60 * 60) @commands.command(name='eggfact', aliases=['fact']) async def easter_facts(self, ctx): diff --git a/bot/seasons/evergreen/issues.py b/bot/seasons/evergreen/issues.py index 840d9ead..c6dbe344 100644 --- a/bot/seasons/evergreen/issues.py +++ b/bot/seasons/evergreen/issues.py @@ -15,7 +15,7 @@ class Issues(commands.Cog): @commands.command(aliases=("issues",)) async def issue(self, ctx, number: int, repository: str = "seasonalbot", user: str = "python-discord"): """Command to retrieve issues from a GitHub repository.""" - url = f"https://api.github.com/repos/{user}/{repository}/issues/{str(number)}" + url = f"https://api.github.com/repos/{user}/{repository}/issues/{number}" status = {"404": f"Issue #{str(number)} doesn't exist in the repository {user}/{repository}.", "403": f"Rate limit exceeded. Please wait a while before trying again!"} @@ -27,8 +27,8 @@ class Issues(commands.Cog): valid = discord.Embed(colour=0x00ff37) valid.add_field(name="Repository", value=f"{user}/{repository}", inline=False) - valid.add_field(name="Issue Number", value=f"#{str(number)}", inline=False) - valid.add_field(name="Status", value=json_data.get("state").title()) + valid.add_field(name="Issue Number", value=f"#{number}", inline=False) + valid.add_field(name="Status", value=json_data["state"].title()) valid.add_field(name="Link", value=url, inline=False) if len(json_data.get("body")) < 1024: valid.add_field(name="Description", value=json_data.get("body"), inline=False) |