forked from Arborator/arborator-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getTree.cgi
executable file
·46 lines (36 loc) · 1.14 KB
/
getTree.cgi
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
#import cgi
import sys,cgi,cgitb, os
cgitb.enable()
form = cgi.FieldStorage()
userdir = 'users/'
thisfile = os.environ.get('SCRIPT_NAME',".")
action = form.getvalue("action",None)
sys.path.append('modules')
from logintools import login
from logintools import isloggedin
action, userconfig = login(form, userdir, thisfile, action)
adminLevel = int(userconfig["admin"])
project = form.getvalue('project',"").decode("utf-8")
treeid = form.getvalue('treeid',None)
compare = form.getvalue('compare',None)
filename = form.getvalue('filename',"").decode("utf-8")
nr = int(form.getvalue('nr',1))
filetype = form.getvalue('filetype',None)
print 'Content-type: application/json\n\n'
#if project=="quickie":
#if filetype == "conll14" or filetype == "conll10" or filetype == "conll4":
#from lib.conll import conll2jsonTree
#conll2jsonTree(filename,nr)
#else:
from lib.database import SQL
sql=SQL(project)
if compare:
treeids={}
for k in form.keys():
if k.startswith("treeids"):
treeids[int(k.split("[")[-1][:-1])]=form.getvalue(k)
sql.compare(treeids)
else:
sql.tree2json(treeid=treeid, adminLevel=adminLevel)