zipaccess

Access files inside zip archives using standard file functions
Download

zipaccess Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Publisher Name:
  • Jan Killian
  • Publisher web site:
  • https://github.com/iki/

zipaccess Tags


zipaccess Description

Access files inside zip archives using standard file functions zipaccess is a Python module that contains patches functions :file+open, and os.path:exists+isfile to enable accessing files inside zip archives using standard file functions.Package: http://pypi.python.org/pypi/zipaccessProject: https://github.com/iki/zipaccessIssues: https://github.com/iki/zipaccess/issuesUpdates: https://github.com/iki/zipaccess/commits/master.atomSources via git: git clone https://github.com/iki/zipaccessSources via hg-git: hg clone git://github.com/iki/zipaccessUsage:Use as a class. Do not instaniate it:class AnyZipAccess(zipaccess.ZipAccess): any_zip = True # custom modifications hereAnyZipAccess.enable()Or use as a module:zipaccess.enable()zipaccess.addzip('data.zip')Optionally, register zipaccess.ZipAccess as os.zipaccess:zipaccess.enable(register=True)so other modules can easily use:try: os.zipaccess.enable(locals())except AttributeError: passNote on Google App Engine (GAE)On GAE, __builtin__ changes are not reflected, even in the current module.To use zip access in any GAE module, you need to enable it for that module locals:try: import zipaccess zipaccess.enable(locals())except ImportError: passAlternatively, only enable zip access, if it was already registered:try: os.zipaccess.enable(locals())except AttributeError: passOr enable it for target modules externally:zipaccess.enable()# It imports all the modules though, which may not be what you want.# If you know, how to hook on module import, let me kindly know.Note, that os.path.isfile and os.path.exists are patched globally. Even on GAE, they apply for all modules of given instance. If some modules do support zip files, they usually first check if regular file exists, and if not, they split the path and check if the zipfile exists. With zipaccess.enabled() the regular file check will succeed, which is ok as long as file/open functions used later are patched too.Example:- In tipfy.debugger.get_loader() the file/zip check is performed, and tipfy.template.Loader or tipfy.template.ZipLoader is used accordingly. With zipaccess enabled, the standard tipfy.template.Loader will be used, and therefore zipaccess.enable('tipfy.template') is needed to make it work.- See https://github.com/moraes/tipfy/blob/master/tipfy/debugger/__init__.py#L26. Requirements: · Python


zipaccess Related Software