# Path: pubs/p3.py
#     def input():
#     def _get_raw_stdout():
#     def _get_raw_stderr():
#     def u_maybe(s):
#         def __init__(self, *args, **kwargs):
#         def write(self, s):
#     def _get_fake_stdio_ucontent(stdio):
#         def _print_message(self, message, file=None):
#     def _get_raw_stdout():
#     def _get_raw_stderr():
#     def u_maybe(s):
#         def __init__(self, *args, **kwargs):
#         def write(self, s):
#     def _fake_stdio(additional_out=False):
#     def _get_fake_stdio_ucontent(stdio):
# def isbasestr(obj):
#     class StdIO(io.BytesIO):
#     class ArgumentParser(argparse.ArgumentParser):
#     class StdIO(io.BytesIO):


import unicodedata
import re
from .p3 import ustr, uchr
def str2citekey(s):
    key = unicodedata.normalize('NFKD', ustr(s)).encode('ascii', 'ignore').decode()
    key = CITEKEY_EXCLUDE_RE.sub('', key)
    # Normalize chars and remove non-ascii
    return key


def check_citekey(citekey):
    if citekey is None or not citekey.strip():
        raise ValueError("Empty citekeys are not valid")


def verify_bibdata(bibdata):
    if bibdata is None or len(bibdata) == 0:
        raise ValueError("no valid bibdata")
    if len(bibdata) > 1:
        raise ValueError("ambiguous: multiple entries in the bibdata.")


def get_entry(bibdata):
    verify_bibdata(bibdata)
    for e in bibdata.items():
        return e


def extract_citekey(bibdata):
    citekey, entry = get_entry(bibdata)
    return citekey



# Path: pubs/p3.py
#     def input():
#     def _get_raw_stdout():
#     def _get_raw_stderr():
#     def u_maybe(s):
#         def __init__(self, *args, **kwargs):
#         def write(self, s):
#     def _get_fake_stdio_ucontent(stdio):
#         def _print_message(self, message, file=None):
#     def _get_raw_stdout():
#     def _get_raw_stderr():
#     def u_maybe(s):
#         def __init__(self, *args, **kwargs):
#         def write(self, s):
#     def _fake_stdio(additional_out=False):
#     def _get_fake_stdio_ucontent(stdio):
# def isbasestr(obj):
#     class StdIO(io.BytesIO):
#     class ArgumentParser(argparse.ArgumentParser):
#     class StdIO(io.BytesIO):


# Path: pubs/bibstruct.py
import unicodedata
import re
from .p3 import ustr, uchr

def str2citekey(s):
    key = unicodedata.normalize('NFKD', ustr(s)).encode('ascii', 'ignore').decode()
    key = CITEKEY_EXCLUDE_RE.sub('', key)
    # Normalize chars and remove non-ascii
    return key


def check_citekey(citekey):
    if citekey is None or not citekey.strip():
        raise ValueError("Empty citekeys are not valid")


def verify_bibdata(bibdata):
    if bibdata is None or len(bibdata) == 0:
        raise ValueError("no valid bibdata")
    if len(bibdata) > 1:
        raise ValueError("ambiguous: multiple entries in the bibdata.")


def get_entry(bibdata):
    verify_bibdata(bibdata)
    for e in bibdata.items():
        return e


def extract_citekey(bibdata):
    citekey, entry = get_entry(bibdata)
    return citekey



def author_last(author_str):