This repository was archived by the owner on Aug 19, 2021. It is now read-only.
forked from job/irrexplorer
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathquery
More file actions
executable file
·47 lines (35 loc) · 1.33 KB
/
query
File metadata and controls
executable file
·47 lines (35 loc) · 1.33 KB
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
#!/usr/bin/env python
# Copyright (c) 2015, NORDUnet A/S
import sys
from irrexplorer import utils, sqldb, report
def main():
if len(sys.argv) == 1:
print "No argument given"
sys.exit(1)
dsn = "dbname=irrexplorer"
db = sqldb.IRRSQLDatabase(dsn)
for arg in sys.argv[1:]:
try:
so = utils.classifySearchString(arg)
if type(so) is utils.Prefix:
result = report.prefix(db, so.value)
# prefix report already prints some stuff (consider changing that)
if type(so) is utils.ASNumber:
result = report.as_prefixes(db, so.value)
for prefix, sources in result['prefixes'].items():
print prefix, sources.keys()
print
for macro, sources in result['macros'].items():
print macro, sources.keys()
if type(so) is utils.ASMacro:
#res = db.query_as_macro(so.value)
result = report.macro_expand(db, so.value)
for e in result['expanded']:
print e
print
for macro, sources in result['macros'].items():
print macro, ' '.join(sources.keys())
except ValueError as e:
print str(e)
if __name__ == '__main__':
main()