本文整理汇总了Python中string.joinfields方法的典型用法代码示例。如果您正苦于以下问题:Python string.joinfields方法的具体用法?Python string.joinfields怎么用?Python string.joinfields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类string
的用法示例。
在下文中一共展示了string.joinfields方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_mailstack
# 需要导入模块: import string [as 别名]
# 或者: from string import joinfields [as 别名]
def do_mailstack(self, arg):
tolist = arg.split()
subject = '[Conary Stacktrace]'
if 'stack' in self.__dict__:
# when we're saving we always
# start from the top
frame = self.stack[-1][0]
else:
frame = sys._getframe(1)
while frame.f_globals['__name__'] in ('epdb', 'pdb', 'bdb', 'cmd'):
frame = frame.f_back
sender = os.environ['USER']
host = socket.getfqdn()
extracontent = None
if self._tb:
lines = traceback.format_exception(self._exc_type, self._exc_msg,
self._tb)
extracontent = string.joinfields(lines, "")
epdb_stackutil.mailStack(frame, tolist, sender + '@' + host, subject,
extracontent)
print "Mailed stack to %s" % tolist
示例2: do_mailstack
# 需要导入模块: import string [as 别名]
# 或者: from string import joinfields [as 别名]
def do_mailstack(self, arg):
tolist = arg.split()
subject = '[Conary Stacktrace]'
if 'stack' in self.__dict__:
# when we're saving we always start from the top
frame = self.stack[-1][0]
else:
frame = sys._getframe(1)
while frame.f_globals['__name__'] in ('epdb', 'pdb', 'bdb', 'cmd'):
frame = frame.f_back
sender = os.environ['USER']
host = socket.getfqdn()
extracontent = None
if self._tb:
lines = traceback.format_exception(self._exc_type, self._exc_msg,
self._tb)
extracontent = string.joinfields(lines, "")
epdb_stackutil.mailStack(frame, tolist, sender + '@' + host, subject,
extracontent)
print("Mailed stack to %s" % tolist)
示例3: __str__
# 需要导入模块: import string [as 别名]
# 或者: from string import joinfields [as 别名]
def __str__(self):
"""Return a human-readable representation.
>>> str(N['dog'][0].synset)
'{noun: dog, domestic dog, Canis familiaris}'
"""
return "{" + self.pos + ": " + string.joinfields(map(lambda sense:sense.form, self.getSenses()), ", ") + "}"
示例4: writelines
# 需要导入模块: import string [as 别名]
# 或者: from string import joinfields [as 别名]
def writelines(self, list):
self.write(string.joinfields(list, ''))
示例5: text
# 需要导入模块: import string [as 别名]
# 或者: from string import joinfields [as 别名]
def text(self, xy, text):
text = string.joinfields(string.splitfields(text, "("), "\\(")
text = string.joinfields(string.splitfields(text, ")"), "\\)")
xy = xy + (text,)
self.fp.write("%d %d M (%s) S\n" % xy)
示例6: write_map
# 需要导入模块: import string [as 别名]
# 或者: from string import joinfields [as 别名]
def write_map(self, m):
sc = StringCodec()
if m is not None:
sc.write_uint32(len(m))
sc.write(string.joinfields(map(self._write_map_elem, m.keys(), m.values()), ""))
self.write_vbin32(sc.encoded)
示例7: normpath
# 需要导入模块: import string [as 别名]
# 或者: from string import joinfields [as 别名]
def normpath(path):
"""Normalize path, eliminating double slashes, etc."""
sep = os.sep
if sep == '\\':
path = path.replace("/", sep)
curdir = os.curdir
pardir = os.pardir
import string
# Treat initial slashes specially
slashes = ''
while path[:1] == sep:
slashes = slashes + sep
path = path[1:]
comps = string.splitfields(path, sep)
i = 0
while i < len(comps):
if comps[i] == curdir:
del comps[i]
while i < len(comps) and comps[i] == '':
del comps[i]
elif comps[i] == pardir and i > 0 and comps[i-1] not in ('', pardir):
del comps[i-1:i+1]
i = i-1
elif comps[i] == '' and i > 0 and comps[i-1] <> '':
del comps[i]
else:
i = i+1
# If the path is now empty, substitute '.'
if not comps and not slashes:
comps.append(curdir)
return slashes + string.joinfields(comps, sep)
示例8: printTraceBack
# 需要导入模块: import string [as 别名]
# 或者: from string import joinfields [as 别名]
def printTraceBack(tb=None, output=sys.stderr, exc_type=None, exc_msg=None):
if isinstance(output, str):
output = open(output, 'w')
exc_info = sys.exc_info()
if tb is None:
tb = exc_info[2]
if exc_type is None:
exc_type = exc_info[0]
if exc_msg is None:
exc_msg = exc_info[1]
if exc_type is not None:
output.write('Exception: ')
exc_info = '\n'.join(traceback.format_exception_only(exc_type, exc_msg))
output.write(exc_info)
output.write('\n\n')
lines = traceback.format_exception(exc_type, exc_msg, tb)
output.write(string.joinfields(lines, ""))
while tb:
_printFrame(tb.tb_frame, output=output)
tb = tb.tb_next
示例9: genExcepthook
# 需要导入模块: import string [as 别名]
# 或者: from string import joinfields [as 别名]
def genExcepthook(self):
def excepthook(type, exc_msg, tb):
cfg = self.recipe.cfg
sys.excepthook = sys.__excepthook__
if cfg.debugRecipeExceptions:
lines = traceback.format_exception(type, exc_msg, tb)
print string.joinfields(lines, "")
if self.linenum is not None:
prefix = "%s:%s:" % (self.file, self.linenum)
prefix_len = len(prefix)
if str(exc_msg)[:prefix_len] != prefix:
exc_message = "%s:%s: %s: %s" % (self.file, self.linenum,
type.__name__, exc_msg)
print exc_message
if self.recipe.buildinfo:
try:
buildinfo = self.recipe.buildinfo
buildinfo.error = exc_message
buildinfo.file = self.file
buildinfo.lastline = self.linenum
buildinfo.stop()
except:
log.warning("could not write out to buildinfo")
if cfg.debugRecipeExceptions and self.recipe.isatty():
debugger.post_mortem(tb, type, exc_msg)
else:
sys.exit(1)
return excepthook
示例10: printTraceBack
# 需要导入模块: import string [as 别名]
# 或者: from string import joinfields [as 别名]
def printTraceBack(tb=None, output=sys.stderr, exc_type=None, exc_msg=None):
if isinstance(output, str):
output = open(output, 'w')
exc_info = sys.exc_info()
if tb is None:
tb = exc_info[2]
if exc_type is None:
exc_type = exc_info[0]
if exc_msg is None:
exc_msg = exc_info[1]
if exc_type is not None:
output.write('Exception: ')
exc_info = '\n'.join(traceback.format_exception_only(
exc_type, exc_msg))
output.write(exc_info)
output.write('\n\n')
lines = traceback.format_exception(exc_type, exc_msg, tb)
output.write(string.joinfields(lines, ""))
while tb:
_printFrame(tb.tb_frame, output=output)
tb = tb.tb_next