Commit cf2042ee authored by Andreas Jung's avatar Andreas Jung

replaced string module calls by string methods

parent 8f12e4a1
...@@ -15,7 +15,6 @@ API documentation help topics ...@@ -15,7 +15,6 @@ API documentation help topics
""" """
import types import types
import string
import HelpTopic import HelpTopic
from Globals import DTMLFile, Persistent from Globals import DTMLFile, Persistent
...@@ -59,12 +58,12 @@ class APIHelpTopic(HelpTopic.HelpTopic): ...@@ -59,12 +58,12 @@ class APIHelpTopic(HelpTopic.HelpTopic):
# try to get title from first non-blank line # try to get title from first non-blank line
# of module docstring # of module docstring
if not self.title: if not self.title:
lines=string.split(self.doc,'\n') lines=self.doc.split('\n')
while 1: while 1:
line=string.strip(lines[0]) line=lines[0].strip()
if line: if line:
# get rid of anything after a colon in the line # get rid of anything after a colon in the line
self.title=string.split(line, ':')[0] self.title=line.split(':')[0]
break break
lines.pop(0) lines.pop(0)
if not lines: if not lines:
...@@ -140,7 +139,7 @@ class APIDoc(Persistent): ...@@ -140,7 +139,7 @@ class APIDoc(Persistent):
if hasattr(klass,'__extends__'): if hasattr(klass,'__extends__'):
self.extends=[] self.extends=[]
for base in klass.__extends__: for base in klass.__extends__:
names=string.split(base, '.') names=base.split( '.')
url="%s/Help/%s.py#%s" % (names[0], names[1], names[2]) url="%s/Help/%s.py#%s" % (names[0], names[1], names[2])
self.extends.append((names[2], url)) self.extends.append((names[2], url))
...@@ -255,20 +254,20 @@ def trim_doc_string(text): ...@@ -255,20 +254,20 @@ def trim_doc_string(text):
Trims a doc string to make it format Trims a doc string to make it format
correctly with structured text. correctly with structured text.
""" """
text=string.strip(text) text=text.strip()
text=string.replace(text, '\r\n', '\n') text=text.replace( '\r\n', '\n')
lines=string.split(text, '\n') lines=text.split('\n')
nlines=[lines[0]] nlines=[lines[0]]
if len(lines) > 1: if len(lines) > 1:
min_indent=None min_indent=None
for line in lines[1:]: for line in lines[1:]:
if not line: if not line:
continue continue
indent=len(line) - len(string.lstrip(line)) indent=len(line) - len(line.lstrip())
if indent < min_indent or min_indent is None: if indent < min_indent or min_indent is None:
min_indent=indent min_indent=indent
for line in lines[1:]: for line in lines[1:]:
nlines.append(line[min_indent:]) nlines.append(line[min_indent:])
return string.join(nlines, '\n') return '\n'.join(nlines)
...@@ -18,7 +18,6 @@ from Globals import Persistent, HTML, DTMLFile, ImageFile ...@@ -18,7 +18,6 @@ from Globals import Persistent, HTML, DTMLFile, ImageFile
from OFS.DTMLDocument import DTMLDocument from OFS.DTMLDocument import DTMLDocument
from OFS.PropertyManager import PropertyManager from OFS.PropertyManager import PropertyManager
import os.path import os.path
import string
import Globals import Globals
class HelpTopicBase: class HelpTopicBase:
...@@ -71,7 +70,7 @@ class HelpTopicBase: ...@@ -71,7 +70,7 @@ class HelpTopicBase:
def url(self): def url(self):
"URL for indexing purposes" "URL for indexing purposes"
return string.join(self.getPhysicalPath(), '/') return '/'.join(self.getPhysicalPath())
# Private indexing methods # Private indexing methods
# ------------------------ # ------------------------
......
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
############################################################################## ##############################################################################
"""Help system support module""" """Help system support module"""
__version__='$Revision: 1.10 $'[11:-2] __version__='$Revision: 1.11 $'[11:-2]
import Globals, Acquisition import Globals, Acquisition
import StructuredText.StructuredText import StructuredText.StructuredText
import sys, os, string, re import sys, os, re
stx_class=StructuredText.StructuredText.HTML stx_class=StructuredText.StructuredText.HTML
...@@ -70,11 +70,11 @@ class object(Acquisition.Implicit): ...@@ -70,11 +70,11 @@ class object(Acquisition.Implicit):
def get_docstring_html(self): def get_docstring_html(self):
doc=self.get_docstring() doc=self.get_docstring()
if string.find(doc, '\n\n') > -1: if doc.find('\n\n') > -1:
doc=string.split(doc, '\n\n') doc=doc.split('\n\n')
if len(doc) > 1: if len(doc) > 1:
doc[1]=string.strip(doc[1]) doc[1]=doc[1].strip()
doc=string.join(doc, '\n\n') doc='\n\n'.join(doc)
return str(stx_class(doc)) return str(stx_class(doc))
...@@ -233,7 +233,7 @@ class methodobject(object): ...@@ -233,7 +233,7 @@ class methodobject(object):
if hasattr(func, '__doc__'): if hasattr(func, '__doc__'):
doc=func.__doc__ doc=func.__doc__
if not doc: doc='' if not doc: doc=''
doc=string.strip(doc) doc=doc.strip()
if hasattr(func, 'func_code'): if hasattr(func, 'func_code'):
if hasattr(func.func_code, 'co_varnames'): if hasattr(func.func_code, 'co_varnames'):
return doc return doc
...@@ -268,14 +268,14 @@ class methodobject(object): ...@@ -268,14 +268,14 @@ class methodobject(object):
if method: args=args[1:] if method: args=args[1:]
if name=='__call__': if name=='__call__':
name='Call Operation' name='Call Operation'
return '%s(%s)' % (name, string.join(args,', ')) return '%s(%s)' % (name, ', '.join(args))
# Other functions - look for something that smells like # Other functions - look for something that smells like
# a signature at the beginning of the docstring. # a signature at the beginning of the docstring.
if hasattr(func, '__doc__'): if hasattr(func, '__doc__'):
doc=func.__doc__ doc=func.__doc__
if not doc: doc='' if not doc: doc=''
doc=string.strip(doc) doc=doc.strip()
mo=sig_match(doc) mo=sig_match(doc)
if mo is not None: if mo is not None:
return doc[:mo.end(0)] return doc[:mo.end(0)]
......
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
############################################################################## ##############################################################################
"""Object Reference implementation""" """Object Reference implementation"""
__version__='$Revision: 1.8 $'[11:-2] __version__='$Revision: 1.9 $'[11:-2]
import sys, os, string, Globals, Acquisition import sys, os, Globals, Acquisition
from HelpUtil import HelpBase, classobject from HelpUtil import HelpBase, classobject
from HelpUtil import is_class, is_module from HelpUtil import is_class, is_module
from Globals import DTMLFile from Globals import DTMLFile
......
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