Files: d40d4eb7917990aa2e886b6827155eef378f567d / helper.py
2572 bytesRaw
1 | #! /usr/bin/env python3 |
2 | |
3 | import time |
4 | import os |
5 | from sys import argv |
6 | import configparser |
7 | import collections |
8 | |
9 | from components import * |
10 | from asanas import * |
11 | import pyglet |
12 | import menu_screen |
13 | from transitions import * |
14 | |
15 | #Lists for Kriyas and where to find them |
16 | kriya_dict = collections.OrderedDict() |
17 | kriya_list = [] |
18 | routine = None |
19 | |
20 | def gather_kriyas(): |
21 | global kriya_dict |
22 | global kriya_list |
23 | for file in os.listdir('kriyas'): |
24 | kriya = 'kriyas/{}'.format(file) |
25 | config = configparser.ConfigParser() |
26 | config.read(kriya) |
27 | for section in config.sections(): |
28 | kriya_dict[section] = kriya |
29 | kriya_list.append(section) |
30 | |
31 | def kriya_choice(choice): |
32 | global routine |
33 | try: |
34 | option = int(choice) |
35 | key = kriya_list[option - 1] |
36 | routine = kriya_dict[key] |
37 | except: |
38 | routine = kriya_dict[choice] |
39 | |
40 | def menu(): |
41 | ascii_art = """ |
42 | _ _ _ |
43 | | | | | (_) |
44 | ___| |__ ___ ___ ___ ___ _ _ ___ _ _ _ __ | | ___ __ _ _ _ __ _ |
45 | / __| '_ \ / _ \ / _ \/ __|/ _ \ | | | |/ _ \| | | | '__| | |/ / '__| | | | |/ _` | |
46 | | (__| | | | (_) | (_) \__ \ __/ | |_| | (_) | |_| | | | <| | | | |_| | (_| | |
47 | \___|_| |_|\___/ \___/|___/\___| \__, |\___/ \__,_|_| |_|\_\_| |_|\__, |\__,_| |
48 | __/ | __/ | |
49 | |___/ |___/ |
50 | """ |
51 | intertwingled.clear() |
52 | print(ascii_art) |
53 | for number, kriya in enumerate(kriya_list, start=1): |
54 | print("{}) {}".format(number, kriya)) |
55 | print("\n"+"="*30) |
56 | choice = input("Choose your Kriya! Either type in the number or write out the kriya!\n> ").title() |
57 | kriya_choice(choice) |
58 | |
59 | |
60 | # Opening Screen, then move through the kriya |
61 | def main(): |
62 | gather_kriyas() |
63 | splashpage.main() |
64 | menu() |
65 | intention.main(routine) |
66 | settle.main() |
67 | kriya(routine) |
68 | closing_remark.main() |
69 | |
70 | def kriya(ini): |
71 | """Run through poses and duration from ini file""" |
72 | config = configparser.ConfigParser() |
73 | config.read(ini) |
74 | for section in config.sections(): |
75 | kriya = str(section) |
76 | for pose, time in config.items(kriya): |
77 | if pose != 'summary': |
78 | func = pose.replace(" ","") |
79 | func_to_run = getattr(Components, func) |
80 | func_to_run(int(time)) |
81 | if __name__ == "__main__": |
82 | main() |
83 |
Built with git-ssb-web