Last active
August 29, 2015 14:02
-
-
Save manicmonkey/749d41664865a538d22c to your computer and use it in GitHub Desktop.
Convert edgeConnect language map to Swedish Chef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xml.etree.ElementTree as ET | |
import urllib | |
import urllib.parse | |
import urllib.request | |
def getChef(value): | |
url = 'http://www.cs.utexas.edu/users/jbc/bork/bork.cgi' | |
values = { | |
'type' : 'chef', | |
'input' : value | |
} | |
data = urllib.parse.urlencode(values).encode('utf-8') | |
req = urllib.request.Request(url, data) | |
response = urllib.request.urlopen(req) | |
the_page = response.read() | |
return the_page.decode('utf-8').replace('\n', ' ').strip() | |
tree = ET.parse('c:\\tmp\\language-map.xml') | |
for ori in tree.getroot().findall(".//ProcessEntityAttr[@name='DisplayText']/Attr"): | |
print('orig ', ori.get('original')) | |
if '$$' in ori.get('original'): continue | |
newval = getChef(ori.get('original')) | |
print('newval', newval) | |
ori.set('value', newval) | |
tree.write('c:\\tmp\\language-map-new.xml') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment