コード例 #1
0
    def __init__(self, archiveName, password=None):
        """Instantiate the archive.

        archiveName is the name of the RAR file.
        password is used to decrypt the files in the archive.

        Properties:
            comment - comment associated with the archive

        >>> print RarFile('test.rar').comment
        This is a test.
        """
        self.archiveName = archiveName
        RarFileImplementation.init(self, password)
コード例 #2
0
ファイル: __init__.py プロジェクト: Amohell/ComicStreamer
    def __init__(self, archiveName, password=None):
        """Instantiate the archive.

        archiveName is the name of the RAR file.
        password is used to decrypt the files in the archive.

        Properties:
            comment - comment associated with the archive

        >>> print RarFile('test.rar').comment
        This is a test.
        """
        self.archiveName = archiveName
        RarFileImplementation.init(self, password)
コード例 #3
0
 def read_files(self, condition='*'):
     """Read specific files from archive into memory.
     If "condition" is a list of numbers, then return files which have those positions in infolist.
     If "condition" is a string, then it is treated as a wildcard for names of files to extract.
     If "condition" is a function, it is treated as a callback function, which accepts a RarInfo object 
         and returns boolean True (extract) or False (skip).
     If "condition" is omitted, all files are returned.
     
     Returns list of tuples (RarInfo info, str contents)
     """
     checker = condition2checker(condition)
     return RarFileImplementation.read_files(self, checker)
コード例 #4
0
ファイル: __init__.py プロジェクト: Amohell/ComicStreamer
 def read_files(self, condition='*'):
     """Read specific files from archive into memory.
     If "condition" is a list of numbers, then return files which have those positions in infolist.
     If "condition" is a string, then it is treated as a wildcard for names of files to extract.
     If "condition" is a function, it is treated as a callback function, which accepts a RarInfo object 
         and returns boolean True (extract) or False (skip).
     If "condition" is omitted, all files are returned.
     
     Returns list of tuples (RarInfo info, str contents)
     """
     checker = condition2checker(condition)
     return RarFileImplementation.read_files(self, checker)
コード例 #5
0
    def infoiter(self):
        """Iterate over all the files in the archive, generating RarInfos.

        >>> import os
        >>> for fileInArchive in RarFile('test.rar').infoiter():
        ...     print os.path.split(fileInArchive.filename)[-1],
        ...     print fileInArchive.isdir,
        ...     print fileInArchive.size,
        ...     print fileInArchive.comment,
        ...     print tuple(fileInArchive.datetime)[0:5],
        ...     print time.strftime('%a, %d %b %Y %H:%M', fileInArchive.datetime)
        test True 0 None (2003, 6, 30, 1, 59) Mon, 30 Jun 2003 01:59
        test.txt False 20 None (2003, 6, 30, 2, 1) Mon, 30 Jun 2003 02:01
        this.py False 1030 None (2002, 2, 8, 16, 47) Fri, 08 Feb 2002 16:47
        """
        for params in RarFileImplementation.infoiter(self):
            yield RarInfo(self, params)
コード例 #6
0
ファイル: __init__.py プロジェクト: Amohell/ComicStreamer
    def infoiter(self):
        """Iterate over all the files in the archive, generating RarInfos.

        >>> import os
        >>> for fileInArchive in RarFile('test.rar').infoiter():
        ...     print os.path.split(fileInArchive.filename)[-1],
        ...     print fileInArchive.isdir,
        ...     print fileInArchive.size,
        ...     print fileInArchive.comment,
        ...     print tuple(fileInArchive.datetime)[0:5],
        ...     print time.strftime('%a, %d %b %Y %H:%M', fileInArchive.datetime)
        test True 0 None (2003, 6, 30, 1, 59) Mon, 30 Jun 2003 01:59
        test.txt False 20 None (2003, 6, 30, 2, 1) Mon, 30 Jun 2003 02:01
        this.py False 1030 None (2002, 2, 8, 16, 47) Fri, 08 Feb 2002 16:47
        """
        for params in RarFileImplementation.infoiter(self):
            yield RarInfo(self, params)
コード例 #7
0
ファイル: __init__.py プロジェクト: Amohell/ComicStreamer
 def extract(self,  condition='*', path='.', withSubpath=True, overwrite=True):
     """Extract specific files from archive to disk.
     
     If "condition" is a list of numbers, then extract files which have those positions in infolist.
     If "condition" is a string, then it is treated as a wildcard for names of files to extract.
     If "condition" is a function, it is treated as a callback function, which accepts a RarInfo object
         and returns either boolean True (extract) or boolean False (skip).
     DEPRECATED: If "condition" callback returns string (only supported for Windows) - 
         that string will be used as a new name to save the file under.
     If "condition" is omitted, all files are extracted.
     
     "path" is a directory to extract to
     "withSubpath" flag denotes whether files are extracted with their full path in the archive.
     "overwrite" flag denotes whether extracted files will overwrite old ones. Defaults to true.
     
     Returns list of RarInfos for extracted files."""
     checker = condition2checker(condition)
     return RarFileImplementation.extract(self, checker, path, withSubpath, overwrite)
コード例 #8
0
ファイル: __init__.py プロジェクト: Bryalle90/autoHTPC
 def extract(self,  condition='*', path='.', withSubpath=True, overwrite=True):
     """Extract specific files from archive to disk.
     
     If "condition" is a list of numbers, then extract files which have those positions in infolist.
     If "condition" is a string, then it is treated as a wildcard for names of files to extract.
     If "condition" is a function, it is treated as a callback function, which accepts a RarInfo object
         and returns either boolean True (extract) or boolean False (skip).
     DEPRECATED: If "condition" callback returns string (only supported for Windows) - 
         that string will be used as a new name to save the file under.
     If "condition" is omitted, all files are extracted.
     
     "path" is a directory to extract to
     "withSubpath" flag denotes whether files are extracted with their full path in the archive.
     "overwrite" flag denotes whether extracted files will overwrite old ones. Defaults to true.
     
     Returns list of RarInfos for extracted files."""
     checker = condition2checker(condition)
     return RarFileImplementation.extract(self, checker, path, withSubpath, overwrite)
コード例 #9
0
 def get_volume(self):
     """Determine which volume is it in a multi-volume archive. Returns None if it's not a 
     multi-volume archive, 0-based volume number otherwise."""
     return RarFileImplementation.get_volume(self)
コード例 #10
0
ファイル: __init__.py プロジェクト: 2mny/mylar
 def get_volume(self):
     """Determine which volume is it in a multi-volume archive. Returns None if it's not a 
     multi-volume archive, 0-based volume number otherwise."""
     return RarFileImplementation.get_volume(self)