Spaces:
Runtime error
Runtime error
Niv Sardi
commited on
Commit
•
4b890a6
1
Parent(s):
e34b2c2
mypy pass
Browse filesSigned-off-by: Niv Sardi <xaiki@debian-BULLSEYE-live-builder-AMD64>
- python/entity.py +2 -2
- python/web.py +4 -5
python/entity.py
CHANGED
@@ -12,8 +12,8 @@ class Entity(NamedTuple):
|
|
12 |
name: str
|
13 |
id: int = 0
|
14 |
bco: str = "debug"
|
15 |
-
url: str =
|
16 |
-
logo: str =
|
17 |
|
18 |
def __repr__(self):
|
19 |
return f"""
|
|
|
12 |
name: str
|
13 |
id: int = 0
|
14 |
bco: str = "debug"
|
15 |
+
url: str = ''
|
16 |
+
logo: str = ''
|
17 |
|
18 |
def __repr__(self):
|
19 |
return f"""
|
python/web.py
CHANGED
@@ -27,11 +27,8 @@ def get_cert(e: Entity):
|
|
27 |
f.write(str(err))
|
28 |
return fn
|
29 |
|
30 |
-
def get_img_logo(src:
|
31 |
-
ext = src.split('.')[-1].split('/')[-1]
|
32 |
res = requests.get(src, stream=True)
|
33 |
-
|
34 |
-
fn = f"{defaults.DATA_PATH}/logos/{e.bco}.{i}.{ext}"
|
35 |
with open(fn, "wb") as f:
|
36 |
shutil.copyfileobj(res.raw, f)
|
37 |
return fn
|
@@ -47,7 +44,9 @@ def get_logos(e: Entity, page):
|
|
47 |
for l in logos:
|
48 |
if 'src' in l.attrs:
|
49 |
src = l.attrs['src']
|
|
|
50 |
if not src.startswith('http'): src = e.url + src
|
51 |
-
|
|
|
52 |
i+=1
|
53 |
return lfn
|
|
|
27 |
f.write(str(err))
|
28 |
return fn
|
29 |
|
30 |
+
def get_img_logo(src: str, fn):
|
|
|
31 |
res = requests.get(src, stream=True)
|
|
|
|
|
32 |
with open(fn, "wb") as f:
|
33 |
shutil.copyfileobj(res.raw, f)
|
34 |
return fn
|
|
|
44 |
for l in logos:
|
45 |
if 'src' in l.attrs:
|
46 |
src = l.attrs['src']
|
47 |
+
ext = src.split('.')[-1].split('/')[-1]
|
48 |
if not src.startswith('http'): src = e.url + src
|
49 |
+
fn = f"{defaults.DATA_PATH}/logos/{e.bco}.{i}.{ext}"
|
50 |
+
lfn.append(get_img_logo(src, fn))
|
51 |
i+=1
|
52 |
return lfn
|