-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
154 lines (121 loc) · 4.9 KB
/
main.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
from datetime import date, timedelta
from modules.char_to_coords import char_to_coords
import os
"""
!ROADMAP!
[*] complete the alphabets (refact to new file).
[*] new func for printing at most 10 letters in the matrix.
[*] algorithm to generate the dates from the matrix.
[*] get the git commit library or make one.
[*] generate standalone folder with all the git stuff ready to push.
[ ] write a good readme add some screenshots.
"""
col = 52
#! this looks ugly should do some thing or take it to other file
matCol1 = [" " for i in range(0, col)]
matCol2 = [" " for i in range(0, col)]
matCol3 = [" " for i in range(0, col)]
matCol4 = [" " for i in range(0, col)]
matCol5 = [" " for i in range(0, col)]
matCol6 = [" " for i in range(0, col)]
matCol7 = [" " for i in range(0, col)]
mat_Date_Col1 = [" " for i in range(0, col)]
mat_Date_Col2 = [" " for i in range(0, col)]
mat_Date_Col3 = [" " for i in range(0, col)]
mat_Date_Col4 = [" " for i in range(0, col)]
mat_Date_Col5 = [" " for i in range(0, col)]
mat_Date_Col6 = [" " for i in range(0, col)]
mat_Date_Col7 = [" " for i in range(0, col)]
mat = [matCol1, matCol2, matCol3, matCol4, matCol5,
matCol6, matCol7] # mat for drawing the stars
matDates = [mat_Date_Col1, mat_Date_Col2, mat_Date_Col3,
mat_Date_Col4, mat_Date_Col5, mat_Date_Col6, mat_Date_Col7] # a reference calender
commitDates = [] # the final dates to do the commits
# ? to print the matrix with out the arrays
def display(mat):
for row in mat:
sttr = ""
for elemnt in row:
sttr = sttr + elemnt
print(sttr)
# ? will print the matrix
def display_mat(mat):
for row in mat:
print(row)
# ? for clearing the display while printing many charector one by one
def clear_display(mat):
for i in range(0, 7):
for j in range(0, col):
mat[i][j] = " "
# ? for drawing the individual co-ordinates.
def draw_mat(ch, pos=1): # if no poss passed then start from 1st co ord
for x, y in ch:
# pos will leave the required space so that letters will not get printed on top of each other
spaceInFront = 1
# to add more space in front ie, number of row to leave at the start change the spaceInFront
mat[x + 1][pos + y + spaceInFront] = "*"
# ? function takes a matrix and year => generates all the dates from JAN to DEC and returns the array
def mat_dates_gen(year, matDates):
commitDate = date(year, 1, 1)
# ! find the starting day of the week
if commitDate.weekday() == 6: # python-date-module week starts from monday. On github it starts from sunday so correcting
weekStart = 0
else:
# monday will return 0 so plus 1 will make it in the second row
weekStart = (commitDate.weekday() + 1)
for y in range(0, 52):
for x in range(weekStart, 7):
matDates[x][y] = commitDate # for testing purpose
commitDate += timedelta(days=1)
weekStart = 0 # reset for everyother week
return matDates
# ? Func loops through the array and find for * if found then will take the co-ord and will get the corresponding date from the OTHER matrix
def get_dates(mat, matDates, commitDates, year):
matDates = mat_dates_gen(year, matDates) # making the OTHER matrix
for y in range(0, 52):
for x in range(0, 7):
if mat[x][y] == "*": # check
# get the corresponding date
commitDates.append(matDates[x][y])
return commitDates
# ? Will create a new folder and commit there with the passed dates
def doTheCommit(commitDates):
workingDir = os.getcwd()
os.system("mkdir showoff")
os.chdir(workingDir+"/showoff")
os.system("git init")
for i in commitDates:
txt = open("text.txt", "w")
txt.write(f"{i}")
txt.close()
os.system("git add .")
os.system(f"git commit -m {i} --date {i}")
# ? PRINT => all char in one matrix
def draw_chars(string):
for indx, l in enumerate(string):
# finding where should the letter come on the matrix. 5 => 4 columns of letter + 1 space
pos = (indx * 5)
char_code = char_to_coords(l)
draw_mat(char_code, pos)
display(mat)
# string = "abcdefghijklmnopqrstuvwxyz"
# ? PRINT => all char diff matrix
# for l in string:
# clear_display(mat)
# char_code = char_to_coords(l)
# draw_mat(char_code)
# display(mat)
# ? PRINT => one letter in one matrix
# char_code = char_to_coords("z")
# draw_mat(char_code)
# display(mat)
# **************** program execution starts here ***************
stringToPrint = input("Enter the string, Bellow 10 Charactors: ")
year = int(input(
"Enter the year, ie the timeline to get printed on: "))
if len(stringToPrint) <= 10 and year > 2010:
draw_chars(stringToPrint)
commitDates = get_dates(mat, matDates, commitDates, year)
doTheCommit(commitDates)
else:
print("Invalid input try! Run the script Again.")