Mercurial > hg > python
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modify.py Mon Mar 09 14:58:04 2020 +0000 @@ -0,0 +1,36 @@ +#!/bin/python +# Usage: modify.py uun fields... +from sys import stdin,argv +from urllib2 import Request,urlopen, HTTPError + +l='' +year='2014' +uuns={} + +def cc(names): + return ' '.join(map(lambda n:n[0]+n[1:].lower(),names.split())) + +eargs=['uun'] +eargs.extend(argv[1:]) + +for l in stdin: + l=l.rstrip().decode('latin-1'); + if l=='': + continue + try: #uun,... + vals=l.split("\t") + except ValueError: + print "Bad input: %s"%l + continue + attrs=" ".join(map(lambda (n,v):'%s="%s"'%(n,v),zip(eargs,vals))) + req='<update year="%s" %s/>'%(year,attrs) + print req + r=Request("http://localhost:8080/exist/apps/phd/updateApp.xq", + req.encode('utf-8'),headers={'Content-Type':'application/xml;charset=UTF-8'}) + try: + res=urlopen(r) + except HTTPError as err: + print "Error:",err.read() + print req + exit(1) + print res.read()