comparison modify.py @ 0:fee51ab07d09

blanket publication of all existing python files in lib/python on maritain
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Mon, 09 Mar 2020 14:58:04 +0000
parents
children 0a3abe59e364
comparison
equal deleted inserted replaced
-1:000000000000 0:fee51ab07d09
1 #!/bin/python
2 # Usage: modify.py uun fields...
3 from sys import stdin,argv
4 from urllib2 import Request,urlopen, HTTPError
5
6 l=''
7 year='2014'
8 uuns={}
9
10 def cc(names):
11 return ' '.join(map(lambda n:n[0]+n[1:].lower(),names.split()))
12
13 eargs=['uun']
14 eargs.extend(argv[1:])
15
16 for l in stdin:
17 l=l.rstrip().decode('latin-1');
18 if l=='':
19 continue
20 try: #uun,...
21 vals=l.split("\t")
22 except ValueError:
23 print "Bad input: %s"%l
24 continue
25 attrs=" ".join(map(lambda (n,v):'%s="%s"'%(n,v),zip(eargs,vals)))
26 req='<update year="%s" %s/>'%(year,attrs)
27 print req
28 r=Request("http://localhost:8080/exist/apps/phd/updateApp.xq",
29 req.encode('utf-8'),headers={'Content-Type':'application/xml;charset=UTF-8'})
30 try:
31 res=urlopen(r)
32 except HTTPError as err:
33 print "Error:",err.read()
34 print req
35 exit(1)
36 print res.read()