[Pkg-gnupg-commit] [gpgme] 71/132: python: Wrap utility functions.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Wed Apr 26 01:01:26 UTC 2017


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch experimental
in repository gpgme.

commit 92adc9bbf640eb5d9177d3ba0189e0f6cee4e995
Author: Justus Winter <justus at g10code.com>
Date:   Tue Feb 14 16:30:30 2017 +0100

    python: Wrap utility functions.
    
    * NEWS: Update.
    * lang/python/gpg/core.py (pubkey_algo_string): New function.
    (pubkey_algo_name): Add docstring.
    (hash_algo_name): Likewise.
    (get_protocol_name): Likewise.
    (addrspec_from_uid): New function.
    * lang/python/gpgme.i (gpgme_pubkey_algo_string): Result must be
    freed.
    (gpgme_addrspec_from_uid): Likewise.
    
    Signed-off-by: Justus Winter <justus at g10code.com>
---
 NEWS                    |  8 +++++---
 lang/python/gpg/core.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 lang/python/gpgme.i     |  2 ++
 3 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 125d54e..a974ec7 100644
--- a/NEWS
+++ b/NEWS
@@ -13,9 +13,11 @@ Noteworthy changes in version 1.8.1 (unreleased)
  cpp: Key::addUid()                                 NEW.
  qt: CryptoConfig::stringValueList()                NEW.
  gpgme_data_rewind                                  UN-DEPRECATE.
- py: Context.__init__  EXTENDED: New keyword argument home_dir.
- py: Context.home_dir  NEW.
- py: Context.keylist   EXTENDED: New keyword argument mode.
+ py: Context.__init__        EXTENDED: New keyword arg home_dir.
+ py: Context.home_dir        NEW.
+ py: Context.keylist         EXTENDED: New keyword arg mode.
+ py: core.pubkey_algo_string NEW.
+ py: core.addrspec_from_uid  NEW.
 
 
 Noteworthy changes in version 1.8.0 (2016-11-16)
diff --git a/lang/python/gpg/core.py b/lang/python/gpg/core.py
index e07ec33..18a7e3a 100644
--- a/lang/python/gpg/core.py
+++ b/lang/python/gpg/core.py
@@ -1118,15 +1118,64 @@ class Data(GpgmeWrapper):
                 chunks.append(result)
             return b''.join(chunks)
 
+def pubkey_algo_string(subkey):
+    """Return short algorithm string
+
+    Return a public key algorithm string (e.g. "rsa2048") for a given
+    SUBKEY.
+
+    Returns:
+    algo      - a string
+
+    """
+    return gpgme.gpgme_pubkey_algo_string(subkey)
+
 def pubkey_algo_name(algo):
+    """Return name of public key algorithm
+
+    Return the name of the public key algorithm for a given numeric
+    algorithm id ALGO (cf. RFC4880).
+
+    Returns:
+    algo      - a string
+
+    """
     return gpgme.gpgme_pubkey_algo_name(algo)
 
 def hash_algo_name(algo):
+    """Return name of hash algorithm
+
+    Return the name of the hash algorithm for a given numeric
+    algorithm id ALGO (cf. RFC4880).
+
+    Returns:
+    algo      - a string
+
+    """
     return gpgme.gpgme_hash_algo_name(algo)
 
 def get_protocol_name(proto):
+    """Get protocol description
+
+    Get the string describing protocol PROTO.
+
+    Returns:
+    proto     - a string
+
+    """
     return gpgme.gpgme_get_protocol_name(proto)
 
+def addrspec_from_uid(uid):
+    """Return the address spec
+
+    Return the addr-spec (cf. RFC2822 section 4.3) from a user id UID.
+
+    Returns:
+    addr_spec - a string
+
+    """
+    return gpgme.gpgme_addrspec_from_uid(uid)
+
 def check_version(version=None):
     return gpgme.gpgme_check_version(version)
 
diff --git a/lang/python/gpgme.i b/lang/python/gpgme.i
index dc691dd..c7fc14e 100644
--- a/lang/python/gpgme.i
+++ b/lang/python/gpgme.i
@@ -113,6 +113,8 @@
 /* Release returned buffers as necessary.  */
 %typemap(newfree) char * "gpgme_free($1);";
 %newobject gpgme_data_release_and_get_mem;
+%newobject gpgme_pubkey_algo_string;
+%newobject gpgme_addrspec_from_uid;
 
 %typemap(arginit) gpgme_key_t [] {
   $1 = NULL;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gpgme.git



More information about the Pkg-gnupg-commit mailing list