Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def find_line(node):
n = node
while n is not None:
if n.line is not None:
return n.line
n = n.parent
return None
def filter_systems(node):
if utils.has_any_node_type(node, (docutils_nodes.system_message,)):
return False
return True
nodes_lines = []
first_line = -1
for n in utils.filtered_traverse(doc, filter_systems):
line = find_line(n)
if line is None:
continue
if first_line == -1:
first_line = line
contained_lines = set(gather_lines(n))
nodes_lines.append((n, (min(contained_lines), max(contained_lines))))
return (nodes_lines, first_line)