--- OSAS/OSA_system/OSAS_add.py 2003/10/13 22:24:35 1.5 +++ OSAS/OSA_system/OSAS_add.py 2004/01/21 07:43:01 1.9 @@ -33,14 +33,18 @@ def add(self, no_upload=0): def getISO(): - f=file('/usr/local/mpiwg/Zope/lib/python/Products/OSA_system/iso639-1.inc','r').readlines() - ret={} - for lineraw in f: - line=lineraw.encode('ascii','replace') - value=string.split(line,'\t')[0].encode('ascii','replace') - key=string.split(line,'\t')[1].encode('ascii','replace') - + try: + f=file('/usr/local/mpiwg/Zope/lib/python/Products/OSA_system/iso639-1.inc','r').readlines() + #f=file('OSA_system/iso639-1.inc','r').readlines() + ret={} + for lineraw in f: + line=lineraw.encode('ascii','replace') + value=string.split(line,'\t')[0].encode('ascii','replace') + key=string.split(line,'\t')[1].encode('ascii','replace') + ret[key]=value + except: + ret={} return ret def add2(self): @@ -177,7 +181,11 @@ def addPresentation(self,path): try: author=archive.getText(dom.getElementsByTagName('author')[0].childNodes) except: - author=archive.getText(dom.getElementsByTagName('Author')[0].childNodes) + try: + author=archive.getText(dom.getElementsByTagName('Author')[0].childNodes) + except: + author=archive.getText(dom.getElementsByTagName('Editor')[0].childNodes) + title=archive.getText(dom.getElementsByTagName('title')[0].childNodes) try: date=archive.getText(dom.getElementsByTagName('year')[0].childNodes) @@ -336,9 +344,9 @@ def addTextExternal(self,path,texturl,ve writefile.close() #registrieren - urllib.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines() + return urllib.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines() + - return "DONE:"+textpath+"/"+name def TextExternalError(text): firsts=text[0:10] @@ -419,7 +427,7 @@ def readArchimedesXML(folder): for item in items: #print item.attributes['dir'].value try: - dict[item.attributes['dir'].value]=item.attributes['uri'].value + dict[item.attributes['dir'].value]=item.attributes['xml'].value #print item.attributes['dir'].value,item.attributes['text'].value except: """nothing""" @@ -499,7 +507,7 @@ def combineTextImage2(self,path): if self.REQUEST.has_key('text'): textfile=os.listdir(path+"/"+self.REQUEST['text'])[0] textfoldernode=dom.createElement('text') - textfoldernodetext=dom.createTextNode(self.REQUEST['text']+"/"+textfile) + textfoldernodetext=dom.createTextNode(path+"/"+self.REQUEST['text']+"/"+textfile) textfoldernode.appendChild(textfoldernodetext) subnode.appendChild(textfoldernode) @@ -521,23 +529,50 @@ def combineTextImage2(self,path): presentationnode.appendChild(presentationnodetext) subnode.appendChild(presentationnode) - node.appendChild(subnode) - try: - node=dom.getElementsByTagName('bib')[0] - sub=dom.getElementsByTagName('lang')[0] + if self.REQUEST.has_key('xslt'): + if not self.REQUEST['xslt']=="": + xsltnode=dom.createElement('xslt') + xsltnodetext=dom.createTextNode(self.REQUEST['xslt']) + xsltnode.appendChild(xsltnodetext) + subnode.appendChild(xsltnode) + + node.appendChild(subnode) - node.removeChild(sub) + try: + node2=node.getElementsByTagName('bib')[0] + subs=node2.getElementsByTagName('lang') + for sub in subs: + print "X",sub + node2.removeChild(sub) except: """nothing""" try: main=dom.getElementsByTagName('bib')[0] node=dom.createElement('lang') textnode=dom.createTextNode(self.REQUEST['lang']) + print "LANG:",lang node.appendChild(textnode) main.appendChild(node) except: - """nothing""" + try: + subs=dom.getElementsByTagName('lang') + main=dom.getElementsByTagName('resource')[0] + for sub in subs: + main.removeChild(sub) + except: + """nothing""" + + try: + main=dom.getElementsByTagName('resource')[0] + node=dom.createElement('lang') + textnode=dom.createTextNode(self.REQUEST['lang']) + #print "LANG:",self.REQUEST['lang'] + node.appendChild(textnode) + main.appendChild(node) + except: + """nothing""" + writefile=file(path+"/index.meta","w") writefile.write(dom.toxml().encode('utf-8')) writefile.close() @@ -546,7 +581,7 @@ def combineTextImage2(self,path): urllib.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines() #return urllib.quote("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path) - os.popen("ssh nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl %s /mpiwg/temp/online/scaled/thumb 90 &"% re.sub('mpiwg/online/','',self.REQUEST['path']+"/"+self.REQUEST['image'])) + os.popen("ssh nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl %s /mpiwg/temp/online/scaled/thumb 90 >> /tmp/sc.out &"% re.sub('/mpiwg/online/','',self.REQUEST['path']+"/"+self.REQUEST['image'])) #return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL2']+'?path='+self.REQUEST['path'])