Mercurial > hg > python
view modify.py @ 43:f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Thu, 24 Feb 2022 15:43:26 +0000 |
parents | 0a3abe59e364 |
children |
line wrap: on
line source
#!/bin/python # Usage: modify.py fields... from sys import stdin,argv from urllib2 import Request,urlopen, HTTPError l='' year='2016' 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://troutbeck: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()