-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrite-letters.py
More file actions
52 lines (41 loc) · 1.28 KB
/
write-letters.py
File metadata and controls
52 lines (41 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import datetime
import sys
import subprocess
import os
from letters import * #import in current namespace
# finds the date x=0,y=0 on github grid
today = datetime.datetime.now()
dayOfTheWeek = datetime.datetime.today().weekday() #starts on sunday
DD_day = datetime.timedelta(days=dayOfTheWeek+1)
DD_year = datetime.timedelta(weeks=52)
dateTopLeftCorner = today - DD_day
dateTopLeftCorner = dateTopLeftCorner - DD_year
earlier_str = dateTopLeftCorner.strftime("%d/%m/%Y")
print(earlier_str)
# word to print
letters = [P,A,T,R,O,W,L];
#compose the list
grid = [];
for letter in letters:
for x in range(len(letter[0])):
for y in range(len(letter)):
grid.append(letter[y][x])
for shift in range(7):
i = shift
s = ""
while i<len(grid):
if grid[i]==1:
s += "x"
else:
s += " "
i += 7
print(s)
# browse on the flattened list
for daysSinceBeginning in range(len(grid)):
#compute date
dateForThisDay = dateTopLeftCorner + datetime.timedelta(days=daysSinceBeginning)
formattedDate = dateForThisDay.strftime("%a %b %d %H:%M:%S CET %Y")
print(formattedDate, "->", grid[daysSinceBeginning], "->", daysSinceBeginning, "/", 365)
if grid[daysSinceBeginning] > 0:
#print(formattedDate, "->", grid[daysSinceBeginning])
subprocess.call(["./create-commit-for-date.sh", formattedDate])