ext.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:linotype 作者: lostatc 项目源码 文件源码
def _get_matching_child(
        parent_node: nodes.Element, child_class: nodes.Element, last=True):
    """Get the first or last child node that matches a Node subclass.

    Args:
        parent_node: The node to find the child of.
        child_class: The Node subclass to check against.
        last: If True, find the last matching child. If False, find the first
            one.

    Returns:
        The first or last child Node object that is an instance of the given
        class.
    """
    if last:
        children = reversed(parent_node.children)
    else:
        children = parent_node.children

    for child_node in children:
        if isinstance(child_node, child_class):
            return child_node
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号