third_party/chevron/chevron/renderer.py
def _get_key(key, scopes):
    """Get a key from the current scope"""

    # If the key is a dot
    if key == '.':
        # Then just return the current scope
        return scopes[0]

    # Loop through the scopes
    for scope in scopes:
        try:
            # For every dot seperated key
            for child in key.split('.'):
                # Move into the scope
                try:
                    # Try subscripting (Normal dictionaries)
                    scope = scope[child]
                except (TypeError, AttributeError):
                    # Try the dictionary (Complex types)
                    scope = scope.__dict__[child]

            # Return an empty string if falsy, with two exceptions
            # 0 should return 0, and False should return False
            if scope in (0, False):
                return scope

            try:
                # This allows for custom falsy data types
                # https://github.com/noahmorrison/chevron/issues/35
                if scope._CHEVRON_return_scope_when_falsy:
                    return scope
            except AttributeError:
                return scope or ''
        except (AttributeError, KeyError):
            # We couldn't find the key in the current scope
            # We'll try again on the next pass
            pass

    # We couldn't find the key in any of the scopes
    return ''
Get a key from the current scope
Get a key from the current scope
Get a key from the current scope
def _get_key(key, scopes):
    if key == '.':
        return scopes[0]
    for scope in scopes:
        try:
            for child in key.split('.'):
                try:
                    scope = scope[child]
                except (TypeError, AttributeError):
                    scope = scope.__dict__[child]
            if scope in (0, False):
                return scope
            try:
                if scope._CHEVRON_return_scope_when_falsy:
                    return scope
            except AttributeError:
                return scope or ''
        except (AttributeError, KeyError):
            pass
    return ''
def _get_key ( key , scopes ) : if key == '.' : return scopes [ 0 ] for scope in scopes : try : for child in key . split ( '.' ) : try : scope = scope [ child ] except ( TypeError , AttributeError ) : scope = scope . __dict__ [ child ] if scope in ( 0 , False ) : return scope try : if scope . _CHEVRON_return_scope_when_falsy : return scope except AttributeError : return scope or '' except ( AttributeError , KeyError ) : pass return ''
Get a key from the current scope
Get a key from the current scope
"""Get a key from the current scope""" # If the key is a dot # Then just return the current scope # Loop through the scopes # For every dot seperated key # Move into the scope # Try subscripting (Normal dictionaries) # Try the dictionary (Complex types) # Return an empty string if falsy, with two exceptions # 0 should return 0, and False should return False # This allows for custom falsy data types # https://github.com/noahmorrison/chevron/issues/35 # We couldn't find the key in the current scope # We'll try again on the next pass # We couldn't find the key in any of the scopes
key
scopes