Exemplo n.º 1
0
def _ParseLinks(links_body: syaml.YAML) -> Set[link.Link]:
  """Parses YAML defining links between the fields of one entity and another.

  Links are always defined on the target entity.

  Args:
    links_body: YAML body for the entity links

  Returns:
    A set of Link instances
  """

  links = set()

  for source_entity, field_map in links_body.items():
    links.add(link.Link(source_entity, field_map))

  return links
def _ParseConnections(
    connections_body: syaml.YAML) -> Set[connection.Connection]:
  """Parses YAML defining connections between one entity and other.

  Connections are always defined on the target entity.

  Args:
    connections_body: YAML body for the entity connections

  Returns:
    A set of Connection instances
  """

  connections = set()

  for source_entity, connection_type in connections_body.items():
    connections.add(connection.Connection(connection_type, source_entity))

  return connections