-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from kevthehermit/feature/refactor-inputs
- Loading branch information
Showing
19 changed files
with
1,091 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from abc import ABC, abstractmethod | ||
from typing import Any, Optional, Dict, List, Union | ||
|
||
import requests | ||
|
||
|
||
class BasePasteSite(ABC): | ||
def make_request(self, url: str, timeout: Optional[int] = 10, headers: Optional[Dict[str, Any]] = None): | ||
""" | ||
Make a request and return the results | ||
:param url: The url to request | ||
:param timeout: The timeout for the request | ||
:param headers: The headers dict | ||
:return: | ||
""" | ||
req = requests.get(url, headers=headers, timeout=timeout) | ||
return req | ||
|
||
@abstractmethod | ||
def remap_raw_item(self, raw_item: [str, Dict]) -> Dict[str, Any]: | ||
""" | ||
Takes a raw item and remaps it to a normalize paste dict | ||
:param raw_item: | ||
:return: The paste dict | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
def get_paste_for_id(self, paste_id: Any) -> str: | ||
""" | ||
Returns a paste for the given paste_id | ||
:param paste_id: The paste to retrieve | ||
:return: A raw paste object | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
def get_paste_id(self, paste_obj: Dict[str, Any]) -> Union[str, int]: | ||
""" | ||
Returns an id for the given paste object | ||
:param paste_obj: The raw paste dict | ||
:return: The paste id | ||
passd (str or int) | ||
""" | ||
|
||
@abstractmethod | ||
def get_recent_items(self, input_history: List[str]): | ||
""" | ||
Gets recent items | ||
:return: a list of recent items | ||
""" | ||
pass |
Oops, something went wrong.