Browse Source

better JSON dump filenames

pull/1/head
Albert Sanchez 8 months ago
parent
commit
2f01431b26
  1. 6
      pseudbot/bot.py
  2. 9
      pseudbot/util.py

6
pseudbot/bot.py

@ -114,7 +114,7 @@ class PseudBot:
)
sleep(901)
jdump(tweets_j)
jdump(tweets_j, extra_tag=self.target_screen_name)
def timeline(self):
"""
@ -125,7 +125,7 @@ class PseudBot:
for tweet in home_tl:
jsons.append(tweet._json)
jdump(jsons, echo=True)
jdump(jsons, extra_tag=self.screen_name)
def _tweet_pasta(self, id_reply_to: int, pasta: [str]):
"""
@ -209,7 +209,7 @@ class PseudBot:
log_t_by_sname(tweet)
jtweets.append(tweet._json)
jdump(jtweets)
jdump(jtweets, extra_tag=self.last_id)
def pasta_tweet(self):
"""

9
pseudbot/util.py

@ -12,8 +12,13 @@ def surl_prefix(screen_name: str):
return "https://twitter.com/" + screen_name + "/status/"
def jdump(itms, echo: bool = False):
dfname = str(inspect.stack()[1][3]) + "." + str(int(time())) + ".dump.json"
def jdump(itms, echo: bool = False, extra_tag: str = None):
tag = "."
if extra_tag is not None:
tag = "." + str(extra_tag) + "."
dfname = str(inspect.stack()[1][3]) + tag + str(int(time())) + ".dump.json"
print('[INFO]: Writing JSON dump to "{}"'.format(dfname))
df = open(dfname, mode="w")
pretty = j.dumps(itms, sort_keys=True, indent=2)

Loading…
Cancel
Save