gnupginterface-0.3.2.orig/0040700000175000017500000000000007417645152015711 5ustar jgoerzenjgoerzengnupginterface-0.3.2.orig/COPYING0100600000175000017500000006347607341621332016751 0ustar jgoerzenjgoerzen GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, 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 this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), 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 distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser 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 Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey 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 library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! gnupginterface-0.3.2.orig/ChangeLog0100600000175000017500000001015107417645133017457 0ustar jgoerzenjgoerzen2002-01-11 15:24 ftobin * NEWS: note that we have other small changes as well 2002-01-11 15:22 ftobin * GnuPGInterface.py, NEWS, setup.py: bump version to 0.3.2 and news 2002-01-11 15:20 ftobin * GnuPGInterface.py: use fcntl instead of FCNTL, since FCNTL is now deprecated as of Python 2.2 2001-12-21 13:01 ftobin * GnuPGInterface.py: doc example fix 2001-12-21 13:00 ftobin * GnuPGInterface.py: small docfix 2001-11-06 12:04 ftobin * GnuPGInterface.py: use isinstance instead of type(o) == aType 2001-11-06 10:27 ftobin * THANKS: put Doobee R. Tzek into the ChangeLog for his nice piping-on-Linux patch 2001-11-03 02:46 ftobin * GnuPGInterface.py, NEWS, setup.py: bunch versions, add NEWS 2001-11-03 02:16 ftobin * GnuPGInterface.py, THANKS: + # pipes are unidirectional - at least on some systems + # which run python. so we have to 'turn the pipe in + # the right direction' --drt@un.bewaff.net 2001-11-03 02:10 ftobin * GnuPGInterface.py: small docstring changes to make emacs friendly 2001-08-25 22:27 ftobin * NEWS: minor formatting error 2001-08-25 22:05 ftobin * README: divide installation into two steps 2001-08-25 20:35 ftobin * GnuPGInterface.py: added a doctest about generating a key, and renamed _test to _run_doctests 2001-08-25 20:34 ftobin * NEWS: bumped version to 0.3.0 2001-08-25 04:21 ftobin * GnuPGInterface.py, NEWS, README, setup.py, unittests.py: lots more doctests and documentation change class GnuPGInterface to simply GnuPG change version to 0.3.0 2001-08-25 02:18 ftobin * MANIFEST, unittests.py: add a bunch of unittests 2001-08-25 02:18 ftobin * COPYING: Change license to LGPL 2001-08-24 22:52 ftobin * GnuPGInterface.py: clarify a little bit on how to set Options instance attributes, and change Options.get_option_args() to Options.get_standard_args() 2001-08-21 11:42 ftobin * GnuPGInterface.py, NEWS, setup.py: remove importing 'types', and bump version to 0.2.1, since we already uploaded 0.2.0 to sourceforge 2001-08-21 11:13 ftobin * GnuPGInterface.py, setup.py: bump version 2001-08-21 10:37 ftobin * GnuPGInterface.py: change some constants to using a class 2001-08-21 09:24 ftobin * GnuPGInterface.py, README, THANKS: change my email addr and add some docs on using pydoc 2001-08-21 09:20 ftobin * GnuPGInterface.py, NEWS: * MAJOR BACKWARDS COMPATIBLITY BREAK: Major API changes with regards to GnuPGInterface's run() method have been made. A much cleaner and more sensible method is now used to request which filehandles are 'created' and which are 'attached'. See the documentation and example code for details. * The ability to have run() 'attach' GnuPG filehandles to already-opened files works now. Really, it does :) (I implemented more doctest tests to make sure now). 2001-08-16 01:31 ftobin * GnuPGInterface.py: We used to test if h was a FileType, but this destroys abstraction, such as if there is a FileType-like object which merely implements everything we need. So now, we test for if h has the value 1, and only if so do we 'generate' a filehandle for it. If h is false, then we will disregard it 2001-07-10 02:25 ftobin * GnuPGInterface.py, NEWS, setup.py: put better descriptions in 2001-07-08 21:45 ftobin * MANIFEST: add NEWS and THANKS 2001-07-08 21:41 ftobin * NEWS, THANKS: just add NEWS and THANKS, standard files for all of my packages 2001-07-08 21:07 ftobin * GnuPGInterface.py, setup.py: allow for GnuPG command args to be passed to run(), and put metadata into packaging info. 2001-07-08 15:44 ftobin * GnuPGInterface.py, MANIFEST: got doctest stuff working 2001-07-07 21:40 ftobin * GnuPGInterface.py, README: Put in a lot of inline docs 2001-07-01 06:55 ftobin * MANIFEST: put changelog into manifest 2001-07-01 06:53 ftobin * COPYING, GnuPGInterface.py, MANIFEST, Makefile, README, entities, index.xml, setup.py: The REAL initial deposit, after accidentally importing htdocs here instead :P 2001-06-29 22:31 ftobin * Makefile, entities, index.xml: Initial revision 2001-06-29 22:31 ftobin * Makefile, entities, index.xml: initial import gnupginterface-0.3.2.orig/GnuPGInterface.py0100600000175000017500000005276007417644554021102 0ustar jgoerzenjgoerzen"""Interface to GNU Privacy Guard (GnuPG) GnuPGInterface is a Python module to interface with GnuPG. It concentrates on interacting with GnuPG via filehandles, providing access to control GnuPG via versatile and extensible means. This module is based on GnuPG::Interface, a Perl module by the same author. Normally, using this module will involve creating a GnuPG object, setting some options in it's 'options' data member (which is of type Options), creating some pipes to talk with GnuPG, and then calling the run() method, which will connect those pipes to the GnuPG process. run() returns a Process object, which contains the filehandles to talk to GnuPG with. Example code: >>> import GnuPGInterface >>> >>> plaintext = "Three blind mice" >>> passphrase = "This is the passphrase" >>> >>> gnupg = GnuPGInterface.GnuPG() >>> gnupg.options.armor = 1 >>> gnupg.options.meta_interactive = 0 >>> gnupg.options.extra_args.append('--no-secmem-warning') >>> >>> # Normally we might specify something in >>> # gnupg.options.recipients, like >>> # gnupg.options.recipients = [ '0xABCD1234', 'bob@foo.bar' ] >>> # but since we're doing symmetric-only encryption, it's not needed. >>> # If you are doing standard, public-key encryption, using >>> # --encrypt, you will need to specify recipients before >>> # calling gnupg.run() >>> >>> # First we'll encrypt the test_text input symmetrically >>> p1 = gnupg.run(['--symmetric'], ... create_fhs=['stdin', 'stdout', 'passphrase']) >>> >>> p1.handles['passphrase'].write(passphrase) >>> p1.handles['passphrase'].close() >>> >>> p1.handles['stdin'].write(plaintext) >>> p1.handles['stdin'].close() >>> >>> ciphertext = p1.handles['stdout'].read() >>> p1.handles['stdout'].close() >>> >>> # process cleanup >>> p1.wait() >>> >>> # Now we'll decrypt what we just encrypted it, >>> # using the convience method to get the >>> # passphrase to GnuPG >>> gnupg.passphrase = passphrase >>> >>> p2 = gnupg.run(['--decrypt'], create_fhs=['stdin', 'stdout']) >>> >>> p2.handles['stdin'].write(ciphertext) >>> p2.handles['stdin'].close() >>> >>> decrypted_plaintext = p2.handles['stdout'].read() >>> p2.handles['stdout'].close() >>> >>> # process cleanup >>> p2.wait() >>> >>> # Our decrypted plaintext: >>> decrypted_plaintext 'Three blind mice' >>> >>> # ...and see it's the same as what we orignally encrypted >>> assert decrypted_plaintext == plaintext, \ "GnuPG decrypted output does not match original input" >>> >>> >>> ################################################## >>> # Now let's trying using run()'s attach_fhs paramter >>> >>> # we're assuming we're running on a unix... >>> input = open('/etc/motd') >>> >>> p1 = gnupg.run(['--symmetric'], create_fhs=['stdout'], ... attach_fhs={'stdin': input}) >>> >>> # GnuPG will read the stdin from /etc/motd >>> ciphertext = p1.handles['stdout'].read() >>> >>> # process cleanup >>> p1.wait() >>> >>> # Now let's run the output through GnuPG >>> # We'll write the output to a temporary file, >>> import tempfile >>> temp = tempfile.TemporaryFile() >>> >>> p2 = gnupg.run(['--decrypt'], create_fhs=['stdin'], ... attach_fhs={'stdout': temp}) >>> >>> # give GnuPG our encrypted stuff from the first run >>> p2.handles['stdin'].write(ciphertext) >>> p2.handles['stdin'].close() >>> >>> # process cleanup >>> p2.wait() >>> >>> # rewind the tempfile and see what GnuPG gave us >>> temp.seek(0) >>> decrypted_plaintext = temp.read() >>> >>> # compare what GnuPG decrypted with our original input >>> input.seek(0) >>> input_data = input.read() >>> >>> assert decrypted_plaintext == input_data, \ "GnuPG decrypted output does not match original input" To do things like public-key encryption, simply pass do something like: gnupg.passphrase = 'My passphrase' gnupg.options.recipients = [ 'bob@foobar.com' ] gnupg.run( ['--sign', '--encrypt'], create_fhs=..., attach_fhs=...) Here is an example of subclassing GnuPGInterface.GnuPG, so that it has an encrypt_string() method that returns ciphertext. >>> import GnuPGInterface >>> >>> class MyGnuPG(GnuPGInterface.GnuPG): ... ... def __init__(self): ... GnuPGInterface.GnuPG.__init__(self) ... self.setup_my_options() ... ... def setup_my_options(self): ... self.options.armor = 1 ... self.options.meta_interactive = 0 ... self.options.extra_args.append('--no-secmem-warning') ... ... def encrypt_string(self, string, recipients): ... gnupg.options.recipients = recipients # a list! ... ... proc = gnupg.run(['--encrypt'], create_fhs=['stdin', 'stdout']) ... ... proc.handles['stdin'].write(string) ... proc.handles['stdin'].close() ... ... output = proc.handles['stdout'].read() ... proc.handles['stdout'].close() ... ... proc.wait() ... return output ... >>> gnupg = MyGnuPG() >>> ciphertext = gnupg.encrypt_string("The secret", ['0x260C4FA3']) >>> >>> # just a small sanity test here for doctest >>> import types >>> assert isinstance(ciphertext, types.StringType), \ "What GnuPG gave back is not a string!" Here is an example of generating a key: >>> import GnuPGInterface >>> gnupg = GnuPGInterface.GnuPG() >>> gnupg.options.meta_interactive = 0 >>> >>> # We will be creative and use the logger filehandle to capture >>> # what GnuPG says this time, instead stderr; no stdout to listen to, >>> # but we capture logger to surpress the dry-run command. >>> # We also have to capture stdout since otherwise doctest complains; >>> # Normally you can let stdout through when generating a key. >>> >>> proc = gnupg.run(['--gen-key'], create_fhs=['stdin', 'stdout', ... 'logger']) >>> >>> proc.handles['stdin'].write('''Key-Type: DSA ... Key-Length: 1024 ... # We are only testing syntax this time, so dry-run ... %dry-run ... Subkey-Type: ELG-E ... Subkey-Length: 1024 ... Name-Real: Joe Tester ... Name-Comment: with stupid passphrase ... Name-Email: joe@foo.bar ... Expire-Date: 2y ... Passphrase: abc ... %pubring foo.pub ... %secring foo.sec ... ''') >>> >>> proc.handles['stdin'].close() >>> >>> report = proc.handles['logger'].read() >>> proc.handles['logger'].close() >>> >>> proc.wait() COPYRIGHT: Copyright (C) 2001 Frank J. Tobin, ftobin@neverending.org LICENSE: This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or see http://www.gnu.org/copyleft/lesser.html """ import os import sys import fcntl __author__ = "Frank J. Tobin, ftobin@neverending.org" __version__ = "0.3.2" __revision__ = "$Id: GnuPGInterface.py,v 1.22 2002/01/11 20:22:04 ftobin Exp $" # "standard" filehandles attached to processes _stds = [ 'stdin', 'stdout', 'stderr' ] # the permissions each type of fh needs to be opened with _fd_modes = { 'stdin': 'w', 'stdout': 'r', 'stderr': 'r', 'passphrase': 'w', 'command': 'w', 'logger': 'r', 'status': 'r' } # correlation between handle names and the arguments we'll pass _fd_options = { 'passphrase': '--passphrase-fd', 'logger': '--logger-fd', 'status': '--status-fd', 'command': '--command-fd' } class GnuPG: """Class instances represent GnuPG. Instance attributes of a GnuPG object are: * call -- string to call GnuPG with. Defaults to "gpg" * passphrase -- Since it is a common operation to pass in a passphrase to GnuPG, and working with the passphrase filehandle mechanism directly can be mundane, if set, the passphrase attribute works in a special manner. If the passphrase attribute is set, and no passphrase file object is sent in to run(), then GnuPG instnace will take care of sending the passphrase to GnuPG, the executable instead of having the user sent it in manually. * options -- Object of type GnuPGInterface.Options. Attribute-setting in options determines the command-line options used when calling GnuPG. """ def __init__(self): self.call = 'gpg' self.passphrase = None self.options = Options() def run(self, gnupg_commands, args=None, create_fhs=None, attach_fhs=None): """Calls GnuPG with the list of string commands gnupg_commands, complete with prefixing dashes. For example, gnupg_commands could be '["--sign", "--encrypt"]' Returns a GnuPGInterface.Process object. args is an optional list of GnuPG command arguments (not options), such as keyID's to export, filenames to process, etc. create_fhs is an optional list of GnuPG filehandle names that will be set as keys of the returned Process object's 'handles' attribute. The generated filehandles can be used to communicate with GnuPG via standard input, standard output, the status-fd, passphrase-fd, etc. Valid GnuPG filehandle names are: * stdin * stdout * stderr * status * passphase * command * logger The purpose of each filehandle is described in the GnuPG documentation. attach_fhs is an optional dictionary with GnuPG filehandle names mapping to opened files. GnuPG will read or write to the file accordingly. For example, if 'my_file' is an opened file and 'attach_fhs[stdin] is my_file', then GnuPG will read its standard input from my_file. This is useful if you want GnuPG to read/write to/from an existing file. For instance: f = open("encrypted.gpg") gnupg.run(["--decrypt"], attach_fhs={'stdin': f}) Using attach_fhs also helps avoid system buffering issues that can arise when using create_fhs, which can cause the process to deadlock. If not mentioned in create_fhs or attach_fhs, GnuPG filehandles which are a std* (stdin, stdout, stderr) are defaulted to the running process' version of handle. Otherwise, that type of handle is simply not used when calling GnuPG. For example, if you do not care about getting data from GnuPG's status filehandle, simply do not specify it. run() returns a Process() object which has a 'handles' which is a dictionary mapping from the handle name (such as 'stdin' or 'stdout') to the respective newly-created FileObject connected to the running GnuPG process. For instance, if the call was process = gnupg.run(["--decrypt"], stdin=1) after run returns 'process.handles["stdin"]' is a FileObject connected to GnuPG's standard input, and can be written to. """ if args == None: args = [] if create_fhs == None: create_fhs = [] if attach_fhs == None: attach_fhs = {} for std in _stds: if not attach_fhs.has_key(std) \ and std not in create_fhs: attach_fhs.setdefault(std, getattr(sys, std)) handle_passphrase = 0 if self.passphrase != None \ and not attach_fhs.has_key('passphrase') \ and 'passphrase' not in create_fhs: handle_passphrase = 1 create_fhs.append('passphrase') process = self._attach_fork_exec(gnupg_commands, args, create_fhs, attach_fhs) if handle_passphrase: passphrase_fh = process.handles['passphrase'] passphrase_fh.write( self.passphrase ) passphrase_fh.close() del process.handles['passphrase'] return process def _attach_fork_exec(self, gnupg_commands, args, create_fhs, attach_fhs): """This is like run(), but without the passphrase-helping (note that run() calls this).""" process = Process() for fh_name in create_fhs + attach_fhs.keys(): if not _fd_modes.has_key(fh_name): raise KeyError, \ "unrecognized filehandle name '%s'; must be one of %s" \ % (fh_name, _fd_modes.keys()) for fh_name in create_fhs: # make sure the user doesn't specify a filehandle # to be created *and* attached if attach_fhs.has_key(fh_name): raise ValueError, \ "cannot have filehandle '%s' in both create_fhs and attach_fhs" \ % fh_name pipe = os.pipe() # fix by drt@un.bewaff.net noting # that since pipes are unidirectional on some systems, # so we have to 'turn the pipe around' # if we are writing if _fd_modes[fh_name] == 'w': pipe = (pipe[1], pipe[0]) process._pipes[fh_name] = Pipe(pipe[0], pipe[1], 0) for fh_name, fh in attach_fhs.items(): process._pipes[fh_name] = Pipe(fh.fileno(), fh.fileno(), 1) process.pid = os.fork() if process.pid == 0: self._as_child(process, gnupg_commands, args) return self._as_parent(process) def _as_parent(self, process): """Stuff run after forking in parent""" for k, p in process._pipes.items(): if not p.direct: os.close(p.child) process.handles[k] = os.fdopen(p.parent, _fd_modes[k]) # user doesn't need these del process._pipes return process def _as_child(self, process, gnupg_commands, args): """Stuff run after forking in child""" # child for std in _stds: p = process._pipes[std] os.dup2( p.child, getattr(sys, "__%s__" % std).fileno() ) for k, p in process._pipes.items(): if p.direct and k not in _stds: # we want the fh to stay open after execing fcntl.fcntl( p.child, fcntl.F_SETFD, 0 ) fd_args = [] for k, p in process._pipes.items(): # set command-line options for non-standard fds if k not in _stds: fd_args.extend([ _fd_options[k], "%d" % p.child ]) if not p.direct: os.close(p.parent) command = [ self.call ] + fd_args + self.options.get_args() \ + gnupg_commands + args os.execvp( command[0], command ) class Pipe: """simple struct holding stuff about pipes we use""" def __init__(self, parent, child, direct): self.parent = parent self.child = child self.direct = direct class Options: """Objects of this class encompass options passed to GnuPG. This class is responsible for determining command-line arguments which are based on options. It can be said that a GnuPG object has-a Options object in its options attribute. Attributes which correlate directly to GnuPG options: Each option here defaults to false or None, and is described in GnuPG documentation. Booleans (set these attributes to booleans) * armor * no_greeting * no_verbose * quiet * batch * always_trust * rfc1991 * openpgp * force_v3_sigs * no_options * textmode Strings (set these attributes to strings) * homedir * default_key * comment * compress_algo * options Lists (set these attributes to lists) * recipients (***NOTE*** plural of 'recipient') * encrypt_to Meta options Meta options are options provided by this module that do not correlate directly to any GnuPG option by name, but are rather bundle of options used to accomplish a specific goal, such as obtaining compatibility with PGP 5. The actual arguments each of these reflects may change with time. Each defaults to false unless otherwise specified. meta_pgp_5_compatible -- If true, arguments are generated to try to be compatible with PGP 5.x. meta_pgp_2_compatible -- If true, arguments are generated to try to be compatible with PGP 2.x. meta_interactive -- If false, arguments are generated to try to help the using program use GnuPG in a non-interactive environment, such as CGI scripts. Default is true. extra_args -- Extra option arguments may be passed in via the attribute extra_args, a list. >>> import GnuPGInterface >>> >>> gnupg = GnuPGInterface.GnuPG() >>> gnupg.options.armor = 1 >>> gnupg.options.recipients = ['Alice', 'Bob'] >>> gnupg.options.extra_args = ['--no-secmem-warning'] >>> >>> # no need for users to call this normally; just for show here >>> gnupg.options.get_args() ['--armor', '--recipient', 'Alice', '--recipient', 'Bob', '--no-secmem-warning'] """ def __init__(self): # booleans self.armor = 0 self.no_greeting = 0 self.verbose = 0 self.no_verbose = 0 self.quiet = 0 self.batch = 0 self.always_trust = 0 self.rfc1991 = 0 self.openpgp = 0 self.force_v3_sigs = 0 self.no_options = 0 self.textmode = 0 # meta-option booleans self.meta_pgp_5_compatible = 0 self.meta_pgp_2_compatible = 0 self.meta_interactive = 1 # strings self.homedir = None self.default_key = None self.comment = None self.compress_algo = None self.options = None # lists self.encrypt_to = [] self.recipients = [] # miscellaneous arguments self.extra_args = [] def get_args( self ): """Generate a list of GnuPG arguments based upon attributes.""" return self.get_meta_args() + self.get_standard_args() + self.extra_args def get_standard_args( self ): """Generate a list of standard, non-meta or extra arguments""" args = [] if self.homedir != None: args.extend( [ '--homedir', self.homedir ] ) if self.options != None: args.extend( [ '--options', self.options ] ) if self.comment != None: args.extend( [ '--comment', self.comment ] ) if self.compress_algo != None: args.extend( [ '--compress-algo', self.compress_algo ] ) if self.default_key != None: args.extend( [ '--default-key', self.default_key ] ) if self.no_options: args.append( '--no-options' ) if self.armor: args.append( '--armor' ) if self.textmode: args.append( '--textmode' ) if self.no_greeting: args.append( '--no-greeting' ) if self.verbose: args.append( '--verbose' ) if self.no_verbose: args.append( '--no-verbose' ) if self.quiet: args.append( '--quiet' ) if self.batch: args.append( '--batch' ) if self.always_trust: args.append( '--always-trust' ) if self.force_v3_sigs: args.append( '--force-v3-sigs' ) if self.rfc1991: args.append( '--rfc1991' ) if self.openpgp: args.append( '--openpgp' ) for r in self.recipients: args.extend( [ '--recipient', r ] ) for r in self.encrypt_to: args.extend( [ '--encrypt-to', r ] ) return args def get_meta_args( self ): """Get a list of generated meta-arguments""" args = [] if self.meta_pgp_5_compatible: args.extend( [ '--compress-algo', '1', '--force-v3-sigs' ] ) if self.meta_pgp_2_compatible: args.append( '--rfc1991' ) if not self.meta_interactive: args.extend( [ '--batch', '--no-tty' ] ) return args class Process: """Objects of this class encompass properties of a GnuPG process spawned by GnuPG.run(). # gnupg is a GnuPG object process = gnupg.run( [ '--decrypt' ], stdout = 1 ) out = process.handles['stdout'].read() ... os.waitpid( process.pid, 0 ) Data Attributes handles -- This is a map of filehandle-names to the file handles, if any, that were requested via run() and hence are connected to the running GnuPG process. Valid names of this map are only those handles that were requested. pid -- The PID of the spawned GnuPG process. Useful to know, since once should call os.waitpid() to clean up the process, especially if multiple calls are made to run(). """ def __init__(self): self._pipes = {} self.handles = {} self.pid = None self._waited = None def wait(self): """Wait on the process to exit, allowing for child cleanup. Will raise an IOError if the process exits non-zero.""" e = os.waitpid(self.pid, 0)[1] if e != 0: raise IOError, "GnuPG exited non-zero, with code %d" % (e << 8) def _run_doctests(): import doctest, GnuPGInterface return doctest.testmod(GnuPGInterface) # deprecated GnuPGInterface = GnuPG if __name__ == '__main__': _run_doctests() gnupginterface-0.3.2.orig/MANIFEST0100600000175000017500000000012607341623143017030 0ustar jgoerzenjgoerzenCOPYING ChangeLog GnuPGInterface.py MANIFEST NEWS README THANKS setup.py unittests.py gnupginterface-0.3.2.orig/NEWS0100600000175000017500000000355107417644772016422 0ustar jgoerzenjgoerzenNoteworthy changes in 0.3.2 ----------------------------------------------------------------- * Internally use fcntl instead of FCNTL, which is deprecated as of Python 2.2. * Small other fixes in code and docs. Noteworthy changes in 0.3.1 ----------------------------------------------------------------- * Thanks to a patch by drt@un.bewaff.net, fixed a nasty fatal bug that manifested itself running on Linux. Noteworthy changes in 0.3.0 ----------------------------------------------------------------- * Renamed class GnuPGInterface.GnuPGInterface to GnuPGInterface.GnuPG. Note only the class name has changed, note the module name. The old class name is still supported for backwards compatbility. * Changed license to the GNU Lesser General Public License. Previous license was GNU General Public License. * Added a convenience Process.wait() method. * Lots of documentation changes, with many more examples. * Lots of unittests are now used, with many thanks to the unittest module: http://py-unit.sourceforge.net/ Noteworthy changes in 0.2.1 ----------------------------------------------------------------- * MAJOR BACKWARDS COMPATIBLITY BREAK: Major API changes with regards to GnuPGInterface's run() method have been made. A much cleaner and more sensible method is now used to request which filehandles are 'created' and which are 'attached'. See the documentation and example code for details. * The ability to have run() 'attach' GnuPG filehandles to already-opened files works now. Really, it does :) (I implemented more doctest tests to make sure now). Noteworthy changes in 0.1.0 ----------------------------------------------------------------- * Initial release: everything described in documentation works (this is not to say the module is bug-free, but that rather there are no "missing features". gnupginterface-0.3.2.orig/README0100600000175000017500000000075107342054426016566 0ustar jgoerzenjgoerzenGnuPGInterface is a Python module to interface with GnuPG. It concentrates on interacting with GnuPG via filehandles, providing access to control GnuPG via versatile and extensible means. This module is based on GnuPG::Interface, a Perl module by the same author. To install this distribution, simply run the following: python setup.py build python setup.py install See 'pydoc GnuPGInterface' for module documentation. Only recent versions of Python include the executable 'pydoc'. gnupginterface-0.3.2.orig/THANKS0100600000175000017500000000047207372000504016610 0ustar jgoerzenjgoerzenGnuPGInterface was originally written by Frank Tobin. Other people contributed by reporting problems, suggesting various improvements or submitting actual code. Here is a list of those people. Help me keep it complete and free of errors. Frank Tobin ftobin@neverending.org Doobee R. Tzeck drt@un.bewaff.net gnupginterface-0.3.2.orig/setup.py0100600000175000017500000000155207417644443017427 0ustar jgoerzenjgoerzenimport distutils.core long_description = """ GnuPGInterface is a Python module to interface with GnuPG. It concentrates on interacting with GnuPG via filehandles, providing access to control GnuPG via versatile and extensible means. This module is based on GnuPG::Interface, a Perl module by the same author. """ distutils.core.setup( name = 'GnuPGInterface', version = '0.3.2', description = 'GnuPG interactions with file handles', long_description = long_description, author = 'Frank J. Tobin', author_email = 'ftobin@users.sourceforge.net', licence = 'LGPL', platforms = 'POSIX', keywords = 'GnuPG gpg', url = 'http://py-gnupg.sourceforge.net/', py_modules = [ 'GnuPGInterface' ] ) gnupginterface-0.3.2.orig/unittests.py0100600000175000017500000002016607341660010020313 0ustar jgoerzenjgoerzen"""py-unit tests for GnuPG COPYRIGHT: Copyright (C) 2001 Frank J. Tobin, ftobin@neverending.org LICENSE: This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or see http://www.gnu.org/copyleft/lesser.html """ import unittest import os import tempfile import GnuPGInterface __author__ = "Frank J. Tobin, ftobin@neverending.org" __version__ = "0.2.2" __revision__ = "$Id: unittests.py,v 1.2 2001/08/25 08:21:28 ftobin Exp $" class BasicTest(unittest.TestCase): """an initializer superclass""" def __init__(self, methodName=None): self.gnupg = GnuPGInterface.GnuPG() unittest.TestCase.__init__(self, methodName) class GnuPGTests(BasicTest): """Tests for GnuPG class""" def __init__(self, methodName=None): BasicTest.__init__(self, methodName) self.gnupg.passphrase = "Three blind mice" self.gnupg.options.armor = 1 self.gnupg.options.meta_interactive = 0 self.gnupg.options.extra_args.append('--no-secmem-warning') def do_create_fh_operation(self, args, input, passphrase=None): creations = ['stdin', 'stdout'] # Make sure we're getting the passphrase to GnuPG # somehow! assert passphrase != None or self.gnupg.passphrase != None, \ "No way to send the passphrase to GnuPG!" # We'll handle the passphrase manually if passphrase != None: creations.append('passphrase') proc = self.gnupg.run( args, create_fhs=creations ) if passphrase != None: proc.handles['passphrase'].write(passphrase) proc.handles['passphrase'].close() proc.handles['stdin'].write(input) proc.handles['stdin'].close() ciphertext = proc.handles['stdout'].read() proc.handles['stdout'].close() # Checking to make sure GnuPG exited successfully proc.wait() return ciphertext def do_attach_fh_operation(self, args, stdin, stdout, passphrase=None): # Make sure we're getting the passphrase to GnuPG # somehow! assert passphrase != None or self.gnupg.passphrase != None, \ "No way to send the passphrase to GnuPG!" creations = [] # We'll handle the passphrase manually if passphrase != None: handles.append('passphrase') attachments = { 'stdin': stdin, 'stdout': stdout } proc = self.gnupg.run( args, create_fhs=creations, attach_fhs=attachments ) if passphrase != None: proc.handles['passphrase'].write(passphrase) proc.handles['passphrase'].close() # Checking to make sure GnuPG exited successfully proc.wait() def test_create_fhs_solely(self): """Do GnuPG operations using solely the create_fhs feature""" plaintext = "Three blind mice" ciphertext = self.do_create_fh_operation( ['--symmetric'], plaintext ) decryption = self.do_create_fh_operation( ['--decrypt'], ciphertext, self.gnupg.passphrase ) assert decryption == plaintext, \ "GnuPG decrypted output does not match original input" def test_attach_fhs(self): """Do GnuPG operations using the attach_fhs feature""" plaintext_source = '/etc/motd' plainfile = open(plaintext_source) temp1 = tempfile.TemporaryFile() temp2 = tempfile.TemporaryFile() self.do_attach_fh_operation( ['--symmetric'], stdin=plainfile, stdout=temp1 ) temp1.seek(0) self.do_attach_fh_operation( ['--decrypt'], stdin=temp1, stdout=temp2 ) plainfile.seek(0) temp2.seek(0) assert fh_cmp(plainfile, temp2), \ "GnuPG decrypted output does not match original input" class OptionsTests(BasicTest): """Tests for Options class""" def __init__(self, methodName=None): BasicTest.__init__(self, methodName) self.reset_options() def reset_options(self): self.gnupg.options = GnuPGInterface.Options() def option_to_arg(self, option): return '--' + option.replace('_', '-') def test_boolean_args(self): """test Options boolean options that they generate proper arguments""" booleans = [ 'armor', 'no_greeting', 'no_verbose', 'batch', 'always_trust', 'rfc1991', 'quiet', 'openpgp', 'force_v3_sigs', 'no_options', 'textmode' ] for option in booleans: self.reset_options() setattr(self.gnupg.options, option, 1) arg = self.option_to_arg(option) should_be = [arg] result = self.gnupg.options.get_args() assert should_be == result, \ "failure to set option '%s'; should be %s, but result is %s" \ % (option, should_be, result) def test_string_args(self): """test Options string-taking options that they generate proper arguments""" strings = [ 'homedir', 'default_key', 'comment', 'compress_algo', 'options' ] string_value = 'test-argument' for option in strings: self.reset_options() setattr(self.gnupg.options, option, string_value) arg = self.option_to_arg(option) should_be = [arg, string_value] result = self.gnupg.options.get_args() assert should_be == result, \ "failure to set option '%s'; should be %s, but result is %s" \ % (option, should_be, result) def test_list_args(self): """test Options string-taking options that they generate proper arguments""" lists = [ 'recipients', 'encrypt_to' ] list_value = ['test1', 'test2'] for option in lists: self.reset_options() setattr(self.gnupg.options, option, list_value) # special case for recipients, since their # respective argument is 'recipient', not 'recipients' if option == 'recipients': arg = '--recipient' else: arg = self.option_to_arg(option) should_be = [] for v in list_value: should_be.extend([arg, v]) result = self.gnupg.options.get_args() assert should_be == result, \ "failure to set option '%s'; should be %s, but result is %s" \ % (option, should_be, result) class PipesTests(unittest.TestCase): """Tests for Pipes class""" def test_constructor(self): self.pipe = GnuPGInterface.Pipe(1, 2, 0) assert self.pipe.parent == 1 assert self.pipe.child == 2 assert not self.pipe.direct ######################################################################## def fh_cmp(f1, f2, bufsize=8192): while 1: b1 = f1.read(bufsize) b2 = f2.read(bufsize) if b1 != b2: return 0 if not b1: return 1 ######################################################################## if __name__ == "__main__": unittest.main() gnupginterface-0.3.2.orig/PKG-INFO0100600000175000017500000000112307417645152017002 0ustar jgoerzenjgoerzenMetadata-Version: 1.0 Name: GnuPGInterface Version: 0.3.2 Summary: GnuPG interactions with file handles Home-page: http://py-gnupg.sourceforge.net/ Author: Frank J. Tobin Author-email: ftobin@users.sourceforge.net License: UNKNOWN Description: GnuPGInterface is a Python module to interface with GnuPG. It concentrates on interacting with GnuPG via filehandles, providing access to control GnuPG via versatile and extensible means. This module is based on GnuPG::Interface, a Perl module by the same author. Keywords: GnuPG gpg Platform: POSIX