All Samples(1251) | Call(1150) | Derive(0) | Import(101)
maketrans(frm, to) -> string Return a translation table (a string of 256 bytes long) suitable for use in string.translate. The strings frm and to must be of the same length.
src/p/k/pksampler-HEAD/pk/stereo/ripper.py pksampler(Download)
def strip_illegal(instr):
'''remove illegal (filename) characters from string'''
str = instr
str = str.strip()
str = string.translate(str, string.maketrans(r'/+{}*.?', r'--()___'))
return str
src/p/y/python-cookbook-HEAD/cb2_examples/cb2_1_9_sol_1.py python-cookbook(Download)
def translator(frm='', to='', delete='', keep=None):
if len(to) == 1:
to = to * len(frm)
trans = string.maketrans(frm, to)
if keep is not None:
allchars = string.maketrans('', '')
delete = allchars.translate(allchars, keep.translate(allchars, delete))
src/p/y/python-cookbook-HEAD/cb2_examples/cb2_1_8_exm_4.py python-cookbook(Download)
import string
notrans = string.maketrans('', '') # identity "translation"
def containsAny(astr, strset):
return len(strset) != len(strset.translate(notrans, astr))
def containsAll(astr, strset):
return not strset.translate(notrans, astr)
src/p/y/python-cookbook-HEAD/cb2_examples/cb2_1_12_exm_2.py python-cookbook(Download)
import string
notrans = string.maketrans('', '') # identity "translation"
def containsAny(str, strset):
return len(strset) != len(strset.translate(notrans, str))
def iscapitalized(s):
return s == s.capitalize() and containsAny(s, string.letters)
src/p/y/python-cookbook-HEAD/cb2_examples/cb2_1_11_sol_1.py python-cookbook(Download)
from __future__ import division # ensure / does NOT truncate
import string
text_characters = "".join(map(chr, range(32, 127))) + "\n\r\t\b"
_null_trans = string.maketrans("", "")
def istext(s, text_characters=text_characters, threshold=0.30):
# if s contains any null, it's not text:
if "\0" in s:
src/p/y/python-cookbook-HEAD/cb2_examples/cb2_1_10_sol_1.py python-cookbook(Download)
import string
# Make a reusable string of all characters, which does double duty
# as a translation table specifying <q>no translation whatsoever</q>
allchars = string.maketrans('', '')
def makefilter(keep):
""" Return a function that takes a string and returns a partial copy
of that string consisting of only the characters in 'keep'.
src/m/a/matplotlib-HEAD/py4science/examples/BeautifulSoup.py matplotlib(Download)
250,251,252,253,254,255)
import string
c.EBCDIC_TO_ASCII_MAP = string.maketrans( \
''.join(map(chr, range(256))), ''.join(map(chr, emap)))
return s.translate(c.EBCDIC_TO_ASCII_MAP)
MS_CHARS = { '\x80' : ('euro', '20AC'),
src/p/o/pony-build-HEAD/examples/push-cgi-notifier/feedparser.py pony-build(Download)
)
import string
_ebcdic_to_ascii_map = string.maketrans( \
''.join(map(chr, range(256))), ''.join(map(chr, emap)))
return s.translate(_ebcdic_to_ascii_map)
_urifixer = re.compile('^([A-Za-z][A-Za-z0-9+-.]*://)(/*)(.*?)')
src/h/t/HTMLtoRST-HEAD/generate_pdf_examples/BeautifulSoup.py HTMLtoRST(Download)
250,251,252,253,254,255)
import string
c.EBCDIC_TO_ASCII_MAP = string.maketrans( \
''.join(map(chr, range(256))), ''.join(map(chr, emap)))
return s.translate(c.EBCDIC_TO_ASCII_MAP)
MS_CHARS = { '\x80' : ('euro', '20AC'),
src/u/n/uniconvertor-HEAD/UniConvertor/trunk/uniconvertor/src/app/Graphics/font.py uniconvertor(Download)
# import os, re, operator from string import split, strip, atoi, atof, lower, translate, maketrans import streamfilter
from app.events.warn import warn, INTERNAL, USER, pdebug
from sk1libs.utils.fs import find_in_path, find_files_in_path
minus_tilde = maketrans('-', '~')
def xlfd_matrix(trafo):
mat = '[%f %f %f %f]' % trafo.matrix()
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next