aboutsummaryrefslogtreecommitdiffstats
path: root/mongoclock
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-02-14 15:27:56 +0100
committerMattias Andrée <maandree@operamail.com>2013-02-14 15:27:56 +0100
commit8dbb6dfd26084037788eab58dfa15c764494b525 (patch)
treee60edb69b12937783af929a9545a62408fc15426 /mongoclock
parenthumongous digits (diff)
downloadmongotimer-8dbb6dfd26084037788eab58dfa15c764494b525.tar.gz
mongotimer-8dbb6dfd26084037788eab58dfa15c764494b525.tar.bz2
mongotimer-8dbb6dfd26084037788eab58dfa15c764494b525.tar.xz
how to print time, without concidering the time or screen dimensions
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rwxr-xr-xmongoclock.py349
1 files changed, 207 insertions, 142 deletions
diff --git a/mongoclock.py b/mongoclock.py
index 6dad499..d36cb3d 100755
--- a/mongoclock.py
+++ b/mongoclock.py
@@ -1,142 +1,207 @@
-MONGO_0 = [" [XXXX] ",
- " [XX] [XX] ",
- "[XX] [XX] ",
- "[XX] [XX] ",
- "[XX] [XX] ",
- "[XX] [] [XX] ",
- "[XX] [] [XX] ",
- "[XX] [XX] ",
- "[XX] [XX] ",
- "[XX] [XX] ",
- " [XX] [XX] ",
- " [XXXX] "]
-
-MONGO_1 = [" [XX] ",
- " [XXXX] ",
- " [XXXXXX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XXXXXXXXXX] "]
-
-MONGO_2 = [" [XXXXXXXX] ",
- "[XX] [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- "[XX] ",
- "[XX] [XX] ",
- "[XXXXXXXXXXXX] "]
-
-MONGO_3 = [" [XXXXXXXX] ",
- "[XX] [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XXXXXX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- "[XX] [XX] ",
- " [XXXXXXXX] "]
-
-MONGO_4 = [" [XX] ",
- " [XXXX] ",
- " [XXXXXX] ",
- " [XX] [XX] ",
- "[XX] [XX] ",
- "[XXXXXXXXXXXX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XXXXXX] "]
-
-MONGO_5 = ["[XXXXXXXXXXXX] ",
- "[XX] ",
- "[XX] ",
- "[XX] ",
- "[XX] ",
- "[XXXXXXXXXX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- "[XX] [XX] ",
- " [XXXXXXXX] "]
-
-MONGO_6 = [" [XXXX] ",
- " [XX] ",
- " [XX] ",
- "[XX] ",
- "[XX] ",
- "[XXXXXXXXXX] ",
- "[XX] [XX] ",
- "[XX] [XX] ",
- "[XX] [XX] ",
- "[XX] [XX] ",
- "[XX] [XX] ",
- " [XXXXXXXX] "]
-
-MONGO_7 = ["[XXXXXXXXXXXX] ",
- "[XX] [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] "]
-
-MONGO_8 = [" [XXXXXXXX] ",
- "[XX] [XX] ",
- "[XX] [XX] ",
- "[XX] [XX] ",
- "[XX] [XX] ",
- " [XXXXXXXX] ",
- "[XX] [XX] ",
- "[XX] [XX] ",
- "[XX] [XX] ",
- "[XX] [XX] ",
- "[XX] [XX] ",
- " [XXXXXXXX] "]
-
-MONGO_9 = [" [XXXXXXXX] ",
- "[XX] [XX] ",
- "[XX] [XX] ",
- "[XX] [XX] ",
- "[XX] [XX] ",
- " [XXXXXXXXXX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XX] ",
- " [XXXX] "]
-
-MONGO__ = [" ",
- " ",
- " [XX] ",
- " [XX] ",
- " ",
- " ",
- " ",
- " ",
- " [XX] ",
- " [XX] ",
- " ",
- " "]
+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()
+