Skip to content

Commit c156e55

Browse files
committed
file-location black
1 parent bf88a3b commit c156e55

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

moddb/pages/base.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,19 @@ def __init__(self, html: BeautifulSoup):
5252
except AttributeError:
5353
self.name = html.find("meta", property="og:title")["content"]
5454

55-
56-
for index, func in enumerate([
57-
lambda: int(re.search(r"siteareaid=(\d*)", html.find("a", class_=["reporticon"])["href"])[1]),
58-
lambda: int(html.find("input", attrs={"name": "siteareaid"})["value"]),
59-
lambda: int(html.find("meta", property="og:image")["content"].split("/")[-2]),
60-
lambda: re.match(r"https:\/\/www\.moddb\.com\/html\/scripts\/autocomplete\.php\?a=mentions&p=home&l=6&u=(\d*)", str(html)).group(1)
61-
]):
55+
for index, func in enumerate(
56+
[
57+
lambda: int(
58+
re.search(r"siteareaid=(\d*)", html.find("a", class_=["reporticon"])["href"])[1]
59+
),
60+
lambda: int(html.find("input", attrs={"name": "siteareaid"})["value"]),
61+
lambda: int(html.find("meta", property="og:image")["content"].split("/")[-2]),
62+
lambda: re.match(
63+
r"https:\/\/www\.moddb\.com\/html\/scripts\/autocomplete\.php\?a=mentions&p=home&l=6&u=(\d*)",
64+
str(html),
65+
).group(1),
66+
]
67+
):
6268
try:
6369
self.id = func()
6470
break

moddb/pages/file.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,22 @@
2020
)
2121
from .base import BaseMetaClass
2222

23+
2324
def parse_location(html) -> list[Thumbnail] | None:
24-
location = html.find("h5", string="Location").parent.find_all('a')
25+
location = html.find("h5", string="Location").parent.find_all("a")
2526
if location is None:
2627
return None
27-
28+
2829
return [
2930
Thumbnail(
30-
type=ThumbnailType[location[x].string.lower()[:-1]],
31-
url=location[x+1]["href"],
32-
name=location[x+1].string,
31+
type=ThumbnailType[location[x].string.lower()[:-1]],
32+
url=location[x + 1]["href"],
33+
name=location[x + 1].string,
3334
)
34-
for x in range(0, len(location)-1, 2)
35+
for x in range(0, len(location) - 1, 2)
3536
]
3637

38+
3739
@concat_docs
3840
class File(BaseMetaClass):
3941
"""An oject representing a file on ModDB, a file is something posted by the page owner which is directly linked
@@ -100,7 +102,7 @@ class File(BaseMetaClass):
100102
location: list[Thumbnail]
101103
An ordered list detailing the hierarchy of entities the
102104
file or addon sits under. The last one being the entity
103-
directly attached to this file.
105+
directly attached to this file.
104106
"""
105107

106108
def __init__(self, html: bs4.BeautifulSoup):
@@ -166,7 +168,7 @@ def save(self, file_obj: BinaryIO, *, mirror=None, chunk_size: int = 10_000_000)
166168
An optional mirror object to download the
167169
file from a specific moddb mirror
168170
chunk_size: int
169-
The size of the chunks to stream the response
171+
The size of the chunks to stream the response
170172
back in. 10MB by default
171173
"""
172174
if mirror is None:
@@ -373,7 +375,7 @@ def save(self, file_obj: BinaryIO, *, chunk_size: int = 10_000_000):
373375
The file obj to save the file to. The binary data
374376
will be streamed to that object.
375377
chunk_size: int
376-
The size of the chunks to stream the response
378+
The size of the chunks to stream the response
377379
back in. 10MB by default
378380
379381
"""

0 commit comments

Comments
 (0)