Separate Paste class definition

This commit is contained in:
agatha 2023-09-12 17:20:28 -04:00
parent 017a694bfd
commit 2f0b324603
2 changed files with 28 additions and 29 deletions

View File

@ -10,6 +10,7 @@ import requests
from requests.adapters import HTTPAdapter from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry from requests.packages.urllib3.util.retry import Retry
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from .paste import Paste
logger = logging.getLogger() logger = logging.getLogger()
@ -19,35 +20,6 @@ class ApiRequestException(Exception):
pass pass
class Paste:
def __init__(self, title, href, lang):
self.title = title
self.href = href
self.lang = lang
self.fetched = False
self.author = None
self.pub_date = None
self.category = None
self.text = None
def __repr__(self):
return ("Paste("
f"title='{self.title}', "
f"href='{self.href}', "
f"lang='{self.lang}', "
f"fetched={self.fetched})"
)
def __hash__(self):
return hash((self.title, self.href, self.lang))
def __eq__(self, other):
if isinstance(other, Paste):
return self.title == other.title and self.href == other.href and self.lang == other.lang
return False
class PastebinAPI: class PastebinAPI:
""" """
Wrapper class for interacting with Pastebin. Wrapper class for interacting with Pastebin.

27
src/pastebin/paste.py Normal file
View File

@ -0,0 +1,27 @@
class Paste:
def __init__(self, title, href, lang):
self.title = title
self.href = href
self.lang = lang
self.fetched = False
self.author = None
self.pub_date = None
self.category = None
self.text = None
def __repr__(self):
return ("Paste("
f"title='{self.title}', "
f"href='{self.href}', "
f"lang='{self.lang}', "
f"fetched={self.fetched})"
)
def __hash__(self):
return hash((self.title, self.href, self.lang))
def __eq__(self, other):
if isinstance(other, Paste):
return self.title == other.title and self.href == other.href and self.lang == other.lang
return False