Commit b955ddbd authored by Andreas Jung's avatar Andreas Jung

dead to the string module

parent 75ee481d
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
# #
############################################################################## ##############################################################################
import ExtensionClass import ExtensionClass
import string
from string import strip, lower, upper, join
from Acquisition import Implicit from Acquisition import Implicit
from Record import Record from Record import Record
...@@ -45,15 +43,15 @@ class Results: ...@@ -45,15 +43,15 @@ class Results:
i=0 i=0
for item in items: for item in items:
name=item['name'] name=item['name']
name=strip(name) name=name.strip()
if not name: if not name:
raise ValueError, 'Empty column name, %s' % name raise ValueError, 'Empty column name, %s' % name
if schema.has_key(name): if schema.has_key(name):
raise ValueError, 'Duplicate column name, %s' % name raise ValueError, 'Duplicate column name, %s' % name
schema[name]=i schema[name]=i
n=lower(name) n=name.lower()
if n != name: aliases.append((n, SQLAlias(name))) if n != name: aliases.append((n, SQLAlias(name)))
n=upper(name) n=name.upper()
if n != name: aliases.append((n, SQLAlias(name))) if n != name: aliases.append((n, SQLAlias(name)))
dd[name]=item dd[name]=item
names.append(name) names.append(name)
...@@ -127,10 +125,9 @@ class Results: ...@@ -127,10 +125,9 @@ class Results:
nstrings=[] nstrings=[]
items=self.__items__ items=self.__items__
indexes=range(len(items)) indexes=range(len(items))
join=string.join
for i in indexes: for i in indexes:
item=items[i] item=items[i]
t=lower(item['type']) t=item['type'].lower()
if t=='s' or t=='t': if t=='s' or t=='t':
t=='t' t=='t'
strings.append(i) strings.append(i)
...@@ -139,23 +136,21 @@ class Results: ...@@ -139,23 +136,21 @@ class Results:
else: r.append(t) else: r.append(t)
r=[join(self._names, '\t'), join(r,'\t')] r=['\t'.join(self._names), '\t'.join(r)]
append=r.append append=r.append
find=string.find
split=string.split
row=['']*len(items) row=['']*len(items)
tostr=str tostr=str
for d in self._data: for d in self._data:
for i in strings: for i in strings:
v=tostr(d[i]) v=tostr(d[i])
if v: if v:
if find(v,'\\') > 0: v=join(split(v,'\\'),'\\\\') if v.find('\\') > 0: v='\\\\'.join(v.split('\\'))
if find(v,'\t') > 0: v=join(split(v,'\t'),'\\t') if v.find('\t') > 0: v='\\t'.join(v.split('\t'))
if find(v,'\n') > 0: v=join(split(v,'\n'),'\\n') if v.find('\n') > 0: v='\\n'.join(v.split('\n'))
row[i]=v row[i]=v
for i in nstrings: for i in nstrings:
row[i]=tostr(d[i]) row[i]=tostr(d[i])
append(join(row,'\t')) append('\t'.join(row))
append('') append('')
return join(r,'\n') return '\n'.join(r)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment