Commit d891e363 authored by Andreas Jung's avatar Andreas Jung

string module free zone

parent df576780
......@@ -16,10 +16,9 @@
This product provides support for external methods, which allow
domain-specific customization of web environments.
"""
__version__='$Revision: 1.45 $'[11:-2]
__version__='$Revision: 1.46 $'[11:-2]
from Globals import Persistent, DTMLFile, MessageDialog, HTML
import OFS.SimpleItem, Acquisition
from string import split, join, find, lower
import AccessControl.Role, sys, os, stat, traceback
from OFS.SimpleItem import pretty_tb
from App.Extensions import getObject, getPath, FuncCode
......
......@@ -10,14 +10,14 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__rcs_id__='$Id: MIMETag.py,v 1.8 2001/11/28 15:50:59 matt Exp $'
__version__='$Revision: 1.8 $'[11:-2]
__rcs_id__='$Id: MIMETag.py,v 1.9 2002/03/11 15:54:38 andreasjung Exp $'
__version__='$Revision: 1.9 $'[11:-2]
from DocumentTemplate.DT_Util import *
from DocumentTemplate.DT_String import String
from MimeWriter import MimeWriter
from cStringIO import StringIO
import string, mimetools
import mimetools
MIMEError = "MIME Tag Error"
......
......@@ -12,14 +12,14 @@
##############################################################################
"""SMTP mail objects
$Id: MailHost.py,v 1.69 2002/01/15 14:58:37 jens Exp $"""
__version__ = "$Revision: 1.69 $"[11:-2]
$Id: MailHost.py,v 1.70 2002/03/11 15:54:38 andreasjung Exp $"""
__version__ = "$Revision: 1.70 $"[11:-2]
from Globals import Persistent, DTMLFile, InitializeClass
from smtplib import SMTP
from AccessControl.Role import RoleManager
from operator import truth
import Acquisition, sys, string, types, mimetools
import Acquisition, sys, types, mimetools
import OFS.SimpleItem, re, quopri, rfc822
from cStringIO import StringIO
from AccessControl import ClassSecurityInfo
......@@ -84,7 +84,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
title=str(title)
smtp_host=str(smtp_host)
if type(smtp_port) is not type(1):
smtp_port=string.atoi(smtp_port)
smtp_port=int(smtp_port)
self.title=title
self.smtp_host=smtp_host
......@@ -142,7 +142,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
if mto:
if type(mto) is type('s'):
mto=map(string.strip, string.split(mto,','))
mto=[ x.strip() for x in mto.split(',')]
headers['to'] = filter(None, mto)
if mfrom:
headers['from'] = mfrom
......@@ -169,7 +169,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
messageText)
if mto:
if type(mto) is type('s'):
mto=map(string.strip, string.split(mto,','))
mto=[ x.strip() for x in mto.split(',')]
headers['to'] = filter(truth, mto)
if mfrom:
headers['from'] = mfrom
......@@ -215,7 +215,7 @@ def _encode(body, encode=None):
if mo.getencoding() != '7bit':
raise MailHostError, 'Message already encoded'
newmfile=StringIO()
newmfile.write(string.joinfields(mo.headers, ''))
newmfile.write(''.join(mo.headers))
newmfile.write('Content-Transfer-Encoding: %s\n' % encode)
if not mo.has_key('Mime-Version'):
newmfile.write('Mime-Version: 1.0\n')
......@@ -226,7 +226,7 @@ def _encode(body, encode=None):
def extractheaders(message):
# return headers of message
mfile=StringIO(string.strip(message))
mfile=StringIO(message.strip())
mo=rfc822.Message(mfile)
hd={}
......
......@@ -10,14 +10,13 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__rcs_id__='$Id: SendMailTag.py,v 1.15 2002/01/15 14:58:37 jens Exp $'
__version__='$Revision: 1.15 $'[11:-2]
__rcs_id__='$Id: SendMailTag.py,v 1.16 2002/03/11 15:54:38 andreasjung Exp $'
__version__='$Revision: 1.16 $'[11:-2]
from MailHost import MailBase
from DocumentTemplate.DT_Util import parse_params,render_blocks
from DocumentTemplate.DT_String import String
from socket import gethostname
import string
class SendMailTag:
'''the send mail tag, used like thus:
......@@ -93,7 +92,7 @@ class SendMailTag:
self.mailfrom=args['mailfrom']
self.subject=None or args['subject']
if args['port'] and type(args['port']) is type('s'):
self.port=args['port']=string.atoi(args['port'])
self.port=args['port']=int(args['port'])
elif args['port']=='':
self.port=args['port']=25
else:
......
......@@ -14,7 +14,6 @@ import Globals, AccessControl.User
from Globals import Persistent
from Acquisition import Implicit
from OFS import SimpleItem
from string import rfind
manage_addPrincipiaDraftForm=Globals.HTMLFile('dtml/draftAdd',globals())
def manage_addPrincipiaDraft(self, id, baseid, PATH_INFO, REQUEST=None):
......@@ -39,7 +38,7 @@ class Draft(Persistent, Implicit, SimpleItem.Item):
self.id=id
self._refid=baseid
version=PATH_INFO
l=rfind(version,'/')
l=version.rfind(/')
if l >= 0: version=version[:l]
self._version="%s/%s" % (version, id)
self.users__draft__=uf=AccessControl.User.UserFolder()
......
......@@ -12,7 +12,7 @@
##############################################################################
"""Version object"""
__version__='$Revision: 1.51 $'[11:-2]
__version__='$Revision: 1.52 $'[11:-2]
import Globals, time
from AccessControl.Role import RoleManager
......@@ -20,7 +20,6 @@ from Globals import MessageDialog
from Globals import Persistent
from Acquisition import Implicit
from OFS.SimpleItem import Item
from string import rfind, join
from Globals import HTML
from App.Dialogs import MessageDialog
from OFS.ObjectManager import BeforeDeleteException
......@@ -186,7 +185,7 @@ class Version(Persistent,Implicit,RoleManager,Item):
def manage_afterAdd(self, item, container):
if not self.cookie:
# Physical path
self.cookie=join(self.getPhysicalPath(),'/')
self.cookie='/'.join(self.getPhysicalPath())
def manage_beforeDelete(self, item, container):
if self.nonempty():
......
......@@ -11,7 +11,7 @@
#
############################################################################
import re, time, string, sys
import re, time, sys
import Globals
from OFS.SimpleItem import Item
from Acquisition import Implicit, Explicit, aq_base
......@@ -150,7 +150,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
'Container path contains characters invalid in a Zope '
'object path'
)
self.obpath = string.split(path, '/')
self.obpath = path.split('/')
elif type(path) in (type([]), type(())):
self.obpath = list(path) # sequence
else:
......@@ -160,7 +160,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
def getContainerPath(self):
""" """
if self.obpath is not None:
return string.join(self.obpath, '/')
return '/'.join(self.obpath)
return '' # blank string represents undefined state
def _hasSessionDataObject(self, key):
......@@ -194,7 +194,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
# be construed as a security hole, albeit a minor one.
# unrestrictedTraverse is also much faster.
if DEBUG and not hasattr(self, '_v_wrote_dc_type'):
args = string.join(self.obpath, '/')
args = '/'.join(self.obpath)
LOG('Session Tracking', BLATHER,
'External data container at %s in use' % args)
self._v_wrote_dc_type = 1
......@@ -202,7 +202,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
except:
raise SessionDataManagerErr, (
"External session data container '%s' not found." %
string.join(self.obpath,'/')
'/'.join(self.obpath)
)
security.declareProtected(MGMT_SCREEN_PERM, 'getRequestName')
......
......@@ -19,7 +19,7 @@ from OFS.History import Historical
from OFS.SimpleItem import SimpleItem
from OFS.ObjectManager import ObjectManager, IFAwareObjectManager
import string, os, sys, time
import os, sys, time
from Acquisition import Implicit
from Persistence import Persistent
......
......@@ -16,7 +16,7 @@ from Globals import HTML, DTMLFile, MessageDialog
import DateTime
import DocumentTemplate
import StructuredText
import string, re
import re
pre_pat=re.compile(r'<PRE>(.+?)</PRE>', re.IGNORECASE|re.DOTALL)
......@@ -45,7 +45,7 @@ class TutorialTopic(TextTopic):
if REQUEST.has_key('tutorialExamplesURL'):
url=REQUEST['tutorialExamplesURL']
base=REQUEST['BASE1']
if string.index(url, base) == 0:
if url.index(base) == 0:
url=url[len(base):]
try:
self.getPhysicalRoot().unrestrictedTraverse(url)
......@@ -129,7 +129,7 @@ class GlossaryTopic(TutorialTopic):
"""
Returns the URL to a API documentation for a given class.
"""
names=string.split(klass, '.')
names=klass.split('.')
url="%s/Control_Panel/Products/%s/Help/%s.py#%s" % (REQUEST['SCRIPT_NAME'],
names[0], names[1], names[2])
return '<a href="%s">API Documentation</a>' % url
......@@ -207,28 +207,28 @@ def clean_pre(match):
Reformat a pre tag to get rid of extra indentation
and extra blank lines.
"""
lines=string.split(match.group(1), '\n')
lines=match.group(1).split('\n')
nlines=[]
min_indent=None
for line in lines:
indent=len(line) - len(string.lstrip(line))
indent=len(line) - len(line.lstrip())
if min_indent is None or indent < min_indent:
if string.strip(line):
if line.strip():
min_indent=indent
for line in lines:
nlines.append(line[min_indent:])
while 1:
if not string.strip(nlines[0]):
if not nlines[0].strip():
nlines.pop(0)
else:
break
while 1:
if not string.strip(nlines[-1]):
if not nlines[-1].strip():
nlines.pop()
else:
break
return "<PRE>%s</PRE>" % string.join(nlines, '\n')
return "<PRE>%s</PRE>" % '\n'.join(nlines)
......@@ -13,7 +13,6 @@
import TutorialTopic
import App.Common
import os.path
import string
import os
import stat
from DateTime import DateTime
......@@ -62,14 +61,14 @@ def initialize(context):
while 1:
line = f.readline()
if (string.strip(line) and string.find(line, ' ') != 0) or line=='':
if (line.strip() and line.find(' ') != 0) or line=='':
# new topic
if lines:
id = id + 1
topic_id = 'topic_%02d' % id
text=string.join(lines[1:], '')
text=''.join(lines[1:])
text=term_pat.sub(glossaryTerm, text)
topic=TutorialTopic.TutorialTopic(topic_id, string.strip(lines[0]), spacestrip(text))
topic=TutorialTopic.TutorialTopic(topic_id, lines[0].strip(), spacestrip(text))
context.registerHelpTopic(topic_id, topic)
lines=[line]
else:
......@@ -89,12 +88,12 @@ def spacestrip(txt):
"""
l = []
for x in string.split(txt,"\n"):
for x in txt.split("\n"):
if len(x)>2 and x[:2]==' ':
l.append(x[2:])
else: l.append(x)
return string.join(l,'\n')
return '\n'.join(l)
# Glossary functions
......
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