提交 99a30ac9 authored 作者: Frederic Bastien's avatar Frederic Bastien

added comment and questions.

上级 282152c4
...@@ -15,11 +15,13 @@ def join(*args): ...@@ -15,11 +15,13 @@ def join(*args):
join('a', 'b', 'c') => 'a.b.c' join('a', 'b', 'c') => 'a.b.c'
""" """
return ".".join(arg for arg in args if arg) return ".".join(arg for arg in args if arg)
def split(sym, n=-1): def split(sym, n=-1):
""" """
Gets the names from their joined representation Gets the names from their joined representation
split('a.b.c') => 'a', 'b', 'c' split('a.b.c') => ['a', 'b', 'c']
Returns the n first names, if n==-1 returns all of them. Returns the n first names, if n==-1 returns all of them.
split('a.b.c',1) => ['a', 'b.c']
""" """
return sym.split('.', n) return sym.split('.', n)
...@@ -27,6 +29,7 @@ def canonicalize(name): ...@@ -27,6 +29,7 @@ def canonicalize(name):
""" """
Splits the name and converts each name to the Splits the name and converts each name to the
right type (e.g. "2" -> 2) right type (e.g. "2" -> 2)
[Fred: why we return the right type? Why int only?]
""" """
if isinstance(name, str): if isinstance(name, str):
name = split(name) name = split(name)
...@@ -48,6 +51,7 @@ class BindError(Exception): ...@@ -48,6 +51,7 @@ class BindError(Exception):
""" """
Exception raised when a Component is already bound and we try to Exception raised when a Component is already bound and we try to
bound it again. bound it again.
see Component.bind() help for more information.
""" """
pass pass
...@@ -103,6 +107,7 @@ class Component(object): ...@@ -103,6 +107,7 @@ class Component(object):
""" """
Populates the memo dictionary with Result -> Container Populates the memo dictionary with Result -> Container
pairings. pairings.
[Fred: what memo mean?]
""" """
raise NotImplementedError raise NotImplementedError
...@@ -112,6 +117,7 @@ class Component(object): ...@@ -112,6 +117,7 @@ class Component(object):
and taking the containers in the memo dictionary. and taking the containers in the memo dictionary.
A Component which builds nothing may return None. A Component which builds nothing may return None.
[Fred: why a Component would build nothing? Method? Member should always build something to my understanding]
""" """
raise NotImplementedError raise NotImplementedError
...@@ -180,11 +186,11 @@ class _RComponent(Component): ...@@ -180,11 +186,11 @@ class _RComponent(Component):
def __init__(self, r): def __init__(self, r):
super(_RComponent, self).__init__() super(_RComponent, self).__init__()
self.r = r self.r = r
self.owns_name = r.name is None self.owns_name = r.name is None #Fred: is not? else the choise of owns_name is bad.
def __set_name__(self, name): def __set_name__(self, name):
super(_RComponent, self).__set_name__(name) super(_RComponent, self).__set_name__(name)
if self.owns_name: if self.owns_name:# Fred: why only if it don't have name?
self.r.name = name self.r.name = name
def __str__(self): def __str__(self):
...@@ -195,7 +201,7 @@ class _RComponent(Component): ...@@ -195,7 +201,7 @@ class _RComponent(Component):
return rval return rval
def dup(self): def dup(self):
return self.__class__(self.r) return self.__class__(self.r)#Fred: this don't dup the results? Is that normal?
class External(_RComponent): class External(_RComponent):
...@@ -260,7 +266,7 @@ class Method(Component): ...@@ -260,7 +266,7 @@ class Method(Component):
Composite which holds references to Members, the Method may Composite which holds references to Members, the Method may
use them without declaring them in the inputs, outputs or use them without declaring them in the inputs, outputs or
updates list. updates list.
[Fred: what are kits? not defined in this file]
inputs, outputs or updates may be strings. In that case, they inputs, outputs or updates may be strings. In that case, they
will be resolved in the Composite which is the parent of this will be resolved in the Composite which is the parent of this
Method. Method.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论