--- OSAS/OSA_system/OSAS_helpers.py 2004/04/14 21:38:02 1.6 +++ OSAS/OSA_system/OSAS_helpers.py 2008/09/05 11:42:55 1.9 @@ -4,11 +4,38 @@ import os.path import re import urllib +def changeIndexMeta(argv,path,dirnames): + """change index.meta""" + subnodes={} + + if not argv['startpage']=='': + subnodes['startpage']=argv['startpage'] + + if not argv['xslt']=='': + subnodes['xslt']=argv['xslt'] + + if not argv['thumbtemplate']=='': + subnodes['thumbtemplate']=argv['thumbtemplate'] + + if not argv['topbar']=='': + subnodes['toptemplate']=argv['toptemplate'] + + + try: + changeNodesInIndexMeta(path,'',subnodes,parent='texttool') + + except: + print "ERROR (changeIndexMeta)",path + + urllib.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines() + return "done" + + def readArchimedesXML(folder): """gib URL aus """ try: - XML=urllib.urlopen("http://archimedes.mpiwg-berlin.mpg.de/cgi-bin/toc/toc.cgi?step=xmlcorpusmanifest").read() + XML=urllib.urlopen("http://archimedes.mpiwg-berlin.mpg.de/cgi-bin/toc/toc.cgi?step=xmrpusmanifest").read() #print XML dom=xml.dom.minidom.parseString(XML) items=dom.getElementsByTagName('item') @@ -79,15 +106,18 @@ def changeNodesInIndexMeta(path,node,sub """nothing""" namenode=dom.createElement(re.sub(r' ','-',subnode)) - namenodetext=dom.createTextNode(unicode(subnodes[subnode],"utf8")) + namenodetext=dom.createTextNode(unide(subnodes[subnode],"utf8")) namenode.appendChild(namenodetext) root.appendChild(namenode) else: nodeOld=root.getElementsByTagName(node) - if nodeOld: # if yes -> delete it - root.removeChild(nodeOld[0]).unlink() + try: + if nodeOld: # if yes -> delete it + root.removeChild(nodeOld[0]).unlink() + except: + """nothing""" nodeNew=dom.createElement(node) # create new @@ -109,8 +139,10 @@ def changeNodesInIndexMeta(path,node,sub writefile=file(path+"/index.meta","w") writefile.write(dom.toxml().encode('utf-8')) writefile.close() - os.chmod(path+"/index.meta",0664) - + try: + os.chmod(path+"/index.meta",0664) + except: + """nothing"""