diff options
| author | Ben McGinnes <[email protected]> | 2018-09-24 23:59:31 +0000 | 
|---|---|---|
| committer | Ben McGinnes <[email protected]> | 2018-09-24 23:59:31 +0000 | 
| commit | 62e4e2cb5edb09183b9f9d448f992fe65cb6db85 (patch) | |
| tree | 76330f0fe5dcd0af59c3d8cd38fddd3fa87e0398 /lang/python/examples/howto/export-key.py | |
| parent | docs: python bindings howto (diff) | |
| download | gpgme-62e4e2cb5edb09183b9f9d448f992fe65cb6db85.tar.gz gpgme-62e4e2cb5edb09183b9f9d448f992fe65cb6db85.zip  | |
docs and examples: python bindings
* Woumd up the "what's new" section.
* Added an example for sending a key to the keyservers via hkp4py.
* Updated the export key code to use a more complete check for the
  $GNUPGHOME location.
* Expanded on the installation and reinstallation troubleshooting
  section.
Tested-by: Ben McGinnes <[email protected]>
Signed-off-by: Ben McGinnes <[email protected]>
Diffstat (limited to 'lang/python/examples/howto/export-key.py')
| -rwxr-xr-x | lang/python/examples/howto/export-key.py | 22 | 
1 files changed, 18 insertions, 4 deletions
diff --git a/lang/python/examples/howto/export-key.py b/lang/python/examples/howto/export-key.py index 80768fe7..c17f2471 100755 --- a/lang/python/examples/howto/export-key.py +++ b/lang/python/examples/howto/export-key.py @@ -51,12 +51,26 @@ else:      logrus = input("Enter the UID matching the key(s) to export: ")      homedir = input("Enter the GPG configuration directory path (optional): ") -if homedir.startswith("~"): -    if os.path.exists(os.path.expanduser(homedir)) is True: -        c.home_dir = os.path.expanduser(homedir) +if len(homedir) == 0: +    homedir = None +elif homedir.startswith("~"): +    userdir = os.path.expanduser(homedir) +    if os.path.exists(userdir) is True: +        homedir = os.path.realpath(userdir) +    else: +        homedir = None +else: +    homedir = os.path.realpath(homedir) + +if os.path.exists(homedir) is False: +    homedir = None +else: +    if os.path.isdir(homedir) is False: +        homedir = None      else:          pass -elif os.path.exists(homedir) is True: + +if homedir is not None:      c.home_dir = homedir  else:      pass  | 
