From 2011da72397281381a176aa91f812df3898c4971 Mon Sep 17 00:00:00 2001 From: agatha Date: Tue, 12 Sep 2023 17:13:30 -0400 Subject: [PATCH] Create util module --- src/main.py | 3 ++- src/pastebin/client.py | 14 -------------- src/pastebin/util.py | 12 ++++++++++++ 3 files changed, 14 insertions(+), 15 deletions(-) create mode 100644 src/pastebin/util.py diff --git a/src/main.py b/src/main.py index 72fd472..1452345 100644 --- a/src/main.py +++ b/src/main.py @@ -1,5 +1,6 @@ import time -from pastebin.client import PastebinClient, search_by_language +from pastebin.client import PastebinClient +from pastebin.util import search_by_language def main(): diff --git a/src/pastebin/client.py b/src/pastebin/client.py index afa42ed..fc5f73b 100644 --- a/src/pastebin/client.py +++ b/src/pastebin/client.py @@ -182,17 +182,3 @@ class PastebinClient(PastebinAPI): self.pastes[i] for i, paste in enumerate(self.pastes) if paste.lang.lower() == lang.lower() ] - - -def search_by_language(pastes, lang): - return [ - pastes[i] for i, paste in enumerate(pastes) - if paste.lang.lower() == lang.lower() - ] - - -def search_by_category(pastes, category): - return [ - pastes[i] for i, paste in enumerate(pastes) - if paste.category == category - ] diff --git a/src/pastebin/util.py b/src/pastebin/util.py new file mode 100644 index 0000000..3ebcd0f --- /dev/null +++ b/src/pastebin/util.py @@ -0,0 +1,12 @@ +def search_by_language(pastes, lang): + return [ + pastes[i] for i, paste in enumerate(pastes) + if paste.lang.lower() == lang.lower() + ] + + +def search_by_category(pastes, category): + return [ + pastes[i] for i, paste in enumerate(pastes) + if paste.category == category + ] \ No newline at end of file -- 2.30.2