aboutsummaryrefslogtreecommitdiffstats
path: root/mongoclock.py
blob: d36cb3d0ebbcec920799818339f5d61f17cd6f18 (plain) (blame)
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
def awesome(e):
    return e.replace('X', ' ').replace('[', '\033[07m ').replace(']', '\033[00m ')


MONGO_0 = [awesome(e) for e in
          ['    [XXXX]      ',
           '  [XX]  [XX]    ',
           '[XX]      [XX]  ',
           '[XX]      [XX]  ',
           '[XX]      [XX]  ',
           '[XX]  []  [XX]  ',
           '[XX]  []  [XX]  ',
           '[XX]      [XX]  ',
           '[XX]      [XX]  ',
           '[XX]      [XX]  ',
           '  [XX]  [XX]    ',
           '    [XXXX]      ']]

MONGO_1 = [awesome(e) for e in
          ['      [XX]      ',
           '    [XXXX]      ',
           '  [XXXXXX]      ',
           '      [XX]      ',
           '      [XX]      ',
           '      [XX]      ',
           '      [XX]      ',
           '      [XX]      ',
           '      [XX]      ',
           '      [XX]      ',
           '      [XX]      ',
           '  [XXXXXXXXXX]  ']]

MONGO_2 = [awesome(e) for e in
          ['  [XXXXXXXX]    ',
           '[XX]      [XX]  ',
           '          [XX]  ',
           '          [XX]  ',
           '          [XX]  ',
           '        [XX]    ',
           '      [XX]      ',
           '    [XX]        ',
           '  [XX]          ',
           '[XX]            ',
           '[XX]      [XX]  ',
           '[XXXXXXXXXXXX]  ']]

MONGO_3 = [awesome(e) for e in
          ['  [XXXXXXXX]    ',
           '[XX]      [XX]  ',
           '          [XX]  ',
           '          [XX]  ',
           '          [XX]  ',
           '    [XXXXXX]    ',
           '          [XX]  ',
           '          [XX]  ',
           '          [XX]  ',
           '          [XX]  ',
           '[XX]      [XX]  ',
           '  [XXXXXXXX]    ']]

MONGO_4 = [awesome(e) for e in
          ['        [XX]    ',
           '      [XXXX]    ',
           '    [XXXXXX]    ',
           '  [XX]  [XX]    ',
           '[XX]    [XX]    ',
           '[XXXXXXXXXXXX]  ',
           '        [XX]    ',
           '        [XX]    ',
           '        [XX]    ',
           '        [XX]    ',
           '        [XX]    ',
           '      [XXXXXX]  ']]

MONGO_5 = [awesome(e) for e in
          ['[XXXXXXXXXXXX]  ',
           '[XX]            ',
           '[XX]            ',
           '[XX]            ',
           '[XX]            ',
           '[XXXXXXXXXX]    ',
           '          [XX]  ',
           '          [XX]  ',
           '          [XX]  ',
           '          [XX]  ',
           '[XX]      [XX]  ',
           '  [XXXXXXXX]    ']]

MONGO_6 = [awesome(e) for e in
          ['      [XXXX]    ',
           '    [XX]        ',
           '  [XX]          ',
           '[XX]            ',
           '[XX]            ',
           '[XXXXXXXXXX]    ',
           '[XX]      [XX]  ',
           '[XX]      [XX]  ',
           '[XX]      [XX]  ',
           '[XX]      [XX]  ',
           '[XX]      [XX]  ',
           '  [XXXXXXXX]    ']]

MONGO_7 = [awesome(e) for e in
          ['[XXXXXXXXXXXX]  ',
           '[XX]      [XX]  ',
           '          [XX]  ',
           '          [XX]  ',
           '        [XX]    ',
           '      [XX]      ',
           '    [XX]        ',
           '    [XX]        ',
           '    [XX]        ',
           '    [XX]        ',
           '    [XX]        ',
           '    [XX]        ']]

MONGO_8 = [awesome(e) for e in
          ['  [XXXXXXXX]    ',
           '[XX]      [XX]  ',
           '[XX]      [XX]  ',
           '[XX]      [XX]  ',
           '[XX]      [XX]  ',
           '  [XXXXXXXX]    ',
           '[XX]      [XX]  ',
           '[XX]      [XX]  ',
           '[XX]      [XX]  ',
           '[XX]      [XX]  ',
           '[XX]      [XX]  ',
           '  [XXXXXXXX]    ']]

MONGO_9 = [awesome(e) for e in
          ['  [XXXXXXXX]    ',
           '[XX]      [XX]  ',
           '[XX]      [XX]  ',
           '[XX]      [XX]  ',
           '[XX]      [XX]  ',
           '  [XXXXXXXXXX]  ',
           '          [XX]  ',
           '          [XX]  ',
           '          [XX]  ',
           '        [XX]    ',
           '      [XX]      ',
           '  [XXXX]        ']]

MONGO__ = [awesome(e) for e in
          ['                ',
           '                ',
           '      [XX]      ',
           '      [XX]      ',
           '                ',
           '                ',
           '                ',
           '                ',
           '      [XX]      ',
           '      [XX]      ',
           '                ',
           '                ']]


DX = len(MONGO_0[0])


class mongoclock:
    def __init__(self):
        pass
    
    
    def print_digit(digit, x, y):
        d = MONGO__
        if   digit == 0:  d = MONGO_0
        elif digit == 1:  d = MONGO_1
        elif digit == 2:  d = MONGO_2
        elif digit == 3:  d = MONGO_3
        elif digit == 4:  d = MONGO_4
        elif digit == 5:  d = MONGO_5
        elif digit == 6:  d = MONGO_6
        elif digit == 7:  d = MONGO_7
        elif digit == 8:  d = MONGO_8
        elif digit == 9:  d = MONGO_9
        x += 1
        for i in range(len(d)):
            y += 1
            print("\033[%i;%iH%s", y, x, d[i])
    
    def print_number(number, x, y):
        print_digit(number // 10, x, y)
        print_digit(number % 10, x + DX, y)
    
    def print_time(h, m, s, x, y):
        print_number(h, x, y)
        x += DX << 1
        print_digit(-1, x, y)
        x += DX
        print_number(m, x, y)
        if s is not None:
            x += DX << 1
            print_digit(-1, x, y)
            x += DX
            print_number(s, x, y)
    
    def get_print_width(has_seconds):
        return 5 * DX + (3 * DX if has_seconds else 0)


if __name__ == '__main__':
    mongoclock()