docs: def _get_keyid_by_gpg_key(key_material):
      """Get a GPG key fingerprint by GPG key material.
      Gets a GPG key fingerprint (40-digit, 160-bit) by the ASCII armor-encoded
      or binary GPG key material. Can be used, for example, to generate file
      names for keys passed via charm options.
  
      :param key_material: ASCII armor-encoded or binary GPG key material
      :type key_material: bytes
      :raises: GPGKeyError if invalid key material has been provided
      :returns: A GPG key fingerprint
      :rtype: str
      """
      # Use the same gpg command for both Xenial and Bionic
      cmd = 'gpg --with-colons --with-fingerprint'
      ps = subprocess.Popen(cmd.split(),
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE,
                            stdin=subprocess.PIPE)
      out, err = ps.communicate(input=key_material)
      if six.PY3:
          out = out.decode('utf-8')
          err = err.decode('utf-8')
      if 'gpg: no valid OpenPGP data found.' in err:
          raise GPGKeyError('Invalid GPG key material provided')
      # from gnupg2 docs: fpr :: Fingerprint (fingerprint is in field 10)
      return re.search(r"^fpr:{9}([0-9A-F]{40}):$", out, re.MULTILINE).group(1)