kifield/schlib.py
def copy_field(self, src, dst):
        """Add a copy of a component field with a different name."""
        src_field = self.get_field(src)
        if not src_field:
            return
        dst_field = self.get_field(dst)
        if not dst_field:
            dst_field = deepcopy(src_field)
            dst_field["name"] = dst
            dst_field["id"] = len(self.fields)
            dst_field["prop"][1] = dst
            id = find_by_key("id", dst_field["prop"])[0]
            id[1] = dst_field["id"]
            self.fields.append(dst_field)
        else:
            dst_field["prop"] = deepcopy(src_field["prop"])
        self.set_field_value(dst, src_field["value"])
        self.data.append(dst_field["prop"])
Add a copy of a component field with a different name.
Add a copy of a component field with a different name.
Add a copy of a component field with a different name .
def copy_field(self, src, dst):
        src_field = self.get_field(src)
        if not src_field:
            return
        dst_field = self.get_field(dst)
        if not dst_field:
            dst_field = deepcopy(src_field)
            dst_field["name"] = dst
            dst_field["id"] = len(self.fields)
            dst_field["prop"][1] = dst
            id = find_by_key("id", dst_field["prop"])[0]
            id[1] = dst_field["id"]
            self.fields.append(dst_field)
        else:
            dst_field["prop"] = deepcopy(src_field["prop"])
        self.set_field_value(dst, src_field["value"])
        self.data.append(dst_field["prop"])
def copy_field ( self , src , dst ) : src_field = self . get_field ( src ) if not src_field : return dst_field = self . get_field ( dst ) if not dst_field : dst_field = deepcopy ( src_field ) dst_field [ "name" ] = dst dst_field [ "id" ] = len ( self . fields ) dst_field [ "prop" ] [ 1 ] = dst id = find_by_key ( "id" , dst_field [ "prop" ] ) [ 0 ] id [ 1 ] = dst_field [ "id" ] self . fields . append ( dst_field ) else : dst_field [ "prop" ] = deepcopy ( src_field [ "prop" ] ) self . set_field_value ( dst , src_field [ "value" ] ) self . data . append ( dst_field [ "prop" ] )
Add a copy of a component field with a different name.
Add a copy of a component field with a different name .
"""Add a copy of a component field with a different name."""
self
src
dst