def setup_keyring(keyring_name):
    '''Setup the keyring'''
    keyring_path = os.path.join("test", "outputdata", keyring_name)
    # Delete the entire keyring
    shutil.rmtree(keyring_path, ignore_errors=True)
    os.makedirs(keyring_path)
    gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg")
    for key_name in ["key1_private", "key1_public"]:
        with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile:
            key_str = "".join(keyfile.readlines())
        import_result = gpg.import_keys(key_str)
        print("Import result:", type(import_result))
        print(import_result.__dict__)
        if import_result.count == 1 and len(set(import_result.fingerprints)) == 1:
            print("Got one import result")
    return gpg
def _kindpatstoglobs(kindpats, recursive=False):
    """Attempt to convert 'kindpats' to glob patterns that can be used in a
    treematcher.

    kindpats should be already normalized to be relative to repo root.

    If recursive is True, `glob:a*` will match both `a1/b` and `a1`, otherwise
    `glob:a*` will only match `a1` but not `a1/b`.

    Return None if there are unsupported patterns (ex. regular expressions).
    """
    if not _usetreematcher:
        return None
    globs = []
    for kindpat in kindpats:
        kind, pat = kindpat[0:2]
        if kind == "re":
            # Attempt to convert the re pat to globs
            reglobs = _convertretoglobs(pat)
            if reglobs is not None:
                globs += reglobs
            else:
                return None
        elif kind == "glob":
            # The treematcher (man gitignore) does not support csh-style
            # brackets (ex. "{a,b,c}"). Expand the brackets to patterns.
            for subpat in pathmatcher.expandcurlybrackets(pat):
                normalized = pathmatcher.normalizeglob(subpat)
                if recursive:
                    normalized = _makeglobrecursive(normalized)
                globs.append(normalized)
        elif kind == "path":
            if pat == ".":
                # Special case. Comes from `util.normpath`.
                pat = ""
            else:
                pat = pathmatcher.plaintoglob(pat)
            pat = _makeglobrecursive(pat)
            globs.append(pat)
        else:
            return None
    return globs