I have Class definition:
Class definition
class Task(object):
def __init__(self, name, *depends):
self.__name = name
self.__depends = set(depends)
@property
def name(self):
return self.__name
@property
def depends(self):
return self.__depends
The rest of the code is using sample definition like this:
a = Task("a", "b")
b = Task("b")
nodes = (a, b)
I am trying to create this objects dynamically by parsing YAML in separate function which returns dictionary data and then I create all the objects:
Yaml File
a:
foo:
- "bar"
graph_dep:
- "b"
b:
foo:
- "bar"
I believe I was able to achieve creation of a and b objects of a Task class via function
def format_input(data):
services = data.keys()
holder = {Task(name=name) for name in services}
return holder
q1: How do I combine them to get nodes object and have same result as using sample definitions?
q2: How do I get values from graph_dep and add them in holder = {Task(name=name) for name in services} string?
Sorry newbie question in Python :)
foo:and- "bar"parts in the YAML? They don't occur in the Python code you show.graph_depare dependencies, the script maps dependencies based on these values