本文整理汇总了Python中os.linesep.join方法的典型用法代码示例。如果您正苦于以下问题:Python linesep.join方法的具体用法?Python linesep.join怎么用?Python linesep.join使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类os.linesep
的用法示例。
在下文中一共展示了linesep.join方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _usage
# 需要导入模块: from os import linesep [as 别名]
# 或者: from os.linesep import join [as 别名]
def _usage(error_message=None):
if error_message:
stderr.write('ERROR: ' + error_message + linesep)
stdout.write(
linesep.join([
'Usage:', ' list_versions.py [OPTION]... [DEPENDENCY]',
'Examples:', ' list_versions.py go',
' list_versions.py -r docker',
' list_versions.py --rc docker',
' list_versions.py -l kubernetes',
' list_versions.py --latest kubernetes', 'Options:',
'-l/--latest Include only the latest version of each major and'
' minor versions sub-tree.',
'-r/--rc Include release candidate versions.',
'-h/--help Prints this!', ''
]))
示例2: standard_parser
# 需要导入模块: from os import linesep [as 别名]
# 或者: from os.linesep import join [as 别名]
def standard_parser(description="Confu configuration script"):
import argparse
from os import linesep
from confu.platform import host, possible_targets
parser = argparse.ArgumentParser(description=description,
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument("--target", dest="target", metavar="PLATFORM", type=Platform,
default=host.name,
help="platform where the code will run. Potential options:" + linesep +
" " + host.name + " (default)" + linesep +
linesep.join(" " + target for target in possible_targets[1:]))
parser.add_argument("--toolchain", dest="toolchain", metavar="TOOLCHAIN",
choices=["auto", "gnu", "clang"], default="auto",
help="toolchain to use for compilation. Potential options:" + linesep +
linesep.join(" " + name for name in ["auto (default)", "gnu", "clang"]))
return parser
示例3: racadm
# 需要导入模块: from os import linesep [as 别名]
# 或者: from os.linesep import join [as 别名]
def racadm(self, ctx, args):
"""
Enter racadmsim console or call sub commands
"""
if len(args) == 1:
racadm = RacadmConsole()
racadm.set_input(self.input)
racadm.set_output(self.output)
racadm.run()
else:
env.logger_r.info("[req][inline] {}".format(" ".join(args)))
racadm = RacadmConsole()
racadm.set_output(self.output)
racadm_cmd = parse(" ".join(args[1:]))
rsp = racadm.do(racadm_cmd)
env.logger_r.info("[rsp][inline]{}{}".format(linesep, rsp))
if rsp:
racadm.output(rsp.strip(linesep))
else:
racadm.output(linesep)
示例4: run
# 需要导入模块: from os import linesep [as 别名]
# 或者: from os.linesep import join [as 别名]
def run(self):
bld = self.generator.bld
linked=[]
target_paths = []
for g in bld.groups:
for tgen in g:
# FIXME it might be better to check if there is a link_task (getattr?)
target_paths += [tgen.path.get_bld().bldpath()]
linked += [t.outputs[0].bldpath()
for t in getattr(tgen, 'tasks', [])
if t.__class__.__name__ in
['cprogram', 'cshlib', 'cxxprogram', 'cxxshlib']]
lib_list = []
if len(linked):
cmd = [self.env.LDD] + linked
# FIXME add DYLD_LIBRARY_PATH+PATH for osx+win32
ldd_env = {'LD_LIBRARY_PATH': ':'.join(target_paths + self.env.LIBPATH)}
# FIXME the with syntax will not work in python 2
with tmpfile() as result:
self.exec_command(cmd, env=ldd_env, stdout=result)
result.seek(0)
for line in result.readlines():
words = line.split()
if len(words) < 3 or words[1] != '=>': continue
lib = words[2]
if lib == 'not': continue
if any([lib.startswith(p) for p in
[bld.bldnode.abspath(), '('] +
self.env.SOFTLINK_EXCLUDE]):
continue
if not isabs(lib):
continue
lib_list.append(lib)
lib_list = sorted(set(lib_list))
self.outputs[0].write(linesep.join(lib_list + self.env.DYNAMIC_LIBS))
return 0
示例5: strip_blank_lines
# 需要导入模块: from os import linesep [as 别名]
# 或者: from os.linesep import join [as 别名]
def strip_blank_lines(value):
return linesep.join(
[s for s in force_text(value).splitlines() if s.strip()])
示例6: fake_data
# 需要导入模块: from os import linesep [as 别名]
# 或者: from os.linesep import join [as 别名]
def fake_data(name):
if not env.racadm_data:
return None
data_path = os.path.join(env.racadm_data, name)
if os.path.exists(data_path):
with open(data_path) as fp:
rsp = linesep.join(fp.read().splitlines())
return rsp
else:
return None
示例7: run
# 需要导入模块: from os import linesep [as 别名]
# 或者: from os.linesep import join [as 别名]
def run(self):
self.welcome()
while True:
# READ
inp = self.input(self.prompt)
# EVAL
cmd = self.refine_cmd(parse(inp))
env.logger_r.info("[req][repl] {}".format(inp))
try:
out = self.do(cmd)
except EOFError:
env.logger_r.warning("[rsp][repl] EOFError")
return
except QuitREPL:
env.logger_r.info("[rsp][repl] Quite REPL")
return
# PRINT
self.output(linesep)
self.output(" ".join(["racadm"]+cmd))
env.logger_r.info("[rsp][repl]{}{}".format(linesep, out))
if out is not None:
self.output(out)
self.output(linesep)
示例8: welcome
# 需要导入模块: from os import linesep [as 别名]
# 或者: from os.linesep import join [as 别名]
def welcome(self):
lines = ["Connecting to {ip}:{port}...",
"Connection established.",
"To escape to local shell, press \'Ctrl+Alt+]\'.",
"", ""]
self.output(linesep.join(lines))
示例9: define
# 需要导入模块: from os import linesep [as 别名]
# 或者: from os.linesep import join [as 别名]
def define(self, ctx, args):
"""
Define a quick function
"""
body = ' '.join(args[2:])
ctx[args[1]] = compile(body, '', 'exec')
return 'def %s(): %s' % (args[1], body)
示例10: unormalize
# 需要导入模块: from os import linesep [as 别名]
# 或者: from os.linesep import join [as 别名]
def unormalize(ustring, ignorenonascii=None, substitute=None):
"""replace diacritical characters with their corresponding ascii characters
Convert the unicode string to its long normalized form (unicode character
will be transform into several characters) and keep the first one only.
The normal form KD (NFKD) will apply the compatibility decomposition, i.e.
replace all compatibility characters with their equivalents.
:type substitute: str
:param substitute: replacement character to use if decomposition fails
:see: Another project about ASCII transliterations of Unicode text
http://pypi.python.org/pypi/Unidecode
"""
# backward compatibility, ignorenonascii was a boolean
if ignorenonascii is not None:
warn("ignorenonascii is deprecated, use substitute named parameter instead",
DeprecationWarning, stacklevel=2)
if ignorenonascii:
substitute = ''
res = []
for letter in ustring[:]:
try:
replacement = MANUAL_UNICODE_MAP[letter]
except KeyError:
replacement = _uninormalize('NFKD', letter)[0]
if ord(replacement) >= 2 ** 7:
if substitute is None:
raise ValueError("can't deal with non-ascii based characters")
replacement = substitute
res.append(replacement)
return u''.join(res)
示例11: normalize_text
# 需要导入模块: from os import linesep [as 别名]
# 或者: from os.linesep import join [as 别名]
def normalize_text(text, line_len=80, indent='', rest=False):
"""normalize a text to display it with a maximum line size and
optionally arbitrary indentation. Line jumps are normalized but blank
lines are kept. The indentation string may be used to insert a
comment (#) or a quoting (>) mark for instance.
:type text: str or unicode
:param text: the input text to normalize
:type line_len: int
:param line_len: expected maximum line's length, default to 80
:type indent: str or unicode
:param indent: optional string to use as indentation
:rtype: str or unicode
:return:
the input text normalized to fit on lines with a maximized size
inferior to `line_len`, and optionally prefixed by an
indentation string
"""
if rest:
normp = normalize_rest_paragraph
else:
normp = normalize_paragraph
result = []
for text in _BLANKLINES_RGX.split(text):
result.append(normp(text, line_len, indent))
return ('%s%s%s' % (linesep, indent, linesep)).join(result)
示例12: normalize_paragraph
# 需要导入模块: from os import linesep [as 别名]
# 或者: from os.linesep import join [as 别名]
def normalize_paragraph(text, line_len=80, indent=''):
"""normalize a text to display it with a maximum line size and
optionally arbitrary indentation. Line jumps are normalized. The
indentation string may be used top insert a comment mark for
instance.
:type text: str or unicode
:param text: the input text to normalize
:type line_len: int
:param line_len: expected maximum line's length, default to 80
:type indent: str or unicode
:param indent: optional string to use as indentation
:rtype: str or unicode
:return:
the input text normalized to fit on lines with a maximized size
inferior to `line_len`, and optionally prefixed by an
indentation string
"""
text = _NORM_SPACES_RGX.sub(' ', text)
line_len = line_len - len(indent)
lines = []
while text:
aline, text = splittext(text.strip(), line_len)
lines.append(indent + aline)
return linesep.join(lines)
示例13: normalize_rest_paragraph
# 需要导入模块: from os import linesep [as 别名]
# 或者: from os.linesep import join [as 别名]
def normalize_rest_paragraph(text, line_len=80, indent=''):
"""normalize a ReST text to display it with a maximum line size and
optionally arbitrary indentation. Line jumps are normalized. The
indentation string may be used top insert a comment mark for
instance.
:type text: str or unicode
:param text: the input text to normalize
:type line_len: int
:param line_len: expected maximum line's length, default to 80
:type indent: str or unicode
:param indent: optional string to use as indentation
:rtype: str or unicode
:return:
the input text normalized to fit on lines with a maximized size
inferior to `line_len`, and optionally prefixed by an
indentation string
"""
toreport = ''
lines = []
line_len = line_len - len(indent)
for line in text.splitlines():
line = toreport + _NORM_SPACES_RGX.sub(' ', line.strip())
toreport = ''
while len(line) > line_len:
# too long line, need split
line, toreport = splittext(line, line_len)
lines.append(indent + line)
if toreport:
line = toreport + ' '
toreport = ''
else:
line = ''
if line:
lines.append(indent + line.strip())
return linesep.join(lines)
示例14: _usage
# 需要导入模块: from os import linesep [as 别名]
# 或者: from os.linesep import join [as 别名]
def _usage(error_message=None):
if error_message:
stderr.write('ERROR: ' + error_message + linesep)
stdout.write(
linesep.join([
'Usage:', ' cross_versions.py [OPTION]...', 'Examples:',
' cross_versions.py', ' cross_versions.py -r',
' cross_versions.py --rc', ' cross_versions.py -l',
' cross_versions.py --latest', 'Options:',
'-l/--latest Include only the latest version of each major and'
' minor versions sub-tree.',
'-r/--rc Include release candidate versions.',
'-h/--help Prints this!', ''
]))
示例15: main
# 需要导入模块: from os import linesep [as 别名]
# 或者: from os.linesep import join [as 别名]
def main(argv):
try:
config = _validate_input(argv)
print(linesep.join('\t'.join(triple)
for triple in cross_versions(config)))
except Exception as e:
print(str(e))
exit(_ERROR_RUNTIME)