kicad: Improve compatibility with old symbol files
This commit is contained in:
parent
2092b86431
commit
f1b3ab5e72
2 changed files with 19 additions and 1 deletions
|
|
@ -345,7 +345,7 @@ class Justify:
|
|||
@sexp_type('effects')
|
||||
class TextEffect:
|
||||
font: FontSpec = field(default_factory=FontSpec)
|
||||
hide: OmitDefault(Named(YesNoAtom())) = False
|
||||
hide: OmitDefault(Named(LegacyCompatibleFlag())) = False
|
||||
justify: OmitDefault(Justify) = field(default_factory=Justify)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -202,6 +202,24 @@ class YesNoAtom:
|
|||
yield self.yes if value else self.no
|
||||
|
||||
|
||||
class LegacyCompatibleFlag:
|
||||
'''Variant of YesNoAtom that accepts both the `(flag <yes/no>)` variant and the bare `flag` variant for compatibility.'''
|
||||
|
||||
def __init__(self, yes=Atom.yes, no=Atom.no, value_when_empty=True):
|
||||
self.yes, self.no = yes, no
|
||||
self.value_when_empty = value_when_empty
|
||||
|
||||
def __map__(self, value, parent=None):
|
||||
if value == []:
|
||||
return self.value_when_empty
|
||||
|
||||
value, = value
|
||||
return value == self.yes
|
||||
|
||||
def __sexp__(self, value):
|
||||
yield self.yes if value else self.no
|
||||
|
||||
|
||||
class Wrap(WrapperType):
|
||||
def __map__(self, value, parent=None):
|
||||
value, = value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue