def _keypath_component_handler(component):
    """

    >>> _keypath_component_handler('str')
    'str'
    >>> _keypath_component_handler('[42]')
    42
    >>> _keypath_component_handler('[label]')
    '[label]'
    >>> _keypath_component_handler('[r1]')
    '[r1]'

    :type component: str
    :rtype: int|str
    """
    match = _keypath_index_subscript_pattern.match(component)
    if match and match.group('index'):
        return int(match.group('index'))
    else:
        return component
dataset/ETHPy150Open sodastsai/taskr/taskr/contrib/collections.py/_keypath_component_handler/original