Пример #1
0
def get_bucket_name_and_location(user):
    """return a tuple of (name, location) that might depend on the
    user."""
    name = settings.SYMBOLS_BUCKET_DEFAULT_NAME
    location = settings.SYMBOLS_BUCKET_DEFAULT_LOCATION
    exceptions = dict(
        (x.lower(), y) for x, y in settings.SYMBOLS_BUCKET_EXCEPTIONS.items()
    )
    if user.email.lower() in exceptions:
        # easy
        exception = exceptions[user.email.lower()]
    else:
        # match against every possible wildcard
        exception = None  # assume no match
        for email_or_wildcard in settings.SYMBOLS_BUCKET_EXCEPTIONS:
            if fnmatch.fnmatch(user.email.lower(), email_or_wildcard.lower()):
                # a match!
                exception = settings.SYMBOLS_BUCKET_EXCEPTIONS[
                    email_or_wildcard
                ]
                break

    if exception:
        if '|' in exception:
            name, location = exception.split('|')
        else:
            name = exception
    return name, location
Пример #2
0
def get_bucket_name_and_location(user):
    """return a tuple of (name, location) that might depend on the
    user."""
    name = settings.SYMBOLS_BUCKET_DEFAULT_NAME
    location = settings.SYMBOLS_BUCKET_DEFAULT_LOCATION
    exceptions = dict(
        (x.lower(), y) for x, y in settings.SYMBOLS_BUCKET_EXCEPTIONS.items())
    if user.email.lower() in exceptions:
        # easy
        exception = exceptions[user.email.lower()]
    else:
        # match against every possible wildcard
        exception = None  # assume no match
        for email_or_wildcard in settings.SYMBOLS_BUCKET_EXCEPTIONS:
            if '*' in email_or_wildcard:
                regex = re.compile(
                    re.escape(email_or_wildcard).replace('\\*', '.'), re.I)
                if regex.findall(user.email):
                    # a match!
                    exception = settings.SYMBOLS_BUCKET_EXCEPTIONS[
                        email_or_wildcard]
                    break

    if exception:
        if '|' in exception:
            name, location = exception.split('|')
        else:
            name = exception
    return name, location
Пример #3
0
def get_bucket_name_and_location(user):
    """return a tuple of (name, location) that might depend on the
    user."""
    name = settings.SYMBOLS_BUCKET_DEFAULT_NAME
    location = settings.SYMBOLS_BUCKET_DEFAULT_LOCATION
    exceptions = dict(
        (x.lower(), y) for x, y in settings.SYMBOLS_BUCKET_EXCEPTIONS.items()
    )
    if user.email.lower() in exceptions:
        # easy
        exception = exceptions[user.email.lower()]
    else:
        # match against every possible wildcard
        exception = None  # assume no match
        for email_or_wildcard in settings.SYMBOLS_BUCKET_EXCEPTIONS:
            if '*' in email_or_wildcard:
                regex = re.compile(re.escape(email_or_wildcard).replace(
                    '\\*',
                    '.'
                ), re.I)
                if regex.findall(user.email):
                    # a match!
                    exception = settings.SYMBOLS_BUCKET_EXCEPTIONS[
                        email_or_wildcard
                    ]
                    break

    if exception:
        if '|' in exception:
            name, location = exception.split('|')
        else:
            name = exception
    return name, location
Пример #4
0
def get_bucket_name_and_location(user):
    """return a tuple of (name, location) that might depend on the
    user."""
    name = settings.SYMBOLS_BUCKET_DEFAULT_NAME
    location = settings.SYMBOLS_BUCKET_DEFAULT_LOCATION
    exceptions = dict(
        (x.lower(), y) for x, y in settings.SYMBOLS_BUCKET_EXCEPTIONS.items())
    if user.email.lower() in exceptions:
        # easy
        exception = exceptions[user.email.lower()]
    else:
        # match against every possible wildcard
        exception = None  # assume no match
        for email_or_wildcard in settings.SYMBOLS_BUCKET_EXCEPTIONS:
            if fnmatch.fnmatch(user.email.lower(), email_or_wildcard.lower()):
                # a match!
                exception = settings.SYMBOLS_BUCKET_EXCEPTIONS[
                    email_or_wildcard]
                break

    if exception:
        if '|' in exception:
            name, location = exception.split('|')
        else:
            name = exception
    return name, location