コード例 #1
0
ファイル: views.py プロジェクト: lonnen/socorro
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
ファイル: views.py プロジェクト: amuntner/socorro
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
ファイル: views.py プロジェクト: 4thAce/socorro
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