:py:mod:`oioioi.base.utils.archive` =================================== .. py:module:: oioioi.base.utils.archive Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: oioioi.base.utils.archive.Archive oioioi.base.utils.archive.BaseArchive oioioi.base.utils.archive.TarArchive oioioi.base.utils.archive.ZipArchive Functions ~~~~~~~~~ .. autoapisummary:: oioioi.base.utils.archive.extract Attributes ~~~~~~~~~~ .. autoapisummary:: oioioi.base.utils.archive.extension_map .. py:exception:: ArchiveException Bases: :py:obj:`RuntimeError` Base exception class for all archive errors. .. py:exception:: UnrecognizedArchiveFormat Bases: :py:obj:`ArchiveException` Error raised when passed file is not a recognized archive format. .. py:exception:: UnsafeArchive Bases: :py:obj:`ArchiveException` Error raised when passed file contains paths that would be extracted outside of the target directory. .. py:function:: extract(path, to_path='', ext='', **kwargs) Unpack the tar or zip file at the specified path to the directory specified by to_path. .. py:class:: Archive(file, ext='') Bases: :py:obj:`object` The external API class that encapsulates an archive implementation. .. py:method:: __del__() .. py:method:: _resolve_streamed_files(file, ext) :staticmethod: .. py:method:: _archive_cls(file, ext='') :staticmethod: Return the proper Archive implementation class, based on the file type. .. py:method:: extract(*args, **kwargs) .. py:method:: filenames() .. py:method:: dirnames() .. py:method:: extracted_size() .. py:class:: BaseArchive Bases: :py:obj:`object` Base Archive class. Implementations should inherit this class. .. py:method:: __del__() .. py:method:: filenames() :abstractmethod: Return a list of the filenames contained in the archive. .. py:method:: dirnames() :abstractmethod: Return a list of the dirnames contained in the archive. .. py:method:: extracted_size() :abstractmethod: Return total file size of extracted files in bytes. .. py:method:: _extract(to_path) Performs the actual extraction. Separate from 'extract' method so that we don't recurse when subclasses don't declare their own 'extract' method. .. py:method:: extract(to_path='', method='safe') .. py:method:: check_files(to_path=None) Check that all of the files contained in the archive are within the target directory. .. py:class:: TarArchive(file) Bases: :py:obj:`BaseArchive` Base Archive class. Implementations should inherit this class. .. py:method:: filenames() Return a list of the filenames contained in the archive. .. py:method:: dirnames() Return a list of the dirnames contained in the archive. .. py:method:: extracted_size() Return total file size of extracted files in bytes. .. py:method:: check_files(to_path=None) Check that all of the files contained in the archive are within the target directory. .. py:class:: ZipArchive(file) Bases: :py:obj:`BaseArchive` Base Archive class. Implementations should inherit this class. .. py:method:: extracted_size() Return total file size of extracted files in bytes. .. py:method:: filenames() Return a list of the filenames contained in the archive. .. py:method:: dirnames() Return a list of the dirnames contained in the archive. .. py:data:: extension_map