当前位置: 首页>>代码示例>>Python>>正文


Python linesep.join方法代码示例

本文整理汇总了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!', ''
        ])) 
开发者ID:weaveworks,项目名称:grafanalib,代码行数:18,代码来源:list_versions.py

示例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 
开发者ID:Maratyszcza,项目名称:confu,代码行数:23,代码来源:__init__.py

示例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) 
开发者ID:InfraSIM,项目名称:infrasim-compute,代码行数:22,代码来源:api.py

示例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 
开发者ID:mattaw,项目名称:SoCFoundationFlow,代码行数:38,代码来源:softlink_libs.py

示例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()]) 
开发者ID:lingdb,项目名称:CoBL-public,代码行数:5,代码来源:middleware.py

示例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 
开发者ID:InfraSIM,项目名称:infrasim-compute,代码行数:12,代码来源:api.py

示例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) 
开发者ID:InfraSIM,项目名称:infrasim-compute,代码行数:30,代码来源:api.py

示例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)) 
开发者ID:InfraSIM,项目名称:infrasim-compute,代码行数:8,代码来源:api.py

示例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) 
开发者ID:InfraSIM,项目名称:infrasim-compute,代码行数:9,代码来源:repl.py

示例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) 
开发者ID:p07r0457,项目名称:Chromium_DepotTools,代码行数:34,代码来源:textutils.py

示例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) 
开发者ID:p07r0457,项目名称:Chromium_DepotTools,代码行数:31,代码来源:textutils.py

示例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) 
开发者ID:p07r0457,项目名称:Chromium_DepotTools,代码行数:30,代码来源:textutils.py

示例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) 
开发者ID:p07r0457,项目名称:Chromium_DepotTools,代码行数:41,代码来源:textutils.py

示例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!', ''
        ])) 
开发者ID:weaveworks,项目名称:grafanalib,代码行数:16,代码来源:cross_versions.py

示例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) 
开发者ID:weaveworks,项目名称:grafanalib,代码行数:10,代码来源:cross_versions.py


注:本文中的os.linesep.join方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。