Commit Graph

152 Commits (4bd45d06cd262ab70ce0a2c517f36a78f2528482)

Author SHA1 Message Date
Isis Lovecruft 4bd45d06cd
Update docstring for GPGBase._homedir_getter() property. 2013-05-28 10:18:43 +00:00
Isis Lovecruft 15d4bc0eb4
Fix a bug resulting from a typo in the @atexit.register'd function. 2013-05-28 10:17:43 +00:00
Isis Lovecruft b7ba572aa1
Update docstring for GPGBase.__remove_path__(). 2013-05-28 10:17:08 +00:00
Isis Lovecruft 7129a4c85f
Update docstring for GPGBase._find_agent(). 2013-05-28 10:15:51 +00:00
Isis Lovecruft 6a47c3cd77
Move several methods and attributes from GPG to GPGBase.
* Move _decode_errors
 * Move _result_map
 * Move _copy_data()
 * Move _read_data()
 * Move _read_response()
 * Move _make_args()
 * Move _open_subprocess()
 * Move _collect_output()
 * Move _handle_io()
2013-05-28 10:12:01 +00:00
Isis Lovecruft 8e2f905859
handle_status() → _handle_status() in _parsers.py and gnupg.py. 2013-05-28 09:24:06 +00:00
Isis Lovecruft cacedc6242
self.gpg → self._gpg in _parsers.py. 2013-05-28 09:18:58 +00:00
Isis Lovecruft d910a48660
GPG.filesystemencoding → GPG._filesystemencoding 2013-05-28 08:52:49 +00:00
Isis Lovecruft 87ced52f85
GPG.encoding → GPG._encoding 2013-05-28 08:48:36 +00:00
Isis Lovecruft 5b731736fe
Remove duplicate attribute primary_key_created from GenKey. 2013-05-28 08:42:03 +00:00
Isis Lovecruft 08bbfb3a68
Fix several missing 's's in doctest calls to GPG(homedir='./tests/doctests'). 2013-05-28 08:37:46 +00:00
Isis Lovecruft 4c1d7599bd
Remove duplicate code from GPGWrapper. 2013-05-28 07:41:32 +00:00
Isis Lovecruft 18f527c514
Add a missing colon in an attribute autodoc comment. 2013-05-28 07:40:55 +00:00
Isis Lovecruft 6f5c7fb610
Split imports in gnupg.py to one-per-line. 2013-05-28 07:40:32 +00:00
Isis Lovecruft bdd08fb31f
Remove GPGMeta and GPGBase specific imports from gnupg.py. 2013-05-28 07:39:02 +00:00
Isis Lovecruft a95a49e04a
Move GPGMeta and GPGBase to _meta.py. 2013-05-28 07:35:15 +00:00
Isis Lovecruft ecd8faa425
Move re import to GPGWrapper class, it isn't used anywhere else. 2013-05-28 07:33:38 +00:00
Isis Lovecruft 72ef15f5a4
Remove unused logging and tempfile imports from gnupg.py. 2013-05-28 07:32:35 +00:00
Isis Lovecruft 6f9c4c7423
Remove commented out code and unused pprint import. 2013-05-28 07:31:04 +00:00
Isis Lovecruft fd85cb8f5c Remove commented out _init_decorator() from GPGMeta class. 2013-05-28 07:22:01 +00:00
Isis Lovecruft 2be8cb1fe6 Fix error in module docstring which had the wrong version we forked from. 2013-05-28 07:21:14 +00:00
Isis Lovecruft 490574c3ec
Change variable name file→filename in GPG.decrypt_file(). 2013-05-27 09:08:49 +00:00
Isis Lovecruft 688ceb9a6d
Change parameter name data→message in GPG.decrypt(). 2013-05-27 09:08:26 +00:00
Isis Lovecruft bfbb189459
GPG.encrypt() should now be called with each recipient as a single parameter. 2013-05-27 09:04:15 +00:00
Isis Lovecruft 7c9c00a957
Rewrite encrypt_file() to handle unicode/str, fn/files, and multi recipients. 2013-05-27 09:01:48 +00:00
Isis Lovecruft 8b355d5541
Update docstring for GPG.encrypt_file() with new parameter type requirements.
* GPG.encrypt_file() isn't ever directly used now, and so we should switch to
   calling it in the same way that GPG._sign_file() is now called when
   necessary though GPG.sign().
2013-05-27 08:59:10 +00:00
Isis Lovecruft 897f32307e
Make the kwargs for GPG.encrypt_file() appear slightly less overwhelming. 2013-05-27 08:53:18 +00:00
Isis Lovecruft b6076a7f65
Add support for using separate keyrings during key generation.
* If GPG.gen_key_input() is called with 'separate_keyring = True', then a
   unique temporary keyring filename will be created in the format:

       username@hostname_timestamp.[pub|sec]ring

   where the timestamp is an integer representing seconds since epoch for
   UTC. The filename for the two temporary keyrings are stored in the class
   attribute GPG.temp_keyring and GPG.temp_secring, so that when GPG.gen_key()
   is called with results of GPG.gen_key_input([...], separate_keyring=True),
   the keys are created using the temporary keyrings, which are then renamed
   to:

       fingerprint.[pub|sec]ring

   where fingerprint is the fingerprint of the key which has just been
   generated. The attributes GPG.temp_keyring and GPG.temp_secring are then
   both reset to None, so that these attributes, if the hold anything, only
   hold the filenames for the last call to GPG.gen_key_input().

 * I didn't especially want to add new features right now, but this turned out
   to be necessary for cases where we want to generate a bunch of keys and
   then use them right away. Without doing this, it would have been necessary
   to store the results of the freshly generated key in memory and then write
   them to a file by hand, which proved to be rather volatile and error-prone,
   as none of the unittests for encryption/decryption for multiple recipients
   were passing, nor had ever passed. (A note again on the latter: upstream's
   unittests for encryption and decryption are entirely encased in try/except
   blocks which CATCH ALL ERRORS. Qu'est-que fuck is the point of a unittest
   if it catches all errors?)
2013-05-27 08:47:17 +00:00
Isis Lovecruft ea58623e75
Fix doctest for GPG.recv_keys(). 2013-05-27 08:23:35 +00:00
Isis Lovecruft 3516431da9
Comment out the pretty printing of results for GPG.import_key() for now. 2013-05-27 08:22:35 +00:00
Isis Lovecruft eb93fd48de
Fix doctest for GPG.import_key(). 2013-05-27 08:22:00 +00:00
Isis Lovecruft 434a650799
Change ivar name p→proc. 2013-05-27 08:21:25 +00:00
Isis Lovecruft de36fe52d1
Change varable name keyid→default_key. 2013-05-27 08:20:27 +00:00
Isis Lovecruft 77bb8d8500
Make GPG._make_args() shorter and prettier. 2013-05-27 08:16:35 +00:00
Isis Lovecruft e501afb6a7
Add initialization of GPG.temp_keyring and GPG.temp_secring objects. 2013-05-27 08:15:50 +00:00
Isis Lovecruft 1dfadbf32f
Remove excessive log statement. 2013-05-27 08:15:10 +00:00
Isis Lovecruft efc10b6791
Remove unused import for socket module. 2013-05-27 08:14:52 +00:00
Isis Lovecruft a0e1d4db6e
Add a utility for getting the current UTC seconds-since-epoch time. 2013-05-27 08:14:08 +00:00
Isis Lovecruft 50b057918b
Change line to check multiple types in the same isinstance() call. 2013-05-27 08:13:27 +00:00
Isis Lovecruft bf591c2dd0
Add a utility for creating a 'user@hostname' string. 2013-05-27 08:12:54 +00:00
Isis Lovecruft cce8785f39
Slice equiv. bytes from strings as we read() from file handles in _copy_data(). 2013-05-27 07:50:36 +00:00
Isis Lovecruft e252f63341
Switch to calling a bound super on Crypt for handle_status() method again. 2013-05-27 07:49:10 +00:00
Isis Lovecruft 1d326f8808
GnuPG only *sometimes* returns the filename for the plaintext.
* We can't split twice at first, because sometimes there isn't a third field
   in the string.
 * There isn't any rhyme or reason to when the filename is present or
   missing. It just is.
2013-05-27 07:46:54 +00:00
Isis Lovecruft 1c3f0c3c9a
There are lots of these list(dict.items()) in the old codebase. Total nonsense.
* These evaluate in all interpreters to functionally the same bytecode, with
   an extra LOAD_GLOBAL and then a CALL_FUNCTION for that GLOBAL which doesn't
   gets a passthrough value. I have absolutely no idea why someone thought it
   was necessary to code it this way, unless there used to be some weird dict
   bug in some version of Python (which is totally possible) that I don't
   remember and have never heard about. Disassembled:

   >>> def normal(things):
   ...     for k,v in things.items():
   ...         print "%s=%s" % (k,v)
   ...
   ...
   >>> def notnormal(things):
   ...     for k,v in list(things.items()):
   ...         print "%s=%s" % (k,v)
   ...
   >>> dis.dis(normal)
      2           0 SETUP_LOOP              41 (to 44)
                  3 LOAD_FAST                0 (things)
                  6 LOAD_ATTR                0 (items)
                  9 CALL_FUNCTION            0
                 12 GET_ITER
            >>   13 FOR_ITER                27 (to 43)
                 16 UNPACK_SEQUENCE          2
                 19 STORE_FAST               1 (k)
                 22 STORE_FAST               2 (v)

      3          25 LOAD_CONST               1 ('%s=%s')
                 28 LOAD_FAST                1 (k)
                 31 LOAD_FAST                2 (v)
                 34 BUILD_TUPLE              2
                 37 BINARY_MODULO
                 38 PRINT_ITEM
                 39 PRINT_NEWLINE
                 40 JUMP_ABSOLUTE           13
            >>   43 POP_BLOCK
            >>   44 LOAD_CONST               0 (None)
                 47 RETURN_VALUE
   >>> dis.dis(notnormal)
      2           0 SETUP_LOOP              47 (to 50)
                  3 LOAD_GLOBAL              0 (list)
                  6 LOAD_FAST                0 (things)
                  9 LOAD_ATTR                1 (items)
                 12 CALL_FUNCTION            0
                 15 CALL_FUNCTION            1
                 18 GET_ITER
            >>   19 FOR_ITER                27 (to 49)
                 22 UNPACK_SEQUENCE          2
                 25 STORE_FAST               1 (k)
                 28 STORE_FAST               2 (v)

      3          31 LOAD_CONST               1 ('%s=%s')
                 34 LOAD_FAST                1 (k)
                 37 LOAD_FAST                2 (v)
                 40 BUILD_TUPLE              2
                 43 BINARY_MODULO
                 44 PRINT_ITEM
                 45 PRINT_NEWLINE
                 46 JUMP_ABSOLUTE           19
            >>   49 POP_BLOCK
            >>   50 LOAD_CONST               0 (None)
                 53 RETURN_VALUE
2013-05-27 07:28:03 +00:00
Isis Lovecruft c31e1303ba
GnuPG status code '17' on imports means '16'. That wasn't documented anywhere. 2013-05-27 07:26:15 +00:00
Isis Lovecruft c3dcd34f5a
This log statement didn't need 2LOC. 2013-05-27 07:25:27 +00:00
Isis Lovecruft e52e9001d1
Rewrite _check_option() in _sanitise() to be way more efficient and readable. 2013-05-27 07:24:31 +00:00
Isis Lovecruft f65022500d
Add note on using itertools.dropwhile() for efficiency in _is_allowed().
* If/when it's rewritten, a simple speed/efficiency check can be done with:
   >>> import dis
   >>> dis.dis(_is_allowed_orig('--dragons'))
   >>> dis.dis(_is_allowed_orig('--encrypt'))
   >>> dis.dis(_is_allowed_new('--dragons'))
   >>> dis.dis(_is_allowed_new('--encrypt'))
2013-05-27 07:19:40 +00:00
Isis Lovecruft 69c6981b66
A unicode(list()) versus a unicode(str()) are different. 2013-05-27 07:15:33 +00:00
Isis Lovecruft 30223d4203
Don't attempt to set up logging to file unless logging is actually enabled. 2013-05-27 07:14:03 +00:00