Controller.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import Alt, Stateful
  2. import datetime
  3. class Client():
  4. def get_config():
  5. # T-B-C...
  6. configs = ['DBType', 'DBPath', 'lang', 'listStyle', 'displayTime']
  7. # rl == 'r'eturn 'l'ist
  8. rl = Stateful.matchTomlKeys("config.toml", configs)
  9. global lang, listStyle, dbType, dbPath
  10. dbType = rl[0]
  11. dbPath = rl[1]
  12. lang = rl[2]
  13. listStyle = rl[3]
  14. displayTimeZone = rl[4]
  15. def get_help():
  16. print(Stateful.matchTomlKey("clean_config.toml", lang, "command-help"))
  17. # not finished
  18. def InUTC(timeZone=0):
  19. dt_now_UTC0 = str(datetime.datetime.now(datetime.timezone.utc))
  20. return(dt_now_UTC0)
  21. def TransitCommand():
  22. # do while or for (1)
  23. while(1):
  24. app_commands = input(currentPath + "/: ", ).split(" ")
  25. # Input exception check
  26. # Add DBType && Path
  27. app_commands.append(dbPath)
  28. app_commands.append(dbType)
  29. Stateful.PackHandler(app_commands)
  30. def start():
  31. # 1. get config
  32. Client.get_config()
  33. global currentPath
  34. currentPath = " "
  35. # ↓↓↓ test code here ↓↓↓
  36. # ↑↑↑ test code here ↑↑↑
  37. # 2. Normalized Start Process
  38. startState = Stateful.TransitHandler(['list', 'board', dbPath, dbType])
  39. print(startState)
  40. Client.TransitCommand()
  41. class View:
  42. def ToDisplayTime(utcTime, TimeZone):
  43. displayTime = "displayTime translation not finished"
  44. return displayTime
  45. def Refresh():
  46. pass
  47. if __name__ == "__main__":
  48. Client.start()