PEP 8 compliance.

This commit is contained in:
yrriban 2025-06-13 01:38:07 -04:00
parent 97616b341d
commit b29e2675d1

View file

@ -5,6 +5,7 @@ import pathlib
import urllib.request import urllib.request
import zipfile import zipfile
class Fetch(dcc.config.Base): class Fetch(dcc.config.Base):
def get_parser(self, prog_name): def get_parser(self, prog_name):
parser = super().get_parser(prog_name) parser = super().get_parser(prog_name)
@ -16,9 +17,16 @@ class Fetch(dcc.config.Base):
if not parsed_args.id_or_name.isdigit(): if not parsed_args.id_or_name.isdigit():
idgames_id = self.search_idgames(parsed_args.id_or_name) idgames_id = self.search_idgames(parsed_args.id_or_name)
with urllib.request.urlopen("https://www.doomworld.com/idgames/api/api.php?action=get&id={}&out=json".format(idgames_id)) as response: with urllib.request.urlopen(
"https://www.doomworld.com/idgames/api/" +
"api.php?action=get&id={}&out=json".format(idgames_id)
) as response:
reply = json.loads(response.read()) reply = json.loads(response.read())
rpath = "/".join([dcc.config.MIRROR, reply["content"]["dir"], reply["content"]["filename"]]) rpath = "/".join([
dcc.config.MIRROR,
reply["content"]["dir"],
reply["content"]["filename"]
])
wad = reply["content"]["filename"][0:-4] wad = reply["content"]["filename"][0:-4]
with urllib.request.urlopen(rpath) as response: with urllib.request.urlopen(rpath) as response:
@ -27,7 +35,10 @@ class Fetch(dcc.config.Base):
# TODO: explicit error handling. Let users choose when >1 result. # TODO: explicit error handling. Let users choose when >1 result.
def search_idgames(self, wad): def search_idgames(self, wad):
with urllib.request.urlopen("https://www.doomworld.com/idgames/api/api.php?action=search&query={}&out=json".format(wad)) as response: with urllib.request.urlopen(
"https://www.doomworld.com/idgames/api/" +
"api.php?action=search&query={}&out=json".format(wad)
) as response:
reply = json.loads(response.read()) reply = json.loads(response.read())
files = reply["content"]["file"] files = reply["content"]["file"]
if type(files) is dict: # One result. if type(files) is dict: # One result.