X-Git-Url: http://unremediatedgender.space/source?a=blobdiff_plain;f=notes%2Fmemoir_wordcounts.py;h=44ba04f35bd0cd614261d4da01ddf5b0ef1ef3e9;hb=e4f60181a18b4f8155761020fcff7ed3799de752;hp=ef36de5b4b52dfa05a8b5fc921f96f3bf232140a;hpb=a4d913d5ed2447ea496a2972748272d4ab678b8b;p=Ultimately_Untrue_Thought.git diff --git a/notes/memoir_wordcounts.py b/notes/memoir_wordcounts.py index ef36de5..44ba04f 100755 --- a/notes/memoir_wordcounts.py +++ b/notes/memoir_wordcounts.py @@ -21,7 +21,7 @@ MONTHS = { } def wordcount_at_this_sha(): - result = subprocess.run("wc -w content/drafts/blanchards-dangerous-idea-and-the-plight-of-the-lucid-crossdreamer.md content/drafts/a-hill-of-validity-in-defense-of-meaning.md content/drafts/if-clarity-seems-like-death-to-them.md content/drafts/agreeing-with-stalin-in-ways-that-exhibit-generally-rationalist-principles.md".split(), stdout=subprocess.PIPE) + result = subprocess.run("wc -w content/drafts/blanchards-dangerous-idea-and-the-plight-of-the-lucid-crossdreamer.md content/drafts/a-hill-of-validity-in-defense-of-meaning.md content/drafts/if-clarity-seems-like-death-to-them.md content/drafts/agreeing-with-stalin-in-ways-that-exhibit-generally-rationalist-principles.md content/drafts/standing-under-the-same-sky.md".split(), stdout=subprocess.PIPE) wc_lines = result.stdout.decode('utf8').split('\n') total_line = wc_lines[-2] # last line is empty return int(total_line.split()[0]) @@ -38,7 +38,7 @@ def look_back(): wordcounts = [] keep_going = True while keep_going: - subprocess.run(["git", "checkout", "HEAD~5"]) + subprocess.run(["git", "checkout", "HEAD~1"]) wordcount = wordcount_at_this_sha() date = date_at_this_sha() if date < datetime.date(2022, 4, 1): @@ -48,6 +48,17 @@ def look_back(): subprocess.run(["git", "checkout", "master"]) return sorted(wordcounts) +def normalize_dates(wordcounts): + eod_wordcounts = [] + for i in range(len(wordcounts)-1): + date, wordcount = wordcounts[i] + next_date, next_wordcount = wordcounts[i+1] + gap = next_date - date + if gap >= datetime.timedelta(1): + eod_wordcounts.append((date, wordcount)) + for i in range(gap.days-1): + eod_wordcounts.append((date + datetime.timedelta(i+1), wordcount)) + return eod_wordcounts def write_csv(wordcounts): with open("memoir_wordcounts.csv", 'w') as f: @@ -57,5 +68,5 @@ def write_csv(wordcounts): if __name__ in "__main__": - wordcounts = look_back() + wordcounts = normalize_dates(look_back()) write_csv(wordcounts)