@@ -974,13 +974,13 @@ def _to_sexpr_raw(self):
974974 pts_expr .append (['xy' , format_float (point .X ), format_float (point .Y )])
975975 expr .append (pts_expr )
976976
977- expr .append (['layer' , escape_and_quote (self .layer )])
978-
979977 if self .width is not None :
980978 expr .append (['width' , self .width ])
981979 elif self .stroke is not None :
982980 expr .append (self .stroke ._to_sexpr_raw ())
983981
982+ expr .append (['layer' , escape_and_quote (self .layer )])
983+
984984 expr .append (format_bool_raw ('locked' , self .locked ))
985985
986986 if self .tstamp is not None :
@@ -995,25 +995,35 @@ class FpProperty:
995995 Helper class for dealing with properties of a footprint.
996996 """
997997
998- type : str = ""
998+ key : str = ""
999+ """The ``key`` string defines the name of the property and must be unique"""
9991000
1000- text : str = ""
1001+ value : str = ""
1002+ """The ``value`` string defines the value of the property"""
10011003
1002- hide : Optional [str ] = None
1004+ hide : Optional [bool ] = None
1005+ """The optional ``hide`` token defines if the property is hidden"""
10031006
1004- unlocked : Optional [str ] = None
1007+ unlocked : Optional [bool ] = None
1008+ """The optional ``unlocked`` token defines if the property can be edited"""
10051009
10061010 position : Optional [Position ] = None
1011+ """The optional ``position`` token defines the X and Y coordinates as well as the rotation angle of the property."""
10071012
10081013 layer : Optional [str ] = None
1014+ """The ``layer`` token defines the canonical layer the text resides on"""
10091015
10101016 ko : Optional [bool ] = None
1017+ """The optional ``ko`` token defines if the property can be edited"""
10111018
10121019 effects : Optional [Effects ] = None
1020+ """The optional ``effects`` section defines how the text is displayed"""
10131021
1014- tstamp : Optional [str ] = None
1022+ uuid : Optional [str ] = None
1023+ """The optional ``uuid`` defines the universally unique identifier"""
10151024
10161025 render_cache : Optional [RenderCache ] = None
1026+ """The ``render_cache`` token defines a cache for none-standard fonts."""
10171027
10181028 @classmethod
10191029 def from_sexpr (cls , exp : list ) -> FpProperty :
@@ -1036,20 +1046,20 @@ def from_sexpr(cls, exp: list) -> FpProperty:
10361046 raise Exception ("Expression does not have the correct type" )
10371047
10381048 object = cls ()
1039- object .type = exp [1 ]
1040- object .text = exp [2 ]
1049+ object .key = exp [1 ]
1050+ object .value = exp [2 ]
10411051 for item in exp [3 :]:
1042- if not isinstance (item , list ):
1052+ if item [0 ] == 'hide' : object .hide = parse_bool (item , 'hide' )
1053+ elif item [0 ] == 'unlocked' : object .unlocked = parse_bool (item , 'unlocked' )
1054+ elif not isinstance (item , list ):
10431055 raise ValueError (f"Expected list property [key, value], got: { item } . Full expression: { exp } " )
1044- elif item [0 ] == 'hide' : object .hide = item [1 ]
1045- elif item [0 ] == 'unlocked' : object .unlocked = item [1 ]
10461056 elif item [0 ] == 'at' : object .position = Position ().from_sexpr (item )
10471057 elif item [0 ] == 'layer' :
10481058 object .layer = item [1 ]
1049- if len (item ) > 2 and item [2 ] == "knockout" :
1059+ if len (item ) == 3 and item [2 ] == "knockout" :
10501060 object .ko = True
10511061 elif item [0 ] == 'effects' : object .effects = Effects .from_sexpr (item )
1052- elif item [0 ] == 'uuid' : object .tstamp = item [1 ]
1062+ elif item [0 ] == 'uuid' : object .uuid = item [1 ]
10531063 elif item [0 ] == 'render_cache' : object .render_cache = RenderCache .from_sexpr (item )
10541064 else :
10551065 raise ValueError (f"Unrecognized property key: { item [0 ]} . Full expression: { item } " )
@@ -1070,32 +1080,32 @@ def to_sexpr(self, indent: int = 2, newline: bool = True) -> str:
10701080 return sexp_to_string (raw_expr )
10711081
10721082 def _to_sexpr_raw (self ):
1073- prop_type = dequote (self .type )
1074- if self .type != "ki_fp_filters" :
1083+ prop_type = dequote (self .key )
1084+ if self .key != "ki_fp_filters" :
10751085 prop_type = quote (prop_type )
10761086
1077- expr = ['property' , prop_type , escape_and_quote (self .text )]
1087+ expr = ['property' , prop_type , escape_and_quote (self .value )]
10781088
10791089 if self .position is not None :
10801090 pos = ['at' , format_float (self .position .X ), format_float (self .position .Y )]
10811091 if self .position .angle is not None :
10821092 pos .append (format_float (self .position .angle ))
10831093 expr .append (pos )
10841094
1085- if self .unlocked is not None :
1086- expr .append ([ 'unlocked' , self .unlocked ] )
1095+ if self .unlocked :
1096+ expr .append (format_bool_raw ( 'unlocked' , self .unlocked ) )
10871097
10881098 if self .layer is not None :
10891099 layer_expr = ['layer' , escape_and_quote (self .layer )]
10901100 if self .ko :
10911101 layer_expr .append ("knockout" )
10921102 expr .append (layer_expr )
10931103
1094- if self .hide is not None :
1095- expr .append ([ 'hide' , self .hide ] )
1104+ if self .hide :
1105+ expr .append (format_bool_raw ( 'hide' , self .hide ) )
10961106
1097- if self .tstamp is not None :
1098- expr .append (['uuid' , quote (self .tstamp )])
1107+ if self .uuid is not None :
1108+ expr .append (['uuid' , quote (self .uuid )])
10991109
11001110 if self .effects is not None :
11011111 expr .append (self .effects ._to_sexpr_raw ())
0 commit comments