Skip to content

Commit

Permalink
Minor cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeldaZach committed Jun 4, 2020
1 parent 096d3f8 commit b3beb08
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 24 deletions.
6 changes: 6 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[settings]
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
line_length = 88
20 changes: 4 additions & 16 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
[MASTER]

# Pickle collected data for later comparisons.
persistent=yes


[MESSAGES CONTROL]

# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
Expand All @@ -16,31 +13,26 @@ persistent=yes
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=
bad-continuation,
C0326,
C0330,
duplicate-code,
line-too-long,
logging-format-interpolation,
too-few-public-methods,
too-many-arguments,
too-many-branches,
too-many-instance-attributes,
too-many-statements,
too-many-arguments,
wrong-import-order,
wrong-import-position,
too-many-nested-blocks


wrong-import-position

[REPORTS]

# Set the output format. Available formats are text, parseable, colorized, json
# and msvs (visual studio).You can also give a reporter class, eg
# mypackage.mymodule.MyReporterClass.
output-format=colorized


[BASIC]

# Good variable names which should always be accepted, separated by a comma.
good-names=
f,
Expand All @@ -53,18 +45,14 @@ good-names=
# not require a docstring.
no-docstring-rgx=__.*__|test_.*


[MISCELLANEOUS]

# List of note tags to take in consideration, separated by a comma.
notes=
FIXME,
TODO


[VARIABLES]

# A regular expression matching the name of dummy variables (i.e. expectedly
# not used).
dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)

2 changes: 1 addition & 1 deletion mtgjson5/providers/cardmarket_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def _build_http_header(self) -> Dict[str, str]:
Generate HTTP Header -- Not Used
:return: Nothing
"""
return {}
return dict()

def download(self, url: str, params: Dict[str, Union[str, int]] = None) -> Any:
"""
Expand Down
26 changes: 25 additions & 1 deletion mtgjson5/providers/gatherer_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,29 @@ class GathererProvider(AbstractProvider):
SETS_TO_REMOVE_PARENTHESES = {"10E"}

def __init__(self) -> None:
"""
Class Initializer
"""
super().__init__(self._build_http_header())

def _build_http_header(self) -> Dict[str, str]:
return {}
"""
Generate HTTP Header -- Not Used
:return: Nothing
"""
return dict()

@ratelimit.sleep_and_retry
@ratelimit.limits(calls=40, period=1)
def download(
self, url: str, params: Dict[str, Union[str, int]] = None
) -> requests.Response:
"""
Download a file from gather, with a rate limit
:param url: URL to download
:param params: URL parameters
:return URL response
"""
session = retryable_session()
session.headers.update(self.session_header)

Expand All @@ -67,6 +80,9 @@ def download(
def get_cards(self, multiverse_id: int, set_code: str = "") -> List[GathererCard]:
"""
Get card(s) matching a given multiverseId
:param multiverse_id: Multiverse ID of the card
:param set_code: Set code to find the card in
:return All found cards matching description
"""
response = self.download(
self.GATHERER_CARD, {"multiverseid": str(multiverse_id), "printed": "true"}
Expand All @@ -81,6 +97,9 @@ def parse_cards(
) -> List[GathererCard]:
"""
Parse all cards from a given gatherer page
:param gatherer_data: Data from gatherer response
:param strip_parentheses: Should strip details
:return All found cards, parsed
"""
soup = bs4.BeautifulSoup(gatherer_data, "html.parser")
columns = soup.find_all("td", class_="rightCol")
Expand All @@ -91,6 +110,9 @@ def _parse_column(
) -> GathererCard:
"""
Parse a single gatherer page 'rightCol' entry
:param gatherer_column: Column from BeautifulSoup's Gatherer parse
:param strip_parentheses: Should additional strip occur
:return Magic card details
"""
label_to_values = {
row.find("div", class_="label")
Expand Down Expand Up @@ -133,6 +155,8 @@ def _parse_column(
def _replace_symbols(tag: bs4.BeautifulSoup) -> bs4.BeautifulSoup:
"""
Replace all image tags with their mapped symbol
:param tag: BS4 data tag
:return BS4 data tag with updated symbols
"""
tag_copy = copy.copy(tag)
images = tag_copy.find_all("img")
Expand Down
2 changes: 1 addition & 1 deletion mtgjson5/providers/github_boosters_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _build_http_header(self) -> Dict[str, str]:
Construct the Authorization header
:return: Authorization header
"""
return {}
return dict()

def download(self, url: str, params: Dict[str, Union[str, int]] = None) -> Any:
"""
Expand Down
2 changes: 1 addition & 1 deletion mtgjson5/providers/github_decks_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _build_http_header(self) -> Dict[str, str]:
Construct the Authorization header
:return: Authorization header
"""
return {}
return dict()

def download(self, url: str, params: Dict[str, Union[str, int]] = None) -> Any:
"""
Expand Down
2 changes: 1 addition & 1 deletion mtgjson5/providers/github_mtgsqlite_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _build_http_header(self) -> Dict[str, str]:
Construct the Authorization header
:return: Authorization header
"""
return {}
return dict()

def download(self, url: str, params: Dict[str, Union[str, int]] = None) -> Any:
"""
Expand Down
9 changes: 8 additions & 1 deletion mtgjson5/providers/whats_in_standard_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@ class WhatsInStandardProvider(AbstractProvider):
standard_legal_sets: Set[str]

def __init__(self) -> None:
"""
Class Initializer
"""
super().__init__(self._build_http_header())
self.logger = logging.getLogger(__name__)
self.standard_legal_sets = set()
self.set_codes = self.standard_legal_set_codes()

def _build_http_header(self) -> Dict[str, str]:
return {}
"""
Construct the Authorization header -- unused
:return: Authorization header
"""
return dict()

def download(self, url: str, params: Dict[str, Union[str, int]] = None) -> Any:
"""
Expand Down
6 changes: 5 additions & 1 deletion mtgjson5/providers/wizards_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ def __init__(self) -> None:
super().__init__(self._build_http_header())

def _build_http_header(self) -> Dict[str, str]:
return {}
"""
Construct the Authorization header -- unused
:return: Authorization header
"""
return dict()

def download(
self, url: str, params: Dict[str, Union[str, int]] = None
Expand Down
2 changes: 1 addition & 1 deletion mtgjson5/set_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def build_base_mtgjson_cards(
"""
Construct all cards in MTGJSON format from a single set
:param set_code: Set to build
:param additional_cards: Additional objects to build (not relevant for normal builds)
:param additional_cards: Additional objs to build (not relevant for normal builds)
:param is_token: Are tokens being copmiled?
:return: Completed card objects
"""
Expand Down

0 comments on commit b3beb08

Please sign in to comment.