version 1.78, 2007/04/27 14:42:28
|
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 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""" |