(placeholder, original)
Resolve a placeholder to the given original object.

    :param placeholder: The placeholder to resolve, in place.
    :type placeholder: dict
    :param original: The object that the placeholder represents.
    :type original: dict
Resolve a placeholder to the given original object.
Resolve a placeholder to the given original object .
def _resolve_placeholder(placeholder, original):
    """Resolve a placeholder to the given original object.

    :param placeholder: The placeholder to resolve, in place.
    :type placeholder: dict
    :param original: The object that the placeholder represents.
    :type original: dict
    """
    new = copy.deepcopy(original)
    # We are supposed to be resolving the placeholder,
    # not replacing it with another.
    assert original["type"] != "placeholder"
    # The name remains the same.
    new["name"] = placeholder["name"]
    new["full_name"] = placeholder["full_name"]
    # Record where the placeholder originally came from.
    new["original_path"] = original["full_name"]
    # The source lines for this placeholder do not exist in this file.
    # The keys might not exist if original is a resolved placeholder.
    new.pop("from_line_no", None)
    new.pop("to_line_no", None)

    # Resolve the children
    stack = list(new.get("children", ()))
    while stack:
        child = stack.pop()
        # Relocate the child to the new location
        assert child["full_name"].startswith(original["full_name"])
        suffix = child["full_name"][len(original["full_name"]) :]
        child["full_name"] = new["full_name"] + suffix
        # The source lines for this placeholder do not exist in this file.
        # The keys might not exist if original is a resolved placeholder.
        child.pop("from_line_no", None)
        child.pop("to_line_no", None)
        # Resolve the remaining children
        stack.extend(child.get("children", ()))

    placeholder.clear()
    placeholder.update(new)
def _resolve_placeholder ( placeholder , original ) : new = copy . deepcopy ( original ) # We are supposed to be resolving the placeholder, # not replacing it with another. assert original [ "type" ] != "placeholder" # The name remains the same. new [ "name" ] = placeholder [ "name" ] new [ "full_name" ] = placeholder [ "full_name" ] # Record where the placeholder originally came from. new [ "original_path" ] = original [ "full_name" ] # The source lines for this placeholder do not exist in this file. # The keys might not exist if original is a resolved placeholder. new . pop ( "from_line_no" , None ) new . pop ( "to_line_no" , None ) # Resolve the children stack = list ( new . get ( "children" , ( ) ) ) while stack : child = stack . pop ( ) # Relocate the child to the new location assert child [ "full_name" ] . startswith ( original [ "full_name" ] ) suffix = child [ "full_name" ] [ len ( original [ "full_name" ] ) : ] child [ "full_name" ] = new [ "full_name" ] + suffix # The source lines for this placeholder do not exist in this file. # The keys might not exist if original is a resolved placeholder. child . pop ( "from_line_no" , None ) child . pop ( "to_line_no" , None ) # Resolve the remaining children stack . extend ( child . get ( "children" , ( ) ) ) placeholder . clear ( ) placeholder . update ( new )