clearer variable names
This commit is contained in:
parent
db14ea6b3d
commit
9b2e9ed74d
12
microblog.py
12
microblog.py
@ -448,11 +448,11 @@ if __name__ == "__main__":
|
|||||||
def get_avatars(profiles, save_path, img_src):
|
def get_avatars(profiles, save_path, img_src):
|
||||||
import hashlib
|
import hashlib
|
||||||
imgs, info = fetch([p["avatar"] for p in profiles])
|
imgs, info = fetch([p["avatar"] for p in profiles])
|
||||||
l = len(imgs)
|
length = len(imgs)
|
||||||
if l != len(profiles) or l == 0:
|
if length != len(profiles) or length == 0:
|
||||||
print("error in retrieving images", file=sys.stderr)
|
print("error in retrieving images", file=sys.stderr)
|
||||||
return
|
return
|
||||||
for i in range(0,l):
|
for i in range(0,length):
|
||||||
content_type = info[i].split('/')
|
content_type = info[i].split('/')
|
||||||
ext = content_type.pop()
|
ext = content_type.pop()
|
||||||
if content_type.pop() != "image":
|
if content_type.pop() != "image":
|
||||||
@ -461,10 +461,10 @@ if __name__ == "__main__":
|
|||||||
data = imgs[i].getvalue()
|
data = imgs[i].getvalue()
|
||||||
h = hashlib.sha1(data).hexdigest()
|
h = hashlib.sha1(data).hexdigest()
|
||||||
filename = "%s.%s" % (h, ext)
|
filename = "%s.%s" % (h, ext)
|
||||||
|
path = "%s/%s" % (save_path, filename)
|
||||||
profiles[i]["avatar"] = "%s/%s" % (img_src, filename)
|
profiles[i]["avatar"] = "%s/%s" % (img_src, filename)
|
||||||
asdf = "%s/%s" % (save_path, filename)
|
if not os.path.isfile(path):
|
||||||
if not os.path.isfile(asdf):
|
with open(path, "wb") as f:
|
||||||
with open(asdf, "wb") as f:
|
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
|
||||||
j, m = fetch(f_cfg["list"])
|
j, m = fetch(f_cfg["list"])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user