-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogoUtils.py
57 lines (46 loc) · 1.69 KB
/
logoUtils.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
import datetime
def print_logo(win, x, y, CustomLogo, nodate):
"""
Prints the logo to the curses window. Can accept a custom logo and a date boolean to hide the date.
"""
logo = """ _____ _
|_ _|__ __| | ___
| |/ _ \ __ / _` |/ _ \\
| | (_) |__| (_| | (_) |
|_|\\___/ \\__,_|\\___/
"""
# If we have a valid custom logo
if len(CustomLogo) > 0 and CustomLogo != " ":
logo = "\n" + CustomLogo
logo_lines = len(logo.split('\n'))
# If we have a space logo (means bo logo)
elif CustomLogo == " ":
logo = ""
logo_lines = 0
# if we have n o custom logo, just use the default one
else:
logo_lines = len(logo.split('\n')) - 1
# PRint eh given logo to the curses window
win.addstr(y, x, logo)
# generate the date
if nodate == "False":\
# get the current date number eg: 13
dateNum = int(datetime.datetime.now().strftime('%d'))
# endings for dates eg 13th or 22nd ot 21st
stEndings = [1, 21, 31]
rdEndings = [3, 23]
ending = "th"
if dateNum in stEndings: ending = "st"
if dateNum in rdEndings: ending = "rd"
# generate the date string eg: Thursday - 14th Feb 2019
dayNum = datetime.datetime.now().strftime('%d')
if dayNum[0] == "0":
dayNum = dayNum[1:]
date = datetime.datetime.now().strftime('%A - {0}{1} %b %G'.format(dayNum, ending))
# print to the curses window
win.addstr(y+logo_lines+1, x, date)
# return the line we finished on plus some padding for the new todo input which comes next
return y + logo_lines+2
else:
# if we havent used a date we use less padding for the new todo input which comes next
return y + logo_lines