pax_global_header00006660000000000000000000000064126332113450014512gustar00rootroot0000000000000052 comment=34ac5e54b60d78f4a3def3e64474577b8d323abd patool-1.10/000077500000000000000000000000001263321134500127315ustar00rootroot00000000000000patool-1.10/COPYING000066400000000000000000001043741263321134500137750ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . patool-1.10/MANIFEST.in000066400000000000000000000002601263321134500144650ustar00rootroot00000000000000include MANIFEST.in include COPYING doc/*.1 doc/*.txt doc/*.tmpl doc/icon/* include Makefile *.bash-completion include scripts/*.bat scripts/*.iss recursive-include tests *.py patool-1.10/Makefile000066400000000000000000000077121263321134500144000ustar00rootroot00000000000000# This Makefile is only used by developers. PYTHON:=python VERSION:=$(shell $(PYTHON) setup.py --version) MAINTAINER:=$(shell $(PYTHON) setup.py --maintainer) AUTHOR:=$(shell $(PYTHON) setup.py --author) APPNAME:=$(shell $(PYTHON) setup.py --name) ARCHIVE_SOURCE:=$(APPNAME)-$(VERSION).tar.gz ARCHIVE_WHEEL:=$(APPNAME)-$(VERSION)-py2.py3-none-any.whl GITUSER:=wummel GITREPO:=$(APPNAME) HOMEPAGE:=$(HOME)/public_html/patool-webpage.git WEBMETA:=doc/web/app.yaml # Pytest options: # --resultlog: write test results in file # -s: do not capture stdout/stderr (some tests fail otherwise) PYTESTOPTS?=--resultlog=testresults.txt -s # which test modules to run TESTS ?= tests/ # set test options TESTOPTS= all: dist: [ -d dist ] || mkdir dist $(PYTHON) setup.py sdist --formats=tar bdist_wheel gzip --best dist/$(APPNAME)-$(VERSION).tar sign: [ -f dist/$(ARCHIVE_SOURCE).asc ] || gpg --detach-sign --armor dist/$(ARCHIVE_SOURCE) [ -f dist/$(ARCHIVE_WHEEL).asc ] || gpg --detach-sign --armor dist/$(ARCHIVE_WHEEL) upload: twine upload dist/$(ARCHIVE_SOURCE) dist/$(ARCHIVE_SOURCE).asc \ dist/$(ARCHIVE_WHEEL) dist/$(ARCHIVE_WHEEL).asc update_webmeta: # update metadata @echo "version: \"$(VERSION)\"" > $(WEBMETA) @echo "name: \"$(APPNAME)\"" >> $(WEBMETA) @echo "maintainer: \"$(MAINTAINER)\"" >> $(WEBMETA) @echo "author: \"$(AUTHOR)\"" >> $(WEBMETA) git add $(WEBMETA) git cm "Updated web meta data." homepage: update_webmeta # relase website $(MAKE) -C doc/web release tag: # add and push the version tag git tag upstream/$(VERSION) git push --tags origin upstream/$(VERSION) # Make a new release by calling all the distinct steps in the correct order. # Each step is a separate target so that it's easy to do this manually if # anything screwed up. release: distclean releasecheck $(MAKE) dist sign upload homepage tag register changelog register: @echo "Register at Python Package Index..." $(PYTHON) setup.py register releasecheck: test check @if egrep -i "xx\.|xxxx|\.xx" doc/changelog.txt > /dev/null; then \ echo "Could not release: edit doc/changelog.txt release date"; false; \ fi @if ! head -n1 doc/changelog.txt | egrep "^$(VERSION)" >/dev/null; then \ echo "Could not release: different versions in doc/changelog.txt and setup.py"; \ echo "Version in doc/changelog.txt:"; head -n1 doc/changelog.txt; \ echo "Version in setup.py: $(VERSION)"; false; \ fi $(PYTHON) setup.py check --restructuredtext check: # The check programs used here are mostly local scripts on my private system. # So for other developers there is no need to execute this target. check-copyright check-pofiles -v py-tabdaddy py-unittest2-compat tests/ $(MAKE) doccheck doccheck: py-check-docstrings --force \ patoolib \ patool \ *.py pyflakes: pyflakes setup.py patool patoolib tests count: # print some code statistics @sloccount patool patoolib clean: -$(PYTHON) setup.py clean --all find . -name '*.py[co]' -exec rm -f {} \; distclean: clean rm -rf build dist $(APPNAME).egg-info rm -f _$(APPNAME)_configdata.py MANIFEST # clean aborted dist builds and output files rm -f testresults.txt rm -rf $(APPNAME)-$(VERSION) rm -f *-stamp* localbuild: $(PYTHON) setup.py build test: localbuild $(PYTHON) -m pytest $(PYTESTOPTS) $(TESTOPTS) $(TESTS) doc/$(APPNAME).txt: doc/$(APPNAME).1 # make text file from man page for wheel builds cols=`stty size | cut -d" " -f2`; stty cols 72; man -l $< | sed -e 's/.\cH//g' > $@; stty cols $$cols update-copyright: # update-copyright is a local tool which updates the copyright year for each # modified file. update-copyright --holder="$(MAINTAINER)" changelog: # github-changelog is a local tool which parses the changelog and automatically # closes issues mentioned in the changelog entries. github-changelog $(DRYRUN) $(GITUSER) $(GITREPO) doc/changelog.txt .PHONY: changelog update-copyright test clean count pyflakes check .PHONY: releasecheck release upload sign dist all tag register homepage .PHONY: localbuild doccheck patool-1.10/PKG-INFO000066400000000000000000000037371263321134500140400ustar00rootroot00000000000000Metadata-Version: 1.1 Name: patool Version: 1.10 Summary: portable archive file manager Home-page: http://wummel.github.io/patool/ Author: Bastian Kleineidam Author-email: bastian.kleineidam@web.de License: GPL Description: Various archive formats can be created, extracted, tested, listed, searched, compared and repacked by patool. The advantage of patool is its simplicity in handling archive files without having to remember a myriad of programs and options. The archive format is determined by the file(1) program and as a fallback by the archive file extension. patool supports 7z (.7z), ACE (.ace), ADF (.adf), ALZIP (.alz), APE (.ape), AR (.a), ARC (.arc), ARJ (.arj), BZIP2 (.bz2), CAB (.cab), COMPRESS (.Z), CPIO (.cpio), DEB (.deb), DMS (.dms), FLAC (.flac), GZIP (.gz), ISO (.iso), LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP (.lzo), RPM (.rpm), RAR (.rar), RZIP (.rz), SHN (.shn), TAR (.tar), XZ (.xz), ZIP (.zip, .jar), ZOO (.zoo) and ZPAQ (.zpaq) formats. It relies on helper applications to handle those archive formats (for example bzip2 for BZIP2 archives). The archive formats TAR, ZIP, BZIP2 and GZIP are supported natively and do not require helper applications to be installed. Keywords: archiver,archive,compression,commandline,manager Platform: UNKNOWN Classifier: Environment :: Console Classifier: Topic :: System :: Archiving Classifier: Development Status :: 5 - Production/Stable Classifier: License :: OSI Approved :: GNU General Public License (GPL) Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Operating System :: OS Independent patool-1.10/doc/000077500000000000000000000000001263321134500134765ustar00rootroot00000000000000patool-1.10/doc/README.txt000066400000000000000000000052411263321134500151760ustar00rootroot00000000000000Patool ======= Patool is an archive file manager. Various archive formats can be created, extracted, tested, listed, searched, repacked and compared with patool. The advantage of patool is its simplicity in handling archive files without having to remember a myriad of programs and options. The archive format is determined by the file(1) program and as a fallback by the archive file extension. patool supports 7z (.7z), ACE (.ace), ADF (.adf), ALZIP (.alz), APE (.ape), AR (.a), ARC (.arc), ARJ (.arj), BZIP2 (.bz2), CAB (.cab), COMPRESS (.Z), CPIO (.cpio), DEB (.deb), DMS (.dms), FLAC (.flac), GZIP (.gz), ISO (.iso), LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP (.lzo), RPM (.rpm), RAR (.rar), RZIP (.rz), SHN (.shn), TAR (.tar), XZ (.xz), ZIP (.zip, .jar) and ZOO (.zoo) formats. It relies on helper applications to handle those archive formats (for example bzip2 for BZIP2 archives). The archive formats TAR, ZIP, BZIP2 and GZIP are supported natively and do not require helper applications to be installed. Examples --------- ``` # Extract several archives with different formats patool extract archive.zip otherarchive.rar # Test archive integrity patool test --verbose dist.tar.gz # List files stored in an archive patool list package.deb # Create a new archive patool create --verbose /path/to/myfiles.zip file1.txt dir/ # Show differences between two archives patool diff release1.0.tar.gz release2.0.zip # Search for text inside archives patool search "def urlopen" python-3.3.tar.gz # Repackage an archive in a different format patool repack linux-2.6.33.tar.gz linux-2.6.33.tar.bz2 ``` Website -------- See http://wummel.github.io/patool/ for more info and downloads. API ---- You can use patool functions from other Python applications. Log output will be on sys.stdout and sys.stderr. On errors, `PatoolError` will be raised. Note that extra options such as password input or customization for specific archive programs are not supported. ``` import patoolib patoolib.extract_archive("archive.zip", outdir="/tmp") patoolib.test_archive("dist.tar.gz", verbosity=1) patoolib.list_archive("package.deb") patoolib.create_archive("/path/to/myfiles.zip", ("file1.txt", "dir/")) patoolib.diff_archives("release1.0.tar.gz", "release2.0.zip") patoolib.search_archive("def urlopen", "python3.3.tar.gz") patoolib.repack_archive("linux-2.6.33.tar.gz", "linux-2.6.33.tar.bz2") ``` Test suite status ------------------ Patool has extensive unit tests to ensure the code quality. [Travis CI](https://travis-ci.org/) is used for continuous build and test integration. [![Build Status](https://travis-ci.org/wummel/patool.png)](https://travis-ci.org/wummel/patool) patool-1.10/doc/changelog.txt000066400000000000000000000174041263321134500161740ustar00rootroot000000000000001.10 (released 10.12.2015) * Added support for VHD (Virtual Hard Disk) archives with 7z. 1.9 (released 07.12.2015) * Fix ZPAQ archive creation. Patch by vitlav * Fix ZPAQ archive testing. * Add more search paths for rar libraries. Patch by vitlav Closes: GH bug #30 * Fix support URL Closes: GH bug #28 * Updated PyPI trove classifiers to include Python 3 Closes: GH bug #25 * Added new option --non-interactive to avoid commandline prompts of archive programs. Closes: GH bug #16, #24 1.8 (released 19.7.2015) * Added support for ZPAQ archives. Closes: GH bug #14 * Use options for maximum compression when creating archives and the archive program has such options. * Added a new "recompress" command which tries to reduce the size of the compressed archive. * Add BZIP2 creation to 7z and 7za commands. 1.7 (released 27.6.2014) * Configure the xz program to also extract LZMA files. * Fixed creation of LZMA files with the Python lzma module. * Handle *.epub and *.apk files as ZIP files. 1.6 (released 8.6.2014) * Search /usr/local/lib for p7zip RAR modules. Closes: GH bug #10 1.5 (released 30.3.2014) * Fix detection of existing broken symlinks when unpacking. 1.4 (released 2.9.2013) * Add missing GZIP creation support for 7z modules. Closes: GH bug #6 1.3 (released 19.7.2013) * Add patoolib.__version__ (see PEP 396). Closes: GH bug #3 * Improved detection of LZMA and LRZIP files with file(1). * Add missing patoolib.programs to Windows installer. Closes: GH bug #5 1.2 (released 27.6.2013) * Fix detection of *.gz with newer libmagic versions. Closes: GH bug #2 1.1 "Clerks" (released 7.4.2013) * Add support for zopfli, Googles new zlib compressor. * Fix an error repacking compressed tar archives with 7z. 1.0 "Robot and Frank" (released 1.3.2013) * Add support for searching in archive contents. * Add support for ISO image handling. * Allow multiple --verbose options to increase program output. * Add patool.exe to the PATH in the windows installer. * Fixed Python lzma archive handling. * Fixed lzop, lrzip and rzip archive handling. * Fixed Python 3.x support. 0.19 "The Kids Are All Right" (released 21.2.2013) * Support the lzma module in Python >= 3.3 * Optimize repacking of archives with the same format. Closes: GH bug #1 0.18 "Skyfall" (released 15.12.2012) * Fixed unadf archive listing. * Added support for Python 3.x. * Use importlib to find program modules and depend on Python >= 2.7. * Added support for archmage and chmlib handling CHM (.chm) archives. 0.17 "I am Bruce Lee" (released 4.8.2012) * Added support for Monkey's Audio Compressor handling APE (.ape) archives. * Added support for shorten handling SHN (.shn) archives. * Added support for flac handling FLAC (.flac) archives. * Added support for the BSD cpio and tar programs. * Added support for lhasa handling LZH (.lzh, .lha) archives. * Added support for lcap handling CAB (.cab) archives. * Added support for shar handling SHAR (.shar) shell archives. * Added support for unadf handling ADF (.adf) amiga disk archives. * Removed support for orange handling self-extracting installers. * Generate standalone Windows .exe and Linux .rpm installer. * Initialize the internal MIME database correct on all platforms. * Improved option compatibility for the ar, cpio and tar programs. * Rename the temporary output directory if it contains multiple files. The name is the archive name without extension, which is more readable than a random filename "UnpackXyz". * Require and use Python >=2.5 0.16 "Game of thrones" (released 12.5.2012) * Document the --outdir option for the extract command. Closes: SF bug #3363964 * Added convenience library function to handle archives. Documentation for those functions can be found in doc/development.txt. Closes: SF bug #3351936 * Fix generating an RPM installer. Closes: SF bug #2977749 * Added support for the lbzip2 program handling BZIP2 archives. * Added support for the plzip program handling LZIP archives. * Prevent overwriting files with repack. * Support extraction of BZIP2 (.bz2) files with the Python bz2 module. * Support extraction of GZIP (.gz) files with the Python gzip module. * Support extraction of ZIP (.zip) files with the Python zipfile module. * Support extraction of TAR (.tar) files with the Python tarfile module. 0.15 "Contraband" (released 8.4.2012) * Print help when unknown options are given. * Print error when archive files do not exist. * Added installation instructions in doc/install.txt * Added support for the pigz program handling GZIP archives. 0.14 "Book of Dragons" (released 30.1.2012) * Handle CRX (.crx) files as ZIP archives. They have garbage at the beginning of the file, but some unzip programs can cope with that. * The xz program supports listing of XZ archives. Adjust the configuration accordingly. 0.13 "Megamind" (released 25.1.2011) * Fix command argument order when extracting cpio archives. * Added correct cpio MIME type on Debian systems. * Added support for the clzip and pdlzip programs who are both capable of handling LZIP (.lz) archives. * Added support for the orange program which is capable of extracting CAB (.cab) archives. * Added support for DMS (.dms) files with the xdms program. * Support ZIP (.zip) file creation with the 7z and 7za programs. * Improved MIME type detection for compressed TAR archives. * Fix needed archive programs for several test cases, including test_repack and test_mime. 0.12 "Galaxy Quest" (released 20.11.2010) * Show commands that are run. * Fix rar extraction unpack directory. * Fix ZIP mimedb detection on Windows systems. 0.11 "Primer" (released 4.10.2010) * Added support for the standalone 7za program. 0.10 "Matchpoint" (released 10.4.2010) * Correct shell quoting of commandline arguments. Now files with spaces or other special characters are handled correctly. * Use correct error routine on rmtree() errors. The previous one did not have the correct number of arguments. 0.9 "Cargo" (released 26.3.2010) * Do not use the diff -B option when comparing archives. * Improved documentation: explain commands in more detail. * Added support for RZIP (.rz) archives. * Added support for ZOO (.zoo) archives. 0.8 "Storage" (released 11.3.2010) * Fix path error by using absolute pathname for archive when changing the current working directory to the unpack directory. * Fix parsing of the "-v" short option. * Added new command "patool diff" to show differences between two archives. * Added new command "patool repack" to repackage archives in another format. 0.7 "3000 Miles to Graceland" (released 8.3.2010) * Added support for ALZIP (.alz) archives. * Added support for LRZIP (.lrz) archives. * Added support for ARC (.arc) archives. 0.6 "Waking Ned" (released 6.3.2010) * Remove the --force option. Local files are now never overwritten. * Added option alias -v for --verbose. * Added --verbose option to create command. * Added support for extracting, listing and testing multiple archives. * Fix permissions of extracted files: make them readable by the current user. * Added support for ACE (.ace) archives. * Added support for AR (.a) archives. * Added support for LZH (.lha, .lzh) archives. 0.5 "Vanishing Point" (released 4.3.2010) * Ported to Python 2.4. * Added support for LZIP (.lz) archives. * Removed support for setting options via config file. 0.4 "Nikita" (released 3.3.2010) * Added support for Windows systems. * Added support for creating ZIP files. * Improved listing of available archive formats. * Improved recognition of MIME types. 0.3 "Management" (released 23.2.2010) * Better test if encodings of archive commands are supported (for example .tar.Z needs a decompress program). 0.2 "Birdy" (released 22.2.2010) * Add support for LZMA and XZ archives. 0.1 "Hard Boiled" (released 21.2.2010) * Initial release. patool-1.10/doc/development.txt000066400000000000000000000051741263321134500165700ustar00rootroot00000000000000Development with the patoolib library ====================================== The patool functionality can also be used in other Python programs. To do this, install the patool program, import the library and use one or more of the convenience functions. import patoolib try: patoolib.extract("myarchive.zip", verbose=True) print("Success.") except patoolib.util.PatoolError as msg: print("Error:", msg) General rules for all convenience functions: * All convenience functions raise PatoolError on errors. * Error messages are printed on stderr, informative messages are printed on stdout. * All file arguments are filenames. File objects are not accepted as input. * Filenames can be relative or absolute. * If verbosity is increased, additional output of the archive program is shown. * Usually the program to be executed is automatically determined but it can be set manually with the program parameter. The convenience functions are: * ``def extract_archive(archive, verbosity=0, outdir=None, program=None)`` Extracts the given archive filename to the current working directory or if specified to the given directory name in outdir. Checks that the archive exists and is readable before extracting it. * ``def list_archive(archive, verbosity=1, program=None)`` Lists the contents of the given archive filename on stdout. Checks that the archive exists and is readable before listing it. * ``def test_archive(archive, verbosity=0, program=None)`` Tests the given archive filename. Checks that the archive exists and is readable before testing it. * ``def create_archive(archive, filenames, verbosity=0, program=None)`` Creates a new archive. The type of archive is determined by the archive filename extension. Checks that the archive is not already existing to avoid overwriting it. Also checks that the filename list is not empty and that all files exist and are readable. * ``diff_archives(archive1, archive2, verbosity=0)`` This function lists differences in the content of the two archives. Both archives are extracted and the contents are compared recursively with the diff(1) program. Checks that both archives exist and are readable. * ``def search_archive(pattern, archive, verbosity=0)`` This function searches the given pattern in the archive file contents with grep(1). Checks that archive exists and is readable. * ``repack_archive (archive, archive_new, verbosity=0)`` This function extracts the contents of the archive and packs them into archive_new. Checks that archive exists and is readable. Also checks that archive_new does not exist to avoid overwriting it. patool-1.10/doc/icon/000077500000000000000000000000001263321134500144265ustar00rootroot00000000000000patool-1.10/doc/icon/Makefile000066400000000000000000000003341263321134500160660ustar00rootroot00000000000000OXYGEN := ${HOME}/src/oxygen-gitsvn ICOICONS := logo16x16.png logo32x32.png all: favicon.ico logo%.png: $(OXYGEN)/%/apps/utilities-file-archiver.png cp $< $@ favicon.ico: $(ICOICONS) png2ico favicon.ico $(ICOICONS) patool-1.10/doc/icon/favicon.ico000066400000000000000000000070661263321134500165600ustar00rootroot00000000000000h& ¨Ž( @ÿÿÿW…¢ŸÆÞ0L\Òáéq§ÈLk}ž©®ÁÊÐu—«„»Ý¡¸Æ´Ó刮ÅJw”b—¸i‹ŸÎÒÐ}³Ó¦Îç~ž³Á×ä—ºÏkŸ¿^ªCpŒ¢²»}©ÄQu‹P~›ÛæëËÛä˜ÁÙ«Ìßp£Sz’]’³—Åà_‰£u¬ÍY‰§¶Ødˆžp”ªÆÛçFsS‚ž™©±q¤ÃNwMz—gœ¾½×çl¡Ão¡¿w™­VƒŸP{—\Ч¡Èßr¦ÅR€eˆœRvŒQœ]Œ©¨­þþÿ¾×æ…¼Ý^‰¢Mk}lŸ¿&&&&&?B&&&&&/*11*/5555::555547777<<77774J ED0))))% !%))))08>HA9 (283I$#+= @,3C F G6'."C;;;;;;;;;;;;;---ÿÿ( @€ÿÿÿN†«¢ÅÛ*_€‹Ÿªx°ÒÊÛåp‰™KsŠgšº¢´½Š¬À5n’‡½Ý[‚–Cyžz¢ºaŒ¦@h€•ºÒn¦È¯ÎáY‘´—§±r˜¯}ªÆ˜¨Š³Ì«ÃÑu‘£e€ŽWw‹.f‰Lz–ÃÕÞ¶Ùe„›?r”=m‹H¤Ž¦¶X‹«ž²™°¿q¡¾h Âb”²£¹Å]—ºgŒŸž®¸tªÎ¯Ím“ª^‡ ‚¤¹’¢­Pƒ¤[|‘u¦Åi—²=vš1jm›·NŒ®y¬ËI{œ„œ©d›¿9r–~²ÓU°i¦™«·‹©»§ÈÛb„—S‡§[¯’ª·m½„°ËZ€›vž,c…3h‰ Â׃»ÚY}–K„§f‚“Bw™E}¡cˆŸb˜¹h‰›¤±¬Ëߤ·Àv©Éq¨Êk£Å\“·5kŒ€­ÉRŠ­Ÿ±¼K¡v­Ïu™²_†œx¦ÂdŒ£iŸ¾e§|´Ö]”{¯Îr¤Ãu¢¾m—±g›¿;q”;u—„»Þ€¡¸l¡Â_˜½?t—@yˆ©½_’²0h‹3lf‡V²?x˜€¶Ö{±Ñq¦È€™¥o£Äb‰¢fžÀbš¼a•µ‚¸Ú[ƒ™\’´8n’“»Ô>wJ‚¥¨¹u«ÌLŠ­c…™n‹šn À^•¸hœ¼d—·L†©Pˆ«g„™oŸ½-e‡†»Ü=s•·ØB{Ÿ´Ô{³ÕX|”x®ÎsªËo§ÉS‹¯j¡Änž»0jŒ:s– ³¼ƒºÜ?w›By›~µ×D{žG|œz±Ó‚°Ìu¬ÏxªÉ`‡Ÿi‰VŒ°X³kŸ¿a™»_—ºi›ºd™¹h—³.c…=u—E¡I¡J‚§t¤Ãm£ÅVޱcŒ¦c™»+`+b„2k6o“=u™@w—AzD| w¯Ñz®ÏF~¢z­ÌG€£t©Ìr©ÌM…¨p¥ÆO‡ªm¤ÇQ‰®gŸÂeÀZ’µc•³7o’9r•‚¹Û€·Ù¶×=w›?vš?xœ|³Õ}³ÓByBzžy°Ó‚¯ËD|Ÿ|¯ÏD|¡D} ÖÍ({§>àЩص׹]♣é\ØØØ…‰ùÎ(ZéĽ ØØØ?!º à(ZçjH•lï ØØØØ?U˜'u ™åçjHÅ :ÚF ØØØØØ&̼ô>ø”;S夲ÓgÕN‚ÚFÙØØØØChü|óÜÿ%I¤²ˆìgÇz*Ý‚ÚFÙØØØØî©Vþ¹ù](®2MHˆì ÇE³OâÝ‚ÚFÙØØØØØ†Û–Ï«](Z"¥YÅì ÇEÒ„™âÝ‚>FÙ†ØØØØØ†™à™Zç^‡og ‘EêfŒ’ZâÝ‚>FÙ†ØØØØØœ™å¤²M[È‘ë.fã¢jZâÝ‚>¶Ù†ØØØØA夲ˆžP‘ë.f±äß HjçZâÿÜ>¶Ù†ØØØÓjHˆì0a³è±äm÷¡HjçZ(ÿÜ>¶Ù†ØØÅHˆì )J·³èe4mòÆgHjçZ(ÿÜ>¶Ù†Ø•Åg ‘k#r°°°sXÇgÓjçZ(ÿÜ>¶Ù†1gÈ‘_cnT~9¨ŽEÇgÓjçZ(]Ü>¶Ù€È‘ëÂËŒ+@š85 5êEÇ ÓjçZ(]Ü>FëE/eÀ­»“}}xb¿EÇ ÓjçZ(]ÜÚ.Êq,´mt$ð¬ËmeLûÇ Ó²çZ(]õ³í` Ÿmút$›îø\ZÆ…` ‡Hœ¨u"œšïaM¡/]ÈbÁÏÂduèùí¢ìF𘋠kGQ=󼿅”½ÊêU/ÍËcq‰5%™ ;±më øù§t.IglTç/¢äPV@W³±®è¡ï5¢Õ-|VW¿ì@ N‹I B@ÃA cç@k3ÈlL•²Ðä‹ÃC£RŸZÎÙ¹ÊWÞ†à’œ³D€ZrÞm`nfnÎAyÜID Æ’‘:nÞ4Q0.@—Z®òewÃ$O¸Òøâ.'Ô•ŽN»…éMã¨.Ô`Ä?H½ˆ„ 3V´|˜<Ýr-%À‹`Õõí v«¯ÛDN£ƒãÉ FMcà\\©åŠ\…Ú8’s h ‡Ù™#É­ulœ©%Éûb¯hÓ,_õJäi|_€Ñ¤JÇÐ!šL5G$¿¼/@#à|ÅŽW¢†É‡HªçCëÜï]É® B°l|Ê]Ñÿ‚×¥£µ=¦Ïªï Ù}–N bJRmX„‰j³…^»¾”\„”±¾Ï?­-øÏ¾÷õñP(¢U Áé{-Ûñ>,²[–Eôx ¢Ã”êR€×T×(å\tûá,ö¾˜;—¶ûª¤…tOÜâ”]ã³Ñ‚û°±‰i0 —j „~7¹¥û~Ôé…ü™êlö`Úîëât·»¬é(ävç\Woµ:èxmÖóÙÁ¹ã§üzÎWv_»€Õ…'·—\Ó:1VŽúü1kÿ윲ûjB ¸f¼öô½{A®çÿS$Bw¯¤IEND®B`‚patool-1.10/doc/install.txt000066400000000000000000000017431263321134500157120ustar00rootroot00000000000000Installation ============ First, install the required software. 1. Python >= 2.7 from http://www.python.org/ Now install the application. 1. Installation with pip If you have pip installed: ``pip install patool`` 2. Installation from source a) Installation as root Run ``sudo python setup.py install`` to install patool. b) Installation as a normal user Run ``python setup.py install --home $HOME``. Note that you have to adjust your PATH and PYTHONPATH environment variables, eg. by adding the commands ``export PYTHONPATH=$HOME/lib/python`` and ``export PATH=$PATH:$HOME/bin`` to your shell configuration file. For more information look at the `Modifying Python's search path`_ documentation. .. _Modifying Python's search path: http://docs.python.org/inst/search-path.html#SECTION000410000000000000000 After installation ------------------ Patool is now installed. Have fun! patool-1.10/doc/patool.1000066400000000000000000000143401263321134500150600ustar00rootroot00000000000000.\" -*- nroff -*- .\" Copyright (C) 2010-2015 Bastian Kleineidam .\" .\" This program is free software: you can redistribute it and/or modify .\" it under the terms of the GNU General Public License as published by .\" the Free Software Foundation, either version 3 of the License, or .\" (at your option) any later version. .\" .\" This program is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .TH PATOOL "1" "July 2013" "patool" .SH NAME patool - portable archive file manager .SH SYNOPSIS \fBpatool\fP [\fIglobal-options\fP] (\fBlist\fP|\fBtest\fP|\fBextract\fP|\fBcreate\fP|\fBdiff\fP|\fBsearch\fP|\fBrepack\fP|\fBrecompressfP|\fBformats\fP) [\fIcommand-options\fP] <\fIcommand-arguments\fP>... .SH DESCRIPTION Various archive formats can be created, extracted, tested, listed, searched, repacked, recompressed and compared by \fBpatool\fP. The advantage of patool is its simplicity in handling archive files without having to remember a myriad of programs and options. .PP The archive format is determined by the file(1) program and as a fallback by the archive file extension. .PP \fBpatool\fP supports 7z (.7z), ACE (.ace), ADF (.adf), ALZIP (.alz), APE (.ape), AR (.a), ARC (.arc), ARJ (.arj), BZIP2 (.bz2), CAB (.cab), COMPRESS (.Z), CPIO (.cpio), DEB (.deb), DMS (.dms), FLAC (.flac), GZIP (.gz), ISO (.iso), LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP (.lzo), RPM (.rpm), RAR (.rar), RZIP (.rz), SHN (.shn), TAR (.tar), XZ (.xz), ZIP (.zip, .jar), ZOO (.zoo) and ZPAQ (.zpaq) formats. It relies on helper applications to handle those archive formats (for example bzip2 for BZIP2 archives). .PP The archive formats TAR, ZIP, BZIP2 and GZIP are supported natively and do not require helper applications to be installed. .SH EXAMPLES \fBpatool extract archive.zip otherarchive.rar\fP \fBpatool --verbose test dist.tar.gz\fP \fBpatool list package.deb\fP \fPpatool --verbose create myfiles.zip file1.txt dir/\fP \fBpatool diff release1.0.tar.xz release2.0.zip\fP \fBpatool search "def urlopen" python-3.3.tar.gz\fP \fBpatool repack linux-2.6.33.tar.gz linux-2.6.33.tar.bz2\fP \fBpatool recompress images.zip\fP .SH GLOBAL OPTIONS .TP \fB\-v\fP, \fB\-\-verbose\fP Display more info about what patool does, and display the output of helper applications. Can be given multiple times to increase the output even more. .TP \fB\-\-non\-interactive\fP Try to prevent any interactive user input (ie. prompting for passwords or for overwriting duplicate files). Use this option with care since overwriting files or ignoring password prompts could lead to unintended consequences. .br This only works for programs that allow preventing user prompts. Currently those are \fBarj\fP, \fB7z\fP and \fBrar\fP. .SH COMMANDS The following rules apply to all commands: .IP "\(bu" 4 Existing files are never overwritten. .IP "\(bu" 4 The original archive will never be removed. .IP "\(bu" 4 Files outside the output directory will never be created. This relies on archive program options to prevent unpacking of files with an absolute path name (eg. \fB\-\-no\-absolute\-filenames\fP for \fBcpio(1)\fP). .PP The following commands are available. .SS extract \fBpatool\fP \fBextract\fP [\fB\-\-outdir\fP \fIdirectory\fP] <\fIarchive\fP>... .PP Extract files from given archives. The original archives will never be removed and are left as is. .TP \fB\-\-outdir\fP \fIdirectory\fP Extract to the given output directory. Default is to extract to the current working directory. .PP If the archive contains exactly one file or directory, the archive contents are extracted directly to the output directory. Else the files are extracted in a newly created subdirectory of the output directory. The new directory is named after the archive filename without the extension. .br This prevents cluttering the output directory with a lot of files from the extracted archive. .PP All extracted files are ensured that they are readable by the current user. .SS list \fBpatool\fP \fBlist\fP <\fIarchive\fP>... .PP List files in archives. .SS create \fBpatool\fP \fBcreate\fP <\fIarchive\fP> <\fIfile-or-directory\fP>... .PP Create an archive from given files. All of the given files to add to the archive must be readable by the current user. The format of the archive to create is determined by the archive file extension. If the archive program has options to maximize file compression, \fBpatool\fP uses those options. .SS test \fBpatool\fP \fBtest\fP <\fIarchive\fP>... .PP Test the given archives. If the helper application does not support testing, the archive contents are listed instead. .SS diff \fBpatool\fP \fBdiff\fP <\fIarchive1\fP> <\fIarchive2\fP> .PP Show differences between two archives with the \fBdiff(1)\fP program. The diff options used are \fB\-urN\fP. .SS search \fBpatool\fP \fBsearch\fP <\fIpattern\fP> <\fIarchive\fP> .PP Search in archive contents for given pattern using the \fBgrep(1)\fP program. The grep options used are \fB\-r\fP; additional options can be supplied with the \fBGREP_OPTIONS\fP environment variable. .SS repack \fBpatool\fP \fBrepack\fP <\fIarchive\fP> <\fIarchive_new\fP> .PP Repackage archive to a different format. The target archive format is determined by the file extension of \fIarchive_new\fP. .SS recompress \fBpatool\fP \fBrecompress\fP <\fIarchive\fP> .PP Recompress archive to a smaller file size. If the resulting file is not smaller, the archive is left unchanged. .SS formats \fBpatool\fP \fBformats\fP .PP Show all supported archive formats (ie. which helper applications are available). .SH HELP OPTION Specifying the help option displays help for patool itself, or a command. .br For example: \fBpatool \-\-help\fP - display help for patool \fBpatool extract \-\-help\fP - display help for the extract command .SH SHELL ALIASES When running under a Unix shell the following aliases can be defined to save some typing: \fBalias pl='patool list'\fP \fBalias px='patool extract'\fP \fBalias pc='patool create'\fP \fBalias pd='patool diff'\fP .SH AUTHOR Bastian Kleineidam .SH COPYRIGHT Copyright \(co 2010-2015 Bastian Kleineidam patool-1.10/doc/patool.txt000066400000000000000000000141561263321134500155440ustar00rootroot00000000000000PATOOL(1) General Commands Manual PATOOL(1) NAME patool - portable archive file manager SYNOPSIS patool [global-options] (list|test|extract|cre†ate|diff|search|repack|recompressfP|formats) [command-options] ... DESCRIPTION Various archive formats can be created, extracted, tested, listed, searched, repacked, recompressed and compared by patool. The advantage of patool is its simplicity in handling archive files without having to remember a myriad of programs and options. The archive format is determined by the file(1) program and as a fallback by the archive file extension. patool supports 7z (.7z), ACE (.ace), ADF (.adf), ALZIP (.alz), APE (.ape), AR (.a), ARC (.arc), ARJ (.arj), BZIP2 (.bz2), CAB (.cab), COMPRESS (.Z), CPIO (.cpio), DEB (.deb), DMS (.dms), FLAC (.flac), GZIP (.gz), ISO (.iso), LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP (.lzo), RPM (.rpm), RAR (.rar), RZIP (.rz), SHN (.shn), TAR (.tar), XZ (.xz), ZIP (.zip, .jar), ZOO (.zoo) and ZPAQ (.zpaq) formats. It relies on helper applications to handle those archive formats (for example bzip2 for BZIP2 archives). The archive formats TAR, ZIP, BZIP2 and GZIP are supported natively and do not require helper applications to be installed. EXAMPLES patool extract archive.zip otherarchive.rar patool --verbose test dist.tar.gz patool list package.deb patool --verbose create myfiles.zip file1.txt dir/ patool diff release1.0.tar.xz release2.0.zip patool search "def urlopen" python-3.3.tar.gz patool repack linux-2.6.33.tar.gz linux-2.6.33.tar.bz2 patool recompress images.zip GLOBAL OPTIONS -v, --verbose Display more info about what patool does, and display the output of helper applications. Can be given multiple times to increase the output even more. --non-interactive Try to prevent any interactive user input (ie. prompting for passwords or for overwriting duplicate files). Use this option with care since overwriting files or ignor†ing password prompts could lead to unintended conse†quences. This only works for programs that allow preventing user prompts. Currently those are arj, 7z and rar. COMMANDS The following rules apply to all commands: · Existing files are never overwritten. · The original archive will never be removed. · Files outside the output directory will never be created. This relies on archive program options to prevent unpacking of files with an absolute path name (eg. --no-abso†lute-filenames for cpio(1)). The following commands are available. extract patool extract [--outdir directory] ... Extract files from given archives. The original archives will never be removed and are left as is. --outdir directory Extract to the given output directory. Default is to extract to the current working directory. If the archive contains exactly one file or directory, the ar†chive contents are extracted directly to the output directory. Else the files are extracted in a newly created subdirectory of the output directory. The new directory is named after the ar†chive filename without the extension. This prevents cluttering the output directory with a lot of files from the extracted archive. All extracted files are ensured that they are readable by the current user. list patool list ... List files in archives. create patool create ... Create an archive from given files. All of the given files to add to the archive must be readable by the current user. The format of the archive to create is determined by the archive file extension. If the archive program has options to maximize file compression, patool uses those options. test patool test ... Test the given archives. If the helper application does not support testing, the archive contents are listed instead. diff patool diff Show differences between two archives with the diff(1) program. The diff options used are -urN. search patool search Search in archive contents for given pattern using the grep(1) program. The grep options used are -r; additional options can be supplied with the GREP_OPTIONS environment variable. repack patool repack Repackage archive to a different format. The target archive format is determined by the file extension of archive_new. recompress patool recompress Recompress archive to a smaller file size. If the resulting file is not smaller, the archive is left unchanged. formats patool formats Show all supported archive formats (ie. which helper applica†tions are available). HELP OPTION Specifying the help option displays help for patool itself, or a command. For example: patool --help - display help for patool patool extract --help - display help for the extract command SHELL ALIASES When running under a Unix shell the following aliases can be defined to save some typing: alias pl='patool list' alias px='patool extract' alias pc='patool create' alias pd='patool diff' AUTHOR Bastian Kleineidam COPYRIGHT Copyright © 2010-2015 Bastian Kleineidam patool July 2013 PATOOL(1) patool-1.10/patool000077500000000000000000000204561263321134500141640ustar00rootroot00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """ patool [global-options] {extract|list|create|diff|search|formats} [sub-command-options] """ from __future__ import print_function import sys import argparse import pydoc import patoolib from patoolib.util import log_error, log_internal_error, PatoolError from patoolib.configuration import App def run_extract(args): """Extract files from archive(s).""" res = 0 for archive in args.archive: try: patoolib.extract_archive(archive, verbosity=args.verbosity, interactive=args.interactive, outdir=args.outdir) except PatoolError as msg: log_error("error extracting %s: %s" % (archive, msg)) res += 1 return res def run_list(args): """List files in archive(s).""" res = 0 for archive in args.archive: try: # increase default verbosity since the listing output should be visible verbosity = args.verbosity + 1 patoolib.list_archive(archive, verbosity=verbosity, interactive=args.interactive) except PatoolError as msg: log_error("error listing %s: %s" % (archive, msg)) res += 1 return res def run_test(args): """Test files in archive(s).""" res = 0 for archive in args.archive: try: patoolib.test_archive(archive, verbosity=args.verbosity, interactive=args.interactive) except PatoolError as msg: log_error("error testing %s: %s" % (archive, msg)) res += 1 return res def run_create(args): """Create an archive from given files.""" res = 0 try: patoolib.create_archive(args.archive, args.filename, verbosity=args.verbosity, interactive=args.interactive) except PatoolError as msg: log_error("error creating %s: %s" % (args.archive, msg)) res = 1 return res def run_diff(args): """Show differences between two archives.""" try: res = patoolib.diff_archives(args.archive1, args.archive2, verbosity=args.verbosity, interactive=args.interactive) except PatoolError as msg: log_error("error showing differences between %s and %s: %s" % (args.archive1, args.archive2, msg)) res = 2 return res def run_search(args): """Search for pattern in given archive.""" try: res = patoolib.search_archive(args.pattern, args.archive, verbosity=args.verbosity, interactive=args.interactive) except PatoolError as msg: log_error("error searching %s: %s" % (args.archive, msg)) res = 2 return res def run_repack(args): """Repackage one archive in another format.""" res = 0 try: patoolib.repack_archive(args.archive_src, args.archive_dst, verbosity=args.verbosity, interactive=args.interactive) except PatoolError as msg: log_error("error repacking %s: %s" % (args.archive_src, msg)) res = 1 return res def run_recompress(args): """Recompress an archive to smaller size.""" res = 0 try: patoolib.recompress_archive(args.archive, verbosity=args.verbosity, interactive=args.interactive) except PatoolError as msg: log_error("error recompressing %s: %s" % (args.archive, msg)) res = 1 return res def run_formats (args): """List supported and available archive formats.""" patoolib.list_formats() return 0 class ArgumentParser(argparse.ArgumentParser): """Custom argument parser.""" def print_help(self, file=None): """Paginate help message on TTYs.""" msg = self.format_help() if file is None: file = sys.stdout if hasattr(file, "isatty") and file.isatty(): pydoc.pager(msg) else: print(msg, file=file) Examples = """\ EXAMPLES patool extract archive.zip otherarchive.rar patool --verbose test dist.tar.gz patool list package.deb patool --verbose create myfiles.zip file1.txt dir/ patool diff release1.0.tar.xz release2.0.zip patool search "def urlopen" python-3.3.tar.gz patool repack linux-2.6.33.tar.gz linux-2.6.33.tar.bz2 patool recompress images.zip """ Version = """\ VERSION %s """ % App def create_argparser(): """Construct and return an argument parser.""" epilog = Examples + "\n" + Version parser = ArgumentParser(description="An archive file manager.", epilog=epilog, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('--verbose', '-v', action='count', default=0, dest='verbosity', help="verbose operation; can be given multiple times") parser.add_argument('--non-interactive', dest='interactive', default=True, action='store_false', help="don't query for user input (ie. passwords or when overwriting duplicate files); use with care since overwriting files or ignoring passwords could be unintended") subparsers = parser.add_subparsers(help='the archive command; type "patool COMMAND -h" for command-specific help', dest='command') # extract parser_extract = subparsers.add_parser('extract', help='extract one or more archives') parser_extract.add_argument('--outdir', help="output directory to extract to") parser_extract.add_argument('archive', nargs='+', help="an archive file") # list parser_list = subparsers.add_parser('list', help='list members or one or more archives') parser_list.add_argument('archive', nargs='+', help="an archive file") # create parser_create = subparsers.add_parser('create', help='create an archive') parser_create.add_argument('archive', help="the archive file; the file extension determines the archive program") parser_create.add_argument('filename', nargs='+', help="a file or directory to add to the archive; note that some archive programs do not support directories") # test parser_test = subparsers.add_parser('test', help='test an archive') parser_test.add_argument('archive', nargs='+', help='an archive file') # repack parser_repack = subparsers.add_parser('repack', help='repack an archive to a different format') parser_repack.add_argument('archive_src', help='source archive file') parser_repack.add_argument('archive_dst', help='target archive file') # recompress parser_recompress = subparsers.add_parser('recompress', help='recompress an archive to smaller size') parser_recompress.add_argument('archive', help='an archive file') # diff parser_diff = subparsers.add_parser('diff', help='show differences between two archives') parser_diff.add_argument('archive1', help='the first archive file') parser_diff.add_argument('archive2', help='the second archive file') # search parser_search = subparsers.add_parser('search', help="search contents of archive members") parser_search.add_argument('pattern', help='the grep(1) compatible search pattern') parser_search.add_argument('archive', help='the archive file') # formats subparsers.add_parser('formats', help="show supported archive formats") # optional bash completion try: import argcomplete argcomplete.autocomplete(parser) except ImportError: pass return parser def main(): """Parse options and execute commands.""" try: argparser = create_argparser() args = argparser.parse_args() if args.command is None: # Python 3.3.1 under linux allows an empty command somehow argparser.error("too few arguments") # run subcommand function res = globals()["run_%s" % args.command](args) except KeyboardInterrupt: log_error("aborted") res = 1 except Exception: log_internal_error() res = 2 return res if __name__ == '__main__': sys.exit(main()) patool-1.10/patool.bash-completion000066400000000000000000000004711263321134500172370ustar00rootroot00000000000000# patool completion have patool && _patool() { local cur prev COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} if type _argcomplete &> /dev/null; then _argcomplete "$@" else _filedir fi return 0 } complete -F _patool $filenames patool patool-1.10/patool.egg-info/000077500000000000000000000000001263321134500157215ustar00rootroot00000000000000patool-1.10/patool.egg-info/PKG-INFO000066400000000000000000000037371263321134500170300ustar00rootroot00000000000000Metadata-Version: 1.1 Name: patool Version: 1.10 Summary: portable archive file manager Home-page: http://wummel.github.io/patool/ Author: Bastian Kleineidam Author-email: bastian.kleineidam@web.de License: GPL Description: Various archive formats can be created, extracted, tested, listed, searched, compared and repacked by patool. The advantage of patool is its simplicity in handling archive files without having to remember a myriad of programs and options. The archive format is determined by the file(1) program and as a fallback by the archive file extension. patool supports 7z (.7z), ACE (.ace), ADF (.adf), ALZIP (.alz), APE (.ape), AR (.a), ARC (.arc), ARJ (.arj), BZIP2 (.bz2), CAB (.cab), COMPRESS (.Z), CPIO (.cpio), DEB (.deb), DMS (.dms), FLAC (.flac), GZIP (.gz), ISO (.iso), LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP (.lzo), RPM (.rpm), RAR (.rar), RZIP (.rz), SHN (.shn), TAR (.tar), XZ (.xz), ZIP (.zip, .jar), ZOO (.zoo) and ZPAQ (.zpaq) formats. It relies on helper applications to handle those archive formats (for example bzip2 for BZIP2 archives). The archive formats TAR, ZIP, BZIP2 and GZIP are supported natively and do not require helper applications to be installed. Keywords: archiver,archive,compression,commandline,manager Platform: UNKNOWN Classifier: Environment :: Console Classifier: Topic :: System :: Archiving Classifier: Development Status :: 5 - Production/Stable Classifier: License :: OSI Approved :: GNU General Public License (GPL) Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Operating System :: OS Independent patool-1.10/patool.egg-info/SOURCES.txt000066400000000000000000000101621263321134500176050ustar00rootroot00000000000000COPYING MANIFEST.in Makefile patool patool.bash-completion setup.cfg setup.py doc/README.txt doc/changelog.txt doc/development.txt doc/install.txt doc/patool.1 doc/patool.txt doc/icon/Makefile doc/icon/favicon.ico doc/icon/logo16x16.png doc/icon/logo32x32.png patool.egg-info/PKG-INFO patool.egg-info/SOURCES.txt patool.egg-info/dependency_links.txt patool.egg-info/top_level.txt patoolib/__init__.py patoolib/configuration.py patoolib/util.py patoolib/programs/__init__.py patoolib/programs/ar.py patoolib/programs/arc.py patoolib/programs/archmage.py patoolib/programs/arj.py patoolib/programs/bsdcpio.py patoolib/programs/bsdtar.py patoolib/programs/bzip2.py patoolib/programs/cabextract.py patoolib/programs/chmlib.py patoolib/programs/clzip.py patoolib/programs/compress.py patoolib/programs/cpio.py patoolib/programs/dpkg.py patoolib/programs/flac.py patoolib/programs/genisoimage.py patoolib/programs/gzip.py patoolib/programs/isoinfo.py patoolib/programs/lbzip2.py patoolib/programs/lcab.py patoolib/programs/lha.py patoolib/programs/lhasa.py patoolib/programs/lrzip.py patoolib/programs/lzip.py patoolib/programs/lzma.py patoolib/programs/lzop.py patoolib/programs/mac.py patoolib/programs/nomarch.py patoolib/programs/p7azip.py patoolib/programs/p7zip.py patoolib/programs/pbzip2.py patoolib/programs/pdlzip.py patoolib/programs/pigz.py patoolib/programs/plzip.py patoolib/programs/py_bz2.py patoolib/programs/py_echo.py patoolib/programs/py_gzip.py patoolib/programs/py_lzma.py patoolib/programs/py_tarfile.py patoolib/programs/py_zipfile.py patoolib/programs/rar.py patoolib/programs/rpm.py patoolib/programs/rpm2cpio.py patoolib/programs/rzip.py patoolib/programs/shar.py patoolib/programs/shorten.py patoolib/programs/star.py patoolib/programs/tar.py patoolib/programs/unace.py patoolib/programs/unadf.py patoolib/programs/unalz.py patoolib/programs/uncompress.py patoolib/programs/unrar.py patoolib/programs/unshar.py patoolib/programs/unzip.py patoolib/programs/xdms.py patoolib/programs/xz.py patoolib/programs/zip.py patoolib/programs/zoo.py patoolib/programs/zopfli.py patoolib/programs/zpaq.py scripts/build.bat scripts/dist.bat scripts/test.bat tests/__init__.py tests/test_config.py tests/test_create.py tests/test_diff.py tests/test_extract.py tests/test_formats.py tests/test_list.py tests/test_mime.py tests/test_recompress.py tests/test_repack.py tests/test_search.py tests/test_test.py tests/test_util.py tests/archives/__init__.py tests/archives/test_7z.py tests/archives/test_7za.py tests/archives/test_ar.py tests/archives/test_arc.py tests/archives/test_archmage.py tests/archives/test_arj.py tests/archives/test_bsdcpio.py tests/archives/test_bsdtar.py tests/archives/test_bzip2.py tests/archives/test_cabextract.py tests/archives/test_chmlib.py tests/archives/test_clzip.py tests/archives/test_compress.py tests/archives/test_cpio.py tests/archives/test_dpkg.py tests/archives/test_flac.py tests/archives/test_genisoimage.py tests/archives/test_gzip.py tests/archives/test_isoinfo.py tests/archives/test_lbzip2.py tests/archives/test_lcab.py tests/archives/test_lha.py tests/archives/test_lhasa.py tests/archives/test_lrzip.py tests/archives/test_lzip.py tests/archives/test_lzma.py tests/archives/test_lzop.py tests/archives/test_mac.py tests/archives/test_nomarch.py tests/archives/test_pbzip2.py tests/archives/test_pdlzip.py tests/archives/test_pigz.py tests/archives/test_plzip.py tests/archives/test_pybz2.py tests/archives/test_pyecho.py tests/archives/test_pygzip.py tests/archives/test_pylzma.py tests/archives/test_pytarfile.py tests/archives/test_pyzipfile.py tests/archives/test_rar.py tests/archives/test_rpm.py tests/archives/test_rpm2cpio.py tests/archives/test_rzip.py tests/archives/test_shar.py tests/archives/test_shorten.py tests/archives/test_star.py tests/archives/test_tar.py tests/archives/test_unace.py tests/archives/test_unadf.py tests/archives/test_unalz.py tests/archives/test_uncompressreal.py tests/archives/test_unrar.py tests/archives/test_unshar.py tests/archives/test_unzip.py tests/archives/test_xdms.py tests/archives/test_xz.py tests/archives/test_zip.py tests/archives/test_zoo.py tests/archives/test_zopfli.py tests/archives/test_zpaq.pypatool-1.10/patool.egg-info/dependency_links.txt000066400000000000000000000000011263321134500217670ustar00rootroot00000000000000 patool-1.10/patool.egg-info/top_level.txt000066400000000000000000000000111263321134500204430ustar00rootroot00000000000000patoolib patool-1.10/patoolib/000077500000000000000000000000001263321134500145425ustar00rootroot00000000000000patool-1.10/patoolib/__init__.py000066400000000000000000000656721263321134500166730ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from __future__ import print_function import sys if not hasattr(sys, "version_info") or sys.version_info < (2, 7, 0, "final", 0): raise SystemExit("This program requires Python 2.7 or later.") import os import shutil import stat import importlib # PEP 396 from .configuration import Version as __version__ __all__ = ['list_formats', 'list_archive', 'extract_archive', 'test_archive', 'create_archive', 'diff_archives', 'search_archive', 'repack_archive', 'recompress_archive'] # Supported archive commands ArchiveCommands = ('list', 'extract', 'test', 'create') # Supported archive formats ArchiveFormats = ( '7z', 'ace', 'adf', 'alzip', 'ape', 'ar', 'arc', 'arj', 'bzip2', 'cab', 'chm', 'compress', 'cpio', 'deb', 'dms', 'flac', 'gzip', 'iso', 'lrzip', 'lzh', 'lzip', 'lzma', 'lzop', 'rar', 'rpm', 'rzip', 'shar', 'shn', 'tar', 'vhd', 'xz', 'zip', 'zoo', 'zpaq') # Supported compressions (used with tar for example) # Note that all compressions must also be archive formats ArchiveCompressions = ('bzip2', 'compress', 'gzip', 'lzip', 'lzma', 'xz') # Map MIME types to archive format ArchiveMimetypes = { 'application/gzip': 'gzip', 'application/java-archive': 'zip', 'application/rar': 'rar', 'application/vnd.ms-cab-compressed': 'cab', 'application/x-7z-compressed': '7z', 'application/x-ace': 'ace', 'application/x-adf': 'adf', 'application/x-alzip': 'alzip', 'application/x-archive': 'ar', 'application/x-arc': 'arc', 'application/x-arj': 'arj', 'application/x-bzip2': 'bzip2', 'application/x-cab': 'cab', 'application/x-chm': 'chm', 'application/x-compress': 'compress', 'application/x-cpio': 'cpio', 'application/x-debian-package': 'deb', 'application/x-dms': 'dms', 'application/x-gzip': 'gzip', 'application/x-iso9660-image': 'iso', 'application/x-lzop': 'lzop', 'application/x-lzma': 'lzma', 'application/x-lzip': 'lzip', 'application/x-lha': 'lzh', 'application/x-lrzip': 'lrzip', 'application/x-lzh': 'lzh', 'application/x-rar': 'rar', 'application/x-redhat-package-manager': 'rpm', 'application/x-rpm': 'rpm', 'application/x-rzip': 'rzip', 'application/x-shar': 'shar', 'application/x-tar': 'tar', 'application/x-vhd': 'vhd', 'application/x-xz': 'xz', 'application/x-zip-compressed': 'zip', 'application/x-zoo': 'zoo', 'application/zip': 'zip', 'application/zpaq': 'zpaq', 'audio/x-ape': 'ape', 'audio/x-shn': 'shn', 'audio/flac': 'flac', } try: # use Python 3 lzma module if available import lzma py_lzma = ('py_lzma',) except ImportError: py_lzma = () # List of programs supporting the given archive format and command. # If command is None, the program supports all commands (list, extract, ...) # Programs starting with "py_" are Python modules. ArchivePrograms = { 'ace': { 'extract': ('unace',), 'test': ('unace',), 'list': ('unace',), }, 'adf': { 'extract': ('unadf',), 'test': ('unadf',), 'list': ('unadf',), }, 'alzip': { 'extract': ('unalz',), 'test': ('unalz',), 'list': ('unalz',), }, 'ape': { 'create': ('mac',), 'extract': ('mac',), 'list': ('py_echo',), 'test': ('mac',), }, 'ar': { None: ('ar',), }, 'arc': { None: ('arc',), 'extract': ('nomarch',), 'test': ('nomarch',), 'list': ('nomarch',), }, 'bzip2': { None: ('7z', '7za'), 'extract': ('pbzip2', 'lbzip2', 'bzip2', 'py_bz2'), 'test': ('pbzip2', 'lbzip2', 'bzip2'), 'create': ('pbzip2', 'lbzip2', 'bzip2', 'py_bz2'), 'list': ('py_echo'), }, 'cab': { 'extract': ('cabextract', '7z'), 'create': ('lcab',), 'list': ('cabextract', '7z'), 'test': ('cabextract', '7z'), }, 'chm': { 'extract': ('archmage', 'extract_chmLib'), 'test': ('archmage',), }, 'flac': { 'extract': ('flac',), 'test': ('flac',), 'create': ('flac',), 'list': ('py_echo',), }, 'tar': { None: ('tar', 'star', 'bsdtar', 'py_tarfile'), }, 'zip': { None: ('7z', '7za', 'py_zipfile'), 'extract': ('unzip',), 'list': ('unzip',), 'test': ('zip', 'unzip',), 'create': ('zip',), }, 'gzip': { None: ('7z', '7za', 'pigz', 'gzip'), 'extract': ('py_gzip',), 'create': ('zopfli', 'py_gzip'), }, 'iso': { 'extract': ('7z',), 'list': ('7z', 'isoinfo'), 'test': ('7z',), 'create': ('genisoimage',), }, 'lzh': { None: ('lha',), 'extract': ('lhasa',), }, 'lzip': { 'extract': ('plzip', 'lzip', 'clzip', 'pdlzip'), 'list': ('py_echo',), 'test': ('plzip', 'lzip', 'clzip', 'pdlzip'), 'create': ('plzip', 'lzip', 'clzip', 'pdlzip'), }, 'lrzip': { 'extract': ('lrzip',), 'list': ('py_echo',), 'test': ('lrzip',), 'create': ('lrzip',), }, 'compress': { 'extract': ('gzip', '7z', '7za', 'uncompress.real'), 'list': ('7z', '7za', 'py_echo',), 'test': ('gzip', '7z', '7za'), 'create': ('compress',), }, '7z': { None: ('7z', '7za'), }, 'rar': { None: ('rar',), 'extract': ('unrar', '7z'), 'list': ('unrar', '7z'), 'test': ('unrar', '7z'), }, 'arj': { None: ('arj',), 'extract': ('7z',), 'list': ('7z',), 'test': ('7z',), }, 'cpio': { 'extract': ('cpio', 'bsdcpio', '7z'), 'list': ('cpio', 'bsdcpio', '7z'), 'test': ('cpio', 'bsdcpio', '7z',), 'create': ('cpio', 'bsdcpio'), }, 'rpm': { 'extract': ('rpm2cpio', '7z'), 'list': ('rpm', '7z', '7za'), 'test': ('rpm', '7z'), }, 'deb': { 'extract': ('dpkg-deb', '7z'), 'list': ('dpkg-deb', '7z'), 'test': ('dpkg-deb', '7z'), }, 'dms': { 'extract': ('xdms',), 'list': ('xdms',), 'test': ('xdms',), }, 'lzop': { None: ('lzop',), }, 'lzma': { 'extract': ('7z', 'lzma', 'xz') + py_lzma, 'list': ('7z', 'py_echo'), 'test': ('7z', 'lzma', 'xz'), 'create': ('lzma', 'xz') + py_lzma, }, 'rzip': { 'extract': ('rzip',), 'list': ('py_echo',), 'create': ('rzip',), }, 'shar': { 'create': ('shar',), 'extract': ('unshar',), }, 'shn': { 'extract': ('shorten',), 'list': ('py_echo',), 'create': ('shorten',), }, 'vhd': { 'extract': ('7z',), 'list': ('7z',), 'test': ('7z',), }, 'xz': { None: ('xz', '7z'), 'extract': py_lzma, 'create': py_lzma, }, 'zoo': { None: ('zoo',), }, 'zpaq': { None: ('zpaq',), }, } # List those programs that have different python module names because of # Python module naming restrictions. ProgramModules = { '7z': 'p7zip', '7za': 'p7azip', 'uncompress.real': 'uncompress', 'dpkg-deb': 'dpkg', 'extract_chmlib': 'chmlib', } from . import util def get_archive_format (filename): """Detect filename archive format and optional compression.""" mime, compression = util.guess_mime(filename) if not (mime or compression): raise util.PatoolError("unknown archive format for file `%s'" % filename) if mime in ArchiveMimetypes: format = ArchiveMimetypes[mime] else: raise util.PatoolError("unknown archive format for file `%s' (mime-type is `%s')" % (filename, mime)) if format == compression: # file cannot be in same format compressed compression = None return format, compression def check_archive_format (format, compression): """Make sure format and compression is known.""" if format not in ArchiveFormats: raise util.PatoolError("unknown archive format `%s'" % format) if compression is not None and compression not in ArchiveCompressions: raise util.PatoolError("unkonwn archive compression `%s'" % compression) def find_archive_program (format, command, program=None): """Find suitable archive program for given format and mode.""" commands = ArchivePrograms[format] programs = [] if program is not None: # try a specific program first programs.append(program) # first try the universal programs with key None for key in (None, command): if key in commands: programs.extend(commands[key]) if not programs: raise util.PatoolError("%s archive format `%s' is not supported" % (command, format)) # return the first existing program for program in programs: if program.startswith('py_'): # it's a Python module and therefore always supported return program exe = util.find_program(program) if exe: if program == '7z' and format == 'rar' and not util.p7zip_supports_rar(): continue return exe # no programs found raise util.PatoolError("could not find an executable program to %s format %s; candidates are (%s)," % (command, format, ",".join(programs))) def program_supports_compression (program, compression): """Decide if the given program supports the compression natively. @return: True iff the program supports the given compression format natively, else False. """ if program in ('tar', 'star', 'bsdtar', 'py_tarfile'): return compression in ('gzip', 'bzip2') + py_lzma return False def list_formats (): """Print information about available archive formats to stdout.""" for format in ArchiveFormats: print(format, "files:") for command in ArchiveCommands: programs = ArchivePrograms[format] if command not in programs and None not in programs: print(" %8s: - (not supported)" % command) continue try: program = find_archive_program(format, command) print(" %8s: %s" % (command, program), end=' ') if format == 'tar': encs = [x for x in ArchiveCompressions if util.find_program(x)] if encs: print("(supported compressions: %s)" % ", ".join(encs), end=' ') elif format == '7z': if util.p7zip_supports_rar(): print("(rar archives supported)", end=' ') else: print("(rar archives not supported)", end=' ') print() except util.PatoolError: handlers = programs.get(None, programs.get(command)) print(" %8s: - (no program found; install %s)" % (command, util.strlist_with_or(handlers))) def check_program_compression(archive, command, program, compression): """Check if a program supports the given compression.""" program = os.path.basename(program) if compression: # check if compression is supported if not program_supports_compression(program, compression): if command == 'create': comp_command = command else: comp_command = 'extract' comp_prog = find_archive_program(compression, comp_command) if not comp_prog: msg = "cannot %s archive `%s': compression `%s' not supported" raise util.PatoolError(msg % (command, archive, compression)) def move_outdir_orphan (outdir): """Move a single file or directory inside outdir a level up. Never overwrite files. Return (True, outfile) if successful, (False, reason) if not.""" entries = os.listdir(outdir) if len(entries) == 1: src = os.path.join(outdir, entries[0]) dst = os.path.join(os.path.dirname(outdir), entries[0]) if os.path.exists(dst) or os.path.islink(dst): return (False, "local file exists") shutil.move(src, dst) os.rmdir(outdir) return (True, entries[0]) return (False, "multiple files in root") def run_archive_cmdlist (archive_cmdlist, verbosity=0): """Run archive command.""" # archive_cmdlist is a command list with optional keyword arguments if isinstance(archive_cmdlist, tuple): cmdlist, runkwargs = archive_cmdlist else: cmdlist, runkwargs = archive_cmdlist, {} return util.run_checked(cmdlist, verbosity=verbosity, **runkwargs) def make_file_readable (filename): """Make file user readable if it is not a link.""" if not os.path.islink(filename): util.set_mode(filename, stat.S_IRUSR) def make_dir_readable (filename): """Make directory user readable and executable.""" util.set_mode(filename, stat.S_IRUSR|stat.S_IXUSR) def make_user_readable (directory): """Make all files in given directory user readable. Also recurse into subdirectories.""" for root, dirs, files in os.walk(directory, onerror=util.log_error): for filename in files: make_file_readable(os.path.join(root, filename)) for dirname in dirs: make_dir_readable(os.path.join(root, dirname)) def cleanup_outdir (outdir, archive): """Cleanup outdir after extraction and return target file name and result string.""" make_user_readable(outdir) # move single directory or file in outdir (success, msg) = move_outdir_orphan(outdir) if success: # msg is a single directory or filename return msg, "`%s'" % msg # outdir remains unchanged # rename it to something more user-friendly (basically the archive # name without extension) outdir2 = util.get_single_outfile("", archive) os.rename(outdir, outdir2) return outdir2, "`%s' (%s)" % (outdir2, msg) def _extract_archive(archive, verbosity=0, interactive=True, outdir=None, program=None, format=None, compression=None): """Extract an archive. @return: output directory if command is 'extract', else None """ if format is None: format, compression = get_archive_format(archive) check_archive_format(format, compression) program = find_archive_program(format, 'extract', program=program) check_program_compression(archive, 'extract', program, compression) get_archive_cmdlist = get_archive_cmdlist_func(program, 'extract', format) if outdir is None: outdir = util.tmpdir(dir=".") do_cleanup_outdir = True else: do_cleanup_outdir = False try: cmdlist = get_archive_cmdlist(archive, compression, program, verbosity, interactive, outdir) if cmdlist: # an empty command list means the get_archive_cmdlist() function # already handled the command (eg. when it's a builtin Python # function) run_archive_cmdlist(cmdlist, verbosity=verbosity) if do_cleanup_outdir: target, msg = cleanup_outdir(outdir, archive) else: target, msg = outdir, "`%s'" % outdir if verbosity >= 0: util.log_info("... %s extracted to %s." % (archive, msg)) return target finally: # try to remove an empty temporary output directory if do_cleanup_outdir: try: os.rmdir(outdir) except OSError: pass def _create_archive(archive, filenames, verbosity=0, interactive=True, program=None, format=None, compression=None): """Create an archive.""" if format is None: format, compression = get_archive_format(archive) check_archive_format(format, compression) program = find_archive_program(format, 'create', program=program) check_program_compression(archive, 'create', program, compression) get_archive_cmdlist = get_archive_cmdlist_func(program, 'create', format) origarchive = None if os.path.basename(program) == 'arc' and \ ".arc" in archive and not archive.endswith(".arc"): # the arc program mangles the archive name if it contains ".arc" origarchive = archive archive = util.tmpfile(dir=os.path.dirname(archive), suffix=".arc") cmdlist = get_archive_cmdlist(archive, compression, program, verbosity, interactive, filenames) if cmdlist: # an empty command list means the get_archive_cmdlist() function # already handled the command (eg. when it's a builtin Python # function) run_archive_cmdlist(cmdlist, verbosity=verbosity) if origarchive: shutil.move(archive, origarchive) def _handle_archive(archive, command, verbosity=0, interactive=True, program=None, format=None, compression=None): """Test and list archives.""" if format is None: format, compression = get_archive_format(archive) check_archive_format(format, compression) if command not in ('list', 'test'): raise util.PatoolError("invalid archive command `%s'" % command) program = find_archive_program(format, command, program=program) check_program_compression(archive, command, program, compression) get_archive_cmdlist = get_archive_cmdlist_func(program, command, format) # prepare keyword arguments for command list cmdlist = get_archive_cmdlist(archive, compression, program, verbosity, interactive) if cmdlist: # an empty command list means the get_archive_cmdlist() function # already handled the command (eg. when it's a builtin Python # function) run_archive_cmdlist(cmdlist, verbosity=verbosity) def get_archive_cmdlist_func (program, command, format): """Get the Python function that executes the given program.""" # get python module for given archive program key = util.stripext(os.path.basename(program).lower()) modulename = ".programs." + ProgramModules.get(key, key) # import the module try: module = importlib.import_module(modulename, __name__) except ImportError as msg: raise util.PatoolError(msg) # get archive handler function (eg. patoolib.programs.star.extract_tar) try: return getattr(module, '%s_%s' % (command, format)) except AttributeError as msg: raise util.PatoolError(msg) def rmtree_log_error (func, path, exc): """Error function for shutil.rmtree(). Raises a PatoolError.""" msg = "Error in %s(%s): %s" % (func.__name__, path, str(exc[1])) util.log_error(msg) def _diff_archives (archive1, archive2, verbosity=0, interactive=True): """Show differences between two archives. @return 0 if archives are the same, else 1 @raises: PatoolError on errors """ if util.is_same_file(archive1, archive2): return 0 diff = util.find_program("diff") if not diff: msg = "The diff(1) program is required for showing archive differences, please install it." raise util.PatoolError(msg) tmpdir1 = util.tmpdir() try: path1 = _extract_archive(archive1, outdir=tmpdir1, verbosity=-1) tmpdir2 = util.tmpdir() try: path2 = _extract_archive(archive2, outdir=tmpdir2, verbosity=-1) return util.run_checked([diff, "-urN", path1, path2], verbosity=1, ret_ok=(0, 1)) finally: shutil.rmtree(tmpdir2, onerror=rmtree_log_error) finally: shutil.rmtree(tmpdir1, onerror=rmtree_log_error) def _search_archive(pattern, archive, verbosity=0, interactive=True): """Search for given pattern in an archive.""" grep = util.find_program("grep") if not grep: msg = "The grep(1) program is required for searching archive contents, please install it." raise util.PatoolError(msg) tmpdir = util.tmpdir() try: path = _extract_archive(archive, outdir=tmpdir, verbosity=-1) return util.run_checked([grep, "-r", "-e", pattern, "."], ret_ok=(0, 1), verbosity=1, cwd=path) finally: shutil.rmtree(tmpdir, onerror=rmtree_log_error) def _repack_archive (archive1, archive2, verbosity=0, interactive=True): """Repackage an archive to a different format.""" format1, compression1 = get_archive_format(archive1) format2, compression2 = get_archive_format(archive2) if format1 == format2 and compression1 == compression2: # same format and compression allows to copy the file util.link_or_copy(archive1, archive2, verbosity=verbosity) return tmpdir = util.tmpdir() try: kwargs = dict(verbosity=verbosity, outdir=tmpdir) same_format = (format1 == format2 and compression1 and compression2) if same_format: # only decompress since the format is the same kwargs['format'] = compression1 path = _extract_archive(archive1, **kwargs) archive = os.path.abspath(archive2) files = tuple(os.listdir(path)) olddir = os.getcwd() os.chdir(path) try: kwargs = dict(verbosity=verbosity, interactive=interactive) if same_format: # only compress since the format is the same kwargs['format'] = compression2 _create_archive(archive, files, **kwargs) finally: os.chdir(olddir) finally: shutil.rmtree(tmpdir, onerror=rmtree_log_error) def _recompress_archive(archive, verbosity=0, interactive=True): """Try to recompress an archive to smaller size.""" format, compression = get_archive_format(archive) if compression: # only recompress the compression itself (eg. for .tar.xz) format = compression tmpdir = util.tmpdir() tmpdir2 = util.tmpdir() base, ext = os.path.splitext(os.path.basename(archive)) archive2 = util.get_single_outfile(tmpdir2, base, extension=ext) try: # extract kwargs = dict(verbosity=verbosity, format=format, outdir=tmpdir) path = _extract_archive(archive, **kwargs) # compress to new file olddir = os.getcwd() os.chdir(path) try: kwargs = dict(verbosity=verbosity, interactive=interactive, format=format) files = tuple(os.listdir(path)) _create_archive(archive2, files, **kwargs) finally: os.chdir(olddir) # check file sizes and replace if new file is smaller filesize = util.get_filesize(archive) filesize2 = util.get_filesize(archive2) if filesize2 < filesize: # replace file os.remove(archive) shutil.move(archive2, archive) diffsize = filesize - filesize2 return "... recompressed file is now %s smaller." % util.strsize(diffsize) finally: shutil.rmtree(tmpdir, onerror=rmtree_log_error) shutil.rmtree(tmpdir2, onerror=rmtree_log_error) return "... recompressed file is not smaller, leaving archive as is." # the patool library API def extract_archive(archive, verbosity=0, outdir=None, program=None, interactive=True): """Extract given archive.""" util.check_existing_filename(archive) if verbosity >= 0: util.log_info("Extracting %s ..." % archive) return _extract_archive(archive, verbosity=verbosity, interactive=interactive, outdir=outdir, program=program) def list_archive(archive, verbosity=1, program=None, interactive=True): """List given archive.""" # Set default verbosity to 1 since the listing output should be visible. util.check_existing_filename(archive) if verbosity >= 0: util.log_info("Listing %s ..." % archive) return _handle_archive(archive, 'list', verbosity=verbosity, interactive=interactive, program=program) def test_archive(archive, verbosity=0, program=None, interactive=True): """Test given archive.""" util.check_existing_filename(archive) if verbosity >= 0: util.log_info("Testing %s ..." % archive) res = _handle_archive(archive, 'test', verbosity=verbosity, interactive=interactive, program=program) if verbosity >= 0: util.log_info("... tested ok.") return res def create_archive(archive, filenames, verbosity=0, program=None, interactive=True): """Create given archive with given files.""" util.check_new_filename(archive) util.check_archive_filelist(filenames) if verbosity >= 0: util.log_info("Creating %s ..." % archive) res = _create_archive(archive, filenames, verbosity=verbosity, interactive=interactive, program=program) if verbosity >= 0: util.log_info("... %s created." % archive) return res def diff_archives(archive1, archive2, verbosity=0, interactive=True): """Print differences between two archives.""" util.check_existing_filename(archive1) util.check_existing_filename(archive2) if verbosity >= 0: util.log_info("Comparing %s with %s ..." % (archive1, archive2)) res = _diff_archives(archive1, archive2, verbosity=verbosity, interactive=interactive) if res == 0 and verbosity >= 0: util.log_info("... no differences found.") def search_archive(pattern, archive, verbosity=0, interactive=True): """Search pattern in archive members.""" if not pattern: raise util.PatoolError("empty search pattern") util.check_existing_filename(archive) if verbosity >= 0: util.log_info("Searching %r in %s ..." % (pattern, archive)) res = _search_archive(pattern, archive, verbosity=verbosity, interactive=interactive) if res == 1 and verbosity >= 0: util.log_info("... %r not found" % pattern) return res def repack_archive (archive, archive_new, verbosity=0, interactive=True): """Repack archive to different file and/or format.""" util.check_existing_filename(archive) util.check_new_filename(archive_new) if verbosity >= 0: util.log_info("Repacking %s to %s ..." % (archive, archive_new)) res = _repack_archive(archive, archive_new, verbosity=verbosity, interactive=interactive) if verbosity >= 0: util.log_info("... repacking successful.") return res def recompress_archive(archive, verbosity=0, interactive=True): """Recompress an archive to hopefully smaller size.""" util.check_existing_filename(archive) util.check_writable_filename(archive) if verbosity >= 0: util.log_info("Recompressing %s ..." % (archive,)) res = _recompress_archive(archive, verbosity=verbosity, interactive=interactive) if res and verbosity >= 0: util.log_info(res) return 0 patool-1.10/patoolib/configuration.py000066400000000000000000000007651263321134500177730ustar00rootroot00000000000000# Copyright (C) 2013-2015 Bastian Kleineidam """ Define basic configuration data like version or application name. """ import _patool_configdata as configdata Version = configdata.version ReleaseDate = configdata.release_date AppName = configdata.name App = AppName+u" "+Version Author = configdata.author Maintainer = configdata.maintainer Copyright = u"Copyright (C) 2004-2015 " + Author Url = configdata.url SupportUrl = u"https://github.com/wummel/patool/issues/" Email = configdata.author_email patool-1.10/patoolib/programs/000077500000000000000000000000001263321134500163745ustar00rootroot00000000000000patool-1.10/patoolib/programs/__init__.py000066400000000000000000000035621263321134500205130ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .. import util def extract_singlefile_standard (archive, compression, cmd, verbosity, interactive, outdir): """Standard routine to extract a singlefile archive (like gzip).""" cmdlist = [util.shell_quote(cmd)] if verbosity > 1: cmdlist.append('-v') outfile = util.get_single_outfile(outdir, archive) cmdlist.extend(['-c', '-d', '--', util.shell_quote(archive), '>', util.shell_quote(outfile)]) return (cmdlist, {'shell': True}) def test_singlefile_standard (archive, compression, cmd, verbosity, interactive): """Standard routine to test a singlefile archive (like gzip).""" cmdlist = [cmd] if verbosity > 1: cmdlist.append('-v') cmdlist.extend(['-t', '--', archive]) return cmdlist def create_singlefile_standard (archive, compression, cmd, verbosity, interactive, filenames): """Standard routine to create a singlefile archive (like gzip).""" cmdlist = [util.shell_quote(cmd)] if verbosity > 1: cmdlist.append('-v') cmdlist.extend(['-c', '--']) cmdlist.extend([util.shell_quote(x) for x in filenames]) cmdlist.extend(['>', util.shell_quote(archive)]) return (cmdlist, {'shell': True}) patool-1.10/patoolib/programs/ar.py000066400000000000000000000026751263321134500173620ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the ar program.""" import os def extract_ar (archive, compression, cmd, verbosity, interactive, outdir): """Extract a AR archive.""" opts = 'x' if verbosity > 1: opts += 'v' cmdlist = [cmd, opts, os.path.abspath(archive)] return (cmdlist, {'cwd': outdir}) def list_ar (archive, compression, cmd, verbosity, interactive): """List a AR archive.""" opts = 't' if verbosity > 1: opts += 'v' return [cmd, opts, archive] test_ar = list_ar def create_ar (archive, compression, cmd, verbosity, interactive, filenames): """Create a AR archive.""" opts = 'rc' if verbosity > 1: opts += 'v' cmdlist = [cmd, opts, archive] cmdlist.extend(filenames) return cmdlist patool-1.10/patoolib/programs/arc.py000066400000000000000000000031721263321134500175160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the arc program.""" import os def extract_arc (archive, compression, cmd, verbosity, interactive, outdir): """Extract a ARC archive.""" # Since extracted files will be placed in the current directory, # the cwd argument has to be the output directory. cmdlist = [cmd, 'x', os.path.abspath(archive)] return (cmdlist, {'cwd': outdir}) def list_arc (archive, compression, cmd, verbosity, interactive): """List a ARC archive.""" cmdlist = [cmd] if verbosity > 1: cmdlist.append('v') else: cmdlist.append('l') cmdlist.append(archive) return cmdlist def test_arc (archive, compression, cmd, verbosity, interactive): """Test a ARC archive.""" return [cmd, 't', archive] def create_arc (archive, compression, cmd, verbosity, interactive, filenames): """Create a ARC archive.""" cmdlist = [cmd, 'a', archive] cmdlist.extend(filenames) return cmdlist patool-1.10/patoolib/programs/archmage.py000066400000000000000000000024051263321134500205160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the archmage program.""" import os from .. import util def extract_chm (archive, compression, cmd, verbosity, interactive, outdir): """Extract a CHM archive.""" # archmage can only extract in non-existing directories # so a nice dirname is created name = util.get_single_outfile("", archive) outfile = os.path.join(outdir, name) return [cmd, '-x', os.path.abspath(archive), outfile] def test_chm (archive, compression, cmd, verbosity, interactive): """Test a CHM archive.""" return [cmd, '-d', os.path.abspath(archive)] patool-1.10/patoolib/programs/arj.py000066400000000000000000000034361263321134500175300ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the arj program.""" def extract_arj (archive, compression, cmd, verbosity, interactive, outdir): """Extract an ARJ archive.""" cmdlist = [cmd, 'x', '-r'] if not interactive: cmdlist.append('-y') cmdlist.extend([archive, outdir]) return cmdlist def list_arj (archive, compression, cmd, verbosity, interactive): """List an ARJ archive.""" cmdlist = [cmd] if verbosity > 1: cmdlist.append('v') else: cmdlist.append('l') if not interactive: cmdlist.append('-y') cmdlist.extend(['-r', archive]) return cmdlist def test_arj (archive, compression, cmd, verbosity, interactive): """Test an ARJ archive.""" cmdlist = [cmd, 't', '-r'] if not interactive: cmdlist.append('-y') cmdlist.append(archive) return cmdlist def create_arj (archive, compression, cmd, verbosity, interactive, filenames): """Create an ARJ archive.""" cmdlist = [cmd, 'a', '-r'] if not interactive: cmdlist.append('-y') cmdlist.append(archive) cmdlist.extend(filenames) return cmdlist patool-1.10/patoolib/programs/bsdcpio.py000066400000000000000000000014571263321134500204000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the bsdcpio program.""" from .cpio import extract_cpio, list_cpio, test_cpio, create_cpio patool-1.10/patoolib/programs/bsdtar.py000066400000000000000000000014521263321134500202270ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the BSD tar program.""" from .tar import extract_tar, list_tar, test_tar, create_tar patool-1.10/patoolib/programs/bzip2.py000066400000000000000000000024541263321134500200010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the bzip2 program.""" from .. import util from . import extract_singlefile_standard, test_singlefile_standard extract_bzip2 = extract_singlefile_standard test_bzip2 = test_singlefile_standard def create_bzip2 (archive, compression, cmd, verbosity, interactive, filenames): """Create a BZIP2 archive.""" cmdlist = [util.shell_quote(cmd)] if verbosity > 1: cmdlist.append('-v') cmdlist.extend(['-c', '-z', '-9', '--']) cmdlist.extend([util.shell_quote(x) for x in filenames]) cmdlist.extend(['>', util.shell_quote(archive)]) return (cmdlist, {'shell': True}) patool-1.10/patoolib/programs/cabextract.py000066400000000000000000000025051263321134500210700ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the cabextract program.""" def extract_cab (archive, compression, cmd, verbosity, interactive, outdir): """Extract a CAB archive.""" cmdlist = [cmd, '-d', outdir] if verbosity > 0: cmdlist.append('-v') cmdlist.append(archive) return cmdlist def list_cab (archive, compression, cmd, verbosity, interactive): """List a CAB archive.""" cmdlist = [cmd, '-l'] if verbosity > 0: cmdlist.append('-v') cmdlist.append(archive) return cmdlist def test_cab (archive, compression, cmd, verbosity, interactive): """Test a CAB archive.""" return [cmd, '-t', archive] patool-1.10/patoolib/programs/chmlib.py000066400000000000000000000016361263321134500202120ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the chmlib programs.""" import os def extract_chm (archive, compression, cmd, verbosity, interactive, outdir): """Extract a CHM archive.""" return [cmd, os.path.abspath(archive), outdir] patool-1.10/patoolib/programs/clzip.py000066400000000000000000000024431263321134500200720ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2011-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the clzip program.""" from . import extract_singlefile_standard, test_singlefile_standard from .. import util extract_lzip = extract_singlefile_standard test_lzip = test_singlefile_standard def create_lzip(archive, compression, cmd, verbosity, interactive, filenames): """Create an LZIP archive.""" cmdlist = [util.shell_quote(cmd)] if verbosity > 1: cmdlist.append('-v') cmdlist.extend(['-c', '-9', '--']) cmdlist.extend([util.shell_quote(x) for x in filenames]) cmdlist.extend(['>', util.shell_quote(archive)]) return (cmdlist, {'shell': True}) patool-1.10/patoolib/programs/compress.py000066400000000000000000000022241263321134500206010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the uncompress.real program.""" from .. import util def create_compress (archive, compression, cmd, verbosity, interactive, filenames): """Create a compressed archive.""" cmdlist = [util.shell_quote(cmd)] if verbosity > 1: cmdlist.append('-v') cmdlist.append('-c') cmdlist.extend([util.shell_quote(x) for x in filenames]) cmdlist.extend(['>', util.shell_quote(archive)]) return (cmdlist, {'shell': True}) patool-1.10/patoolib/programs/cpio.py000066400000000000000000000041561263321134500177060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the cpio program.""" import os import sys from .. import util def extract_cpio (archive, compression, cmd, verbosity, interactive, outdir): """Extract a CPIO archive.""" cmdlist = [util.shell_quote(cmd), '--extract', '--make-directories', '--preserve-modification-time'] if sys.platform.startswith('linux') and not cmd.endswith('bsdcpio'): cmdlist.extend(['--no-absolute-filenames', '--force-local', '--nonmatching', r'"*\.\.*"']) if verbosity > 1: cmdlist.append('-v') cmdlist.extend(['<', util.shell_quote(os.path.abspath(archive))]) return (cmdlist, {'cwd': outdir, 'shell': True}) def list_cpio (archive, compression, cmd, verbosity, interactive): """List a CPIO archive.""" cmdlist = [cmd, '-i', '-t'] if verbosity > 1: cmdlist.append('-v') cmdlist.extend(['-F', archive]) return cmdlist test_cpio = list_cpio def create_cpio(archive, compression, cmd, verbosity, interactive, filenames): """Create a CPIO archive.""" cmdlist = [util.shell_quote(cmd), '--create'] if verbosity > 1: cmdlist.append('-v') if len(filenames) != 0: findcmd = ['find'] findcmd.extend([util.shell_quote(x) for x in filenames]) findcmd.extend(['-print0', '|']) cmdlist[0:0] = findcmd cmdlist.append('-0') cmdlist.extend([">", util.shell_quote(archive)]) return (cmdlist, {'shell': True}) patool-1.10/patoolib/programs/dpkg.py000066400000000000000000000023011263321134500176670ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the dpkg-deb program.""" def extract_deb (archive, compression, cmd, verbosity, interactive, outdir): """Extract a DEB archive.""" cmdlist = [cmd] if verbosity > 1: cmdlist.append('--vextract') else: cmdlist.append('--extract') cmdlist.extend(['--', archive, outdir]) return cmdlist def list_deb (archive, compression, cmd, verbosity, interactive): """List a DEB archive.""" return [cmd, '--contents', '--', archive] test_deb = list_deb patool-1.10/patoolib/programs/flac.py000066400000000000000000000026041263321134500176550ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the flac program.""" from .. import util def extract_flac (archive, compression, cmd, verbosity, interactive, outdir): """Decompress a FLAC archive to a WAV file.""" outfile = util.get_single_outfile(outdir, archive, extension=".wav") cmdlist = [cmd, '--decode', archive, '--output-name', outfile] return cmdlist def create_flac (archive, compression, cmd, verbosity, interactive, filenames): """Compress a WAV file to a FLAC archive.""" cmdlist = [cmd, filenames[0], '--best', '--output-name', archive] return cmdlist def test_flac (archive, compression, cmd, verbosity, interactive): """Test a FLAC file.""" return [cmd, '--test', archive] patool-1.10/patoolib/programs/genisoimage.py000066400000000000000000000021731263321134500212400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2013-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the genisoimage program.""" def create_iso (archive, compression, cmd, verbosity, interactive, filenames): """Create an ISO archive.""" # Use Joliet (-J) and Rock-Ridge (-r) format. cmdlist = [cmd, '-r', '-J'] if verbosity > 1: cmdlist.append('-v') if verbosity > 2: cmdlist.append('-v') cmdlist.extend(['-o', archive]) cmdlist.extend(filenames) return cmdlist patool-1.10/patoolib/programs/gzip.py000066400000000000000000000030541263321134500177210ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the gzip program.""" from . import extract_singlefile_standard, test_singlefile_standard from .. import util extract_gzip = extract_compress = extract_singlefile_standard test_gzip = test_compress = test_singlefile_standard def create_gzip(archive, compression, cmd, verbosity, interactive, filenames): """Create a GZIP archive.""" cmdlist = [util.shell_quote(cmd)] if verbosity > 1: cmdlist.append('-v') cmdlist.extend(['-c', '-9', '--']) cmdlist.extend([util.shell_quote(x) for x in filenames]) cmdlist.extend(['>', util.shell_quote(archive)]) return (cmdlist, {'shell': True}) def list_gzip (archive, compression, cmd, verbosity, interactive): """List a GZIP archive.""" cmdlist = [cmd] if verbosity > 0: cmdlist.append('-v') cmdlist.extend(['-l', '--', archive]) return cmdlist patool-1.10/patoolib/programs/isoinfo.py000066400000000000000000000016701263321134500204200ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2013-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the isoinfo program.""" def list_iso (archive, compression, cmd, verbosity, interactive): """List an ISO archive.""" # Use Joliet (-J) and Rock-Ridge (-R) options. return [cmd, '-l', '-R', '-J', '-i', archive] patool-1.10/patoolib/programs/lbzip2.py000066400000000000000000000015101263321134500201450ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the pbzip2 program.""" # bzip2 and lbzip2 are compatible from .bzip2 import extract_bzip2, test_bzip2, create_bzip2 patool-1.10/patoolib/programs/lcab.py000066400000000000000000000017051263321134500176520ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the lcab program.""" def create_cab (archive, compression, cmd, verbosity, interactive, filenames): """Create a CAB archive.""" cmdlist = [cmd, '-r'] cmdlist.extend(filenames) cmdlist.append(archive) return cmdlist patool-1.10/patoolib/programs/lha.py000066400000000000000000000032041263321134500175110ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the lha program.""" def extract_lzh (archive, compression, cmd, verbosity, interactive, outdir): """Extract a LZH archive.""" opts = 'x' if verbosity > 1: opts += 'v' opts += "w=%s" % outdir return [cmd, opts, archive] def list_lzh (archive, compression, cmd, verbosity, interactive): """List a LZH archive.""" cmdlist = [cmd] if verbosity > 1: cmdlist.append('v') else: cmdlist.append('l') cmdlist.append(archive) return cmdlist def test_lzh (archive, compression, cmd, verbosity, interactive): """Test a LZH archive.""" opts = 't' if verbosity > 1: opts += 'v' return [cmd, opts, archive] def create_lzh (archive, compression, cmd, verbosity, interactive, filenames): """Create a LZH archive.""" opts = 'a' if verbosity > 1: opts += 'v' cmdlist = [cmd, opts, archive] cmdlist.extend(filenames) return cmdlist patool-1.10/patoolib/programs/lhasa.py000066400000000000000000000014101263321134500200320ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the lhasa program.""" from .lha import extract_lzh patool-1.10/patoolib/programs/lrzip.py000066400000000000000000000030611263321134500201060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the lrzip program.""" import os from .. import util def extract_lrzip (archive, compression, cmd, verbosity, interactive, outdir): """Extract a LRZIP archive.""" cmdlist = [cmd, '-d'] if verbosity > 1: cmdlist.append('-v') outfile = util.get_single_outfile(outdir, archive) cmdlist.extend(["-o", outfile, os.path.abspath(archive)]) return cmdlist def test_lrzip (archive, compression, cmd, verbosity, interactive): """Test a LRZIP archive.""" cmdlist = [cmd, '-t'] if verbosity > 1: cmdlist.append('-v') cmdlist.append(archive) return cmdlist def create_lrzip (archive, compression, cmd, verbosity, interactive, filenames): """Create a LRZIP archive.""" cmdlist = [cmd, '-o', archive] if verbosity > 1: cmdlist.append('-v') cmdlist.extend(filenames) return cmdlist patool-1.10/patoolib/programs/lzip.py000066400000000000000000000017171263321134500177320ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the lzip program.""" from . import extract_singlefile_standard, \ test_singlefile_standard, create_singlefile_standard extract_lzip = extract_singlefile_standard test_lzip = test_singlefile_standard create_lzip = create_singlefile_standard patool-1.10/patoolib/programs/lzma.py000066400000000000000000000017171263321134500177170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the lzma program.""" from . import extract_singlefile_standard, \ test_singlefile_standard, create_singlefile_standard extract_lzma = extract_singlefile_standard test_lzma = test_singlefile_standard create_lzma = create_singlefile_standard patool-1.10/patoolib/programs/lzop.py000066400000000000000000000030761263321134500177400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the lzop program.""" from . import extract_singlefile_standard extract_lzop = extract_singlefile_standard def list_lzop (archive, compression, cmd, verbosity, interactive): """List a LZOP archive.""" cmdlist = [cmd, '--list'] if verbosity > 1: cmdlist.append('--verbose') cmdlist.extend(['--', archive]) return cmdlist def test_lzop (archive, compression, cmd, verbosity, interactive): """Test a LZOP archive.""" cmdlist = [cmd, '--test'] if verbosity > 1: cmdlist.append('--verbose') cmdlist.extend(['--', archive]) return cmdlist def create_lzop (archive, compression, cmd, verbosity, interactive, filenames): """Create a LZOP archive.""" cmdlist = [cmd] if verbosity > 1: cmdlist.append('-v') cmdlist.extend(['-o', archive, '--']) cmdlist.extend(filenames) return cmdlist patool-1.10/patoolib/programs/mac.py000066400000000000000000000025731263321134500175150ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the MAC.exe program.""" from .. import util def extract_ape (archive, compression, cmd, verbosity, interactive, outdir): """Decompress an APE archive to a WAV file.""" outfile = util.get_single_outfile(outdir, archive, extension=".wav") return [cmd, archive, outfile, '-d'] def create_ape (archive, compression, cmd, verbosity, interactive, filenames): """Compress a WAV file to an APE archive.""" cmdlist = [cmd] cmdlist.extend(filenames) cmdlist.append(archive) cmdlist.append('-c2000') return cmdlist def test_ape (archive, compression, cmd, verbosity, interactive): """Test an APE archive.""" return [cmd, archive, '-v'] patool-1.10/patoolib/programs/nomarch.py000066400000000000000000000026331263321134500204010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the nomarch program.""" import os def extract_arc (archive, compression, cmd, verbosity, interactive, outdir): """Extract an ARC archive.""" # Since extracted files will be placed in the current directory, # the cwd argument has to be the output directory. cmdlist = [cmd, os.path.abspath(archive)] return (cmdlist, {'cwd': outdir}) def list_arc (archive, compression, cmd, verbosity, interactive): """List an ARC archive.""" cmdlist = [cmd, '-l'] if verbosity > 1: cmdlist.append('-v') cmdlist.append(archive) return cmdlist def test_arc (archive, compression, cmd, verbosity, interactive): """Test an ARC archive.""" return [cmd, '-t', archive] patool-1.10/patoolib/programs/p7azip.py000066400000000000000000000024361263321134500201650ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the 7za program. From the man page: 7za is a stand-alone executable. 7za handles less archive formats than 7z, but does not need any others. """ from .p7zip import \ extract_bzip2, \ extract_gzip, \ extract_zip, \ extract_compress, \ extract_rar, \ extract_cab, \ extract_7z, \ list_bzip2, \ list_gzip, \ list_zip, \ list_compress, \ list_rar, \ list_cab, \ list_rpm, \ list_7z, \ test_bzip2, \ test_gzip, \ test_zip, \ test_compress, \ test_rar, \ test_cab, \ test_7z, \ create_7z, \ create_zip, \ create_gzip, \ create_bzip2 patool-1.10/patoolib/programs/p7zip.py000066400000000000000000000100171263321134500200160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the 7z program.""" def extract_7z(archive, compression, cmd, verbosity, interactive, outdir): """Extract a 7z archive.""" cmdlist = [cmd, 'x'] if not interactive: cmdlist.append('-y') cmdlist.extend(['-o%s' % outdir, '--', archive]) return cmdlist def extract_7z_singlefile(archive, compression, cmd, verbosity, interactive, outdir): """Extract a singlefile archive (eg. gzip or bzip2) with '7z e'. This makes sure a single file and no subdirectories are created, which would cause errors with patool repack.""" cmdlist = [cmd, 'e'] if not interactive: cmdlist.append('-y') cmdlist.extend(['-o%s' % outdir, '--', archive]) return cmdlist extract_bzip2 = \ extract_gzip = \ extract_compress = \ extract_xz = \ extract_lzma = \ extract_7z_singlefile extract_zip = \ extract_rar = \ extract_cab = \ extract_arj = \ extract_cpio = \ extract_rpm = \ extract_deb = \ extract_iso = \ extract_vhd = \ extract_7z def list_7z (archive, compression, cmd, verbosity, interactive): """List a 7z archive.""" cmdlist = [cmd, 'l'] if not interactive: cmdlist.append('-y') cmdlist.extend(['--', archive]) return cmdlist list_bzip2 = \ list_gzip = \ list_zip = \ list_compress = \ list_rar = \ list_cab = \ list_arj = \ list_cpio = \ list_rpm = \ list_deb = \ list_iso = \ list_xz = \ list_lzma = \ list_vhd = \ list_7z def test_7z (archive, compression, cmd, verbosity, interactive): """Test a 7z archive.""" cmdlist = [cmd, 't'] if not interactive: cmdlist.append('-y') cmdlist.extend(['--', archive]) return cmdlist test_bzip2 = \ test_gzip = \ test_zip = \ test_compress = \ test_rar = \ test_cab = \ test_arj = \ test_cpio = \ test_rpm = \ test_deb = \ test_iso = \ test_xz = \ test_lzma = \ test_vhd = \ test_7z def create_7z(archive, compression, cmd, verbosity, interactive, filenames): """Create a 7z archive.""" cmdlist = [cmd, 'a'] if not interactive: cmdlist.append('-y') cmdlist.extend(['-t7z', '-mx=9', '--', archive]) cmdlist.extend(filenames) return cmdlist def create_zip(archive, compression, cmd, verbosity, interactive, filenames): """Create a ZIP archive.""" cmdlist = [cmd, 'a'] if not interactive: cmdlist.append('-y') cmdlist.extend(['-tzip', '-mx=9', '--', archive]) cmdlist.extend(filenames) return cmdlist def create_xz(archive, compression, cmd, verbosity, interactive, filenames): """Create an XZ archive.""" cmdlist = [cmd, 'a'] if not interactive: cmdlist.append('-y') cmdlist.extend(['-txz', '-mx=9', '--', archive]) cmdlist.extend(filenames) return cmdlist def create_gzip(archive, compression, cmd, verbosity, interactive, filenames): """Create a GZIP archive.""" cmdlist = [cmd, 'a'] if not interactive: cmdlist.append('-y') cmdlist.extend(['-tgzip', '-mx=9', '--', archive]) cmdlist.extend(filenames) return cmdlist def create_bzip2(archive, compression, cmd, verbosity, interactive, filenames): """Create a BZIP2 archive.""" cmdlist = [cmd, 'a'] if not interactive: cmdlist.append('-y') cmdlist.extend(['-tbzip2', '-mx=9', '--', archive]) cmdlist.extend(filenames) return cmdlist patool-1.10/patoolib/programs/pbzip2.py000066400000000000000000000015151263321134500201560ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the pbzip2 program.""" # bzip2 and pbzip2 are compatible from .bzip2 import extract_bzip2, test_bzip2, create_bzip2 patool-1.10/patoolib/programs/pdlzip.py000066400000000000000000000017201263321134500202500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2011-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the clzip program.""" from . import extract_singlefile_standard, \ test_singlefile_standard, create_singlefile_standard extract_lzip = extract_singlefile_standard test_lzip = test_singlefile_standard create_lzip = create_singlefile_standard patool-1.10/patoolib/programs/pigz.py000066400000000000000000000014531263321134500177220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the pigz program.""" from .gzip import extract_gzip, test_gzip, create_gzip, list_gzip patool-1.10/patoolib/programs/plzip.py000066400000000000000000000017131263321134500201060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the plzip program.""" from . import extract_singlefile_standard, \ test_singlefile_standard, create_singlefile_standard extract_lzip = extract_singlefile_standard test_lzip = test_singlefile_standard create_lzip = create_singlefile_standard patool-1.10/patoolib/programs/py_bz2.py000066400000000000000000000044131263321134500201550ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the bz2 Python module.""" from .. import util try: # try external bz2file module with multi-stream support import bz2file as bz2 except ImportError: import bz2 # read in 1MB chunks READ_SIZE_BYTES = 1024*1024 def extract_bzip2 (archive, compression, cmd, verbosity, interactive, outdir): """Extract a BZIP2 archive with the bz2 Python module.""" targetname = util.get_single_outfile(outdir, archive) try: with bz2.BZ2File(archive) as bz2file: with open(targetname, 'wb') as targetfile: data = bz2file.read(READ_SIZE_BYTES) while data: targetfile.write(data) data = bz2file.read(READ_SIZE_BYTES) except Exception as err: msg = "error extracting %s to %s: %s" % (archive, targetname, err) raise util.PatoolError(msg) return None def create_bzip2 (archive, compression, cmd, verbosity, interactive, filenames): """Create a BZIP2 archive with the bz2 Python module.""" if len(filenames) > 1: raise util.PatoolError('multi-file compression not supported in Python bz2') try: with bz2.BZ2File(archive, 'wb') as bz2file: filename = filenames[0] with open(filename, 'rb') as srcfile: data = srcfile.read(READ_SIZE_BYTES) while data: bz2file.write(data) data = srcfile.read(READ_SIZE_BYTES) except Exception as err: msg = "error creating %s: %s" % (archive, err) raise util.PatoolError(msg) return None patool-1.10/patoolib/programs/py_echo.py000066400000000000000000000027161263321134500204020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands echoing data, implemented by the Python print statement.""" from __future__ import print_function from .. import util def list_bzip2 (archive, compression, cmd, verbosity, interactive): """List a BZIP2 archive.""" return stripext(cmd, archive, verbosity) list_compress = \ list_lzma = \ list_xz = \ list_lzip = \ list_lrzip = \ list_rzip = \ list_bzip2 def list_ape (archive, compression, cmd, verbosity, interactive): """List an APE archive.""" return stripext(cmd, archive, verbosity, extension=".wav") list_shn = \ list_flac = \ list_ape def stripext (cmd, archive, verbosity, extension=""): """Print the name without suffix.""" if verbosity >= 0: print(util.stripext(archive)+extension) return None patool-1.10/patoolib/programs/py_gzip.py000066400000000000000000000043671263321134500204410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the gzip Python module.""" from __future__ import absolute_import # now gzip refers to the Python standard module, not the local one import gzip from .. import util READ_SIZE_BYTES = 1024*1024 def extract_gzip (archive, compression, cmd, verbosity, interactive, outdir): """Extract a GZIP archive with the gzip Python module.""" targetname = util.get_single_outfile(outdir, archive) try: with gzip.GzipFile(archive) as gzipfile: with open(targetname, 'wb') as targetfile: data = gzipfile.read(READ_SIZE_BYTES) while data: targetfile.write(data) data = gzipfile.read(READ_SIZE_BYTES) except Exception as err: msg = "error extracting %s to %s: %s" % (archive, targetname, err) raise util.PatoolError(msg) return None def create_gzip (archive, compression, cmd, verbosity, interactive, filenames): """Create a GZIP archive with the gzip Python module.""" if len(filenames) > 1: raise util.PatoolError('multi-file compression not supported in Python gzip') try: with gzip.GzipFile(archive, 'wb') as gzipfile: filename = filenames[0] with open(filename, 'rb') as srcfile: data = srcfile.read(READ_SIZE_BYTES) while data: gzipfile.write(data) data = srcfile.read(READ_SIZE_BYTES) except Exception as err: msg = "error creating %s: %s" % (archive, err) raise util.PatoolError(msg) return None patool-1.10/patoolib/programs/py_lzma.py000066400000000000000000000060641263321134500204270ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the lzma Python module.""" from .. import util import lzma READ_SIZE_BYTES = 1024*1024 def _extract(archive, compression, cmd, format, verbosity, outdir): """Extract an LZMA or XZ archive with the lzma Python module.""" targetname = util.get_single_outfile(outdir, archive) try: with lzma.LZMAFile(archive, format=format) as lzmafile: with open(targetname, 'wb') as targetfile: data = lzmafile.read(READ_SIZE_BYTES) while data: targetfile.write(data) data = lzmafile.read(READ_SIZE_BYTES) except Exception as err: msg = "error extracting %s to %s: %s" % (archive, targetname, err) raise util.PatoolError(msg) return None def extract_lzma(archive, compression, cmd, verbosity, interactive, outdir): """Extract an LZMA archive with the lzma Python module.""" return _extract(archive, compression, cmd, lzma.FORMAT_ALONE, verbosity, outdir) def extract_xz(archive, compression, cmd, verbosity, interactive, outdir): """Extract an XZ archive with the lzma Python module.""" return _extract(archive, compression, cmd, lzma.FORMAT_XZ, verbosity, outdir) def _create(archive, compression, cmd, format, verbosity, filenames): """Create an LZMA or XZ archive with the lzma Python module.""" if len(filenames) > 1: raise util.PatoolError('multi-file compression not supported in Python lzma') try: with lzma.LZMAFile(archive, mode='wb', format=format, preset=9) as lzmafile: filename = filenames[0] with open(filename, 'rb') as srcfile: data = srcfile.read(READ_SIZE_BYTES) while data: lzmafile.write(data) data = srcfile.read(READ_SIZE_BYTES) except Exception as err: msg = "error creating %s: %s" % (archive, err) raise util.PatoolError(msg) return None def create_lzma(archive, compression, cmd, verbosity, interactive, filenames): """Create an LZMA archive with the lzma Python module.""" return _create(archive, compression, cmd, lzma.FORMAT_ALONE, verbosity, filenames) def create_xz(archive, compression, cmd, verbosity, interactive, filenames): """Create an XZ archive with the lzma Python module.""" return _create(archive, compression, cmd, lzma.FORMAT_XZ, verbosity, filenames) patool-1.10/patoolib/programs/py_tarfile.py000066400000000000000000000046751263321134500211200ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the tarfile Python module.""" from .. import util, py_lzma import tarfile READ_SIZE_BYTES = 1024*1024 def list_tar (archive, compression, cmd, verbosity, interactive): """List a TAR archive with the tarfile Python module.""" try: with tarfile.open(archive) as tfile: tfile.list(verbose=verbosity>1) except Exception as err: msg = "error listing %s: %s" % (archive, err) raise util.PatoolError(msg) return None test_tar = list_tar def extract_tar (archive, compression, cmd, verbosity, interactive, outdir): """Extract a TAR archive with the tarfile Python module.""" try: with tarfile.open(archive) as tfile: tfile.extractall(path=outdir) except Exception as err: msg = "error extracting %s: %s" % (archive, err) raise util.PatoolError(msg) return None def create_tar (archive, compression, cmd, verbosity, interactive, filenames): """Create a TAR archive with the tarfile Python module.""" mode = get_tar_mode(compression) try: with tarfile.open(archive, mode) as tfile: for filename in filenames: tfile.add(filename) except Exception as err: msg = "error creating %s: %s" % (archive, err) raise util.PatoolError(msg) return None def get_tar_mode (compression): """Determine tarfile open mode according to the given compression.""" if compression == 'gzip': return 'w:gz' if compression == 'bzip2': return 'w:bz2' if compression == 'lzma' and py_lzma: return 'w:xz' if compression: msg = 'pytarfile does not support %s for tar compression' raise util.PatoolError(msg % compression) # no compression return 'w' patool-1.10/patoolib/programs/py_zipfile.py000066400000000000000000000047701263321134500211300ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the zipfile Python module.""" from __future__ import print_function from .. import util import zipfile import os READ_SIZE_BYTES = 1024*1024 def list_zip(archive, compression, cmd, verbosity, interactive): """List member of a ZIP archive with the zipfile Python module.""" try: with zipfile.ZipFile(archive, "r") as zfile: for name in zfile.namelist(): if verbosity >= 0: print(name) except Exception as err: msg = "error listing %s: %s" % (archive, err) raise util.PatoolError(msg) return None test_zip = list_zip def extract_zip(archive, compression, cmd, verbosity, interactive, outdir): """Extract a ZIP archive with the zipfile Python module.""" try: with zipfile.ZipFile(archive) as zfile: zfile.extractall(outdir) except Exception as err: msg = "error extracting %s: %s" % (archive, err) raise util.PatoolError(msg) return None def create_zip(archive, compression, cmd, verbosity, interactive, filenames): """Create a ZIP archive with the zipfile Python module.""" try: with zipfile.ZipFile(archive, 'w') as zfile: for filename in filenames: if os.path.isdir(filename): write_directory(zfile, filename) else: zfile.write(filename) except Exception as err: msg = "error creating %s: %s" % (archive, err) raise util.PatoolError(msg) return None def write_directory (zfile, directory): """Write recursively all directories and filenames to zipfile instance.""" for dirpath, dirnames, filenames in os.walk(directory): zfile.write(dirpath) for filename in filenames: zfile.write(os.path.join(dirpath, filename)) patool-1.10/patoolib/programs/rar.py000066400000000000000000000035511263321134500175360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the rar program.""" import os def extract_rar (archive, compression, cmd, verbosity, interactive, outdir): """Extract a RAR archive.""" cmdlist = [cmd, 'x'] if not interactive: cmdlist.extend(['-p-', '-y']) cmdlist.extend(['--', os.path.abspath(archive)]) return (cmdlist, {'cwd': outdir}) def list_rar (archive, compression, cmd, verbosity, interactive): """List a RAR archive.""" cmdlist = [cmd] if verbosity > 1: cmdlist.append('v') else: cmdlist.append('l') if not interactive: cmdlist.extend(['-p-', '-y']) cmdlist.extend(['--', archive]) return cmdlist def test_rar (archive, compression, cmd, verbosity, interactive): """Test a RAR archive.""" cmdlist = [cmd, 't'] if not interactive: cmdlist.extend(['-p-', '-y']) cmdlist.extend(['--', archive]) return cmdlist def create_rar (archive, compression, cmd, verbosity, interactive, filenames): """Create a RAR archive.""" cmdlist = [cmd, 'a'] if not interactive: cmdlist.append('-y') cmdlist.extend(['-r', '-m5', '--', archive]) cmdlist.extend(filenames) return cmdlist patool-1.10/patoolib/programs/rpm.py000066400000000000000000000023101263321134500175400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the rpm program.""" def list_rpm (archive, compression, cmd, verbosity, interactive): """List a RPM archive.""" cmdlist = [cmd, '-q', '-l'] if verbosity > 1: cmdlist.append('-v') cmdlist.extend(['-p', '--', archive]) return cmdlist def test_rpm (archive, compression, cmd, verbosity, interactive): """Test a RPM archive.""" cmdlist = [cmd, 'V'] if verbosity > 1: cmdlist.append('-v') cmdlist.extend(['-p', '--', archive]) return cmdlist patool-1.10/patoolib/programs/rpm2cpio.py000066400000000000000000000026701263321134500205060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the rpm2cpio program.""" import os from .. import util def extract_rpm (archive, compression, cmd, verbosity, interactive, outdir): """Extract a RPM archive.""" # also check cpio cpio = util.find_program("cpio") if not cpio: raise util.PatoolError("cpio(1) is required for rpm2cpio extraction; please install it") path = util.shell_quote(os.path.abspath(archive)) cmdlist = [util.shell_quote(cmd), path, "|", util.shell_quote(cpio), '--extract', '--make-directories', '--preserve-modification-time', '--no-absolute-filenames', '--force-local', '--nonmatching', r'"*\.\.*"'] if verbosity > 1: cmdlist.append('-v') return (cmdlist, {'cwd': outdir, 'shell': True}) patool-1.10/patoolib/programs/rzip.py000066400000000000000000000025041263321134500177330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the rzip program.""" from .. import util def extract_rzip (archive, compression, cmd, verbosity, interactive, outdir): """Extract an RZIP archive.""" cmdlist = [cmd, '-d', '-k'] if verbosity > 1: cmdlist.append('-v') outfile = util.get_single_outfile(outdir, archive) cmdlist.extend(["-o", outfile, archive]) return cmdlist def create_rzip (archive, compression, cmd, verbosity, interactive, filenames): """Create an RZIP archive.""" cmdlist = [cmd, '-k', '-9', '-o', archive] if verbosity > 1: cmdlist.append('-v') cmdlist.extend(filenames) return cmdlist patool-1.10/patoolib/programs/shar.py000066400000000000000000000020621263321134500177030ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the shar program.""" from .. import util def create_shar (archive, compression, cmd, verbosity, interactive, filenames): """Create a SHAR archive.""" cmdlist = [util.shell_quote(cmd)] cmdlist.extend([util.shell_quote(x) for x in filenames]) cmdlist.extend(['>', util.shell_quote(archive)]) return (cmdlist, {'shell': True}) patool-1.10/patoolib/programs/shorten.py000066400000000000000000000030261263321134500204310ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the shorten program.""" from .. import util def extract_shn (archive, compression, cmd, verbosity, interactive, outdir): """Decompress a SHN archive to a WAV file.""" cmdlist = [util.shell_quote(cmd)] outfile = util.get_single_outfile(outdir, archive, extension=".wav") cmdlist.extend(['-x', '-', util.shell_quote(outfile), '<', util.shell_quote(archive)]) return (cmdlist, {'shell': True}) def create_shn (archive, compression, cmd, verbosity, interactive, filenames): """Compress a WAV file to a SHN archive.""" if len(filenames) > 1: raise util.PatoolError("multiple filenames for shorten not supported") cmdlist = [util.shell_quote(cmd)] cmdlist.extend(['-', util.shell_quote(archive), '<', util.shell_quote(filenames[0])]) return (cmdlist, {'shell': True}) patool-1.10/patoolib/programs/star.py000066400000000000000000000030701263321134500177170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the star program.""" from .tar import add_tar_opts as add_star_opts def extract_tar (archive, compression, cmd, verbosity, interactive, outdir): """Extract a TAR archive.""" cmdlist = [cmd, '-x'] add_star_opts(cmdlist, compression, verbosity) cmdlist.extend(['-C', outdir, 'file=%s' % archive]) return cmdlist def list_tar (archive, compression, cmd, verbosity, interactive): """List a TAR archive.""" cmdlist = [cmd, '-n'] add_star_opts(cmdlist, compression, verbosity) cmdlist.append("file=%s" % archive) return cmdlist test_tar = list_tar def create_tar (archive, compression, cmd, verbosity, interactive, filenames): """Create a TAR archive.""" cmdlist = [cmd, '-c'] add_star_opts(cmdlist, compression, verbosity) cmdlist.append("file=%s" % archive) cmdlist.extend(filenames) return cmdlist patool-1.10/patoolib/programs/tar.py000066400000000000000000000044611263321134500175410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the GNU tar program.""" import os def extract_tar (archive, compression, cmd, verbosity, interactive, outdir): """Extract a TAR archive.""" cmdlist = [cmd, '--extract'] add_tar_opts(cmdlist, compression, verbosity) cmdlist.extend(["--file", archive, '--directory', outdir]) return cmdlist def list_tar (archive, compression, cmd, verbosity, interactive): """List a TAR archive.""" cmdlist = [cmd, '--list'] add_tar_opts(cmdlist, compression, verbosity) cmdlist.extend(["--file", archive]) return cmdlist test_tar = list_tar def create_tar (archive, compression, cmd, verbosity, interactive, filenames): """Create a TAR archive.""" cmdlist = [cmd, '--create'] add_tar_opts(cmdlist, compression, verbosity) cmdlist.extend(["--file", archive, '--']) cmdlist.extend(filenames) return cmdlist def add_tar_opts (cmdlist, compression, verbosity): """Add tar options to cmdlist.""" progname = os.path.basename(cmdlist[0]) if compression == 'gzip': cmdlist.append('-z') elif compression == 'compress': cmdlist.append('-Z') elif compression == 'bzip2': cmdlist.append('-j') elif compression in ('lzma', 'xz') and progname == 'bsdtar': cmdlist.append('--%s' % compression) elif compression in ('lzma', 'xz', 'lzip'): # use the compression name as program name since # tar is picky which programs it can use program = compression # set compression program cmdlist.extend(['--use-compress-program', program]) if verbosity > 1: cmdlist.append('--verbose') patool-1.10/patoolib/programs/unace.py000066400000000000000000000025461263321134500200500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the unace program.""" def extract_ace (archive, compression, cmd, verbosity, interactive, outdir): """Extract an ACE archive.""" cmdlist = [cmd, 'x'] if not outdir.endswith('/'): outdir += '/' cmdlist.extend([archive, outdir]) return cmdlist def list_ace (archive, compression, cmd, verbosity, interactive): """List an ACE archive.""" cmdlist = [cmd] if verbosity > 1: cmdlist.append('v') else: cmdlist.append('l') cmdlist.append(archive) return cmdlist def test_ace (archive, compression, cmd, verbosity, interactive): """Test an ACE archive.""" return [cmd, 't', archive] patool-1.10/patoolib/programs/unadf.py000066400000000000000000000020401263321134500200370ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the unadf program.""" def extract_adf (archive, compression, cmd, verbosity, interactive, outdir): """Extract an ADF archive.""" return [cmd, archive, '-d', outdir] def list_adf (archive, compression, cmd, verbosity, interactive): """List an ADF archive.""" return [cmd, '-l', archive] test_adf = list_adf patool-1.10/patoolib/programs/unalz.py000066400000000000000000000020511263321134500200750ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the unalz program.""" def extract_alzip (archive, compression, cmd, verbosity, interactive, outdir): """Extract a ALZIP archive.""" return [cmd, '-d', outdir, archive] def list_alzip (archive, compression, cmd, verbosity, interactive): """List a ALZIP archive.""" return [cmd, '-l', archive] test_alzip = list_alzip patool-1.10/patoolib/programs/uncompress.py000066400000000000000000000022511263321134500211440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the uncompress.real program.""" from .. import util def extract_compress (archive, compression, cmd, verbosity, interactive, outdir): """Extract a compressed archive.""" cmdlist = [util.shell_quote(cmd)] if verbosity > 1: cmdlist.append('-v') outfile = util.get_single_outfile(outdir, archive) cmdlist.extend(['-c', util.shell_quote(archive), '>', util.shell_quote(outfile)]) return (cmdlist, {'shell': True}) patool-1.10/patoolib/programs/unrar.py000066400000000000000000000014411263321134500200750ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the unrar program.""" from .rar import extract_rar, list_rar, test_rar patool-1.10/patoolib/programs/unshar.py000066400000000000000000000016771263321134500202610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the unshar program.""" import os def extract_shar (archive, compression, cmd, verbosity, interactive, outdir): """Extract a SHAR archive.""" cmdlist = [cmd, os.path.abspath(archive)] return (cmdlist, {'cwd': outdir}) patool-1.10/patoolib/programs/unzip.py000066400000000000000000000026641263321134500201230ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the unzip program.""" def extract_zip (archive, compression, cmd, verbosity, interactive, outdir): """Extract a ZIP archive.""" cmdlist = [cmd] if verbosity > 1: cmdlist.append('-v') cmdlist.extend(['--', archive, '-d', outdir]) return cmdlist def list_zip (archive, compression, cmd, verbosity, interactive): """List a ZIP archive.""" cmdlist = [cmd, '-l'] if verbosity > 1: cmdlist.append('-v') cmdlist.extend(['--', archive]) return cmdlist def test_zip (archive, compression, cmd, verbosity, interactive): """Test a ZIP archive.""" cmdlist = [cmd, '-t'] if verbosity > 1: cmdlist.append('-v') cmdlist.extend(['--', archive]) return cmdlist patool-1.10/patoolib/programs/xdms.py000066400000000000000000000032001263321134500177140ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2011-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the xdms program.""" from .. import util def extract_dms (archive, compression, cmd, verbosity, interactive, outdir): """Extract a DMS archive.""" check_archive_ext(archive) cmdlist = [cmd, '-d', outdir] if verbosity > 1: cmdlist.append('-v') cmdlist.extend(['u', archive]) return cmdlist def list_dms (archive, compression, cmd, verbosity, interactive): """List a DMS archive.""" check_archive_ext(archive) return [cmd, 'v', archive] def test_dms (archive, compression, cmd, verbosity, interactive): """Test a DMS archive.""" check_archive_ext(archive) return [cmd, 't', archive] def check_archive_ext (archive): """xdms(1) cannot handle files with extensions other than '.dms'.""" if not archive.lower().endswith(".dms"): rest = archive[-4:] msg = "xdms(1) archive file must end with `.dms', not `%s'" % rest raise util.PatoolError(msg) patool-1.10/patoolib/programs/xz.py000066400000000000000000000050751263321134500174160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the xz program.""" from . import extract_singlefile_standard, test_singlefile_standard from .. import util extract_xz = extract_singlefile_standard test_xz = test_singlefile_standard def list_xz (archive, compression, cmd, verbosity, interactive): """List a XZ archive.""" cmdlist = [cmd] cmdlist.append('-l') if verbosity > 1: cmdlist.append('-v') cmdlist.append(archive) return cmdlist def create_xz(archive, compression, cmd, verbosity, interactive, filenames): """Create an XZ archive.""" cmdlist = [util.shell_quote(cmd)] if verbosity > 1: cmdlist.append('-v') cmdlist.extend(['-c', '-9', '--']) cmdlist.extend([util.shell_quote(x) for x in filenames]) cmdlist.extend(['>', util.shell_quote(archive)]) return (cmdlist, {'shell': True}) def extract_lzma(archive, compression, cmd, verbosity, interactive, outdir): """Extract an LZMA archive.""" cmdlist = [util.shell_quote(cmd), '--format=lzma'] if verbosity > 1: cmdlist.append('-v') outfile = util.get_single_outfile(outdir, archive) cmdlist.extend(['-c', '-d', '--', util.shell_quote(archive), '>', util.shell_quote(outfile)]) return (cmdlist, {'shell': True}) def test_lzma(archive, compression, cmd, verbosity, interactive): """Test an LZMA archive.""" cmdlist = [cmd, '--format=lzma'] if verbosity > 1: cmdlist.append('-v') cmdlist.extend(['--test', archive]) return cmdlist def create_lzma(archive, compression, cmd, verbosity, interactive, filenames): """Create an LZMA archive.""" cmdlist = [util.shell_quote(cmd), '--format=lzma'] if verbosity > 1: cmdlist.append('-v') cmdlist.extend(['-c', '-9', '--']) cmdlist.extend([util.shell_quote(x) for x in filenames]) cmdlist.extend(['>', util.shell_quote(archive)]) return (cmdlist, {'shell': True}) patool-1.10/patoolib/programs/zip.py000066400000000000000000000023361263321134500175540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the zip program.""" def create_zip (archive, compression, cmd, verbosity, interactive, filenames): """Create a ZIP archive.""" cmdlist = [cmd, '-r', '-9'] if verbosity > 1: cmdlist.append('-v') cmdlist.append(archive) cmdlist.extend(filenames) return cmdlist def test_zip (archive, compression, cmd, verbosity, interactive): """Test a ZIP archive.""" cmdlist = [cmd, '--test'] if verbosity > 1: cmdlist.append('-v') cmdlist.append(archive) return cmdlist patool-1.10/patoolib/programs/zoo.py000066400000000000000000000030171263321134500175560ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the zoo program.""" import os def extract_zoo(archive, compression, cmd, verbosity, interactive, outdir): """Extract a ZOO archive.""" # Since extracted files will be placed in the current directory, # the cwd argument has to be the output directory. cmdlist = [cmd, '-extract', os.path.abspath(archive)] return (cmdlist, {'cwd': outdir}) def list_zoo(archive, compression, cmd, verbosity, interactive): """List a ZOO archive.""" return [cmd, '-list', archive] def test_zoo(archive, compression, cmd, verbosity, interactive): """Test a ZOO archive.""" return [cmd, '-test', archive] def create_zoo(archive, compression, cmd, verbosity, interactive, filenames): """Create a ZOO archive.""" cmdlist = [cmd, '-add', archive] cmdlist.extend(filenames) return cmdlist patool-1.10/patoolib/programs/zopfli.py000066400000000000000000000021241263321134500202500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2013-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the zopfli program.""" from .. import util def create_gzip(archive, compression, cmd, verbosity, interactive, filenames): """Create a GZIP archive.""" cmdlist = [util.shell_quote(cmd)] cmdlist.extend(['-c', '--']) cmdlist.extend([util.shell_quote(x) for x in filenames]) cmdlist.extend(['>', util.shell_quote(archive)]) return (cmdlist, {'shell': True}) patool-1.10/patoolib/programs/zpaq.py000066400000000000000000000025761263321134500177330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2014-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the zpaq program.""" import os def extract_zpaq(archive, compression, cmd, verbosity, interactive, outdir): """Extract a ZPAQ archive.""" cmdlist = [cmd, 'x', os.path.abspath(archive)] return (cmdlist, {'cwd': outdir}) def list_zpaq(archive, compression, cmd, verbosity, interactive): """List a ZPAQ archive.""" return [cmd, 'l', archive] def create_zpaq(archive, compression, cmd, verbosity, interactive, filenames): """Create a ZPAQ archive.""" cmdlist = [cmd, 'a', archive] cmdlist.extend(filenames) cmdlist.extend(['-method', '4']) return cmdlist # zpaq has no separate test mode, so use listing instead test_zpaq = list_zpaq patool-1.10/patoolib/util.py000066400000000000000000000610071263321134500160750ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Utility functions.""" from __future__ import print_function import os import sys import shutil import subprocess import mimetypes import tempfile import time import traceback import locale from . import configuration, ArchiveMimetypes, ArchiveCompressions try: from shutil import which except ImportError: # from Python 3.3 def which(cmd, mode=os.F_OK | os.X_OK, path=None): """Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can be overridden with a custom search path. """ def _access_check(fn, mode): """Check that a given file can be accessed with the correct mode. Additionally check that `fn` is not a directory, as on Windows directories pass the os.access check.""" return (os.path.exists(fn) and os.access(fn, mode) and not os.path.isdir(fn)) # If we're given a path with a directory part, look it up directly rather # than referring to PATH directories. This includes checking relative to the # current directory, e.g. ./script if os.path.dirname(cmd): if _access_check(cmd, mode): return cmd return None path = (path or os.environ.get("PATH", os.defpath)).split(os.pathsep) if sys.platform == "win32": # The current directory takes precedence on Windows. if not os.curdir in path: path.insert(0, os.curdir) # PATHEXT is necessary to check on Windows. pathext = os.environ.get("PATHEXT", "").split(os.pathsep) # See if the given file matches any of the expected path extensions. # This will allow us to short circuit when given "python.exe". # If it does match, only test that one, otherwise we have to try # others. if any(cmd.lower().endswith(ext.lower()) for ext in pathext): files = [cmd] else: files = [cmd + ext for ext in pathext] else: # On other platforms you don't have things like PATHEXT to tell you # what file suffixes are executable, so just pass on cmd as-is. files = [cmd] seen = set() for dir in path: normdir = os.path.normcase(dir) if not normdir in seen: seen.add(normdir) for thefile in files: name = os.path.join(dir, thefile) if _access_check(name, mode): return name return None # internal MIME database mimedb = None def init_mimedb(): """Initialize the internal MIME database.""" global mimedb try: mimedb = mimetypes.MimeTypes(strict=False) except Exception as msg: log_error("could not initialize MIME database: %s" % msg) return add_mimedb_data(mimedb) def add_mimedb_data(mimedb): """Add missing encodings and mimetypes to MIME database.""" mimedb.encodings_map['.bz2'] = 'bzip2' mimedb.encodings_map['.lzma'] = 'lzma' mimedb.encodings_map['.xz'] = 'xz' mimedb.encodings_map['.lz'] = 'lzip' mimedb.suffix_map['.tbz2'] = '.tar.bz2' add_mimetype(mimedb, 'application/x-lzop', '.lzo') add_mimetype(mimedb, 'application/x-adf', '.adf') add_mimetype(mimedb, 'application/x-arj', '.arj') add_mimetype(mimedb, 'application/x-lzma', '.lzma') add_mimetype(mimedb, 'application/x-xz', '.xz') add_mimetype(mimedb, 'application/java-archive', '.jar') add_mimetype(mimedb, 'application/x-rar', '.rar') add_mimetype(mimedb, 'application/x-7z-compressed', '.7z') add_mimetype(mimedb, 'application/x-cab', '.cab') add_mimetype(mimedb, 'application/x-rpm', '.rpm') add_mimetype(mimedb, 'application/x-debian-package', '.deb') add_mimetype(mimedb, 'application/x-ace', '.ace') add_mimetype(mimedb, 'application/x-archive', '.a') add_mimetype(mimedb, 'application/x-alzip', '.alz') add_mimetype(mimedb, 'application/x-arc', '.arc') add_mimetype(mimedb, 'application/x-lrzip', '.lrz') add_mimetype(mimedb, 'application/x-lha', '.lha') add_mimetype(mimedb, 'application/x-lzh', '.lzh') add_mimetype(mimedb, 'application/x-rzip', '.rz') add_mimetype(mimedb, 'application/x-zoo', '.zoo') add_mimetype(mimedb, 'application/x-dms', '.dms') add_mimetype(mimedb, 'application/x-zip-compressed', '.crx') add_mimetype(mimedb, 'application/x-shar', '.shar') add_mimetype(mimedb, 'application/x-vhd', '.vhd') add_mimetype(mimedb, 'audio/x-ape', '.ape') add_mimetype(mimedb, 'audio/x-shn', '.shn') add_mimetype(mimedb, 'audio/flac', '.flac') add_mimetype(mimedb, 'application/x-chm', '.chm') add_mimetype(mimedb, 'application/x-iso9660-image', '.iso') add_mimetype(mimedb, 'application/zip', '.epub') add_mimetype(mimedb, 'application/zip', '.apk') add_mimetype(mimedb, 'application/zpaq', '.zpaq') def add_mimetype(mimedb, mimetype, extension): """Add or replace a mimetype to be used with the given extension.""" # If extension is already a common type, strict=True must be used. strict = extension in mimedb.types_map[True] mimedb.add_type(mimetype, extension, strict=strict) class PatoolError (Exception): """Raised when errors occur.""" pass class memoized (object): """Decorator that caches a function's return value each time it is called. If called later with the same arguments, the cached value is returned, and not re-evaluated.""" def __init__(self, func): """Set func and init cache.""" self.func = func self.cache = {} def __call__(self, *args): """Try to find result for function arguments in local cache or execute the function and fill the cache with the result.""" try: return self.cache[args] except KeyError: self.cache[args] = value = self.func(*args) return value except TypeError: # uncachable -- for instance, passing a list as an argument. # Better to not cache than to blow up entirely. return self.func(*args) def __repr__(self): """Return the function's docstring.""" return self.func.__doc__ def backtick (cmd, encoding='utf-8'): """Return decoded output from command.""" data = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0] return data.decode(encoding) def run (cmd, verbosity=0, **kwargs): """Run command without error checking. @return: command return code""" # Note that shell_quote_nt() result is not suitable for copy-paste # (especially on Unix systems), but it looks nicer than shell_quote(). if verbosity >= 0: log_info("running %s" % " ".join(map(shell_quote_nt, cmd))) if kwargs: if verbosity >= 0: log_info(" with %s" % ", ".join("%s=%s" % (k, shell_quote(str(v)))\ for k, v in kwargs.items())) if kwargs.get("shell"): # for shell calls the command must be a string cmd = " ".join(cmd) if verbosity < 1: # hide command output on stdout with open(os.devnull, 'wb') as devnull: kwargs['stdout'] = devnull res = subprocess.call(cmd, **kwargs) else: res = subprocess.call(cmd, **kwargs) return res def run_checked (cmd, ret_ok=(0,), **kwargs): """Run command and raise PatoolError on error.""" retcode = run(cmd, **kwargs) if retcode not in ret_ok: msg = "Command `%s' returned non-zero exit status %d" % (cmd, retcode) raise PatoolError(msg) return retcode @memoized def guess_mime (filename): """Guess the MIME type of given filename using file(1) and if that fails by looking at the filename extension with the Python mimetypes module. The result of this function is cached. """ mime, encoding = guess_mime_file(filename) if mime is None: mime, encoding = guess_mime_mimedb(filename) assert mime is not None or encoding is None return mime, encoding Encoding2Mime = { 'gzip': "application/gzip", 'bzip2': "application/x-bzip2", 'compress': "application/x-compress", 'lzma': "application/x-lzma", 'lzip': "application/x-lzip", 'xz': "application/x-xz", } Mime2Encoding = dict([(_val, _key) for _key, _val in Encoding2Mime.items()]) # libmagic before version 5.14 identified .gz files as application/x-gzip Mime2Encoding['application/x-gzip'] = 'gzip' def guess_mime_mimedb (filename): """Guess MIME type from given filename. @return: tuple (mime, encoding) """ mime, encoding = None, None if mimedb is not None: mime, encoding = mimedb.guess_type(filename, strict=False) if mime not in ArchiveMimetypes and encoding in ArchiveCompressions: # Files like 't.txt.gz' are recognized with encoding as format, and # an unsupported mime-type like 'text/plain'. Fix this. mime = Encoding2Mime[encoding] encoding = None return mime, encoding def guess_mime_file (filename): """Determine MIME type of filename with file(1): (a) using `file --mime` (b) using `file` and look the result string @return: tuple (mime, encoding) """ mime, encoding = None, None base, ext = os.path.splitext(filename) if ext.lower() in ('.alz',): # let mimedb recognize these extensions return mime, encoding if os.path.isfile(filename): file_prog = find_program("file") if file_prog: mime, encoding = guess_mime_file_mime(file_prog, filename) if mime is None: mime = guess_mime_file_text(file_prog, filename) encoding = None if mime in Mime2Encoding: # try to look inside compressed archives cmd = [file_prog, "--brief", "--mime", "--uncompress", filename] try: outparts = backtick(cmd).strip().split(";") except OSError: # ignore errors, as file(1) is only a fallback return mime, encoding mime2 = outparts[0].split(" ", 1)[0] # Some file(1) implementations return an empty or unknown mime type # when the uncompressor program is not installed, other # implementation return the original file type. # The following detects both cases. if (mime2 in ('application/x-empty', 'application/octet-stream') or mime2 in Mime2Encoding): # The uncompressor program file(1) uses is not installed # or is not able to uncompress. # Try to get mime information from the file extension. mime2, encoding2 = guess_mime_mimedb(filename) if mime2 in ArchiveMimetypes: mime = mime2 encoding = encoding2 elif mime2 in ArchiveMimetypes: mime = mime2 encoding = get_file_mime_encoding(outparts) return mime, encoding def guess_mime_file_mime (file_prog, filename): """Determine MIME type of filename with file(1) and --mime option. @return: tuple (mime, encoding) """ mime, encoding = None, None cmd = [file_prog, "--brief", "--mime-type", filename] try: mime = backtick(cmd).strip() except OSError: # ignore errors, as file(1) is only a fallback pass if mime not in ArchiveMimetypes: mime, encoding = None, None return mime, encoding def get_file_mime_encoding (parts): """Get encoding value from splitted output of file --mime --uncompress.""" for part in parts: for subpart in part.split(" "): if subpart.startswith("compressed-encoding="): mime = subpart.split("=")[1].strip() return Mime2Encoding.get(mime) return None # Match file(1) output text to mime types FileText2Mime = { "7-zip archive data": "application/x-7z-compressed", "ACE archive data": "application/x-ace", "Amiga DOS disk": "application/x-adf", "ARJ archive data": "application/x-arj", "bzip2 compressed data": "application/x-bzip2", "cpio archive": "application/x-cpio", "ASCII cpio archive": "application/x-cpio", "Debian binary package": "application/x-debian-package", "gzip compressed data": "application/x-gzip", "LZMA compressed data": "application/x-lzma", "LRZIP compressed data": "application/x-lrzip", "lzop compressed data": "application/x-lzop", "Microsoft Cabinet archive data": "application/vnd.ms-cab-compressed", "RAR archive data": "application/x-rar", "RPM ": "application/x-redhat-package-manager", "POSIX tar archive": "application/x-tar", "xz compressed data": "application/x-xz", "Zip archive data": "application/zip", "compress'd data": "application/x-compress", "lzip compressed data": "application/x-lzip", "rzip compressed data": "application/x-rzip", "current ar archive": "application/x-archive", "LHa ": "application/x-lha", "ARC archive data": "application/x-arc", "Zoo archive data": "application/x-zoo", "DMS archive data": "application/x-dms", "Monkey's Audio": "audio/x-ape", "FLAC audio bitstream data": "audio/flac", "MS Windows HtmlHelp Data": "application/x-chm", "ZPAQ stream": "application/zpaq", } def guess_mime_file_text (file_prog, filename): """Determine MIME type of filename with file(1).""" cmd = [file_prog, "--brief", filename] try: output = backtick(cmd).strip() except OSError: # ignore errors, as file(1) is only a fallback return None # match output against known strings for matcher, mime in FileText2Mime.items(): if output.startswith(matcher) and mime in ArchiveMimetypes: return mime return None def check_existing_filename (filename, onlyfiles=True): """Ensure that given filename is a valid, existing file.""" if not os.path.exists(filename): raise PatoolError("file `%s' was not found" % filename) if not os.access(filename, os.R_OK): raise PatoolError("file `%s' is not readable" % filename) if onlyfiles and not os.path.isfile(filename): raise PatoolError("`%s' is not a file" % filename) def check_writable_filename(filename): """Ensure that the given filename is writable.""" if not os.access(filename, os.W_OK): raise PatoolError("file `%s' is not writable" % filename) def check_new_filename (filename): """Check that filename does not already exist.""" if os.path.exists(filename): raise PatoolError("cannot overwrite existing file `%s'" % filename) def check_archive_filelist (filenames): """Check that file list is not empty and contains only existing files.""" if not filenames: raise PatoolError("cannot create archive with empty filelist") for filename in filenames: check_existing_filename(filename, onlyfiles=False) def set_mode (filename, flags): """Set mode flags for given filename if not already set.""" try: mode = os.lstat(filename).st_mode except OSError: # ignore return if not (mode & flags): try: os.chmod(filename, flags | mode) except OSError as msg: log_error("could not set mode flags for `%s': %s" % (filename, msg)) def get_filesize(filename): """Return file size in Bytes, or -1 on error.""" return os.path.getsize(filename) def strsize(b, grouping=True): """Return human representation of bytes b. A negative number of bytes raises a value error.""" if b < 0: raise ValueError("Invalid negative byte number") if b < 1024: return u"%sB" % locale.format("%d", b, grouping) if b < 1024 * 10: return u"%sKB" % locale.format("%d", (b // 1024), grouping) if b < 1024 * 1024: return u"%sKB" % locale.format("%.2f", (float(b) / 1024), grouping) if b < 1024 * 1024 * 10: return u"%sMB" % locale.format("%.2f", (float(b) / (1024*1024)), grouping) if b < 1024 * 1024 * 1024: return u"%sMB" % locale.format("%.1f", (float(b) / (1024*1024)), grouping) if b < 1024 * 1024 * 1024 * 10: return u"%sGB" % locale.format("%.2f", (float(b) / (1024*1024*1024)), grouping) return u"%sGB" % locale.format("%.1f", (float(b) / (1024*1024*1024)), grouping) def tmpdir (dir=None): """Return a temporary directory for extraction.""" return tempfile.mkdtemp(suffix='', prefix='Unpack_', dir=dir) def tmpfile (dir=None, prefix="temp", suffix=None): """Return a temporary file.""" return tempfile.mkstemp(suffix=suffix, prefix=prefix, dir=dir)[1] def shell_quote (value): """Quote all shell metacharacters in given string value with strong (ie. single) quotes, handling the single quote especially.""" if os.name == 'nt': return shell_quote_nt(value) return "'%s'" % value.replace("'", r"'\''") def shell_quote_nt (value): """Quote argument for Windows system. Modeled after distutils _nt_quote_args() function.""" if " " in value: return '"%s"' % value return value def stripext (filename): """Return the basename without extension of given filename.""" return os.path.splitext(os.path.basename(filename))[0] def get_single_outfile (directory, archive, extension=""): """Get output filename if archive is in a single file format like gzip.""" outfile = os.path.join(directory, stripext(archive)) if os.path.exists(outfile + extension): # prevent overwriting existing files i = 1 newfile = "%s%d" % (outfile, i) while os.path.exists(newfile + extension): newfile = "%s%d" % (outfile, i) i += 1 outfile = newfile return outfile + extension def log_error (msg, out=sys.stderr): """Print error message to stderr (or any other given output).""" print("patool error:", msg, file=out) def log_info (msg, out=sys.stdout): """Print info message to stdout (or any other given output).""" print("patool:", msg, file=out) def log_internal_error(out=sys.stderr, etype=None, evalue=None, tb=None): """Print internal error message (output defaults to stderr).""" print(os.linesep, file=out) print("""********** Oops, I did it again. ************* You have found an internal error in %(app)s. Please write a bug report at %(url)s and include at least the information below: Not disclosing some of the information below due to privacy reasons is ok. I will try to help you nonetheless, but you have to give me something I can work with ;) . """ % dict(app=configuration.AppName, url=configuration.SupportUrl), file=out) if etype is None: etype = sys.exc_info()[0] if evalue is None: evalue = sys.exc_info()[1] print(etype, evalue, file=out) if tb is None: tb = sys.exc_info()[2] traceback.print_exception(etype, evalue, tb, None, out) print_app_info(out=out) print_locale_info(out=out) print(os.linesep, "******** %s internal error, over and out ********" % configuration.AppName, file=out) def print_env_info(key, out=sys.stderr): """If given environment key is defined, print it out.""" value = os.getenv(key) if value is not None: print(key, "=", repr(value), file=out) def print_locale_info(out=sys.stderr): """Print locale info.""" for key in ("LANGUAGE", "LC_ALL", "LC_CTYPE", "LANG"): print_env_info(key, out=out) def print_app_info(out=sys.stderr): """Print system and application info (output defaults to stderr).""" print("System info:", file=out) print(configuration.App, file=out) print("Python %(version)s on %(platform)s" % {"version": sys.version, "platform": sys.platform}, file=out) stime = strtime(time.time()) print("Local time:", stime, file=out) print("sys.argv", sys.argv, file=out) def strtime(t): """Return ISO 8601 formatted time.""" return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(t)) + \ strtimezone() def strtimezone(): """Return timezone info, %z on some platforms, but not supported on all. """ if time.daylight: zone = time.altzone else: zone = time.timezone return "%+04d" % (-zone//3600) def p7zip_supports_rar(): """Determine if the RAR codec is installed for 7z program.""" if os.name == 'nt': # Assume RAR support is compiled into the binary. return True # the subdirectory and codec name codecname = 'p7zip/Codecs/Rar29.so' # search canonical user library dirs for libdir in ('/usr/lib', '/usr/local/lib', '/usr/lib64', '/usr/local/lib64', '/usr/lib/i386-linux-gnu', '/usr/lib/x86_64-linux-gnu'): fname = os.path.join(libdir, codecname) if os.path.exists(fname): return True return False @memoized def find_program (program): """Look for program in environment PATH variable.""" if os.name == 'nt': path = os.environ['PATH'] path = append_to_path(path, get_nt_7z_dir()) path = append_to_path(path, get_nt_mac_dir()) else: # use default path path = None return which(program, path=path) def append_to_path (path, directory): """Add a directory to the PATH environment variable, if it is a valid directory.""" if not os.path.isdir(directory) or directory in path: return path if not path.endswith(os.pathsep): path += os.pathsep return path + directory def get_nt_7z_dir (): """Return 7-Zip directory from registry, or an empty string.""" # Python 3.x renamed the _winreg module to winreg try: import _winreg as winreg except ImportError: import winreg try: key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\7-Zip") try: return winreg.QueryValueEx(key, "Path")[0] finally: winreg.CloseKey(key) except WindowsError: return "" def get_nt_program_dir (): """Return the Windows program files directory.""" progvar = "%ProgramFiles%" return os.path.expandvars(progvar) def get_nt_mac_dir (): """Return Monkey Audio Compressor (MAC) directory, or an empty string.""" return os.path.join(get_nt_program_dir(), "Monkey's Audio") def strlist_with_or (alist): """Return comma separated string, and last entry appended with ' or '.""" if len(alist) > 1: return "%s or %s" % (", ".join(alist[:-1]), alist[-1]) return ", ".join(alist) def is_same_file (filename1, filename2): """Check if filename1 and filename2 point to the same file object. There can be false negatives, ie. the result is False, but it is the same file anyway. Reason is that network filesystems can create different paths to the same physical file. """ if filename1 == filename2: return True if os.name == 'posix': return os.path.samefile(filename1, filename2) return is_same_filename(filename1, filename2) def is_same_filename (filename1, filename2): """Check if filename1 and filename2 are the same filename.""" return os.path.realpath(filename1) == os.path.realpath(filename2) def link_or_copy(src, dst, verbosity=0): """Try to make a hard link from src to dst and if that fails copy the file. Hard links save some disk space and linking should fail fast since no copying is involved. """ if verbosity > 0: log_info("Copying %s -> %s" % (src, dst)) try: os.link(src, dst) except (AttributeError, OSError): try: shutil.copy(src, dst) except OSError as msg: raise PatoolError(msg) def chdir(directory): """Remember and return current directory before calling os.chdir(). If the current directory could not be determined, return None. """ try: olddir = os.getcwd() except OSError: olddir = None os.chdir(directory) return olddir init_mimedb() patool-1.10/scripts/000077500000000000000000000000001263321134500144205ustar00rootroot00000000000000patool-1.10/scripts/build.bat000066400000000000000000000015741263321134500162160ustar00rootroot00000000000000:: Build patool :: Copyright (C) 2012 Bastian Kleineidam :: This program is free software; you can redistribute it and/or modify :: it under the terms of the GNU General Public License as published by :: the Free Software Foundation; either version 2 of the License, or :: (at your option) any later version. :: :: This program is distributed in the hope that it will be useful, :: but WITHOUT ANY WARRANTY; without even the implied warranty of :: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the :: GNU General Public License for more details. :: :: You should have received a copy of the GNU General Public License along :: with this program; if not, write to the Free Software Foundation, Inc., :: 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. @echo off :: Python version set PYDIR=C:\Python27 set PYVER=2.7 %PYDIR%\python.exe setup.py build patool-1.10/scripts/dist.bat000066400000000000000000000016051263321134500160550ustar00rootroot00000000000000:: Create patool Windows distribution file :: Copyright (C) 2010-2012 Bastian Kleineidam :: This program is free software: you can redistribute it and/or modify :: it under the terms of the GNU General Public License as published by :: the Free Software Foundation, either version 3 of the License, or :: (at your option) any later version. :: :: This program is distributed in the hope that it will be useful, :: but WITHOUT ANY WARRANTY; without even the implied warranty of :: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the :: GNU General Public License for more details. :: :: You should have received a copy of the GNU General Public License :: along with this program. If not, see . @echo off set PYDIR=c:\python27 rd /s /q build > nul 2>&1 call %~dp0\build.bat rd /s /q dist > nul 2>&1 %PYDIR%\python.exe setup.py py2exe pause patool-1.10/scripts/test.bat000066400000000000000000000014501263321134500160670ustar00rootroot00000000000000:: Run patool test suite :: Copyright (C) 2010-2012 Bastian Kleineidam :: This program is free software: you can redistribute it and/or modify :: it under the terms of the GNU General Public License as published by :: the Free Software Foundation, either version 3 of the License, or :: (at your option) any later version. :: :: This program is distributed in the hope that it will be useful, :: but WITHOUT ANY WARRANTY; without even the implied warranty of :: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the :: GNU General Public License for more details. :: :: You should have received a copy of the GNU General Public License :: along with this program. If not, see . @echo off set PYDIR=C:\Python27 %PYDIR%\python.exe -m pytest tests pause patool-1.10/setup.cfg000066400000000000000000000001421263321134500145470ustar00rootroot00000000000000[global] [bdist_wheel] universal = 1 [egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 patool-1.10/setup.py000066400000000000000000000224711263321134500144510ustar00rootroot00000000000000#!/usr/bin/python # -*- coding: iso-8859-1 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """ Setup file for the distuils module. """ from __future__ import print_function import sys if not hasattr(sys, "version_info") or sys.version_info < (2, 7, 0, "final", 0): raise SystemExit("This program requires Python 2.7 or later.") import os import re import shutil import glob import subprocess from setuptools import setup from distutils.core import Distribution from distutils.command.install_lib import install_lib from distutils import util from distutils.file_util import write_file AppName = "patool" AppVersion = "1.10" MyName = "Bastian Kleineidam" MyEmail = "bastian.kleineidam@web.de" def normpath (path): """Norm a path name to platform specific notation.""" return os.path.normpath(path) def cnormpath (path): """Norm a path name to platform specific notation and make it absolute.""" path = normpath(path) if os.name == 'nt': # replace slashes with backslashes path = path.replace("/", "\\") if not os.path.isabs(path): path = normpath(os.path.join(sys.prefix, path)) return path release_ro = re.compile(r"\(released (.+)\)") def get_release_date (): """Parse and return relase date as string from doc/changelog.txt.""" fname = os.path.join("doc", "changelog.txt") release_date = "unknown" with open(fname) as fd: # the release date is on the first line line = fd.readline() mo = release_ro.search(line) if mo: release_date = mo.groups(1) return release_date data_files = [] if os.name == 'nt': data_files.append(('share', ['doc/patool.txt'])) else: data_files.append(('share/man/man1', ['doc/patool.1'])) def get_nt_platform_vars (): """Return program file path and architecture for NT systems.""" platform = util.get_platform() if platform == "win-amd64": # the Visual C++ runtime files are installed in the x86 directory progvar = "%ProgramFiles(x86)%" architecture = "amd64" elif platform == "win32": progvar = "%ProgramFiles%" architecture = "x86" else: raise ValueError("Unsupported platform %r" % platform) return os.path.expandvars(progvar), architecture class MyInstallLib (install_lib, object): """Custom library installation.""" def install (self): """Install the generated config file.""" outs = super(MyInstallLib, self).install() infile = self.create_conf_file() outfile = os.path.join(self.install_dir, os.path.basename(infile)) self.copy_file(infile, outfile) outs.append(outfile) return outs def create_conf_file (self): """Create configuration file.""" cmd_obj = self.distribution.get_command_obj("install") cmd_obj.ensure_finalized() # we have to write a configuration file because we need the # directory (and other stuff like author, url, ...) # all paths are made absolute by cnormpath() data = [] for d in ['purelib', 'platlib', 'lib', 'headers', 'scripts', 'data']: attr = 'install_%s' % d if cmd_obj.root: # cut off root path prefix cutoff = len(cmd_obj.root) # don't strip the path separator if cmd_obj.root.endswith(os.sep): cutoff -= 1 val = getattr(cmd_obj, attr)[cutoff:] else: val = getattr(cmd_obj, attr) if attr == 'install_data': cdir = os.path.join(val, "share", AppName) data.append('config_dir = %r' % cnormpath(cdir)) elif attr == 'install_lib': if cmd_obj.root: _drive, tail = os.path.splitdrive(val) if tail.startswith(os.sep): tail = tail[1:] self.install_lib = os.path.join(cmd_obj.root, tail) else: self.install_lib = val data.append("%s = %r" % (attr, cnormpath(val))) self.distribution.create_conf_file(data, directory=self.install_lib) return self.get_conf_output() def get_conf_output (self): """Get filename for distribution configuration file.""" return self.distribution.get_conf_filename(self.install_lib) def get_outputs (self): """Add the generated config file to the list of outputs.""" outs = super(MyInstallLib, self).get_outputs() conf_output = self.get_conf_output() outs.append(conf_output) if self.compile: outs.extend(self._bytecode_filenames([conf_output])) return outs class MyDistribution (Distribution, object): """Custom distribution class generating config file.""" def __init__ (self, attrs): """Set console and windows scripts.""" super(MyDistribution, self).__init__(attrs) self.console = ['patool'] def run_commands (self): """Generate config file and run commands.""" cwd = os.getcwd() data = [] data.append('config_dir = %r' % os.path.join(cwd, "config")) data.append("install_data = %r" % cwd) data.append("install_scripts = %r" % cwd) self.create_conf_file(data) super(MyDistribution, self).run_commands() def get_conf_filename (self, directory): """Get name for config file.""" return os.path.join(directory, "_%s_configdata.py" % self.get_name()) def create_conf_file (self, data, directory=None): """Create local config file from given data (list of lines) in the directory (or current directory if not given).""" data.insert(0, "# this file is automatically created by setup.py") data.insert(0, "# -*- coding: iso-8859-1 -*-") if directory is None: directory = os.getcwd() filename = self.get_conf_filename(directory) # add metadata metanames = ("name", "version", "author", "author_email", "maintainer", "maintainer_email", "url", "license", "description", "long_description", "keywords", "platforms", "fullname", "contact", "contact_email") for name in metanames: method = "get_" + name val = getattr(self.metadata, method)() data.append("%s = %r" % (name, val)) data.append('release_date = "%s"' % get_release_date()) # write the config file util.execute(write_file, (filename, data), "creating %s" % filename, self.verbose >= 1, self.dry_run) args = dict( name = AppName, version = AppVersion, description = "portable archive file manager", long_description = """Various archive formats can be created, extracted, tested, listed, searched, compared and repacked by patool. The advantage of patool is its simplicity in handling archive files without having to remember a myriad of programs and options. The archive format is determined by the file(1) program and as a fallback by the archive file extension. patool supports 7z (.7z), ACE (.ace), ADF (.adf), ALZIP (.alz), APE (.ape), AR (.a), ARC (.arc), ARJ (.arj), BZIP2 (.bz2), CAB (.cab), COMPRESS (.Z), CPIO (.cpio), DEB (.deb), DMS (.dms), FLAC (.flac), GZIP (.gz), ISO (.iso), LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP (.lzo), RPM (.rpm), RAR (.rar), RZIP (.rz), SHN (.shn), TAR (.tar), XZ (.xz), ZIP (.zip, .jar), ZOO (.zoo) and ZPAQ (.zpaq) formats. It relies on helper applications to handle those archive formats (for example bzip2 for BZIP2 archives). The archive formats TAR, ZIP, BZIP2 and GZIP are supported natively and do not require helper applications to be installed. """, author = MyName, author_email = MyEmail, maintainer = MyName, maintainer_email = MyEmail, license = "GPL", url = "http://wummel.github.io/patool/", packages = ['patoolib', 'patoolib.programs'], data_files = data_files, scripts = ['patool'], keywords = "archiver,archive,compression,commandline,manager", classifiers = [ 'Environment :: Console', 'Topic :: System :: Archiving', 'Development Status :: 5 - Production/Stable', 'License :: OSI Approved :: GNU General Public License (GPL)', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Operating System :: OS Independent', ], distclass = MyDistribution, cmdclass = { 'install_lib': MyInstallLib, }, ) setup(**args) patool-1.10/tests/000077500000000000000000000000001263321134500140735ustar00rootroot00000000000000patool-1.10/tests/__init__.py000066400000000000000000000071041263321134500162060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import os import sys import patoolib import pytest import importlib basedir = os.path.dirname(__file__) datadir = os.path.join(basedir, 'data') patool_cmd = os.path.join(os.path.dirname(basedir), "patool") # Python 3.x renamed the function name attribute if sys.version_info[0] > 2: fnameattr = '__name__' else: fnameattr = 'func_name' def _need_func(testfunc, name, description): """Decorator skipping test if given testfunc returns False.""" def check_func(func): def newfunc(*args, **kwargs): if not testfunc(name): raise pytest.skip("%s %r is not available" % (description, name)) return func(*args, **kwargs) setattr(newfunc, fnameattr, getattr(func, fnameattr)) return newfunc return check_func def needs_os(name): """Decorator skipping test if given operating system is not available.""" return _need_func(lambda x: os.name == x, name, 'operating system') def needs_program(name): """Decorator skipping test if given program is not available.""" return _need_func(lambda x: patoolib.util.find_program(x), name, 'program') def needs_one_program(programs): """Decorator skipping test if not one of given programs are available.""" return _need_func(lambda x: all(map(patoolib.util.find_program, x)), programs, 'programs') def needs_module(name): """Decorator skipping test if given module is not available.""" def has_module(module): try: importlib.import_module(module) return True except ImportError: return False return _need_func(has_module, name, 'Python module') def needs_codec (program, codec): """Decorator skipping test if given program codec is not available.""" def check_prog (f): def newfunc (*args, **kwargs): if not patoolib.util.find_program(program): raise pytest.skip("program `%s' not available" % program) if not has_codec(program, codec): raise pytest.skip("codec `%s' for program `%s' not available" % (codec, program)) return f(*args, **kwargs) setattr(newfunc, fnameattr, getattr(f, fnameattr)) return newfunc return check_prog def has_codec (program, codec): """Test if program supports given codec.""" if program == '7z' and codec == 'rar': return patoolib.util.p7zip_supports_rar() if patoolib.program_supports_compression(program, codec): return True return patoolib.util.find_program(codec) def skip_on_travis(): """Skip test if TRAVIS build environment is detected.""" def check_func(func): def newfunc(*args, **kwargs): if "TRAVIS" in os.environ: raise pytest.skip("Skip on TRAVIS CI build.") return func(*args, **kwargs) setattr(newfunc, fnameattr, getattr(func, fnameattr)) return newfunc return check_func patool-1.10/tests/archives/000077500000000000000000000000001263321134500156775ustar00rootroot00000000000000patool-1.10/tests/archives/__init__.py000066400000000000000000000234041263321134500200130ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest import os import shutil import patoolib from .. import basedir, datadir # All text files have '42' as content. TextFileContent = '42' class Content: """The test archives have one of several set of content files. The different content file sets have each a constant defined by this class. """ # Recursive archives for extraction have a text file in a directory: # t/t.txt # Recursive archives for creation have two text files in directories: # foo dir/t.txt # foo dir/bar/t.txt Recursive = 'recursive' # Singlefile archives for extraction have a text file t.txt # Singlefile archives for creation have a text file `foo .txt' Singlefile = 'singlefile' # Multifile archives for extraction have two text files: t.txt and t2.txt # Multifile archives for creation have two text files: foo .txt and foo2 .txt Multifile = 'multifile' class ArchiveTest (unittest.TestCase): """Helper class for archive tests, handling one commandline program.""" # set program to use for archive handling in subclass program = None def archive_commands (self, filename, **kwargs): """Run archive commands list, test, extract and create. All keyword arguments are delegated to the create test function.""" self.archive_list(filename) if not kwargs.get('skip_test'): self.archive_test(filename) self.archive_extract(filename, check=kwargs.get('check', Content.Recursive)) if not kwargs.get('skip_create'): self.archive_create(filename, **kwargs) def archive_extract (self, filename, check=Content.Recursive): """Test archive extraction.""" archive = os.path.join(datadir, filename) self.assertTrue(os.path.isabs(archive), "archive path is not absolute: %r" % archive) self._archive_extract(archive, check) # archive name relative to tmpdir relarchive = os.path.join("..", archive[len(basedir)+1:]) self._archive_extract(relarchive, check, verbosity=1) def _archive_extract (self, archive, check, verbosity=0): # create a temporary directory for extraction tmpdir = patoolib.util.tmpdir(dir=basedir) try: olddir = patoolib.util.chdir(tmpdir) try: output = patoolib.extract_archive(archive, program=self.program, verbosity=verbosity, interactive=False) if check: self.check_extracted_archive(archive, output, check) finally: if olddir: os.chdir(olddir) finally: shutil.rmtree(tmpdir) def check_extracted_archive (self, archive, output, check): if check == Content.Recursive: # outdir is the 't' directory of the archive self.assertEqual(output, 't') self.check_directory(output, 't') txtfile = os.path.join(output, 't.txt') self.check_textfile(txtfile, 't.txt') elif check == Content.Singlefile: # a non-existing directory to ensure files do not exist in it ned = get_nonexisting_directory(os.getcwd()) expected_output = os.path.basename(patoolib.util.get_single_outfile(ned, archive)) self.check_textfile(output, expected_output) elif check == Content.Multifile: txtfile = os.path.join(output, 't.txt') self.check_textfile(txtfile, 't.txt') txtfile2 = os.path.join(output, 't2.txt') self.check_textfile(txtfile2, 't2.txt') def check_directory (self, dirname, expectedname): """Check that directory exists.""" self.assertTrue(os.path.isdir(dirname), dirname) self.assertEqual(os.path.basename(dirname), expectedname) def check_textfile (self, filename, expectedname): """Check that filename exists and has the default content.""" self.assertTrue(os.path.isfile(filename), repr(filename)) self.assertEqual(os.path.basename(filename), expectedname) self.assertEqual(get_filecontent(filename), TextFileContent) def archive_list (self, filename): """Test archive listing.""" archive = os.path.join(datadir, filename) for verbosity in (-1, 0, 1, 2): patoolib.list_archive(archive, program=self.program, verbosity=verbosity, interactive=False) def archive_test (self, filename): """Test archive testing.""" archive = os.path.join(datadir, filename) for verbosity in (-1, 0, 1, 2): patoolib.test_archive(archive, program=self.program, verbosity=verbosity, interactive=False) def archive_create (self, archive, srcfiles=None, check=Content.Recursive): """Test archive creation.""" if srcfiles is None: if check == Content.Recursive: srcfiles = ('t',) elif check == Content.Singlefile: srcfiles = ('t.txt',) elif check == Content.Multifile: srcfiles = ('t.txt', 't2.txt',) else: raise ValueError('invalid check value %r' % check) olddir = patoolib.util.chdir(datadir) try: # The format and compression arguments are needed for creating # archives with unusual file extensions. for verbosity in (-1, 0, 1, 2): self._archive_create(archive, srcfiles, program=self.program, verbosity=verbosity) finally: if olddir: os.chdir(olddir) def _archive_create (self, archive, srcfiles, program=None, verbosity=0): """Create archive from filename.""" for srcfile in srcfiles: self.assertFalse(os.path.isabs(srcfile)) self.assertTrue(os.path.exists(srcfile)) # create a temporary directory for creation tmpdir = patoolib.util.tmpdir(dir=basedir) try: archive = os.path.join(tmpdir, archive) self.assertTrue(os.path.isabs(archive), "archive path is not absolute: %r" % archive) patoolib.create_archive(archive, srcfiles, verbosity=verbosity, interactive=False, program=program) self.assertTrue(os.path.isfile(archive)) self.check_created_archive_with_test(archive) self.check_created_archive_with_diff(archive, srcfiles) finally: shutil.rmtree(tmpdir) def check_created_archive_with_test(self, archive): command = patoolib.test_archive program = self.program # special case for programs that cannot test what they create if self.program in ('compress', 'py_gzip'): program = 'gzip' elif self.program == 'py_bz2': program = 'bzip2' elif self.program == 'py_lzma': program = 'xz' elif self.program == 'zip': program = 'unzip' elif self.program in ('rzip', 'shorten'): program = 'py_echo' command = patoolib.list_archive elif self.program == 'lcab': program = 'cabextract' elif self.program == 'genisoimage': program = '7z' elif self.program == 'shar': return command(archive, program=program) def check_created_archive_with_diff(self, archive, srcfiles): """Extract created archive again and compare the contents.""" # diff srcfile and output diff = patoolib.util.find_program("diff") if not diff: return program = self.program # special case for programs that cannot extract what they create if self.program == 'compress': program = 'gzip' elif self.program == 'zip': program = 'unzip' elif self.program == 'lcab': program = 'cabextract' elif self.program == 'shar': program = 'unshar' elif self.program == 'genisoimage': program = '7z' tmpdir = patoolib.util.tmpdir(dir=basedir) try: olddir = patoolib.util.chdir(tmpdir) try: output = patoolib.extract_archive(archive, program=program, interactive=False) if len(srcfiles) == 1: source = os.path.join(datadir, srcfiles[0]) patoolib.util.run_checked([diff, "-urN", source, output]) else: for srcfile in srcfiles: source = os.path.join(datadir, srcfile) target = os.path.join(output, srcfile) patoolib.util.run_checked([diff, "-urN", source, target]) finally: if olddir: os.chdir(olddir) finally: shutil.rmtree(tmpdir) def get_filecontent(filename): """Get file data as text.""" with open(filename) as fo: return fo.read() def get_nonexisting_directory(basedir): """Note: this is _not_ intended to be used to create a directory.""" d = os.path.join(basedir, "foo") while os.path.exists(d): d += 'a' if len(d) > 100: # wtf raise ValueError('could not construct unique directory name at %r' % basedir) return d patool-1.10/tests/archives/test_7z.py000066400000000000000000000112641263321134500176540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program, needs_codec class Test7z (ArchiveTest): program = '7z' @needs_program(program) def test_7z (self): self.archive_commands('t .7z') self.archive_commands('t.zip') self.archive_commands('t.txt.xz', check=Content.Singlefile) self.archive_list('t.txt.gz') self.archive_list('t.txt.bz2') self.archive_list('t.txt.lzma') self.archive_list('t.jar') self.archive_list('t.txt.Z') self.archive_list('t.cab') self.archive_list('t.arj') self.archive_list('t.cpio') self.archive_list('t.rpm') self.archive_list('t.deb') self.archive_list('t.iso') self.archive_list('t.vhd') self.archive_extract('t.txt.gz', check=Content.Singlefile) self.archive_extract('t.txt.bz2', check=Content.Singlefile) self.archive_extract('t.txt.lzma', check=Content.Singlefile) self.archive_extract('t.jar', check=None) self.archive_extract('t.txt.Z', check=Content.Singlefile) self.archive_extract('t.cab') self.archive_extract('t.arj') self.archive_extract('t.cpio') self.archive_extract('t.rpm', check=None) self.archive_extract('t.deb', check=None) self.archive_extract('t.iso') self.archive_extract('t.vhd', check=None) self.archive_test('t.txt.gz') self.archive_test('t.txt.bz2') self.archive_test('t.txt.lzma') self.archive_test('t.jar') self.archive_test('t.txt.Z') self.archive_test('t.cab') self.archive_test('t.arj') self.archive_test('t.cpio') self.archive_test('t.rpm') self.archive_test('t.deb') self.archive_test('t.iso') self.archive_test('t.vhd') self.archive_create('t.txt.gz', check=Content.Singlefile) self.archive_create('t.txt.bz2', check=Content.Singlefile) @needs_codec(program, 'rar') def test_7z_rar (self): # only succeeds with the rar module for 7z installed self.archive_list('t.rar') self.archive_extract('t.rar') self.archive_test('t.rar') @needs_program('file') @needs_program(program) def test_7z_file (self): self.archive_commands('t.7z.foo', skip_create=True) self.archive_commands('t.zip.foo', skip_create=True) self.archive_commands('t.txt.xz.foo', skip_create=True, check=Content.Singlefile) self.archive_list('t.txt.gz.foo') self.archive_list('t.txt.bz2.foo') self.archive_list('t.jar.foo') self.archive_list('t.txt.Z.foo') self.archive_list('t.cab.foo') self.archive_list('t.arj.foo') self.archive_list('t.cpio.foo') self.archive_list('t.rpm.foo') self.archive_list('t.deb.foo') self.archive_list('t.iso.foo') self.archive_extract('t.txt.gz.foo', check=None) self.archive_extract('t.txt.bz2.foo', check=Content.Singlefile) self.archive_extract('t.jar.foo', check=None) self.archive_extract('t.txt.Z.foo', check=Content.Singlefile) self.archive_extract('t.cab.foo') self.archive_extract('t.arj.foo') self.archive_extract('t.cpio.foo') self.archive_extract('t.rpm.foo', check=None) self.archive_extract('t.deb.foo', check=None) self.archive_extract('t.iso.foo') self.archive_test('t.txt.gz.foo') self.archive_test('t.txt.bz2.foo') self.archive_test('t.jar.foo') self.archive_test('t.txt.Z.foo') self.archive_test('t.cab.foo') self.archive_test('t.arj.foo') self.archive_test('t.cpio.foo') self.archive_test('t.rpm.foo') self.archive_test('t.deb.foo') self.archive_test('t.iso.foo') @needs_program('file') @needs_codec(program, 'rar') def test_7z_rar_file (self): # only succeeds with the rar module for 7z installed self.archive_list('t.rar.foo') self.archive_extract('t.rar.foo') self.archive_test('t.rar.foo') patool-1.10/tests/archives/test_7za.py000066400000000000000000000052511263321134500200140ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class Test7za (ArchiveTest): program = '7za' @needs_program(program) def test_p7azip (self): self.archive_commands('t .7z') self.archive_commands('t.zip') self.archive_list('t.txt.gz') self.archive_list('t.txt.bz2') self.archive_list('t.jar') self.archive_list('t.txt.Z') self.archive_list('t.cab') self.archive_list('t.rpm') self.archive_extract('t.txt.gz', check=Content.Singlefile) self.archive_extract('t.txt.bz2', check=Content.Singlefile) self.archive_extract('t.jar', check=None) self.archive_extract('t.txt.Z', check=Content.Singlefile) self.archive_extract('t.cab') self.archive_test('t.txt.gz') self.archive_test('t.txt.bz2') self.archive_test('t.jar') self.archive_test('t.txt.Z') self.archive_test('t.cab') self.archive_create('t.txt.gz', check=Content.Singlefile) self.archive_create('t.txt.bz2', check=Content.Singlefile) @needs_program('file') @needs_program(program) def test_7za_file (self): self.archive_commands('t.7z.foo', skip_create=True) self.archive_commands('t.zip.foo', skip_create=True) self.archive_list('t.txt.gz.foo') self.archive_list('t.txt.bz2.foo') self.archive_list('t.jar.foo') self.archive_list('t.txt.Z.foo') self.archive_list('t.cab.foo') self.archive_list('t.rpm.foo') self.archive_extract('t.txt.gz.foo', check=None) self.archive_extract('t.txt.bz2.foo', check=Content.Singlefile) self.archive_extract('t.jar.foo', check=None) self.archive_extract('t.txt.Z.foo', check=Content.Singlefile) self.archive_extract('t.cab.foo') self.archive_test('t.txt.gz.foo') self.archive_test('t.txt.bz2.foo') self.archive_test('t.jar.foo') self.archive_test('t.txt.Z.foo') self.archive_test('t.cab.foo') patool-1.10/tests/archives/test_ar.py000066400000000000000000000022011263321134500177050ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program, needs_os class TestAr (ArchiveTest): program = 'ar' @needs_os('posix') @needs_program(program) def test_ar(self): self.archive_commands('t.txt.a', check=Content.Singlefile) @needs_os('posix') @needs_program('file') @needs_program(program) def test_ar_file(self): self.archive_commands('t.txt.a.foo', skip_create=True, check=None) patool-1.10/tests/archives/test_arc.py000066400000000000000000000021241263321134500200540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestArc(ArchiveTest): program = 'arc' @needs_program(program) def test_arc(self): self.archive_commands('t.arc', check=Content.Multifile) @needs_program('file') @needs_program(program) def test_arc_file(self): self.archive_commands('t.arc.foo', check=Content.Multifile, skip_create=True) patool-1.10/tests/archives/test_archmage.py000066400000000000000000000021701263321134500210570ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestArchmage (ArchiveTest): program = 'archmage' @needs_program(program) def test_archmage (self): self.archive_extract('t.chm', check=None) self.archive_test('t.chm') @needs_program('file') @needs_program(program) def test_archmage_file (self): self.archive_extract('t.chm.foo', check=None) self.archive_test('t.chm.foo') patool-1.10/tests/archives/test_arj.py000066400000000000000000000020321263321134500200610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestArj (ArchiveTest): program = 'arj' @needs_program(program) def test_arj(self): self.archive_commands('t.arj') @needs_program('file') @needs_program(program) def test_arj_file(self): self.archive_commands('t.arj.foo', skip_create=True) patool-1.10/tests/archives/test_bsdcpio.py000066400000000000000000000020541263321134500207340ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestBsdcpio (ArchiveTest): program = 'bsdcpio' @needs_program(program) def test_bsdcpio(self): self.archive_commands('t.cpio') @needs_program('file') @needs_program(program) def test_bsdcpio_file(self): self.archive_commands('t.cpio.foo', skip_create=True) patool-1.10/tests/archives/test_bsdtar.py000066400000000000000000000063411263321134500205730ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program, needs_codec class TestBsdtar (ArchiveTest): program = 'bsdtar' @needs_program(program) def test_bsdtar (self): self.archive_commands('t.tar') @needs_codec(program, 'gzip') def test_bsdtar_gz (self): self.archive_commands('t.tar.gz') self.archive_commands('t.tgz') @needs_program(program) @needs_program('compress') def test_bsdtar_z (self): self.archive_commands('t.tar.Z') self.archive_commands('t.taz') @needs_codec(program, 'bzip2') def test_bsdtar_bz2 (self): self.archive_commands('t.tar.bz2') self.archive_commands('t.tbz2') @needs_codec(program, 'lzma') def test_bsdtar_lzma (self): self.archive_commands('t.tar.lzma') # bsdtar cannot read archives created with tar and lzip #@needs_program(program) #@needs_program('lzip') #def test_bsdtar_lzip (self): # self.archive_commands('t.tar.lz') @needs_codec(program, 'xz') def test_bsdtar_xz (self): self.archive_commands('t.tar.xz') @needs_program('file') @needs_program(program) def test_bsdtar_file (self): self.archive_commands('t.tar.foo', skip_create=True) @needs_program('file') @needs_codec(program, 'gzip') def test_bsdtar_gz_file (self): self.archive_commands('t.tar.gz.foo', skip_create=True) self.archive_commands('t.tgz.foo', skip_create=True) @needs_program('file') @needs_codec(program, 'compress') def test_bsdtar_z_file (self): self.archive_commands('t.tar.Z.foo', skip_create=True) self.archive_commands('t.taz.foo', skip_create=True) @needs_program('file') @needs_codec(program, 'bzip2') def test_bsdtar_bz2_file (self): self.archive_commands('t.tar.bz2.foo', skip_create=True) self.archive_commands('t.tbz2.foo', skip_create=True) # file(1) does not recognize .lzma files (at least not with --uncompress) #@needs_program('file') #@needs_codec(program, 'lzma') #def test_bsdtar_lzma_file (self): # self.archive_commands('t.tar.lzma.foo', skip_create=True) # bsdtar cannot read archives created with tar and lzip #@needs_program('lzip') #@needs_program('file') #@needs_codec(program, 'lzip') #def test_bsdtar_lzip_file (self): # self.archive_commands('t.tar.lz.foo', skip_create=True) @needs_program('file') @needs_codec(program, 'xz') def test_bsdtar_xz_file (self): self.archive_commands('t.tar.xz.foo', skip_create=True) patool-1.10/tests/archives/test_bzip2.py000066400000000000000000000023521263321134500203400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestBzip2 (ArchiveTest): program = 'bzip2' @needs_program(program) def test_bzip2 (self): self.archive_extract('t.txt.bz2', check=Content.Singlefile) self.archive_test('t.txt.bz2') self.archive_create('t.txt.bz2', check=Content.Singlefile) @needs_program('file') @needs_program(program) def test_bzip2_file (self): self.archive_extract('t.txt.bz2.foo', check=Content.Singlefile) self.archive_test('t.txt.bz2.foo') patool-1.10/tests/archives/test_cabextract.py000066400000000000000000000022051263321134500214270ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestCabextract (ArchiveTest): program = 'cabextract' @needs_program(program) def test_cabextract (self): self.archive_list('t.cab') self.archive_extract('t.cab', check=None) @needs_program('file') @needs_program(program) def test_cabextract_file(self): self.archive_list('t.cab.foo') self.archive_extract('t.cab.foo', check=None) patool-1.10/tests/archives/test_chmlib.py000066400000000000000000000020621263321134500205460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestChmlib (ArchiveTest): program = 'extract_chmLib' @needs_program(program) def test_archmage (self): self.archive_extract('t.chm', check=None) @needs_program('file') @needs_program(program) def test_archmage_file (self): self.archive_extract('t.chm.foo', check=None) patool-1.10/tests/archives/test_clzip.py000066400000000000000000000023431263321134500204330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestClzip (ArchiveTest): program = 'clzip' @needs_program(program) def test_clzip(self): self.archive_test('t.txt.lz') self.archive_extract('t.txt.lz', check=Content.Singlefile) self.archive_create('t.txt.lz', check=Content.Singlefile) @needs_program('file') @needs_program(program) def test_clzip_file(self): self.archive_test('t.txt.lz.foo') self.archive_extract('t.txt.lz.foo', check=Content.Singlefile) patool-1.10/tests/archives/test_compress.py000066400000000000000000000016721263321134500211510ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestCompress (ArchiveTest): program = 'compress' @needs_program(program) def test_compress (self): self.archive_create('t.txt.Z', check=Content.Singlefile) patool-1.10/tests/archives/test_cpio.py000066400000000000000000000020401263321134500202360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestCpio (ArchiveTest): program = 'cpio' @needs_program(program) def test_cpio(self): self.archive_commands('t.cpio') @needs_program('file') @needs_program(program) def test_cpio_file(self): self.archive_commands('t.cpio.foo', skip_create=True) patool-1.10/tests/archives/test_dpkg.py000066400000000000000000000022721263321134500202400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestDpkg (ArchiveTest): program = 'dpkg-deb' @needs_program(program) def test_dpkg(self): self.archive_list('t.deb') self.archive_extract('t.deb', check=None) self.archive_test('t.deb') @needs_program('file') @needs_program(program) def test_dpkg_file(self): self.archive_list('t.deb.foo') self.archive_extract('t.deb.foo', check=None) self.archive_test('t.deb.foo') patool-1.10/tests/archives/test_flac.py000066400000000000000000000022521263321134500202160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestFlac (ArchiveTest): program = 'flac' @needs_program(program) def test_flac(self): self.archive_extract('t.flac', check=None) self.archive_test('t.flac') self.archive_create('t.flac', srcfiles=("t.wav",)) @needs_program('file') @needs_program(program) def test_flac_file(self): self.archive_extract('t.flac.foo', check=None) self.archive_test('t.flac.foo') patool-1.10/tests/archives/test_genisoimage.py000066400000000000000000000017201263321134500215770ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2013-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestGenisoimage(ArchiveTest): program = 'genisoimage' # needs 7z for testing @needs_program('7z') @needs_program(program) def test_genisoimage(self): self.archive_create('t.iso') patool-1.10/tests/archives/test_gzip.py000066400000000000000000000023341263321134500202630ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestGzip (ArchiveTest): program = 'gzip' @needs_program(program) def test_gzip (self): self.archive_commands('t.txt.gz', check=Content.Singlefile) self.archive_extract('t.txt.Z', check=Content.Singlefile) @needs_program('file') @needs_program(program) def test_gzip_file(self): self.archive_commands('t.txt.gz.foo', skip_create=True, check=None) self.archive_extract('t.txt.Z.foo', check=Content.Singlefile) patool-1.10/tests/archives/test_isoinfo.py000066400000000000000000000017631263321134500207650ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2013-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestIsoinfo(ArchiveTest): program = 'isoinfo' @needs_program(program) def test_isoinfo(self): self.archive_list('t.iso') @needs_program(program) def test_isoinfo_file(self): self.archive_list('t.iso.foo') patool-1.10/tests/archives/test_lbzip2.py000066400000000000000000000023561263321134500205200ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestLbzip2 (ArchiveTest): program = 'lbzip2' @needs_program(program) def test_lbzip2 (self): self.archive_extract('t.txt.bz2', check=Content.Singlefile) self.archive_test('t.txt.bz2') self.archive_create('t.txt.bz2', check=Content.Singlefile) @needs_program('file') @needs_program(program) def test_lbzip2_file (self): self.archive_extract('t.txt.bz2.foo', check=Content.Singlefile) self.archive_test('t.txt.bz2.foo') patool-1.10/tests/archives/test_lcab.py000066400000000000000000000016531263321134500202160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestLcab (ArchiveTest): program = 'lcab' @needs_program(program) @needs_program('cabextract') def test_lcab (self): self.archive_create('t.cab') patool-1.10/tests/archives/test_lha.py000066400000000000000000000020711263321134500200540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestLha (ArchiveTest): program = 'lha' @needs_program(program) def _test_lha(self): # XXX currently fails self.archive_commands('t.lha') @needs_program('file') @needs_program(program) def test_lha_file(self): self.archive_commands('t.lha.foo', skip_create=True) patool-1.10/tests/archives/test_lhasa.py000066400000000000000000000016151263321134500204030ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestLhasa (ArchiveTest): program = 'lhasa' @needs_program(program) def test_lhasa(self): self.archive_extract('t.lha') patool-1.10/tests/archives/test_lrzip.py000066400000000000000000000025271263321134500204560ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestLrzip (ArchiveTest): program = 'lrzip' @needs_program(program) def test_lrzip(self): self.archive_test('t.txt.lrz') self.archive_extract('t.txt.lrz', check=Content.Singlefile) self.archive_create('t.txt.lrz', check=Content.Singlefile) # file(1) does not recognize .lrz files #@needs_program('file') #@needs_program(program) #def test_lrzip_file(self): # self.archive_test('t.txt.lrz.foo') # self.archive_extract('t.txt.lrz.foo') # self.archive_create('t.txt.lrz.foo', format="lrzip", check=Content.Singlefile) patool-1.10/tests/archives/test_lzip.py000066400000000000000000000023371263321134500202730ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestLzip (ArchiveTest): program = 'lzip' @needs_program(program) def test_lzip(self): self.archive_test('t.txt.lz') self.archive_extract('t.txt.lz', check=Content.Singlefile) self.archive_create('t.txt.lz', check=Content.Singlefile) @needs_program('file') @needs_program(program) def test_lzip_file(self): self.archive_test('t.txt.lz.foo') self.archive_extract('t.txt.lz.foo', check=Content.Singlefile) patool-1.10/tests/archives/test_lzma.py000066400000000000000000000023711263321134500202560ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestLzma (ArchiveTest): program = 'lzma' @needs_program(program) def test_lzma(self): self.archive_test('t.txt.lzma') self.archive_extract('t.txt.lzma', check=Content.Singlefile) self.archive_create('t.txt.lzma', check=Content.Singlefile) # file(1) does not recognize .lzma files #@needs_program('file') #@needs_program(program) #def test_lzma_file(self): # self.archive_test('t.lzma.foo') # self.archive_extract('t.lzma.foo') patool-1.10/tests/archives/test_lzop.py000066400000000000000000000021431263321134500202740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestLzop (ArchiveTest): program = 'lzop' @needs_program(program) def test_lzop(self): self.archive_commands('t.txt.lzo', check=Content.Singlefile) @needs_program('file') @needs_program(program) def test_lzop_file(self): self.archive_commands('t.txt.lzo.foo', skip_create=True, check=Content.Singlefile) patool-1.10/tests/archives/test_mac.py000066400000000000000000000021731263321134500200530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestMac (ArchiveTest): program = 'mac' @needs_program(program) def test_mac(self): self.archive_extract('t.ape', check=None) self.archive_test('t.ape') self.archive_create('t.ape', srcfiles=("t.wav",)) @needs_program('file') @needs_program(program) def test_mac_file(self): self.archive_extract('t.ape.foo', check=None) patool-1.10/tests/archives/test_nomarch.py000066400000000000000000000023441263321134500207420ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestNomarch(ArchiveTest): program = 'nomarch' @needs_program(program) def test_nomarch(self): self.archive_test('t.arc') self.archive_list('t.arc') self.archive_extract('t.arc', check=Content.Multifile) @needs_program('file') @needs_program(program) def test_nomarch_file(self): self.archive_test('t.arc.foo') self.archive_list('t.arc.foo') self.archive_extract('t.arc.foo', check=Content.Multifile) patool-1.10/tests/archives/test_pbzip2.py000066400000000000000000000023561263321134500205240ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestPbzip2 (ArchiveTest): program = 'pbzip2' @needs_program(program) def test_pbzip2 (self): self.archive_extract('t.txt.bz2', check=Content.Singlefile) self.archive_test('t.txt.bz2') self.archive_create('t.txt.bz2', check=Content.Singlefile) @needs_program('file') @needs_program(program) def test_pbzip2_file (self): self.archive_extract('t.txt.bz2.foo', check=Content.Singlefile) self.archive_test('t.txt.bz2.foo') patool-1.10/tests/archives/test_pdlzip.py000066400000000000000000000023471263321134500206200ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestPdlzip (ArchiveTest): program = 'pdlzip' @needs_program(program) def test_pdlzip(self): self.archive_test('t.txt.lz') self.archive_extract('t.txt.lz', check=Content.Singlefile) self.archive_create('t.txt.lz', check=Content.Singlefile) @needs_program('file') @needs_program(program) def test_pdlzip_file(self): self.archive_test('t.txt.lz.foo') self.archive_extract('t.txt.lz.foo', check=Content.Singlefile) patool-1.10/tests/archives/test_pigz.py000066400000000000000000000021741263321134500202650ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestPigz (ArchiveTest): program = 'pigz' @needs_program(program) def test_pigz (self): self.archive_commands('t.txt.gz', check=Content.Singlefile) @needs_program('file') @needs_program(program) def test_pigz_file (self): self.archive_commands('t.txt.gz.foo', check=Content.Singlefile, skip_create=True, skip_test=True) patool-1.10/tests/archives/test_plzip.py000066400000000000000000000023431263321134500204500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestPlzip (ArchiveTest): program = 'plzip' @needs_program(program) def test_plzip(self): self.archive_test('t.txt.lz') self.archive_extract('t.txt.lz', check=Content.Singlefile) self.archive_create('t.txt.lz', check=Content.Singlefile) @needs_program('file') @needs_program(program) def test_plzip_file(self): self.archive_test('t.txt.lz.foo') self.archive_extract('t.txt.lz.foo', check=Content.Singlefile) patool-1.10/tests/archives/test_pybz2.py000066400000000000000000000022631263321134500203610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestPybz2 (ArchiveTest): program = 'py_bz2' @needs_program('bzip2') def test_py_bz2 (self): self.archive_extract('t.txt.bz2', check=Content.Singlefile) # bzip2 is used to test the created archive self.archive_create('t.txt.bz2', check=Content.Singlefile) @needs_program('file') def test_py_bz2_file (self): self.archive_extract('t.txt.bz2.foo', check=Content.Singlefile) patool-1.10/tests/archives/test_pyecho.py000066400000000000000000000032601263321134500206000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestPyecho (ArchiveTest): program = 'py_echo' def test_py_echo (self): self.archive_list('t.txt.bz2') self.archive_list('t.txt.Z') self.archive_list('t.txt.lzma') self.archive_list('t.txt.lz') self.archive_list('t.txt.lrz') self.archive_list('t.txt.rz') self.archive_list('t.ape') self.archive_list('t.shn') self.archive_list('t.flac') @needs_program('file') def test_py_echo_file (self): self.archive_list('t.txt.bz2.foo') self.archive_list('t.txt.Z.foo') # file(1) does not recognize .lzma files #self.archive_list('t.lzma.foo') self.archive_list('t.txt.lz.foo') self.archive_list('t.txt.lrz') self.archive_list('t.txt.rz.foo') self.archive_list('t.ape.foo') # file(1) does not recognize .shn files #self.archive_list('t.shn.foo') self.archive_list('t.flac.foo') patool-1.10/tests/archives/test_pygzip.py000066400000000000000000000022621263321134500206340ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestPygzip (ArchiveTest): program = 'py_gzip' @needs_program('gzip') def test_py_gzip (self): self.archive_extract('t.txt.gz', check=Content.Singlefile) # gzip is used to test the created archive self.archive_create('t.txt.gz', check=Content.Singlefile) @needs_program('file') def test_py_gzip_file (self): self.archive_extract('t.txt.gz.foo', check=Content.Singlefile) patool-1.10/tests/archives/test_pylzma.py000066400000000000000000000027021263321134500206250ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2013-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program, needs_module class TestPylzma (ArchiveTest): program = 'py_lzma' @needs_program('xz') @needs_module('lzma') def test_py_lzma (self): self.archive_extract('t.txt.lzma', check=Content.Singlefile) self.archive_extract('t.txt.xz', check=Content.Singlefile) # xz is used to test the created archive self.archive_create('t.txt.lzma', check=Content.Singlefile) self.archive_create('t.txt.xz', check=Content.Singlefile) @needs_program('file') @needs_module('lzma') def test_py_lzma_file (self): self.archive_extract('t.txt.lzma.foo', check=Content.Singlefile) self.archive_extract('t.txt.xz.foo', check=Content.Singlefile) patool-1.10/tests/archives/test_pytarfile.py000066400000000000000000000031611263321134500213100ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestPytarfile (ArchiveTest): program = 'py_tarfile' def test_py_tarfile (self): self.archive_commands('t.tar') def test_py_tarfile_gz (self): self.archive_commands('t.tar.gz') self.archive_commands('t.tgz') def test_py_tarfile_bz2 (self): self.archive_commands('t.tar.bz2') self.archive_commands('t.tbz2') @needs_program('file') def test_py_tarfile_file (self): self.archive_commands('t.tar.foo', skip_create=True) @needs_program('file') def test_py_tarfile_gz_file (self): self.archive_commands('t.tar.gz.foo', skip_create=True) self.archive_commands('t.tgz.foo', skip_create=True) @needs_program('file') def test_py_tarfile_bz2_file (self): self.archive_commands('t.tar.bz2.foo', skip_create=True) self.archive_commands('t.tbz2.foo', skip_create=True) patool-1.10/tests/archives/test_pyzipfile.py000066400000000000000000000017751263321134500213350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestPyzipfile (ArchiveTest): program = 'py_zipfile' def test_py_zipfile(self): self.archive_commands('t.zip') @needs_program('file') def test_py_zipfile_file(self): self.archive_commands('t.zip.foo', skip_create=True) patool-1.10/tests/archives/test_rar.py000066400000000000000000000020321263321134500200710ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestRar (ArchiveTest): program = 'rar' @needs_program(program) def test_rar(self): self.archive_commands('t.rar') @needs_program('file') @needs_program(program) def test_rar_file(self): self.archive_commands('t.rar.foo', skip_create=True) patool-1.10/tests/archives/test_rpm.py000066400000000000000000000026141263321134500201110ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestRpm (ArchiveTest): program = 'rpm' @needs_program('rpm') def test_rpm(self): self.archive_list('t.rpm') # The rpm test fails on non-rpm system with missing dependencies. # I am too lazy to build a tiny rpm with one file # and no dependency. #self.archive_test('t.rpm') @needs_program('file') @needs_program(program) def test_rpm_file(self): self.archive_list('t.rpm.foo') # The rpm test fails on non-rpm system with missing dependencies. # I am too lazy to build a tiny rpm with one file # and no dependency. #self.archive_test('t.rpm.foo') patool-1.10/tests/archives/test_rpm2cpio.py000066400000000000000000000021501263321134500210410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestRpm2cpio (ArchiveTest): program = 'rpm2cpio' @needs_program(program) @needs_program('cpio') def test_rpm2cpio(self): self.archive_extract('t.rpm', check=None) @needs_program('file') @needs_program(program) @needs_program('cpio') def test_rpm2cpio_file(self): self.archive_extract('t.rpm.foo', check=None) patool-1.10/tests/archives/test_rzip.py000066400000000000000000000021641263321134500202770ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestRzip (ArchiveTest): program = 'rzip' @needs_program(program) def test_rzip(self): self.archive_extract('t.txt.rz', check=Content.Singlefile) self.archive_create('t.txt.rz', check=Content.Singlefile) @needs_program(program) def test_rzip_file(self): self.archive_extract('t.txt.rz.foo', check=Content.Singlefile) patool-1.10/tests/archives/test_shar.py000066400000000000000000000017121263321134500202460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestShar (ArchiveTest): program = 'shar' @needs_program(program) @needs_program('unshar') def test_shar(self): self.archive_create('t.shar', check=Content.Singlefile) patool-1.10/tests/archives/test_shorten.py000066400000000000000000000022301263321134500207670ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestShorten (ArchiveTest): program = 'shorten' @needs_program(program) def test_shorten(self): self.archive_extract('t.shn', check=None) self.archive_create('t.shn', srcfiles=("t.wav",)) # file(1) does not recognize .shn files #@needs_program('file') #@needs_program(program) #def test_shorten_file(self): # self.archive_extract('t.shn.foo', check=None) patool-1.10/tests/archives/test_star.py000066400000000000000000000060041263321134500202610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program, needs_codec class TestStar (ArchiveTest): program = 'star' @needs_program(program) def test_star (self): self.archive_commands('t.tar') @needs_codec(program, 'gzip') def test_star_gz (self): self.archive_commands('t.tar.gz') self.archive_commands('t.tgz') @needs_program(program) @needs_program('compress') def test_star_z (self): self.archive_commands('t.tar.Z') self.archive_commands('t.taz') @needs_codec(program, 'bzip2') def test_star_bz2 (self): self.archive_commands('t.tar.bz2') self.archive_commands('t.tbz2') @needs_codec(program, 'lzma') def test_star_lzma (self): self.archive_commands('t.tar.lzma') @needs_program(program) @needs_program('lzip') def test_star_lzip (self): self.archive_commands('t.tar.lz') @needs_codec(program, 'xz') def test_star_xz (self): self.archive_commands('t.tar.xz') @needs_program('file') @needs_program(program) def test_star_file (self): self.archive_commands('t.tar.foo', skip_create=True) @needs_program('file') @needs_codec(program, 'gzip') def test_star_gz_file (self): self.archive_commands('t.tar.gz.foo', skip_create=True) self.archive_commands('t.tgz.foo', skip_create=True) @needs_program('file') @needs_codec(program, 'compress') def test_star_z_file (self): self.archive_commands('t.tar.Z.foo', skip_create=True) self.archive_commands('t.taz.foo', skip_create=True) @needs_program('file') @needs_codec(program, 'bzip2') def test_star_bz2_file (self): self.archive_commands('t.tar.bz2.foo', skip_create=True) self.archive_commands('t.tbz2.foo', skip_create=True) # file(1) does not recognize .lzma files #@needs_program('file') #@needs_codec(program, 'lzma') #def test_star_lzma_file (self): # self.archive_commands('t.tar.lzma.foo', skip_create=True) @needs_program('file') @needs_codec(program, 'lzip') def test_star_lzip_file (self): self.archive_commands('t.tar.lz.foo', skip_create=True) @needs_program('file') @needs_codec(program, 'xz') def test_star_xz_file (self): self.archive_commands('t.tar.xz.foo', skip_create=True) patool-1.10/tests/archives/test_tar.py000066400000000000000000000065201263321134500201010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program, needs_codec class TestTar (ArchiveTest): program = 'tar' @needs_program(program) def test_tar (self): self.archive_commands('t.tar') @needs_codec(program, 'gzip') def test_tar_gz (self): self.archive_commands('t.tar.gz') self.archive_commands('t.tgz') @needs_program(program) @needs_program('compress') def test_tar_z (self): self.archive_commands('t.tar.Z') self.archive_commands('t.taz') @needs_codec(program, 'bzip2') def test_tar_bz2 (self): self.archive_commands('t.tar.bz2') self.archive_commands('t.tbz2') @needs_codec(program, 'lzma') def test_tar_lzma (self): self.archive_commands('t.tar.lzma') # even though clzip would support extracting .lz files, the # file(1) --uncompress command does not use it for achive detection @needs_program(program) @needs_program('lzip') def test_tar_lzip (self): self.archive_commands('t.tar.lz') @needs_codec(program, 'xz') def test_tar_xz (self): self.archive_commands('t.tar.xz') @needs_program('file') @needs_program(program) def test_tar_file (self): self.archive_commands('t.tar.foo', skip_create=True) @needs_program('file') @needs_codec(program, 'gzip') def test_tar_gz_file (self): self.archive_commands('t.tar.gz.foo', skip_create=True) self.archive_commands('t.tgz.foo', skip_create=True) @needs_program('file') @needs_codec(program, 'compress') def test_tar_z_file (self): self.archive_commands('t.tar.Z.foo', skip_create=True) self.archive_commands('t.taz.foo', skip_create=True) @needs_program('file') @needs_codec(program, 'bzip2') def test_tar_bz2_file (self): self.archive_commands('t.tar.bz2.foo', skip_create=True) self.archive_commands('t.tbz2.foo', skip_create=True) # file(1) does not recognize .lzma files (at least not with --uncompress) #@needs_program('file') #@needs_codec(program, 'lzma') #def test_tar_lzma_file (self): # self.archive_commands('t.tar.lzma.foo', format="tar", compression="lzma") # even though clzip would support extracting .lz files, the # file(1) --uncompress command does not use it for achive detection @needs_program('lzip') @needs_program('file') @needs_codec(program, 'lzip') def test_tar_lzip_file (self): self.archive_commands('t.tar.lz.foo', skip_create=True) @needs_program('file') @needs_codec(program, 'xz') def test_tar_xz_file (self): self.archive_commands('t.tar.xz.foo', skip_create=True) patool-1.10/tests/archives/test_unace.py000066400000000000000000000022421263321134500204030ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestUnace (ArchiveTest): program = 'unace' @needs_program(program) def test_unace(self): self.archive_list('t.ace') self.archive_test('t.ace') self.archive_extract('t.ace') @needs_program('file') @needs_program(program) def test_unace_file(self): self.archive_list('t.ace.foo') self.archive_test('t.ace.foo') self.archive_extract('t.ace.foo') patool-1.10/tests/archives/test_unadf.py000066400000000000000000000025131263321134500204060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program, skip_on_travis class TestUnadf (ArchiveTest): program = 'unadf' # On a Travis CI build the test fails. @skip_on_travis() @needs_program(program) def test_unadf(self): self.archive_extract('t.adf', check=None) self.archive_list('t.adf') self.archive_test('t.adf') # On a Travis CI build the test fails. @skip_on_travis() @needs_program('file') @needs_program(program) def test_unadf_file(self): self.archive_extract('t.adf.foo', check=None) self.archive_test('t.adf.foo') self.archive_list('t.adf.foo') patool-1.10/tests/archives/test_unalz.py000066400000000000000000000023241263321134500204420ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestUnalz (ArchiveTest): program = 'unalz' @needs_program(program) def test_unalz(self): self.archive_test('t.alz') self.archive_list('t.alz') self.archive_extract('t.alz') # file(1) does not recognize .alz files #@needs_program('file') #@needs_program(program) #def test_unalz_file(self): # self.archive_test('t.alz.foo') # self.archive_list('t.alz.foo') # self.archive_extract('t.alz.foo') patool-1.10/tests/archives/test_uncompressreal.py000066400000000000000000000021561263321134500223560ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestUncompressReal (ArchiveTest): program = 'uncompress.real' @needs_program(program) def test_uncompress (self): self.archive_extract('t.txt.Z', check=Content.Singlefile) @needs_program('file') @needs_program(program) def test_uncompress_file (self): self.archive_extract('t.txt.Z.foo', check=Content.Singlefile) patool-1.10/tests/archives/test_unrar.py000066400000000000000000000021301263321134500204330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestUnrar (ArchiveTest): program = 'unrar' @needs_program(program) def test_unrar(self): self.archive_list('t.rar') self.archive_extract('t.rar') @needs_program('file') @needs_program(program) def test_unrar_file(self): self.archive_list('t.rar.foo') self.archive_extract('t.rar.foo') patool-1.10/tests/archives/test_unshar.py000066400000000000000000000016341263321134500206140ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestUnshar (ArchiveTest): program = 'unshar' @needs_program(program) def test_unshar(self): self.archive_extract('t.shar', check=None) patool-1.10/tests/archives/test_unzip.py000066400000000000000000000035151263321134500204610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestUnzip (ArchiveTest): program = 'unzip' @needs_program(program) def test_unzip (self): self.archive_extract('t.zip', check=None) self.archive_list('t.zip') self.archive_test('t.zip') self.archive_extract('t.jar', check=None) self.archive_list('t.jar') self.archive_test('t.jar') self.archive_extract('t.epub', check=None) self.archive_list('t.epub') self.archive_test('t.epub') self.archive_list('t.apk') self.archive_test('t.apk') @needs_program('file') @needs_program(program) def test_unzip_file (self): self.archive_extract('t.zip.foo', check=None) self.archive_list('t.zip.foo') self.archive_test('t.zip.foo') self.archive_extract('t.jar.foo', check=None) self.archive_list('t.jar.foo') self.archive_test('t.jar.foo') self.archive_extract('t.epub.foo', check=None) self.archive_list('t.epub.foo') self.archive_test('t.epub.foo') self.archive_list('t.apk.foo') self.archive_test('t.apk.foo') patool-1.10/tests/archives/test_xdms.py000066400000000000000000000023171263321134500202660ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestXdms (ArchiveTest): program = 'xdms' @needs_program(program) def test_xdms(self): self.archive_extract('t.dms', check=None) self.archive_list('t.dms') self.archive_test('t.dms') # xdms(1) cannot handle files without '.dms' extension #@needs_program(program) #def test_xdms_file(self): # self.archive_extract('t.dms.foo') # self.archive_test('t.dms.foo') # self.archive_list('t.dms.foo') patool-1.10/tests/archives/test_xz.py000066400000000000000000000025261263321134500177560ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestXz (ArchiveTest): program = 'xz' @needs_program(program) def test_xz(self): self.archive_commands('t.txt.xz', check=Content.Singlefile) @needs_program('file') @needs_program(program) def test_xz_file(self): self.archive_test('t.txt.xz.foo') self.archive_extract('t.txt.xz.foo', check=Content.Singlefile) @needs_program(program) def test_lzma(self): self.archive_test('t.txt.lzma') self.archive_extract('t.txt.lzma', check=Content.Singlefile) self.archive_create('t.txt.lzma', check=Content.Singlefile) patool-1.10/tests/archives/test_zip.py000066400000000000000000000020461263321134500201140ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest from .. import needs_program class TestZip (ArchiveTest): program = 'zip' @needs_program(program) def test_zip (self): self.archive_create('t.zip') self.archive_test('t.zip') @needs_program('file') @needs_program(program) def test_zip_file (self): self.archive_test('t.zip.foo') patool-1.10/tests/archives/test_zoo.py000066400000000000000000000023461263321134500201240ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program, skip_on_travis class TestZoo (ArchiveTest): program = 'zoo' # On a Travis CI build the test fails. @skip_on_travis() @needs_program(program) def test_zoo(self): self.archive_commands('t.zoo', check=Content.Multifile) # On a Travis CI build the test fails. @skip_on_travis() @needs_program('file') @needs_program(program) def test_zoo_file(self): self.archive_commands('t.zoo.foo', skip_create=True, check=Content.Multifile) patool-1.10/tests/archives/test_zopfli.py000066400000000000000000000021231263321134500206110ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2013-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestZopfli(ArchiveTest): program = 'zopfli' @needs_program(program) def test_zopfli(self): self.archive_extract('t.txt.gz', check=Content.Singlefile) @needs_program('file') @needs_program(program) def test_zopfli_file(self): self.archive_extract('t.txt.gz.foo', check=Content.Singlefile) patool-1.10/tests/archives/test_zpaq.py000066400000000000000000000022261263321134500202650ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import ArchiveTest, Content from .. import needs_program class TestZpaq(ArchiveTest): program = 'zpaq' @needs_program(program) def test_zpaq(self): self.archive_commands('t.zpaq', check=Content.Multifile) @needs_program('file') @needs_program(program) def test_zpaq_file(self): self.archive_extract('t.zpaq.foo', check=Content.Multifile) self.archive_test('t.zpaq.foo') self.archive_list('t.zpaq.foo') patool-1.10/tests/test_config.py000066400000000000000000000037371263321134500167630ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest import patoolib class TestConfiguration (unittest.TestCase): def test_archive_mimetypes (self): # test that each format has a MIME type self.assertEqual(set(patoolib.ArchiveFormats), set(patoolib.ArchiveMimetypes.values())) def test_archive_programs (self): # test that the key is an archive format self.assertEqual(set(patoolib.ArchiveFormats), set(patoolib.ArchivePrograms.keys())) for commands in patoolib.ArchivePrograms.values(): for command in commands: if command is not None: self.assertTrue(command in patoolib.ArchiveCommands) def test_compression_programs (self): self.assertTrue(set(patoolib.ArchiveCompressions).issubset( set(patoolib.ArchiveFormats))) def test_encoding_mimes (self): self.assertEqual(set(patoolib.ArchiveCompressions), set(patoolib.util.Encoding2Mime.keys())) for mime in patoolib.util.Encoding2Mime.values(): self.assertTrue(mime in patoolib.ArchiveMimetypes) def test_filetext_mime (self): for mime in patoolib.util.FileText2Mime.values(): self.assertTrue(mime in patoolib.ArchiveMimetypes) patool-1.10/tests/test_create.py000066400000000000000000000024671263321134500167600ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2013-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest import os import sys import shutil from patoolib import util from . import basedir, datadir, needs_program, patool_cmd class ArchiveCreateTest (unittest.TestCase): @needs_program('7z') def test_create(self): tmpdir = util.tmpdir(dir=basedir) try: files = [os.path.join(datadir, "t"), os.path.join(datadir, "t.txt")] archive = os.path.join(tmpdir, "t.7z") cmd = [sys.executable, patool_cmd, "-vv", "--non-interactive", "create", archive] cmd.extend(files) util.run_checked(cmd) finally: shutil.rmtree(tmpdir) patool-1.10/tests/test_diff.py000066400000000000000000000022431263321134500164150ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest import os import sys from patoolib.util import run_checked from . import datadir, needs_program, patool_cmd class ArchiveDiffTest (unittest.TestCase): @needs_program('diff') @needs_program('tar') @needs_program('unzip') def test_diff (self): archive1 = os.path.join(datadir, "t.tar") archive2 = os.path.join(datadir, "t.zip") run_checked([sys.executable, patool_cmd, "-vv", "--non-interactive", "diff", archive1, archive2]) patool-1.10/tests/test_extract.py000066400000000000000000000023131263321134500171550ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2013-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest import os import sys import shutil from patoolib import util from . import basedir, datadir, needs_program, patool_cmd class ArchiveExtractTest (unittest.TestCase): @needs_program('7z') def test_extract(self): tmpdir = util.tmpdir(dir=basedir) try: archive = os.path.join(datadir, "t .7z") util.run_checked([sys.executable, patool_cmd, "-vv", "--non-interactive", "extract", "--outdir", tmpdir, archive]) finally: shutil.rmtree(tmpdir) patool-1.10/tests/test_formats.py000066400000000000000000000016771263321134500171720ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest import sys from patoolib.util import run_checked from . import patool_cmd class TestFormats (unittest.TestCase): def test_list_formats (self): run_checked([sys.executable, patool_cmd, "-vv", "--non-interactive", 'formats']) patool-1.10/tests/test_list.py000066400000000000000000000020551263321134500164610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2013-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest import os import sys from patoolib.util import run_checked from . import datadir, needs_program, patool_cmd class ArchiveListTest (unittest.TestCase): @needs_program('tar') def test_list(self): archive = os.path.join(datadir, "t.tar") run_checked([sys.executable, patool_cmd, "-vv", "--non-interactive", "list", archive]) patool-1.10/tests/test_mime.py000066400000000000000000000264561263321134500164500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest import os import patoolib from . import needs_program, datadir class TestMime (unittest.TestCase): def mime_test (self, func, filename, mime, encoding): """Test that file has given mime and encoding as determined by given function.""" archive = os.path.join(datadir, filename) file_mime, file_encoding = func(archive) fail_msg = "%s for archive `%s' should be %s, but was %s" if isinstance(mime, tuple): self.assertTrue(file_mime in mime, fail_msg % ("MIME type", filename, "in %s" % str(mime), file_mime)) else: self.assertEqual(file_mime, mime, fail_msg % ("MIME type", filename, mime, file_mime)) self.assertEqual(file_encoding, encoding, fail_msg % ("Encoding", filename, encoding, file_encoding)) def mime_test_file (self, filename, mime, encoding=None): """Test that file has given mime and encoding as determined by file(1).""" self.mime_test(patoolib.util.guess_mime_file, filename, mime, encoding) def mime_test_mimedb (self, filename, mime, encoding=None): """Test that file has given mime and encoding as determined by the mimetypes module.""" self.mime_test(patoolib.util.guess_mime_mimedb, filename, mime, encoding) @needs_program('file') def test_mime_file (self): self.mime_test_file("t .7z", "application/x-7z-compressed") self.mime_test_file("t.7z.foo", "application/x-7z-compressed") self.mime_test_file("t.arj", "application/x-arj") self.mime_test_file("t.arj.foo", "application/x-arj") self.mime_test_file("t.txt.bz2", "application/x-bzip2") self.mime_test_file("t.txt.bz2.foo", "application/x-bzip2") self.mime_test_file("t.cab", "application/vnd.ms-cab-compressed") self.mime_test_file("t.cab.foo", "application/vnd.ms-cab-compressed") self.mime_test_file("t.cpio", "application/x-cpio") self.mime_test_file("t.cpio.foo", "application/x-cpio") self.mime_test_file("t.deb", "application/x-debian-package") self.mime_test_file("t.deb.foo", "application/x-debian-package") self.mime_test_file("t.txt.gz", ("application/gzip", "application/x-gzip")) self.mime_test_file("t.txt.gz.foo", ("application/gzip", "application/x-gzip")) self.mime_test_file("t.jar", "application/zip") self.mime_test_file("t.jar.foo", "application/zip") self.mime_test_file("t.txt.lzma", "application/x-lzma") self.mime_test_file("t.txt.lzma.foo", "application/x-lzma") self.mime_test_file("t.txt.lz", "application/x-lzip") self.mime_test_file("t.txt.lz.foo", "application/x-lzip") self.mime_test_file("t.txt.lzo", "application/x-lzop") self.mime_test_file("t.txt.lzo.foo", "application/x-lzop") self.mime_test_file("t.rar", "application/x-rar") self.mime_test_file("t.rar.foo", "application/x-rar") self.mime_test_file("t.rpm", "application/x-rpm") self.mime_test_file("t.rpm.foo", "application/x-rpm") self.mime_test_file("t.tar", "application/x-tar") self.mime_test_file("t.tar.foo", "application/x-tar") self.mime_test_file("t.tar.lz", "application/x-tar", "lzip") self.mime_test_file("t.tar.bz2", "application/x-tar", "bzip2") self.mime_test_file("t.tbz2", "application/x-tar", "bzip2") self.mime_test_file("t.tar.gz", "application/x-tar", "gzip") self.mime_test_file("t.taz", "application/x-tar", "gzip") self.mime_test_file("t.tgz", "application/x-tar", "gzip") self.mime_test_file("t.tar.xz", "application/x-tar", "xz") self.mime_test_file("t.tar.Z", "application/x-tar", "compress") self.mime_test_file("t.tar.lzma", "application/x-tar", "lzma") # file(1) cannot uncompress .lzma files #self.mime_test_file("t.tar.lzma.foo", "application/x-tar", "lzma") self.mime_test_file("t.txt.xz", "application/x-xz") self.mime_test_file("t.txt.xz.foo", "application/x-xz") self.mime_test_file("t.txt.Z", "application/x-compress") self.mime_test_file("t.txt.Z.foo", "application/x-compress") self.mime_test_file("t.jar", "application/zip") self.mime_test_file("t.jar.foo", "application/zip") self.mime_test_file("t.zip", "application/zip") self.mime_test_file("t.zip.foo", "application/zip") self.mime_test_file("t.ace", "application/x-ace") self.mime_test_file("t.ace.foo", "application/x-ace") self.mime_test_file("t.txt.a", "application/x-archive") self.mime_test_file("t.txt.a.foo", "application/x-archive") self.mime_test_file("t.lha", "application/x-lha") self.mime_test_file("t.lzh", "application/x-lha") self.mime_test_file("t.lha.foo", "application/x-lha") # file(1) does not recognize .alz files #self.mime_test_file("t.alz", "application/x-alzip") #self.mime_test_file("t.alz.foo", "application/x-alzip") self.mime_test_file("t.arc", "application/x-arc") self.mime_test_file("t.arc.foo", "application/x-arc") self.mime_test_file("t.txt.lrz", "application/x-lrzip") self.mime_test_file("t.txt.lrz.foo", "application/x-lrzip") self.mime_test_file("t.txt.rz", "application/x-rzip") self.mime_test_file("t.txt.rz.foo", "application/x-rzip") self.mime_test_file("t.zoo", "application/x-zoo") self.mime_test_file("t.zoo.foo", "application/x-zoo") self.mime_test_file("t.dms", "application/x-dms") self.mime_test_file("t.dms.foo", "application/x-dms") self.mime_test_file("t.ape", "audio/x-ape") self.mime_test_file("t.ape.foo", "audio/x-ape") # file(1) does not recognize .shn files #self.mime_test_file("t.shn", "audio/x-shn") #self.mime_test_file("t.shn.foo", "audio/x-shn") self.mime_test_file("t.flac", "audio/flac") self.mime_test_file("t.flac.foo", "audio/flac") self.mime_test_file("t.adf", "application/x-adf") self.mime_test_file("t.adf.foo", "application/x-adf") self.mime_test_file("t.chm", "application/x-chm") self.mime_test_file("t.chm.foo", "application/x-chm") self.mime_test_file("t.iso", "application/x-iso9660-image") self.mime_test_file("t.epub", "application/zip") self.mime_test_file("t.apk", ("application/zip", "application/java-archive")) self.mime_test_file("t.zpaq", "application/zpaq") self.mime_test_file("t.zpaq.foo", "application/zpaq") @needs_program('file') @needs_program('lzip') def test_mime_file_lzip (self): self.mime_test_file("t.tar.lz.foo", "application/x-tar", "lzip") @needs_program('file') @needs_program('bzip2') def test_mime_file_bzip (self): self.mime_test_file("t.tar.bz2.foo", "application/x-tar", "bzip2") self.mime_test_file("t.tbz2.foo", "application/x-tar", "bzip2") @needs_program('file') @needs_program('gzip') def test_mime_file_gzip (self): self.mime_test_file("t.tar.gz.foo", "application/x-tar", "gzip") self.mime_test_file("t.taz.foo", "application/x-tar", "gzip") self.mime_test_file("t.tgz.foo", "application/x-tar", "gzip") @needs_program('file') @needs_program('xz') def test_mime_file_xzip (self): self.mime_test_file("t.tar.xz.foo", "application/x-tar", "xz") @needs_program('file') @needs_program('uncompress') def test_mime_file_compress (self): self.mime_test_file("t.tar.Z.foo", "application/x-tar", "compress") def test_mime_mimedb (self): self.mime_test_mimedb("t .7z", "application/x-7z-compressed") self.mime_test_mimedb("t.arj", "application/x-arj") self.mime_test_mimedb("t .bz2", "application/x-bzip2") self.mime_test_mimedb("t.cab", "application/x-cab") self.mime_test_mimedb("t.cpio", "application/x-cpio") self.mime_test_mimedb("t.deb", "application/x-debian-package") self.mime_test_mimedb("t.gz", "application/gzip") self.mime_test_mimedb("t.jar", "application/java-archive") self.mime_test_mimedb("t.lzma", "application/x-lzma") self.mime_test_mimedb("t.txt.lz", "application/x-lzip") self.mime_test_mimedb("t.lzo", "application/x-lzop") self.mime_test_mimedb("t.rar", ("application/rar", "application/x-rar")) self.mime_test_mimedb("t.rpm", ("application/x-redhat-package-manager", "application/x-rpm")) self.mime_test_mimedb("t.tar", "application/x-tar") self.mime_test_mimedb("t.tar.bz2", "application/x-tar", "bzip2") self.mime_test_mimedb("t.tar.gz", "application/x-tar", "gzip") self.mime_test_mimedb("t.tar.lzma", "application/x-tar", "lzma") self.mime_test_mimedb("t.tar.xz", "application/x-tar", "xz") self.mime_test_mimedb("t.tar.lz", "application/x-tar", "lzip") self.mime_test_mimedb("t.tar.Z", "application/x-tar", "compress") self.mime_test_mimedb("t.taz", "application/x-tar", "gzip") self.mime_test_mimedb("t.tbz2", "application/x-tar", "bzip2") self.mime_test_mimedb("t.tgz", "application/x-tar", "gzip") self.mime_test_mimedb("t.txt.gz", "application/gzip") self.mime_test_mimedb("t.txt.bz2", "application/x-bzip2") self.mime_test_mimedb("t .xz", "application/x-xz") self.mime_test_mimedb("t.Z", "application/x-compress") self.mime_test_mimedb("t.zip", ("application/zip", "application/x-zip-compressed")) self.mime_test_mimedb("t.ace", "application/x-ace") self.mime_test_mimedb("t.a", "application/x-archive") self.mime_test_mimedb("t.lha", "application/x-lha") self.mime_test_mimedb("t.lzh", "application/x-lzh") self.mime_test_mimedb("t.alz", "application/x-alzip") self.mime_test_mimedb("t.arc", "application/x-arc") self.mime_test_mimedb("t.lrz", "application/x-lrzip") self.mime_test_mimedb("t.rz", "application/x-rzip") self.mime_test_mimedb("t.zoo", "application/x-zoo") self.mime_test_mimedb("t.dms", "application/x-dms") self.mime_test_mimedb("t.shar", "application/x-shar") self.mime_test_mimedb("t.ape", "audio/x-ape") self.mime_test_mimedb("t.shn", "audio/x-shn") self.mime_test_mimedb("t.flac", "audio/flac") self.mime_test_mimedb("t.adf", "application/x-adf") self.mime_test_mimedb("t.chm", "application/x-chm") self.mime_test_mimedb("t.iso", "application/x-iso9660-image") self.mime_test_mimedb("t.epub", "application/zip") self.mime_test_mimedb("t.apk", "application/zip") self.mime_test_mimedb("t.vhd", "application/x-vhd") self.mime_test_mimedb("t.zpaq", "application/zpaq") patool-1.10/tests/test_recompress.py000066400000000000000000000026621263321134500176740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest import os import sys import shutil from patoolib import util from . import datadir, needs_one_program, patool_cmd class ArchiveRecompressTest (unittest.TestCase): def recompress(self, name): """Recompress archive with given name.""" archive = os.path.join(datadir, name) ext = os.path.splitext(archive)[1] tmpfile = util.tmpfile(suffix=ext) try: shutil.copy(archive, tmpfile) util.run_checked([sys.executable, patool_cmd, "-vv", "--non-interactive", "recompress", tmpfile]) finally: if os.path.exists(tmpfile): os.remove(tmpfile) @needs_one_program(('zip', '7z')) def test_repack (self): self.recompress('t.zip') patool-1.10/tests/test_repack.py000066400000000000000000000036471263321134500167630ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest import os import sys import shutil from patoolib import util from . import datadir, needs_program, needs_one_program, patool_cmd class ArchiveRepackTest (unittest.TestCase): def repack(self, name1, name2): """Repack archive with name1 to archive with name2.""" archive1 = os.path.join(datadir, name1) tmpdir = util.tmpdir() try: archive2 = os.path.join(tmpdir, name2) util.run_checked([sys.executable, patool_cmd, "-vv", "--non-interactive", "repack", archive1, archive2]) util.run_checked([sys.executable, patool_cmd, "--non-interactive", "diff", archive1, archive2]) finally: shutil.rmtree(tmpdir) @needs_program('diff') @needs_one_program(('tar', 'star', '7z')) @needs_one_program(('zip', '7z')) def test_repack (self): self.repack('t.tar', 't.zip') @needs_program('diff') @needs_one_program(('gzip', '7z')) @needs_one_program(('bzip2', '7z')) def test_repack_same_format_different_compression (self): self.repack('t.tar.gz', 't.tar.bz2') @needs_program('diff') def test_repack_same_format (self): self.repack('t.tar.gz', 't1.tar.gz') self.repack('t.zip', 't1.zip') patool-1.10/tests/test_search.py000066400000000000000000000024601263321134500167530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2013-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest import os import sys from patoolib.util import run_checked from . import datadir, needs_program, patool_cmd class ArchiveSearchTest (unittest.TestCase): @needs_program('grep') @needs_program('unzip') @needs_program('tar') def test_search(self): pattern = "42" archive = os.path.join(datadir, "t.tar") self.search(pattern, archive) archive = os.path.join(datadir, "t.zip") self.search(pattern, archive) def search(self, pattern, archive): run_checked([sys.executable, patool_cmd, "-vv", "--non-interactive", "search", pattern, archive]) patool-1.10/tests/test_test.py000066400000000000000000000020451263321134500164640ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2013-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest import os import sys from patoolib.util import run_checked from . import datadir, needs_program, patool_cmd class ArchiveTestTest (unittest.TestCase): @needs_program('7z') def test_test(self): archive = os.path.join(datadir, "t .7z") run_checked([sys.executable, patool_cmd, "--non-interactive", "test", archive]) patool-1.10/tests/test_util.py000066400000000000000000000031241263321134500164610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest import os from patoolib import util class UtilTest (unittest.TestCase): def test_samefile1 (self): filename1 = filename2 = __file__ self.assertTrue(util.is_same_filename(filename1, filename2)) self.assertTrue(util.is_same_file(filename1, filename2)) def test_samefile2 (self): parentdir = os.path.dirname(__file__) filename1 = os.path.dirname(parentdir) filename2 = os.path.join(parentdir, '..') self.assertTrue(util.is_same_filename(filename1, filename2)) self.assertTrue(util.is_same_file(filename1, filename2)) def test_samefile3 (self): parentdir = os.path.dirname(__file__) filename1 = os.path.dirname(parentdir) filename2 = os.path.join(parentdir, '.') self.assertFalse(util.is_same_file(filename1, filename2)) self.assertFalse(util.is_same_filename(filename1, filename2))