Create util module

This commit is contained in:
agatha 2023-09-12 17:13:30 -04:00
parent 68141fbbf2
commit 2011da7239
3 changed files with 14 additions and 15 deletions

View File

@ -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():

View File

@ -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
]

12
src/pastebin/util.py Normal file
View File

@ -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
]