From de78ad42b8e685cefcb716842ff81b02f370b5b5 Mon Sep 17 00:00:00 2001 From: likhy Date: Wed, 30 Aug 2023 00:07:37 -0700 Subject: [PATCH] simplified export_profile() --- microblog.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/microblog.py b/microblog.py index 2c12e2a..21a3794 100644 --- a/microblog.py +++ b/microblog.py @@ -353,25 +353,17 @@ if __name__ == "__main__": return s import json - # generate json basd on profile def export_profile(post_count, last_update, config): if "profile" not in config: return - if "username" not in config["profile"] \ - or "url" not in config["profile"]: + p = config["profile"] + p["post-count"] = post_count + p["last-updated"] = last_update + if "username" not in p or "url" not in p: print("Warning: no profile exported", file=sys.stderr) return - profile = { - "username" : config["profile"]["username"], - "url": config["profile"]["url"], - "last-updated": last_update, - "short-bio" : config["profile"]["short_bio"], - "post-count" : post_count - } - if "avatar" in config["profile"]: - profile["avatar"] = config["profile"]["avatar"] with open(config["file_output"], 'w') as f: - print(json.dumps(profile), file=f) + print(json.dumps(p), file=f) def fn1(webring_config): # come up with better name later/ import pycurl