Separate Paste class definition
This commit is contained in:
parent
017a694bfd
commit
2f0b324603
@ -10,6 +10,7 @@ import requests
|
||||
from requests.adapters import HTTPAdapter
|
||||
from requests.packages.urllib3.util.retry import Retry
|
||||
from bs4 import BeautifulSoup
|
||||
from .paste import Paste
|
||||
|
||||
|
||||
logger = logging.getLogger()
|
||||
@ -19,35 +20,6 @@ class ApiRequestException(Exception):
|
||||
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:
|
||||
"""
|
||||
Wrapper class for interacting with Pastebin.
|
||||
|
27
src/pastebin/paste.py
Normal file
27
src/pastebin/paste.py
Normal 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
|
Loading…
Reference in New Issue
Block a user