def string_bitmap(text): """ Like char_bitmap() but takes a string and returns a bitmap of the entire word. The resulting width will by len(text) * 8, and height 7. See bitmap.py """ bm = Bitmap(WIDTH * len(text), HEIGHT) for i, char in enumerate(text): bm.apply(char_bitmap(char), x=i * WIDTH, y=0) return bm
def main(): text = ' '.join(argv[1:]) if not text: stderr.write('ERROR: missing text\n') exit(1) one_year_ago = date.today() - timedelta(days=365) while one_year_ago.weekday() != 6: # go to start of week (sunday) one_year_ago -= timedelta(days=1) canvas = Bitmap(width=52, height=7) # year of weeks label = string_bitmap(text) canvas.apply(label, x=canvas.width - label.width) # right align if label.width > canvas.width: stderr.write('WARNING: text truncated\n') stderr.write('preview:\n\n') canvas.dump(stderr) print('#!/bin/bash') print('set -euo pipefail') print('echo "Generating a bunch of git commits..."') print('git init') n = 0 for contrib_date in bitmap_to_contribution_dates(canvas, one_year_ago): stamp = datetime.combine(contrib_date, time(12, 0)).isoformat() for i in range(commits_per_pixel): print('echo {} > .greendot'.format(n)) print('git add .greendot') print( 'GIT_COMMITTER_DATE="{}" GIT_AUTHOR_DATE="{}" git commit -m "greendot {}"' .format(stamp, stamp, n)) n += 1 print('echo "All done. Commits: {}"'.format(n))