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


Python rarfile.PATH_SEP属性代码示例

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


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

示例1: getinfo

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import PATH_SEP [as 别名]
def getinfo(self, member):
        """Return RarInfo for filename
        """
        if isinstance(member, RarInfo):
            fname = member.filename
        else:
            fname = member

        # accept both ways here
        if PATH_SEP == '/':
            fname2 = fname.replace("\\", "/")
        else:
            fname2 = fname.replace("/", "\\")

        try:
            return self._info_map[fname]
        except KeyError:
            try:
                return self._info_map[fname2]
            except KeyError:
                raise NoRarEntry("No such file: %s" % fname)

    # read rar 
开发者ID:BasioMeusPuga,项目名称:Lector,代码行数:25,代码来源:rarfile.py

示例2: _open_unrar

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import PATH_SEP [as 别名]
def _open_unrar(self, rarfile, inf, psw=None, tmpfile=None, force_file=False):
        cmd = [UNRAR_TOOL] + list(OPEN_ARGS)
        add_password_arg(cmd, psw)
        cmd.append("--")
        cmd.append(rarfile)

        # not giving filename avoids encoding related problems
        if not tmpfile or force_file:
            fn = inf.filename
            if PATH_SEP != os.sep:
                fn = fn.replace(PATH_SEP, os.sep)
            cmd.append(fn)

        # read from unrar pipe
        return PipeReader(self, inf, cmd, tmpfile)

#
# RAR3 format
# 
开发者ID:BasioMeusPuga,项目名称:Lector,代码行数:21,代码来源:rarfile.py

示例3: getinfo

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import PATH_SEP [as 别名]
def getinfo(self, member):
        """Return RarInfo for filename
        """
        if isinstance(member, RarInfo):
            fname = member.filename
        elif _have_pathlib and isinstance(member, Path):
            fname = str(member)
        else:
            fname = member

        # accept both ways here
        if PATH_SEP == '/':
            fname2 = fname.replace("\\", "/")
        else:
            fname2 = fname.replace("/", "\\")

        try:
            return self._info_map[fname]
        except KeyError:
            try:
                return self._info_map[fname2]
            except KeyError:
                raise NoRarEntry("No such file: %s" % fname)

    # read rar 
开发者ID:alfa-addon,项目名称:addon,代码行数:27,代码来源:rarfile.py

示例4: getinfo

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import PATH_SEP [as 别名]
def getinfo(self, fname):
        '''Return RarInfo for file.'''

        if isinstance(fname, RarInfo):
            return fname

        # accept both ways here
        if PATH_SEP == '/':
            fname2 = fname.replace("\\", "/")
        else:
            fname2 = fname.replace("/", "\\")

        try:
            return self._info_map[fname]
        except KeyError:
            try:
                return self._info_map[fname2]
            except KeyError:
                raise NoRarEntry("No such file: "+fname) 
开发者ID:entynetproject,项目名称:arissploit,代码行数:21,代码来源:rarfile.py

示例5: _open_unrar

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import PATH_SEP [as 别名]
def _open_unrar(self, rarfile, inf, psw = None, tmpfile = None):
        if is_filelike(rarfile):
            raise ValueError("Cannot use unrar directly on memory buffer")
        cmd = [UNRAR_TOOL] + list(OPEN_ARGS)
        add_password_arg(cmd, psw)
        cmd.append("--")
        cmd.append(rarfile)

        # not giving filename avoids encoding related problems
        if not tmpfile:
            fn = inf.filename
            if PATH_SEP != os.sep:
                fn = fn.replace(PATH_SEP, os.sep)
            cmd.append(fn)

        # read from unrar pipe
        return PipeReader(self, inf, cmd, tmpfile) 
开发者ID:entynetproject,项目名称:arissploit,代码行数:19,代码来源:rarfile.py

示例6: _extract

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import PATH_SEP [as 别名]
def _extract(self, fnlist, path=None, psw=None):
        cmd = [UNRAR_TOOL] + list(EXTRACT_ARGS)

        # pasoword
        psw = psw or self._password
        add_password_arg(cmd, psw)
        cmd.append('--')

        # rar file
        with XTempFile(self._rarfile) as rarfn:
            cmd.append(rarfn)

            # file list
            for fn in fnlist:
                if os.sep != PATH_SEP:
                    fn = fn.replace(PATH_SEP, os.sep)
                cmd.append(fn)

            # destination path
            if path is not None:
                cmd.append(path + os.sep)

            # call
            p = custom_popen(cmd)
            output = p.communicate()[0]
            check_returncode(p, output)

#
# File format parsing
# 
开发者ID:BasioMeusPuga,项目名称:Lector,代码行数:32,代码来源:rarfile.py

示例7: _extract

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import PATH_SEP [as 别名]
def _extract(self, fnlist, path=None, psw=None):
        cmd = [UNRAR_TOOL] + list(EXTRACT_ARGS)

        # pasoword
        psw = psw or self._password
        add_password_arg(cmd, psw)
        cmd.append('--')

        # rar file
        with XTempFile(self._rarfile) as rarfn:
            cmd.append(rarfn)

            # file list
            for fn in fnlist:
                if os.sep != PATH_SEP:
                    fn = fn.replace(PATH_SEP, os.sep)
                cmd.append(fn)

            # destination path
            if path is not None:
                if _have_pathlib and isinstance(path, Path):
                    path = str(path)
                #cmd.append(path + os.sep)
                cmd.append(path)

            # call
            p = custom_popen(cmd)
            output = p.communicate()[0]
            check_returncode(p, output)

#
# File format parsing
# 
开发者ID:alfa-addon,项目名称:addon,代码行数:35,代码来源:rarfile.py

示例8: _extract

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import PATH_SEP [as 别名]
def _extract(self, fnlist, path=None, psw=None):
        cmd = [UNRAR_TOOL] + list(EXTRACT_ARGS)

        # pasoword
        psw = psw or self._password
        add_password_arg(cmd, psw)
        cmd.append('--')

        # rar file
        if is_filelike(self.rarfile):
            tmpname = membuf_tempfile(self.rarfile)
            cmd.append(tmpname)
        else:
            tmpname = None
            cmd.append(self.rarfile)

        # file list
        for fn in fnlist:
            if os.sep != PATH_SEP:
                fn = fn.replace(PATH_SEP, os.sep)
            cmd.append(fn)

        # destination path
        if path is not None:
            cmd.append(path + os.sep)

        # call
        try:
            p = custom_popen(cmd)
            output = p.communicate()[0]
            check_returncode(p, output)
        finally:
            if tmpname:
                os.unlink(tmpname)

##
## Utility classes
## 
开发者ID:entynetproject,项目名称:arissploit,代码行数:40,代码来源:rarfile.py

示例9: _parse_file_header

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import PATH_SEP [as 别名]
def _parse_file_header(self, h, hdata, pos):
        fld = S_FILE_HDR.unpack_from(hdata, pos)
        pos += S_FILE_HDR.size

        h.compress_size = fld[0]
        h.file_size = fld[1]
        h.host_os = fld[2]
        h.CRC = fld[3]
        h.date_time = parse_dos_time(fld[4])
        h.mtime = to_datetime(h.date_time)
        h.extract_version = fld[5]
        h.compress_type = fld[6]
        name_size = fld[7]
        h.mode = fld[8]

        h._md_class = CRC32Context
        h._md_expect = h.CRC

        if h.flags & RAR_FILE_LARGE:
            h1, pos = load_le32(hdata, pos)
            h2, pos = load_le32(hdata, pos)
            h.compress_size |= h1 << 32
            h.file_size |= h2 << 32
            h.add_size = h.compress_size

        name, pos = load_bytes(hdata, name_size, pos)
        if h.flags & RAR_FILE_UNICODE:
            nul = name.find(ZERO)
            h.orig_filename = name[:nul]
            u = UnicodeFilename(h.orig_filename, name[nul + 1:])
            h.filename = u.decode()

            # if parsing failed fall back to simple name
            if u.failed:
                h.filename = self._decode(h.orig_filename)
        else:
            h.orig_filename = name
            h.filename = self._decode(name)

        # change separator, if requested
        if PATH_SEP != '\\':
            h.filename = h.filename.replace('\\', PATH_SEP)

        if h.flags & RAR_FILE_SALT:
            h.salt, pos = load_bytes(hdata, 8, pos)
        else:
            h.salt = None

        # optional extended time stamps
        if h.flags & RAR_FILE_EXTTIME:
            pos = _parse_ext_time(h, hdata, pos)
        else:
            h.mtime = h.atime = h.ctime = h.arctime = None

        return pos

    # find old-style comment subblock 
开发者ID:BasioMeusPuga,项目名称:Lector,代码行数:59,代码来源:rarfile.py


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