kifield/common.py
def find_by_key(key, array):
    """Return a list of array elements whose first element matches the key.

    Args:
        key (string): Slash-separated string of keys to search for.
        array (list): Nested list of lists where first member of each list is a key.

    Returns:
        list: Elements from the list with the matching key.
    """

    try:
        k, sub_key = key.split("/", maxsplit=1)
    except ValueError:
        k = key
        sub_key = None

    found_elements = []
    for e in array:
        try:
            k = e[0].value().lower()
        except (IndexError, AttributeError, TypeError):
            pass
        else:
            if k == key:
                if not sub_key:
                    found_elements.append(e)
                else:
                    found_elements.extend(find_by_key(sub_key, e))
    return found_elements
Return a list of array elements whose first element matches the key.

    Args:
        key (string): Slash-separated string of keys to search for.
        array (list): Nested list of lists where first member of each list is a key.

    Returns:
        list: Elements from the list with the matching key.
    
Return a list of array elements whose first element matches the key.
Return a list of array elements whose first element matches the key .
def find_by_key(key, array):
    try:
        k, sub_key = key.split("/", maxsplit=1)
    except ValueError:
        k = key
        sub_key = None
    found_elements = []
    for e in array:
        try:
            k = e[0].value().lower()
        except (IndexError, AttributeError, TypeError):
            pass
        else:
            if k == key:
                if not sub_key:
                    found_elements.append(e)
                else:
                    found_elements.extend(find_by_key(sub_key, e))
    return found_elements
def find_by_key ( key , array ) : try : k , sub_key = key . split ( "/" , maxsplit = 1 ) except ValueError : k = key sub_key = None found_elements = [ ] for e in array : try : k = e [ 0 ] . value ( ) . lower ( ) except ( IndexError , AttributeError , TypeError ) : pass else : if k == key : if not sub_key : found_elements . append ( e ) else : found_elements . extend ( find_by_key ( sub_key , e ) ) return found_elements
Return a list of array elements whose first element matches the key.
Return a list of array elements whose first element matches the key .
"""Return a list of array elements whose first element matches the key.

    Args:
        key (string): Slash-separated string of keys to search for.
        array (list): Nested list of lists where first member of each list is a key.

    Returns:
        list: Elements from the list with the matching key.
    """
Elements from the list with the matching key.
Elements from the list with the matching key .
list
key
Slash-separated string of keys to search for.
Slash - separated string of keys to search for .
array
Nested list of lists where first member of each list is a key.
Nested list of lists where first member of each list is a key .