We could always cast counts.keys() to a list, from the dictionary view they
are but a more efficient way of doing this is to simply pop the items from
our result list as we traverse the returned iterable dictionary view.
* CHANGE an occurence of xrange() iteration over a fixed length list to use
range(); Python3's range() function is equivalent to Python2's xrange(),
while the small fixed length of the list in this case doesn't effect speed
at all.
The following snippet shows that to create a proper timestamp, we should
feed mktime() with localtime() data rather than gmtime(), as it is locale
aware.
>>> from time import mktime, gmtime, localtime
>>> bad = gmtime(mktime(gmtime()))
>>> good = gmtime(mktime(localtime()))
>>> judge = gmtime()
>>> if bad == good: "You're using UTC. Demonstration is impossible."
... elif bad == judge: "I can be wrong"
... elif good == judge: "but this shows I'm right"
...
"but this shows I'm right"
The above code checks whether gmtime() == gmtime(timestamp) from
mktime(). Obviously we don't get the same 'now' if we feed the bad value
to mktime.
GPG signature timestamps are considered UTC, this may cause times to be off
by delta > 1000 in def test_signature_string_verification because it
incorrectly gave gmtime() as an argument to mktime().
Python 2 and 3 docs both say that mktime should have a struct_time argument
"which expresses the time in local time, not UTC". So the test is now using
time.localtime() instead of time.gmtime()
* Change the returned _parsers.GenKey from gnupg.GPG.gen_key() to store the
location of the renamed temporary keyrings as attributes. This way, one can
do something like:
>>> key = gpg.gen_key(key_input)
>>> key.keyring
'./generated-keys/328A5C6C1B2F0891125ECBE4624276B5A2296478.pubring.gpg'
* Generated keys in separate keyring would not be available after switching
back to the normal keyrings (not the ones set up for key generation), so at
first in the unittests I imported them back into the main keyrings… this,
however, is would be stupid, as in nullifies half the reasons for using
separate keyrings in the first place, thus the code was commented out. Now
that the temporary keyrings are placed in the gnupg.GPG._generated_keys
directory, it would be nice to eventually either extend GPG.import_keys()
or add a new helper function for doing:
$ gpg --no-default-keyring --keyring pubring.gpg \
--keyring ./generated-keys/<some_fingerprint>.gpg
* Add GPG._generated_keys as an _utils.InheritableProperty class for storing
a configurable (even by subclasses of GPGBase, without property overrides)
subdirectory of whichever directory gnupg.GPG.homedir is set to. This
subdirectory can be used via the 'separate_keyring=True' option to
gnupg.GPG.gen_key_input(), which will switch temporarily to new pubring.gpg
and secring.gpg keyrings during key creation, and upon finishing creation
of the new key, will ask for the new key's fingerprint, and move the
keyrings into this GPG._generated_keys directory, renamed in the format
"<GPG.homedir>/<GPG._generated_keys>/<fingerprint>.[pub|sec]ring.gpg".