Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    zip_open 0.2.0

    Download button

    No screenshots available
    Downloads: 344  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Takayuki SHIMIZUKAWA | More programs
    Python License / FREE
    December 1st, 2011, 01:52 GMT [view history]
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    zip_open description

    File open from nested zip file archive

    zip_open allows you to open a file from a nested zip file archive.

    If you use static file like as 'data.zip' and open this from your python code, Your program will become like open(os.path.join(os.path.dirname(__file__), 'data.zip')). But if your packages are packed into packages.zip file (zipped-egg, or cases to gather in one file on Google App Engine matter), your cord doesn't work fine.

    In this situation, the file path of data.zip becomes /path/to/packages.zip/data.zip, then your program can't open the data.zip file.

    zip_open package solves this problem.

    Usage sample1: open the file from zip file

    packages1.zip is:

    packages1.zip
     + file1.txt


    Open file1.txt:

    >>> from zip_open import zopen
    >>> fobj = zopen('packages1.zip/file1.txt')
    >>> data = fobj.read()
    >>> print data
    I am file1.txt, ok.


    This code sample equivalent to below code:

    >>> from zipfile import ZipFile
    >>> zipobj = ZipFile('packages1.zip')
    >>> data = zipobj.read('file1.txt')
    >>> print data
    I am file1.txt, ok.


    Usage sample2: open the file from nested zip file

    packages2.zip is:

    packages2.zip
     + data2.zip
     + file2.txt


    Open file2.txt:

    >>> from zip_open import zopen
    >>> fobj = zopen('packages2.zip/data2.zip/file2.txt')
    >>> print fobj.read()
    I am file2.txt, ok.


    Usage sample3: open the file included in package oneself

    packages3.zip is:

    packages3.zip
     + foo.py
     + file1.txt
     + data3.zip
     + file3.txt


    foo.py:

    import os
    from zip_open import zopen


    def loader(filename):
     fobj = zopen(os.path.join(os.path.dirname(__file__), filename))
     return fobj


    execute loader() from interactive shell:

    >>> import sys
    >>> sys.path.insert(0, 'packages3.zip')
    >>> import foo
    >>> fobj = foo.loader('file1.txt')
    >>> print fobj.read()
    I am file1.txt, ok.
    >>> fobj = foo.loader('data3.zip/file3.txt')
    >>> print fobj.read()
    I am file3.txt, ok.



    Product's homepage

    Requirements:

    · Python

    What's New in This Release: [ read full changelog ]

    · Change license from PSL to Apache License 2.0
    · Add feature: open from file-like-object.

      


    TAGS:

    nested archive | zip archive | zip | nested | archive

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM