-
Notifications
You must be signed in to change notification settings - Fork 0
/
fancify.py
122 lines (106 loc) · 2.75 KB
/
fancify.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
# O-----o #
# O---o #
# O-o #
# O #
# o-O #
# o---O #
# o-----O #
# O-----0 #
# O---o #
# O-o #
# O #
# o-O #
# o---O #
# o-----O #
# O-----o #
# O---o #
# O-o #
# O #
# o-O #
# o---O #
# o-----O #
# Generator
def getLineCode(line):
if line == 0:
return "# O-----o #"
if line == 1:
return "# O---o #"
if line == 2:
return "# O-o #"
if line == 3:
return "# O #"
if line == 4:
return "# o-O #"
if line == 5:
return "# o---O #"
if line == 6:
return "# o-----O #"
if line == 7:
return "# o-----O #"
if line == 8:
return "# o---O #"
if line == 9:
return "# o-O #"
if line == 10:
return "# O #"
if line == 11:
return "# O-o #"
if line == 12:
return "# O---o #"
if line == 13:
return "# O-----o #"
if line == 14:
return "# o-----O #"
if line == 15:
return "# o---O #"
if line == 16:
return "# o-O #"
if line == 17:
return "# O #"
if line == 18:
return "# O-o #"
if line == 19:
return "# O---o #"
if line == 20:
return "# O-----o #"
if line == 21:
return "# o-----O #"
def fancify():
''' Calc Max Lenght of '''
maxLine = 0
with open('Individual_fancyTest.py', 'r') as file:
for line in file:
if len(line) > maxLine:
maxLine = len(line)
'''Read Data from file'''
with open('Individual_fancyTest.py', 'r') as file:
data = file.readlines()
if (maxLine + 13 + 5) > 119:
print("Reached over 120 chars per line ")
'''Process Array'''
for line in range(len(data)):
add = getLineCode(line % 21)
spaces = maxLine - len(data[line]) + 5
data[line] = data[line][0:-1] + (spaces * " ") + add + "\n"
'''Write Lines back'''
with open('Individual_fancyTest.py', 'w') as file:
file.writelines(data)
def unfancify():
''' Calc Max Lenght of '''
maxLine = 0
with open('Individual_fancyTest.py', 'r') as file:
for line in file:
if len(line) > maxLine:
maxLine = len(line)
'''Read Data from file'''
with open('Individual_fancyTest.py', 'r') as file:
data = file.readlines()
if (maxLine + 13 + 5) > 119:
print("Reached over 120 chars per line ")
'''Process Array'''
for line in range(len(data)):
data[line] = data[line][0:-19] + "\n"
'''Write Lines back'''
with open('Individual_fancyTest.py', 'w') as file:
file.writelines(data)
unfancify()