-
Notifications
You must be signed in to change notification settings - Fork 0
/
vspath.py
executable file
·53 lines (39 loc) · 1.42 KB
/
vspath.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
#!/usr/bin/env python3
"""vspath find shortest route between two points."""
import logging
import sys
import graph_tool as gt
from textual.app import App
from textual.widgets import Header
from lib.pathfinder.commander import MasterCommander
from lib.pathfinder.config import config
from lib.pathfinder.ui import Terminal, Prompt
logging.basicConfig(level=logging.DEBUG)
class VSPath(App):
CSS_PATH = 'config/ui.css'
def __init__(self):
super().__init__(watch_css=config.debugmode)
# Populate Data
try:
graph = gt.load_graph(config.data_file)
except IOError:
graph = None
logging.warning('No existing Navgraph found')
self.commander = MasterCommander(self, graph)
def compose(self):
"""Compose app-widgets"""
yield Header(id='header', show_clock=True)
yield Terminal(id='textlog', highlight=True, markup=True)
yield Prompt(id='prompt', classes='box')
def on_prompt_submitted(self, message):
self.query_one(Terminal).write(message.user_input)
self.commander.process(message.user_input)
def action_import_file(self, filename):
self.commander.graph_commander.do_import(filename)
def action_closest_traders(self, origin, distance=1000):
pass
if __name__ == "__main__":
logging.debug(f"Storing Data under {config.data_file}")
# import new data
app = VSPath()
app.run()