Merge pull request 'Create util module' (#1) from dev-v2 into master
Reviewed-on: #1
This commit is contained in:
commit
017a694bfd
@ -1,5 +1,6 @@
|
|||||||
import time
|
import time
|
||||||
from pastebin.client import PastebinClient, search_by_language
|
from pastebin.client import PastebinClient
|
||||||
|
from pastebin.util import search_by_language
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -182,17 +182,3 @@ class PastebinClient(PastebinAPI):
|
|||||||
self.pastes[i] for i, paste in enumerate(self.pastes)
|
self.pastes[i] for i, paste in enumerate(self.pastes)
|
||||||
if paste.lang.lower() == lang.lower()
|
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
12
src/pastebin/util.py
Normal 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
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user