-
Notifications
You must be signed in to change notification settings - Fork 10
/
app.py
70 lines (59 loc) · 2.23 KB
/
app.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
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Stocky McStockface for Indian stock markets
# https://github.com/justgoodin/stocky
# Copyright (C) 2021 Rehan Haider (justgoodin)
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import sys
from termcolor import colored
from lib.screen.screenManager import ScreenManager
from lib.bin.bhavCopy import bhavUpdate
from lib.bin.yahoo import yahooDataManager
_DEFAULT = 0
_BHAV = 1
_YAHOO = 2
_EXIT = 3
_ERROR = -1
def main():
exitApp = False
screen = _DEFAULT
while True:
if exitApp:
sys.exit(0)
if screen == _DEFAULT:
ScreenManager()
option = ScreenManager.getUserInput()
elif option == _ERROR:
print(colored("Not a valid selection. Please choose a valid option from below", "red"))
continue
if option == _BHAV:
screen = 1
print(colored("Rebuilding will delete the previous version.", "yellow", "on_red"))
if ScreenManager.getConfirmation():
bhavUpdate()
screen = _DEFAULT
elif option == _YAHOO:
print(colored("This will download all data and may take a long time.", "yellow", "on_red"))
if ScreenManager.getConfirmation():
ydm = yahooDataManager()
ydm.updateData()
screen = _DEFAULT
if option == _EXIT:
print(colored("Terminate program and exit?", "yellow", "on_red"))
if ScreenManager.getConfirmation():
exitApp = True
# print options
if __name__ == "__main__":
main()