-
Notifications
You must be signed in to change notification settings - Fork 0
/
grdb
executable file
·80 lines (65 loc) · 1.55 KB
/
grdb
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
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/python3 -B
import commands
import component
import components
import config
import graph
import graphs
import os
import shlex
import shutil
import sys
print('grdb (C) Frank W. Miller')
rdir = os.path.expanduser(config.GRDB_DIR)
try:
os.stat(rdir)
# print('Database directory:', rdir)
except:
# print('Create database directory:', rdir)
os.mkdir(rdir)
# Determine initial current graph and component number
gno = (-1)
cno = (-1)
glist = graphs.get_list()
gnolist = list(map(int, glist))
if gnolist:
gno = min(gnolist)
if gno >= 0:
clist = components.get_list(gno)
cnolist = list(map(int, clist))
if cnolist:
cno = min(cnolist or (-1))
# Main command line loop
while True:
# Determine appropriate prompt
if gno < 0 or cno < 0:
line = input(config.PROMPT)
else:
line = input(str(gno) + '.' + str(cno) + '> ')
argv = shlex.split(line)
if len(argv) == 0:
continue
if argv[0] == 'quit':
sys.exit(0)
if argv[0] == 'clear':
rdir = os.path.expanduser(config.GRDB_DIR)
shutil.rmtree(rdir, ignore_errors=True)
os.mkdir(rdir)
gno = (-1)
cno = (-1)
continue;
if argv[0] == 'graph' or argv[0] == 'g':
gno, cno = commands.graph_cmd(argv, gno, cno)
continue
if argv[0] == 'component' or argv[0] == 'c':
gno, cno = commands.component_cmd(argv, gno, cno)
continue
if argv[0] == 'schema' or argv[0] == 's':
commands.schema_cmd(argv, gno, cno)
continue
if argv[0] == 'edge' or argv[0] == 'e':
commands.edge_cmd(argv, gno, cno)
continue
if argv[0] == 'tuple' or argv[0] == 't':
commands.tuple_cmd(argv, gno, cno)
continue