import re
import unicodedata


def slugify(name, allow_periods=False):
    """
    Returns a tuple with slug and lowered slug based on name
    """
    RE_NON_ALPHA_ETC = re.compile(r'[^.\w]+' if allow_periods else r'[^\w]+')
    slug = RE_NON_ALPHA_ETC.sub('-',  # replace non ". alphanum_" sequences into single -
        unicodedata.normalize('NFKD', name).encode('ascii', 'ignore').decode().replace("'", '')  # asciify & strip apostophes.   https://stackoverflow.com/a/53261200
    ).strip('-')  # leading - or trailing - gets removed
    return slug, slug.lower()