Example #1
0
 def to_yaml(cls, r: Representer, n: "Sub") -> Any:
     fmt = n.v._ig_format._ig_value
     kwargs = {}
     for k, v in n.v._ig_kwargs._ig_value.items():
         old = new = f"${{{k._ig_value}}}"
         if isinstance(v, core.Parameter):
             new = f"${{{_getidn(v._ig_name)}}}"
         elif isinstance(v, core.Ref):
             new = f"${{{_getnidn(v._ig_node)}}}"
         elif isinstance(v, core.Attribute):
             new = f"${{{_getnidn(v._ig_node)}.{_getaidn(v._ig_name)}}}"
         elif isinstance(getattr(v, "_ig_value", None), (str, int, float)):
             new = f"{v._ig_value}"
         else:
             kwargs[k] = v
         fmt = fmt.replace(old, new)
     if not kwargs:
         return r.represent_scalar(cls.tag, _t(fmt))
     return r.represent_sequence(cls.tag, _t([fmt, kwargs]))
Example #2
0
 def to_yaml(cls, r: Representer, n: "CIDR") -> Any:
     return r.represent_sequence(
         cls.tag, _t([n.v._ig_block, n.v._ig_count, n.v._ig_bits]))
Example #3
0
 def to_yaml(cls, r: Representer, n: "Select") -> Any:
     return r.represent_sequence(
         cls.tag,
         _t([n.v._ig_index, n.v._ig_items]),
     )
Example #4
0
 def to_yaml(cls, r: Representer, n: "Split") -> Any:
     return r.represent_sequence(
         cls.tag,
         _t([n.v._ig_separator, n.v._ig_target]),
     )
Example #5
0
 def to_yaml(cls, r: Representer, n: "Join") -> Any:
     return r.represent_sequence(
         cls.tag,
         _t([n.v._ig_separator, n.v._ig_items]),
     )