version 1.77, 2007/04/27 14:22:33
|
version 1.79, 2007/08/31 14:22:52
|
Line 28 import copy
|
Line 28 import copy
|
import codecs |
import codecs |
import sys |
import sys |
|
|
|
def unicodify(s): |
|
"""decode str (utf-8 or latin-1 representation) into unicode object""" |
|
if not s: |
|
return u"" |
|
if isinstance(s, str): |
|
try: |
|
return s.decode('utf-8') |
|
except: |
|
return s.decode('latin-1') |
|
else: |
|
return s |
|
|
|
def utf8ify(s): |
|
"""encode unicode object or string into byte string in utf-8 representation. |
|
assumes string objects to be utf-8""" |
|
if not s: |
|
return "" |
|
if isinstance(s, str): |
|
return s |
|
else: |
|
return s.encode('utf-8') |
|
|
|
|
def generateXMLReturn(hash): |
def generateXMLReturn(hash): |
"""erzeugt das xml file als returnwert fuer uploadATFRPC""" |
"""erzeugt das xml file als returnwert fuer uploadATFRPC""" |
|
|
Line 1430 class CDLIFileObject(CatalogAware,extVer
|
Line 1453 class CDLIFileObject(CatalogAware,extVer
|
|
|
security.declarePublic('makeThisVersionCurrent') |
security.declarePublic('makeThisVersionCurrent') |
|
|
security.declareProtected('manage','index.html') |
security.declareProtected('manage','index_html') |
def PrincipiaSearchSource(self): |
def PrincipiaSearchSource(self): |
"""Return cataloguable key for ourselves.""" |
"""Return cataloguable key for ourselves.""" |
return str(self) |
return str(self) |
Line 1542 class CDLIFile(extVersionedFile,CatalogA
|
Line 1565 class CDLIFile(extVersionedFile,CatalogA
|
security=ClassSecurityInfo() |
security=ClassSecurityInfo() |
meta_type="CDLI file" |
meta_type="CDLI file" |
default_catalog='CDLICatalog' |
default_catalog='CDLICatalog' |
|
security.declareProtected('manage','index_html') |
#security.declarePublic('history') |
#security.declarePublic('history') |
def getLastVersionData(self): |
def getLastVersionData(self): |
"""get last version data""" |
"""get last version data""" |
Line 2249 class CDLIRoot(Folder):
|
Line 2272 class CDLIRoot(Folder):
|
"""get lines with word fromFileId""" |
"""get lines with word fromFileId""" |
|
|
file=self.showFile(fileId) |
file=self.showFile(fileId) |
tagStr="""<span class="found">%s</span>""" |
tagStr=u'<span class="found">%s</span>' |
ret=[] |
ret=[] |
|
|
if regExp: # wenn regexp dann generiere alle worte aus der list die der regexp entsprechen |
if regExp: # wenn regexp dann generiere alle worte aus der list die der regexp entsprechen |
Line 2258 class CDLIRoot(Folder):
|
Line 2281 class CDLIRoot(Folder):
|
wordlist=[word] |
wordlist=[word] |
|
|
for line in file.split("\n"): |
for line in file.split("\n"): |
|
line = unicodify(line) |
found=False |
found=False |
for word in wordlist: |
for word in wordlist: |
if line.find(word)>-1: #word ist gefunden dann makiere und breche die Schleife ab |
if line.find(word)>-1: #word ist gefunden dann makiere und breche die Schleife ab |
Line 2275 class CDLIRoot(Folder):
|
Line 2299 class CDLIRoot(Folder):
|
if not found: #word wurde nicht gefunden keine makierung |
if not found: #word wurde nicht gefunden keine makierung |
ret.append(line) |
ret.append(line) |
|
|
return "<br>\n".join(ret) |
return u'<br>\n'.join(ret) |
|
|
def URLquote(self,str): |
def URLquote(self,str): |
"""quote url""" |
"""quote url""" |