Skip to content

Commit c366f43

Browse files
committed
Removed unused statements
1 parent 61d4dc1 commit c366f43

File tree

6 files changed

+3
-76
lines changed

6 files changed

+3
-76
lines changed

bot.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from colorama import init, Fore, Style
4242
from emoji import UNICODE_EMOJI
4343

44-
from core.clients import Github, ModmailApiClient, SelfHostedClient
44+
from core.clients import ModmailApiClient, SelfHostedClient
4545
from core.thread import ThreadManager
4646
from core.config import ConfigManager
4747
from core.changelog import ChangeLog
@@ -616,18 +616,6 @@ async def autoupdate_loop(self):
616616

617617
await asyncio.sleep(3600)
618618

619-
async def get_latest_updates(self, limit=3):
620-
latest_commits = ''
621-
622-
async for commit in Github(self).get_latest_commits(limit=limit):
623-
short_sha = commit['sha'][:6]
624-
html_url = commit['html_url']
625-
message = commit['commit']['message'].splitlines()[0]
626-
627-
latest_commits += f'[`{short_sha}`]({html_url}) {message}\n'
628-
629-
return latest_commits
630-
631619

632620
if __name__ == '__main__':
633621
uvloop.install()

core/clients.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,6 @@ async def star_repository(self) -> None:
9292
await self.request(self.STAR_URL, method='PUT',
9393
headers={'Content-Length': '0'})
9494

95-
# TODO: Broken.
96-
async def get_latest_commits(self, limit: int = 3) -> None:
97-
# resp = await self.request(self.commit_url)
98-
# for index in range(limit):
99-
# yield resp[index]
100-
...
101-
10295
@classmethod
10396
async def login(cls, bot) -> 'Github':
10497
self = cls(bot, bot.config.get('github_access_token'), )

core/decorators.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import asyncio
21
import functools
32

43
from discord import Embed, Color
@@ -45,17 +44,3 @@ async def predicate(ctx: commands.Context) -> bool:
4544
return ctx.author.id in allowed
4645

4746
return commands.check(predicate)
48-
49-
50-
def async_executor(loop=None, executor=None):
51-
loop = loop or asyncio.get_event_loop()
52-
53-
def decorator(func):
54-
@functools.wraps(func)
55-
def wrapper(*args, **kwargs):
56-
partial = functools.partial(func, *args, **kwargs)
57-
return loop.run_in_executor(executor, partial)
58-
59-
return wrapper
60-
61-
return decorator

core/models.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,6 @@ async def process_modmail(self, message: Message) -> None:
139139
def overwrites(ctx: commands.Context) -> dict:
140140
raise NotImplementedError
141141

142-
# Broken.
143-
@abc.abstractmethod
144-
async def get_latest_updates(self, limit: int = 3) -> typing.NoReturn:
145-
raise NotImplementedError
146-
147142

148143
class UserClient(abc.ABC):
149144
@property
@@ -385,9 +380,3 @@ async def find_or_create(self,
385380
recipient: typing.Union[Member, User]) \
386381
-> 'ThreadABC':
387382
raise NotImplementedError
388-
389-
@abc.abstractmethod
390-
async def get_dominant_color(self,
391-
url: str = None,
392-
quality: float = 10) -> Color:
393-
raise NotImplementedError

core/thread.py

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22
import string
33
import asyncio
44
import typing
5-
from io import BytesIO
65
from datetime import datetime, timedelta
7-
from traceback import print_exc
86

97
import discord
108
from discord.ext.commands import UserInputError, CommandError
119

12-
from colorthief import ColorThief
1310

14-
from core.decorators import async_executor
15-
from core.utils import is_image_url, days, match_user_id, parse_image_url
11+
from core.utils import is_image_url, days, match_user_id
1612
from core.models import Bot, ThreadManagerABC, ThreadABC
1713

1814

@@ -579,31 +575,6 @@ async def find_or_create(self, recipient):
579575
return await self.find(recipient=recipient) or \
580576
await self.create(recipient)
581577

582-
@staticmethod
583-
@async_executor()
584-
def _do_get_dc(image, quality):
585-
with BytesIO(image) as f:
586-
return ColorThief(f).get_color(quality=quality)
587-
588-
async def get_dominant_color(self, url=None, quality=10):
589-
"""
590-
Returns the dominant color of an image from a URL
591-
(misc)
592-
"""
593-
url = parse_image_url(url)
594-
595-
if not url:
596-
raise ValueError('Invalid image url passed.')
597-
try:
598-
async with self.bot.session.get(url) as resp:
599-
image = await resp.read()
600-
color = await self._do_get_dc(image, quality)
601-
except Exception:
602-
print_exc()
603-
return discord.Color.blurple()
604-
else:
605-
return discord.Color.from_rgb(*color)
606-
607578
def _format_channel_name(self, author):
608579
"""Sanitises a username for use with text channel names"""
609580
name = author.name.lower()

core/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88

99
class User(commands.IDConverter):
10+
# noinspection PyCallByClass,PyTypeChecker
1011
async def convert(self, ctx, argument):
1112
try:
1213
return await commands.MemberConverter.convert(self, ctx, argument)

0 commit comments

Comments
 (0)