⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 run.py

📁 XML tutorial
💻 PY
字号:
#!/usr/bin/pythonimport os,re,systry:    lang = str(sys.argv[1])except IndexError:    lang=""print "lang: " + langif (not(lang == '')):    langsuffix = "_" + lang    langparam = "lang=" + lang    langsuffixparam = "langsuffix=" + langsuffixelse:    langsuffix = ""    langparam = ""    langsuffixparam = ""if re.compile("Python\Z").search(os.getcwd()):    os.chdir("..") os.chdir("ExampleSources" + langsuffix)data=''for f in os.listdir("."):    if not(re.compile("\.xml\Z").search(f)):           continue    input=open(f)    data = data + input.read()    input.close()os.chdir('..')### data=re.compile('<description lang="cs">.*?</description>',re.S).sub('',data)output=open("Data" + langsuffix + "/source.xml","w")sys.stdout = outputprint """<!-- generated by run.py  --><!DOCTYPE allExamples [ <!ENTITY eacute '&#233;'> <!ENTITY ugrave '&#249;'> <!ENTITY agrave '&#224;'> <!ENTITY egrave '&#232;'> <!ENTITY ograve '&#242;'> <!ENTITY icirc  '&#238;'> <!ENTITY ecirc  '&#234;'> <!ENTITY ccedil '&#231;'>]><allExamples>"""print dataprint "</allExamples>"output.close()sys.stdout = sys.__stdout__command = "saxonclient -o General" + langsuffix + "/contents.html Data" + langsuffix + "/source.xml XSL/stylesheet.xsl pwd=${PWD}/ " + langparam +" "+ langsuffixparamprint "command: " + commandos.system(command)os.chdir("Output" + langsuffix)def aaa(hit):#    print hit.group(2)    text = re.compile("\n",re.S).sub('<br></br>',hit.group(2))    text = re.compile(" ",re.S).sub('&nbsp;',text)    text = re.compile("\t",re.S).sub('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',text)    text = re.compile("span&nbsp;class",re.S).sub('span class',text)#    print text    return hit.group(1) + text +hit.group(3)for f in os.listdir("."):#    print "file " + f    if not(re.compile("\.html\Z").search(f)):           continue    input=open(f)    data = input.read()    input.close()    data=re.compile('(<td class="doc">)(.*?)(</td>)',re.S).sub(aaa,data)        output=open(f,'w')    output.write(data)    output.close()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -