def _map_plays_to_roles(graph, dirs, git_dir, key, type_1, type_2):
 Node = namedtuple('Node', ['name', 'type'])
 for d in dirs:
  d = pathlib2.Path(git_dir, d)
  for item in d.iterdir():
   if item.match('*.yml'):
    yaml_file = _open_yaml_file(item)
    if (yaml_file is not None):
     for play in yaml_file:
      if (key in play):
       for role in play[key]:
        name = _get_role_name(role)
        node_1 = Node(item.stem, type_1)
        node_2 = Node(name, type_2)
        graph.add_edge(node_2, node_1)

def _map_plays_to_roles ( graph , dirs , git_dir , key , type_1 , type_2 ) : Node = namedtuple ( 'Node' , [ 'name' , 'type' ] ) for d in dirs : d = pathlib2 . Path ( git_dir , d ) for item in d . iterdir ( ) : if item . match ( '*.yml' ) : yaml_file = _open_yaml_file ( item ) if ( yaml_file is not None ) : for play in yaml_file : if ( key in play ) : for role in play [ key ] : name = _get_role_name ( role ) node_1 = Node ( item . stem , type_1 ) node_2 = Node ( name , type_2 ) graph . add_edge ( node_2 , node_1 )
maps plays to the roles they use .