Python rarfile.PATH_SEP Examples
The following are 15
code examples of rarfile.PATH_SEP().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
rarfile
, or try the search function
.
Example #1
Source File: rarfile.py From Lector with GNU General Public License v3.0 | 6 votes |
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
Example #2
Source File: rarfile.py From Lector with GNU General Public License v3.0 | 6 votes |
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 #
Example #3
Source File: rarfile.py From addon with GNU General Public License v3.0 | 6 votes |
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
Example #4
Source File: rarfile.py From addon with GNU General Public License v3.0 | 6 votes |
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 #
Example #5
Source File: rarfile.py From bazarr with GNU General Public License v3.0 | 6 votes |
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
Example #6
Source File: rarfile.py From bazarr with GNU General Public License v3.0 | 6 votes |
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 #
Example #7
Source File: rarfile.py From arissploit with GNU General Public License v3.0 | 6 votes |
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)
Example #8
Source File: rarfile.py From arissploit with GNU General Public License v3.0 | 6 votes |
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)
Example #9
Source File: rarfile.py From Lector with GNU General Public License v3.0 | 5 votes |
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 #
Example #10
Source File: rarfile.py From addon with GNU General Public License v3.0 | 5 votes |
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 #
Example #11
Source File: rarfile.py From bazarr with GNU General Public License v3.0 | 5 votes |
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 #
Example #12
Source File: rarfile.py From arissploit with GNU General Public License v3.0 | 5 votes |
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 ##
Example #13
Source File: rarfile.py From Lector with GNU General Public License v3.0 | 4 votes |
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
Example #14
Source File: rarfile.py From addon with GNU General Public License v3.0 | 4 votes |
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
Example #15
Source File: rarfile.py From bazarr with GNU General Public License v3.0 | 4 votes |
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