Ejemplo n.º 1
0
def replace_link(obj):
    try:
        link = obj.link
        try:
            through = link["through"]
        except KeyError:
            through = None

        try:
            through_str = through[1:-1]
        except TypeError:
            through_str = None

        if through_str:
            through_dict = str_to_dict(through_str)
        else:
            through_dict = {}

        model_dict = str_to_dict(link["model"][1:-1])

        ls = m.LinkSpec(
            obj,
            m.LinkDefinition(
                link["link"][1:-1],
                obj.name,
                model_dict,
                link["port"][1:-1],
                through_dict,
            ),
        )
        return ls
    except BaseException:
        return obj
Ejemplo n.º 2
0
def replace_link(obj):
    try:
        link = obj.link
        try:
            through = link['through']
        except KeyError:
            through = None

        try:
            through_str = through[1:-1]
        except TypeError:
            through_str = None

        if through_str:
            through_dict = str_to_dict(through_str)
        else:
            through_dict = {}

        model_dict = str_to_dict(link['model'][1:-1])

        ls = m.LinkSpec(
            obj,
            m.LinkDefinition(link['link'][1:-1], obj.name, model_dict,
                             link['port'][1:-1], through_dict))
        return ls
    except:
        return obj
Ejemplo n.º 3
0
 def map_field(self, obj, s):
     if 'model' in s:
         link = m.LinkDefinition('onetoone','src','name','dst', obj.linespan, obj.lexspan, obj.p)
         lspec = m.LinkSpec(link, obj)
     else:
         lspec = obj
     return lspec
Ejemplo n.º 4
0
 def map_field(self, obj, s):
     if "model" in s:
         link = m.LinkDefinition("onetoone", "src", "name", "dst",
                                 obj.linespan, obj.lexspan, obj.p)
         lspec = m.LinkSpec(link, obj)
     else:
         lspec = obj
     return lspec