All Samples(3711) | Call(3609) | Derive(0) | Import(102)
replace (str, old, new[, maxsplit]) -> string Return a copy of string str with all occurrences of substring old replaced by new. If the optional argument maxsplit is given, only the first maxsplit occurrences are replaced.
def replace(s, old, new, maxsplit=-1):
"""replace (str, old, new[, maxsplit]) -> string
Return a copy of string str with all occurrences of substring
old replaced by new. If the optional argument maxsplit is
given, only the first maxsplit occurrences are replaced.
"""
return s.replace(old, new, maxsplit)
from smartcard.CardConnectionObserver import CardConnectionObserver from smartcard.util import toHexString from string import replace class TracerAndSELECTInterpreter(CardConnectionObserver):
elif 'command' == ccevent.type:
str = toHexString(ccevent.args[0])
str = replace(str, "A0 A4 00 00 02", "SELECT")
str = replace(str, "A0 C0 00 00", "GET RESPONSE")
print '>', str
src/p/y/pyscard-HEAD/pyscard/src/smartcard/Examples/framework/sample_apduTracerInterpreter.py pyscard(Download)
from smartcard.CardConnectionObserver import CardConnectionObserver from smartcard.util import toHexString from string import replace class TracerAndSELECTInterpreter(CardConnectionObserver):
elif 'command' == ccevent.type:
str = toHexString(ccevent.args[0])
str = replace(str, "A0 A4 00 00 02", "SELECT")
str = replace(str, "A0 C0 00 00", "GET RESPONSE")
print '>', str
src/z/e/zetadb-HEAD/zetadb_openoffice.py zetadb(Download)
from OFS import Folder, Image from zipfile import ZipFile from StringIO import StringIO from string import split, join, lower, find, replace, strip from zetadb_zpt import ZetadbZpt from zetadb_context_utils import zetadb_current_version from string import join
# 2 first line are not in the dom
result = u"" + join(file_content.split(">")[0:2], ">") + ">\n"
# Change the document encoding
result = replace(result, OO_ENCODING, self.encoding.replace('_','-'))
# Indent it !!
result += self.indent_recursive(dom.documentElement, 0)
# We've said we will use this encode :-)
i = 0
while (i<attributes.length):
value = attributes.item(i).value
value = replace(value, '>', '>')
value = replace(value, '<', '<')
result += """ %s="%s" """ % (attributes.item(i).name, value)
i = i + 1
if node.nodeType == node.TEXT_NODE:
result = (" " * level) + node.data + "\n"
result = replace(result, '>', '>')
result = replace(result, '<', '<')
return result
i = 0
while (i<attributes.length):
value = attributes.item(i).value
value = replace(value, '>', '>')
value = replace(value, '<', '<')
result += """ %s="%s" """ % (attributes.item(i).name, value)
i = i + 1
if node.nodeType == node.TEXT_NODE:
result = node.data
result = replace(result, '>', '>')
result = replace(result, '<', '<')
return result
dom = xml.dom.minidom.parseString(content)
# Change the document encoding
result = u"" + join(content.split(">")[0:2], ">") + ">"
result = replace(result, self.encoding.replace('_','-'), OO_ENCODING)
# Dedent previous indented content
result += self.dedent_recursive(dom.documentElement)
# We shoud produce utf-8 for OpenOffice
i = 0
while (i<attributes.length):
value = attributes.item(i).value
value = replace(value, '>', '>')
value = replace(value, '<', '<')
result += u' %s="%s"' % (attributes.item(i).name, value)
i = i + 1
result += u"</" + node.tagName + ">"
if node.nodeType == node.TEXT_NODE:
result = strip(replace(node.data, "\n", ""))
result = replace(result, '>', '>')
result = replace(result, '<', '<')
if (result == ''):
i = 0
while (i<attributes.length):
value = attributes.item(i).value
value = replace(value, '>', '>')
value = replace(value, '<', '<')
result += ' %s="%s"' % (attributes.item(i).name, value)
i = i + 1
if node.nodeType == node.TEXT_NODE:
result = node.data
result = replace(result, '>', '>')
result = replace(result, '<', '<')
return result
src/p/y/PyZ3950-HEAD/apache/CQLParser.py PyZ3950(Download)
# With thanks to Adam from IndexData and Mike Taylor for their valuable input from shlex import shlex from string import split, replace, find, lower, count, join from xml.sax.saxutils import escape from xml.dom.minidom import Node, parseString from SRWDiagnostics import *
raise diag
else:
t[-1] = "#"
t = replace(t, "\\^", "^")
t = replace(t, "\\?", "?")
t = replace(t, "\\*", "*")
return t
def convertMetacharsSQL(self, t):
"Convert SRW meta characters in to SQL's LIKE meta characters"
# First escape % and _ (Errr....??)
# This needs real work, but is probably custom job anyway.
t = replace(t, '*', '%')
t = replace(t, '?', '_')
t = replace(t, "\\^", "^")
t = replace(t, "\\?", "?")
t = replace(t, "\\*", "*")
# Unescape quotes
if (irt.term and irt.term[0] == '"' and irt.term[-1] == '"'):
irt.term = irt.term[1:-1]
irt.term = replace(irt.term, '\\"', '"')
elif not irt.term:
# Term is not present, not empty
diag = Diagnostic10()
src/k/m/kmkey-HEAD/bundles/kmkey-08.03.01/TextIndexNG3/src/textindexng/converters/stripogram/html2text.py kmkey(Download)
# $Id: html2text.py 1072 2005-05-01 12:05:51Z ajung $ import sgmllib from string import lower, replace, split, join class HTML2Text(sgmllib.SGMLParser):
def add_text(self,text):
# convert text into words
words = split(replace(text,'\n',' '))
self.line.extend(words)
def add_break(self):
self.lines.append((self.indent,self.line))
src/k/m/kmkey-HEAD/bundles/kmkey-08.02.02/TextIndexNG3/src/textindexng/converters/stripogram/html2text.py kmkey(Download)
# $Id: html2text.py 1072 2005-05-01 12:05:51Z ajung $ import sgmllib from string import lower, replace, split, join class HTML2Text(sgmllib.SGMLParser):
def add_text(self,text):
# convert text into words
words = split(replace(text,'\n',' '))
self.line.extend(words)
def add_break(self):
self.lines.append((self.indent,self.line))
src/k/m/kmkey-HEAD/bundles/kmkey-08.01.02/TextIndexNG3/src/textindexng/converters/stripogram/html2text.py kmkey(Download)
# $Id: html2text.py 1072 2005-05-01 12:05:51Z ajung $ import sgmllib from string import lower, replace, split, join class HTML2Text(sgmllib.SGMLParser):
def add_text(self,text):
# convert text into words
words = split(replace(text,'\n',' '))
self.line.extend(words)
def add_break(self):
self.lines.append((self.indent,self.line))
src/h/a/happydoc-HEAD/trunk/happydoclib/docset/docset_TAL/PythonExpr.py happydoc(Download)
__version__='$Revision: 1.1 $'[11:-2] from hdTALES import CompilerError from string import strip, split, join, replace, lstrip from sys import exc_info class getSecurityManager:
def __init__(self, name, expr, engine):
self.expr = expr = replace(strip(expr), '\n', ' ')
try:
d = {}
exec 'def f():\n return %s\n' % strip(expr) in d
self._f = d['f']
except:
src/h/a/happydoc-HEAD/happydoclib/docset/docset_TAL/PythonExpr.py happydoc(Download)
__version__='$Revision: 1.1 $'[11:-2] from hdTALES import CompilerError from string import strip, split, join, replace, lstrip from sys import exc_info class getSecurityManager:
def __init__(self, name, expr, engine):
self.expr = expr = replace(strip(expr), '\n', ' ')
try:
d = {}
exec 'def f():\n return %s\n' % strip(expr) in d
self._f = d['f']
except:
src/t/e/textindexng-HEAD/zopyx.txng3.core/trunk/zopyx/txng3/core/converters/stripogram/html2text.py textindexng(Download)
# $Id: html2text.py 1072 2005-05-01 12:05:51Z ajung $ import sgmllib from string import lower, replace, split, join class HTML2Text(sgmllib.SGMLParser):
def add_text(self,text):
# convert text into words
words = split(replace(text,'\n',' '))
self.line.extend(words)
def add_break(self):
self.lines.append((self.indent,self.line))
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next