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


Python FilePath.strip方法代码示例

本文整理汇总了Python中twisted.python.filepath.FilePath.strip方法的典型用法代码示例。如果您正苦于以下问题:Python FilePath.strip方法的具体用法?Python FilePath.strip怎么用?Python FilePath.strip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.python.filepath.FilePath的用法示例。


在下文中一共展示了FilePath.strip方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: postOptions

# 需要导入模块: from twisted.python.filepath import FilePath [as 别名]
# 或者: from twisted.python.filepath.FilePath import strip [as 别名]
 def postOptions(self):
     store = self.parent.getStore()
     path = self.decodeCommandLine(self['file'])
     content = FilePath(path).getContent()
     for line in content.strip().split('\n'):
         steamID, name = line.split(',', 1)
         Author(store=store, name=name.decode('utf8'), steamID=int(steamidTo64(steamID)))
     steamID = int(self.decodeCommandLine(self['steamid']))
开发者ID:jsza,项目名称:jump-map-list,代码行数:10,代码来源:maplistcmd.py

示例2: _losetup_list_parse

# 需要导入模块: from twisted.python.filepath import FilePath [as 别名]
# 或者: from twisted.python.filepath.FilePath import strip [as 别名]
def _losetup_list_parse(output):
    """
    Parse the output of ``losetup --all`` which varies depending on the
    privileges of the user.

    :param unicode output: The output of ``losetup --all``.
    :returns: A ``list`` of
        2-tuple(FilePath(device_file), FilePath(backing_file))
    """
    devices = []
    for line in output.splitlines():
        parts = line.split(u":", 2)
        if len(parts) != 3:
            continue
        device_file, _, backing_file = parts
        device_file = FilePath(device_file.strip().encode("utf-8"))

        # Trim everything from the first left bracket, skipping over the
        # possible inode number which appears only when run as root.
        left_bracket_offset = backing_file.find(b"(")
        backing_file = backing_file[left_bracket_offset + 1:]

        # Trim everything from the right most right bracket
        right_bracket_offset = backing_file.rfind(b")")
        backing_file = backing_file[:right_bracket_offset]

        # Trim a possible embedded deleted flag
        expected_suffix_list = [b"(deleted)"]
        for suffix in expected_suffix_list:
            offset = backing_file.rfind(suffix)
            if offset > -1:
                backing_file = backing_file[:offset]

        # Remove the space that may have been between the path and the deleted
        # flag.
        backing_file = backing_file.rstrip()
        backing_file = FilePath(backing_file.encode("utf-8"))
        devices.append((device_file, backing_file))
    return devices
开发者ID:AlexRRR,项目名称:flocker,代码行数:41,代码来源:loopback.py


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