docs: def import_key(key):
      """Import an ASCII Armor key.
  
      A Radix64 format keyid is also supported for backwards
      compatibility. In this case Ubuntu keyserver will be
      queried for a key via HTTPS by its keyid. This method
      is less preferrable because https proxy servers may
      require traffic decryption which is equivalent to a
      man-in-the-middle attack (a proxy server impersonates
      keyserver TLS certificates and has to be explicitly
      trusted by the system).
  
      :param key: A GPG key in ASCII armor format,
                    including BEGIN and END markers or a keyid.
      :type key: (bytes, str)
      :raises: GPGKeyError if the key could not be imported
      """
      key = key.strip()
      if '-' in key or '\n' in key:
          # Send everything not obviously a keyid to GPG to import, as
          # we trust its validation better than our own. eg. handling
          # comments before the key.
          log("PGP key found (looks like ASCII Armor format)", level=DEBUG)
          if ('-----BEGIN PGP PUBLIC KEY BLOCK-----' in key and
                  '-----END PGP PUBLIC KEY BLOCK-----' in key):
              log("Writing provided PGP key in the binary format", level=DEBUG)
              if six.PY3:
                  key_bytes = key.encode('utf-8')
              else:
                  key_bytes = key
              key_name = _get_keyid_by_gpg_key(key_bytes)
              key_gpg = _dearmor_gpg_key(key_bytes)
              _write_apt_gpg_keyfile(key_name=key_name, key_material=key_gpg)
          else:
              raise GPGKeyError("ASCII armor markers missing from GPG key")
      else:
          log("PGP key found (looks like Radix64 format)", level=WARNING)
          log("SECURELY importing PGP key from keyserver; "
              "full key not provided.", level=WARNING)
          # as of bionic add-apt-repository uses curl with an HTTPS keyserver URL
          # to retrieve GPG keys. `apt-key adv` command is deprecated as is
          # apt-key in general as noted in its manpage. See lp:1433761 for more
          # history. Instead, /etc/apt/trusted.gpg.d is used directly to drop
          # gpg
          key_asc = _get_key_by_keyid(key)
          # write the key in GPG format so that apt-key list shows it
          key_gpg = _dearmor_gpg_key(key_asc)
          _write_apt_gpg_keyfile(key_name=key, key_material=key_gpg)