當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。