timy-cli 2.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
timy_cli/__init__.py ADDED
File without changes
timy_cli/__main__.py ADDED
@@ -0,0 +1,7 @@
1
+
2
+ import sys
3
+
4
+ from timy import cli
5
+
6
+ if __name__ == "__main__":
7
+ sys.exit(cli())
timy_cli/timy.py ADDED
@@ -0,0 +1,189 @@
1
+
2
+ import math
3
+ import time
4
+ import sys
5
+ import argparse
6
+ import importlib.metadata
7
+ from os import system, name, get_terminal_size
8
+
9
+ from colorama import Fore, init
10
+ init(autoreset=True)
11
+
12
+
13
+ # Set __version__
14
+ try:
15
+ __version__ = f"timy {importlib.metadata.version('timy-cli')}"
16
+ except importlib.metadata.PackageNotFoundError:
17
+ __version__ = "Package not installed..."
18
+
19
+
20
+ parser = argparse.ArgumentParser(description='Print an analog clock to the consol!', add_help=False)
21
+
22
+ parser.add_argument('-?', '--help', action='help', help='Show this help message and exit.')
23
+
24
+ parser.add_argument('-v', '--version', action='version', version='%(prog)s {version}'.format(version=__version__))
25
+
26
+ parser.add_argument('-r', '--refresh', dest='_refresh', action='store_true', help='Refresh every minute until stopped')
27
+
28
+ parser.add_argument('-c', '--continuous', dest='_refresh', action='store_true', help='Alias for --refresh')
29
+
30
+ parser.add_argument('-t', '--timer', metavar='M', action='append', type=int, nargs='?', const=60, help='Countdown timer for [M] minutes (default 60)')
31
+
32
+ args = parser.parse_args() #Execute parse_args()
33
+
34
+
35
+
36
+
37
+ def clear():
38
+ # for windows
39
+ if name == 'nt':
40
+ _ = system('cls')
41
+ # for mac and linux(here, os.name is 'posix')
42
+ else:
43
+ _ = system('clear')
44
+
45
+ def countdownTimer(Minutes):
46
+ clear()
47
+ paddingWithGlass = get_terminal_size()[1] - 32 # 32 is length of the following outputs
48
+ if paddingWithGlass > 0:
49
+ print("\n" * paddingWithGlass)
50
+ print('''
51
+ _.-"""-._
52
+ _.-"" ""-._
53
+ :"-. .-":
54
+ '"-_"-._ _.-".-"'
55
+ ||T+._"-._.-"_.-"|
56
+ ||: "-.|.-" : ||
57
+ || . ' || . ||
58
+ || . '|| . ||
59
+ || ';.:||' ||
60
+ || '::|| ||
61
+ || :|| ||
62
+ || ':|| ||
63
+ || .' :||. ||
64
+ || ' . :||.' ||
65
+ ||.'- .:|| -'._||
66
+ .-'": .::::||:. : "'-.
67
+ :"-.'::::::||::' .-":
68
+ "-."-._"--:" .-".-"
69
+ "-._"-._.-".-"
70
+ "-.|.-"
71
+ ''')
72
+ try:
73
+ for m in progressbar(range(Minutes), prefix="Timer: " +str(Minutes) + " Min ", sufix="(pass ← wait)"):
74
+ time.sleep(60)
75
+ if m == Minutes - 1:
76
+ clear()
77
+ print("\n" * get_terminal_size()[1])
78
+ print(f'''{Fore.LIGHTGREEN_EX}
79
+ +====+
80
+ |( )|
81
+ | )( |
82
+ |(::)|
83
+ +====+
84
+ Timer has ended!''')
85
+ print("\a")
86
+ except:
87
+ print(f"\n\n{Fore.YELLOW}[Timer interrupted]\n\n")
88
+
89
+
90
+ def progressbar(it, prefix="", sufix=""): #progressbar --> prefix: [############################.............................] i/it
91
+ size = abs(get_terminal_size()[0] - len(prefix) - len(sufix) - 16)
92
+ count = len(it)
93
+ def show(j):
94
+ x = int(size*j/count)
95
+ sys.stdout.write("%s[%s%s] %i ← %i %s \r" % (prefix, "#"*x, "."*(size-x), j, (count-j), sufix))
96
+ sys.stdout.flush()
97
+ show(0) #This prints the progressbar at 0 progress. Then next for loop renders the rest (stating at 1)
98
+ for i, item in enumerate(it): #This is the 'i' in the comment on the 'def' line
99
+ yield item
100
+ show(i+1)
101
+ sys.stdout.write("\n")
102
+ sys.stdout.flush()
103
+
104
+ def p(t,r,sym='*'):
105
+ global c
106
+ if stretch_x == True:
107
+ c[int((clock_hight-r*math.cos(t))/2)][int(clock_hight+r*math.sin(t))]=sym
108
+ else:
109
+ c[int(clock_hight-r*math.cos(t))][int(clock_hight+r*math.sin(t))]=sym
110
+
111
+ def analog_clock(_refresh):
112
+ global c
113
+ global stretch_x
114
+ global clock_hight
115
+
116
+ hr_fmt = 12
117
+ stretch_x = True #--> if clock_width is twice that of clock_hight
118
+ min_size = 0.02
119
+ hr_size = 0.01
120
+ clock_width = 50
121
+ clock_hight = 25
122
+
123
+ try:
124
+ while True:
125
+ print('\n' * 4)
126
+ c = [[' '] * clock_width for i in range(clock_width)]
127
+ t = time.localtime()
128
+ h = t.tm_hour * 6.283 + t.tm_min / 9.549
129
+ for i in range(999):
130
+ p(i/158.0,24)
131
+ p(h,i*min_size,"▓")
132
+ p(h/hr_fmt,i*hr_size,"█")
133
+ for q in range(12):
134
+ p(q/1.91,24-i*.005,'•')
135
+ for y in range(clock_hight):
136
+ print(''.join(c[y]))
137
+ print((" "*int(((clock_width/2)-2))) + str(time.localtime().tm_hour).zfill(2) + ":" + str(time.localtime().tm_min).zfill(2))
138
+ if _refresh == True:
139
+ print("\n[ctrl + c] to terminate", end='')
140
+ time.sleep(60)
141
+ clear()
142
+ else:
143
+ break
144
+ except:
145
+ #exit without error message
146
+ return
147
+
148
+ def mini_clocks(_refresh):
149
+ global c
150
+ global stretch_x
151
+ global clock_hight
152
+
153
+ hr_fmt = 12
154
+ stretch_x = True #--> if clock_width is twice that of clock_hight
155
+ min_size = 0.02
156
+ hr_size = 0.01
157
+ clock_width = 26
158
+ clock_hight = 13
159
+
160
+ try:
161
+ while True:
162
+ print('\n' * 4)
163
+ c = [[' '] * clock_width for i in range(clock_width)]
164
+ t = time.localtime()
165
+ h = t.tm_hour * 6.283 + t.tm_min / 9.549
166
+ for i in range(999):
167
+ p(i/158.0,24)
168
+ p(h,i*min_size,"▓")
169
+ p(h/hr_fmt,i*hr_size,"█")
170
+ for q in range(12):
171
+ p(q/1.91,24-i*.005,'•')
172
+ for y in range(clock_hight):
173
+ print(''.join(c[y]))
174
+ print((" "*int(((clock_width/2)-2))) + str(time.localtime().tm_hour).zfill(2) + ":" + str(time.localtime().tm_min).zfill(2))
175
+ if _refresh == True:
176
+ print("\n[ctrl + c] to terminate", end='')
177
+ time.sleep(60)
178
+ clear()
179
+ else:
180
+ break
181
+ except:
182
+ #exit without error message
183
+ return
184
+
185
+ def cli():
186
+ if args.timer != None:
187
+ countdownTimer(args.timer[0])
188
+ else:
189
+ analog_clock(args._refresh)
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 espehon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,20 @@
1
+ Metadata-Version: 2.1
2
+ Name: timy-cli
3
+ Version: 2.0.0
4
+ Summary: Analog Clock and Timer
5
+ Author-email: espehon <espehon@gmail.com>
6
+ Project-URL: Homepage, https://github.com/espehon/timy-cli
7
+ Project-URL: Bug Tracker, https://github.com/espehon/timy-cli/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Environment :: Console
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Topic :: Utilities
14
+ Requires-Python: >=3.8
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: colorama (>=0.4.6)
18
+
19
+ # timy
20
+ Simple console clock/timer
@@ -0,0 +1,9 @@
1
+ timy_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ timy_cli/__main__.py,sha256=WCdbJNS9AcHK1wPzNT9ETPfjItnE6N9nDuyYn_q54H0,87
3
+ timy_cli/timy.py,sha256=AqlB7iUEejEbSjqQsqN5wpRB93jdjomo-x3FDaV9JYA,6007
4
+ timy_cli-2.0.0.dist-info/LICENSE,sha256=bEAN5qOX7zr0T4KXimB0zwjVTMOqXJLtg3VBVAgNOGg,1085
5
+ timy_cli-2.0.0.dist-info/METADATA,sha256=Ml9MTnDrEge6Ou9bJfAMHEC00pWmTFt1CmT6wIKZiC8,684
6
+ timy_cli-2.0.0.dist-info/WHEEL,sha256=AtBG6SXL3KF_v0NxLf0ehyVOh0cold-JbJYXNGorC6Q,92
7
+ timy_cli-2.0.0.dist-info/entry_points.txt,sha256=4DN2ryC7FiEMyiUlO8yH9coMhMBz1YijUVUWSErNaS8,43
8
+ timy_cli-2.0.0.dist-info/top_level.txt,sha256=Yc4Ie7xGW5EJ3uqqZ4kSZIuFdZjKuCIE3iUoF7d5ZlA,9
9
+ timy_cli-2.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.41.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ timy = timy_cli.timy:cli
@@ -0,0 +1 @@
1
+ timy_cli