Skip to content

Commit

Permalink
dependency upgrades (#30)
Browse files Browse the repository at this point in the history
* dependency upgrades

* fixup! dependency upgrades

* fixup! dependency upgrades

* fixup! dependency upgrades

* fixup! dependency upgrades

* fixup! dependency upgrades
  • Loading branch information
Tigge committed Sep 24, 2024
1 parent fc5c8e8 commit 774dbc2
Show file tree
Hide file tree
Showing 13 changed files with 791 additions and 570 deletions.
20 changes: 12 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
name: Build

on: [push, pull_request]
on:
push:
branches: ['main']
pull_request:
branches: ['main']

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: psf/black@stable

build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1.1.1
uses: snok/install-poetry@v1.4.1

- name: Install Dependencies using Poetry
run: poetry install
Expand All @@ -38,7 +42,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pip install coveralls
pip3 install --upgrade coveralls
coveralls --service=github
- name: Build
Expand Down
17 changes: 12 additions & 5 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,18 @@ async def plugin_update(self, plugin):

def run(self):

self.loop = asyncio.get_event_loop()
self.loop = asyncio.new_event_loop()
asyncio.set_event_loop(self.loop)
self.reactor = irc.client_aio.AioReactor(loop=self.loop)
self.reactor.add_global_handler("all_events", self._dispatcher, -10)

# Load plugins
if "plugins" in self.settings:
for plugin_name, plugin_settings in self.settings["plugins"].items():
self.load_plugin(plugin_name, plugin_settings)
async def load_plugins():
if "plugins" in self.settings:
for plugin_name, plugin_settings in self.settings["plugins"].items():
self.load_plugin(plugin_name, plugin_settings)

self.loop.run_until_complete(load_plugins())

# Connect to servers
servers = self.settings["servers"]
Expand All @@ -221,7 +225,10 @@ def run(self):
server.name = server_name
server.buffer_class = jaraco.stream.buffer.LenientDecodingLineBuffer
use_ssl = "ssl" in server_settings and server_settings["ssl"]
factory = irc.connection.AioFactory(ssl=use_ssl)
ssl_context = ssl.create_default_context()
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
factory = irc.connection.AioFactory(ssl=ssl_context if use_ssl else None)
self.loop.run_until_complete(
server.connect(
server_settings["host"],
Expand Down
4 changes: 3 additions & 1 deletion plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

class Plugin:
def __init__(self, name):

locale.setlocale(locale.LC_ALL, "")
logging.basicConfig(filename=name + ".log", level=logging.DEBUG)

Expand Down Expand Up @@ -108,7 +109,8 @@ async def _run(self):
@classmethod
def run(cls):

loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)

instance = cls()
logging.info("Plugin.run %s, %s", cls, instance)
Expand Down
8 changes: 4 additions & 4 deletions plugins/feedretriever/feedretriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
"feed will be used instead."
)

REMOVING_FEED_MESSAGE = u"Removing: #{} - {}"
LIST_FEED_ITEM_MESSAGE = u"#{}: {}"
NO_FEED_MESSAGE = u"No feeds"
REMOVING_FEED_MESSAGE = "Removing: #{} - {}"
LIST_FEED_ITEM_MESSAGE = "#{}: {}"
NO_FEED_MESSAGE = "No feeds"

DEFAULT_FETCH_TIME = 10 * 60


def FeedItemToString(title, link, feed_title=""):
return str_utils.sanitize_string(u"{}: {} <{}>".format(feed_title, title, link))
return str_utils.sanitize_string("{}: {} <{}>".format(feed_title, title, link))


# Simple polling class, fetches the feed in a regular interval and passes
Expand Down
1 change: 1 addition & 0 deletions plugins/packagetracker/provider_bring.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

__author__ = "reeen"


# Bring API https://developer.bring.com/api/tracking/
class BringPackage(Package):
API_URL = "https://tracking.bring.com/api/v2/tracking.json"
Expand Down
34 changes: 17 additions & 17 deletions plugins/titlegiver/test/test_titlegiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,69 +99,69 @@ def test_redirect(self):
result = Titlegiver.get_title_from_url(
self.URL + "/redirect?count=10&url={0}".format(url)
)
self.assertEqual(result, u"Simple")
self.assertEqual(result, "Simple")

def test_meta_redirect(self):
result = Titlegiver.get_title_from_url(self.URL + "/pages/meta_redirect")
self.assertEqual(result, u"Simple")
self.assertEqual(result, "Simple")

def test_meta_redirect_in_noscript(self):
result = Titlegiver.get_title_from_url(
self.URL + "/pages/meta_redirect_in_noscript"
)
self.assertEqual(result, u"Title without refreshing")
self.assertEqual(result, "Title without refreshing")

def test_specialchars(self):
result = Titlegiver.get_title_from_url(self.URL + "/pages/specialchar")
self.assertEqual(
result,
u"Title with special characters §½!\"@#£¤$%&/{([)]=}+?\`´'^~*'<>|,;.:-_",
"Title with special characters §½!\"@#£¤$%&/{([)]=}+?\`´'^~*'<>|,;.:-_",
)

def test_linebreaks(self):
result = Titlegiver.get_title_from_url(self.URL + "/pages/linebreaks")
self.assertEqual(result, u"Title with line breaks and carriage returns")
self.assertEqual(result, "Title with line breaks and carriage returns")

def test_attributes(self):
result = Titlegiver.get_title_from_url(self.URL + "/pages/attributes")
self.assertEqual(result, u'Title with attribute id="pageTitle"')
self.assertEqual(result, 'Title with attribute id="pageTitle"')

def test_entities(self):
result = Titlegiver.get_title_from_url(self.URL + "/pages/entities")
self.assertEqual(
result,
u"Title with entities. "
u'XML: "& '
u"HTML: <Å©†♥ "
u"Int/hex: Hello "
u"Invalid: &#x23k;&#123456789;&fail;",
"Title with entities. "
'XML: "& '
"HTML: <Å©†♥ "
"Int/hex: Hello "
"Invalid: &#x23k;&#123456789;&fail;",
)

def test_nonascii(self):
result = Titlegiver.get_title_from_url(self.URL + "/pages/nönàscii")
self.assertEqual(result, u"Page with nön-àscii path")
self.assertEqual(result, "Page with nön-àscii path")

def test_encoding_bom(self):
result = Titlegiver.get_title_from_url(self.URL + "/pages/encoding_bom")
self.assertEqual(result, u"Gådzölla - ゴジラ")
self.assertEqual(result, "Gådzölla - ゴジラ")

def test_encoding_xmldecl(self):
result = Titlegiver.get_title_from_url(self.URL + "/pages/encoding_xmldecl")
self.assertEqual(result, u"Samoraj - 武家")
self.assertEqual(result, "Samoraj - 武家")

def test_encoding_meta_charset(self):
result = Titlegiver.get_title_from_url(
self.URL + "/pages/encoding_meta_charset"
)
self.assertEqual(result, u"Россия-Матушка")
self.assertEqual(result, "Россия-Матушка")

def test_encoding_meta_httpequiv(self):
result = Titlegiver.get_title_from_url(
self.URL + "/pages/encoding_meta_httpequiv"
)
self.assertEqual(result, u"올드보이")
self.assertEqual(result, "올드보이")

def test_split_strip_and_slice(self):
title = Titlegiver.get_title_from_url(self.URL + "/pages/linebreaks_with_cr")
result = Titlegiver.split_strip_and_slice(title, 2)
self.assertEqual(result, [u"Line1", "Line2"])
self.assertEqual(result, ["Line1", "Line2"])
6 changes: 3 additions & 3 deletions plugins/trakt/test/test_trakt.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ def mock_fetch_new_activities(url, typ, func):

def test_no_new_episodes(self):
mock_fetch, mock_echo, _ = self.setupMocks(
lambda url, typ, func: [ACTIVITY_PRESET_EPISODE_1]
if typ == "episodes"
else [],
lambda url, typ, func: (
[ACTIVITY_PRESET_EPISODE_1] if typ == "episodes" else []
),
lambda _: [],
)
self.trakt.users["adam"]["last_sync_episodes"] = api.Trakt.get_date(
Expand Down
6 changes: 3 additions & 3 deletions plugins/trakt/trakt.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ def create_activity_summary(self, activities):

season_number = activity["episode"]["season"]
episode_number = activity["episode"]["number"]
result[key]["seasons"][season_number]["episodes"][
episode_number
] = activity["episode"]
result[key]["seasons"][season_number]["episodes"][episode_number] = (
activity["episode"]
)

# Filter seasons without episodes
for key in result:
Expand Down
2 changes: 1 addition & 1 deletion plugins/twitter/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def process(self, id, server, channel):
self.privmsg(server, channel, f"- {author}{date_diff}{stats}")

def on_pubmsg(self, server, user, channel, message):
for (_, _, id) in re.findall(Twitter.URL_REGEX, message):
for _, _, id in re.findall(Twitter.URL_REGEX, message):
logging.info("Twitter.on_pubmsg %s", id)
try:
self._thread(self.process, id, server, channel)
Expand Down
Loading

0 comments on commit 774dbc2

Please sign in to comment.