[QR Lib][Added] Error when the symbol and footprint libs collide
- Also more detailed explanation for the output option Related to #483
This commit is contained in:
parent
dc3628eaa1
commit
12151a7356
|
|
@ -2924,7 +2924,8 @@ outputs:
|
|||
options:
|
||||
# [string='QR'] Short name for the library
|
||||
lib: 'QR'
|
||||
# [string='%f-%i%I%v.%x'] Filename for the output (%i=qr, %x=lib). Affected by global options
|
||||
# [string='%f-%i%I%v.%x'] Filename/dirname for the output (%i=qr, %x=lib/kicad_sym/pretty).
|
||||
# You must use %x in the name to get a symbols lib and a footprint. Affected by global options
|
||||
output: '%f-%i%I%v.%x'
|
||||
# [list(dict)] QR codes to include in the library
|
||||
qrs:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ Parameters:
|
|||
- Valid keys:
|
||||
|
||||
- **lib** :index:`: <pair: output - qr_lib - options; lib>` [string='QR'] Short name for the library.
|
||||
- **output** :index:`: <pair: output - qr_lib - options; output>` [string='%f-%i%I%v.%x'] Filename for the output (%i=qr, %x=lib). Affected by global options.
|
||||
- **output** :index:`: <pair: output - qr_lib - options; output>` [string='%f-%i%I%v.%x'] Filename/dirname for the output (%i=qr, %x=lib/kicad_sym/pretty).
|
||||
You must use %x in the name to get a symbols lib and a footprint. Affected by global options.
|
||||
- **qrs** :index:`: <pair: output - qr_lib - options; qrs>` [list(dict)] QR codes to include in the library.
|
||||
|
||||
- Valid keys:
|
||||
|
|
|
|||
|
|
@ -102,7 +102,8 @@ class QR_LibOptions(BaseOptions):
|
|||
def __init__(self):
|
||||
with document:
|
||||
self.output = GS.def_global_output
|
||||
""" *Filename for the output (%i=qr, %x=lib) """
|
||||
""" *Filename/dirname for the output (%i=qr, %x=lib/kicad_sym/pretty).
|
||||
You must use %x in the name to get a symbols lib and a footprint """
|
||||
self.lib = 'QR'
|
||||
""" *Short name for the library """
|
||||
self.reference = 'QR'
|
||||
|
|
@ -249,9 +250,7 @@ class QR_LibOptions(BaseOptions):
|
|||
f.write(dumps(mod))
|
||||
f.write('\n')
|
||||
|
||||
def symbol_lib_k5(self):
|
||||
self._expand_ext = 'lib'
|
||||
output = os.path.join(self._odir_sch, self.expand_filename_sch(self.output))
|
||||
def symbol_lib_k5(self, output):
|
||||
logger.debug('Creating KiCad 5 symbols library: '+output)
|
||||
with open(output, 'wt') as f:
|
||||
f.write("EESchema-LIBRARY Version 2.4\n")
|
||||
|
|
@ -272,9 +271,7 @@ class QR_LibOptions(BaseOptions):
|
|||
f.effects.hide = True
|
||||
return f.write()+[Sep()]
|
||||
|
||||
def symbol_lib_k6(self):
|
||||
self._expand_ext = 'kicad_sym'
|
||||
output = os.path.join(self._odir_sch, self.expand_filename_sch(self.output))
|
||||
def symbol_lib_k6(self, output):
|
||||
logger.debug('Creating KiCad 6 symbols library: '+output)
|
||||
# Lib header
|
||||
lib = [Symbol('kicad_symbol_lib')]
|
||||
|
|
@ -507,6 +504,12 @@ class QR_LibOptions(BaseOptions):
|
|||
self._odir_pcb = GS.pcb_dir
|
||||
else:
|
||||
self._odir_pcb = self._odir_sch = self._parent.output_dir
|
||||
self._expand_ext = 'pretty'
|
||||
dir_pretty = os.path.join(self._odir_pcb, self.expand_filename_pcb(self.output))
|
||||
self._expand_ext = 'lib' if GS.ki5 else 'kicad_sym'
|
||||
sch_output = os.path.join(self._odir_sch, self.expand_filename_sch(self.output))
|
||||
if sch_output == dir_pretty:
|
||||
raise KiPlotConfigurationError(f'The symbol and footprint outputs are the same, use %x to solve it ({sch_output})')
|
||||
# Create the QR codes
|
||||
for qr in self.qrs:
|
||||
qr._text_sch = self.expand_filename_both(qr.text, make_safe=False)
|
||||
|
|
@ -515,12 +518,10 @@ class QR_LibOptions(BaseOptions):
|
|||
qr._code_pcb = qrcodegen.QrCode.encode_text(qr._text_pcb, QR_ECCS[qr.correction_level])
|
||||
# Create the symbols
|
||||
if GS.ki5:
|
||||
self.symbol_lib_k5()
|
||||
self.symbol_lib_k5(sch_output)
|
||||
else:
|
||||
self.symbol_lib_k6()
|
||||
self.symbol_lib_k6(sch_output)
|
||||
# Create the footprints
|
||||
self._expand_ext = 'pretty'
|
||||
dir_pretty = os.path.join(self._odir_pcb, self.expand_filename_pcb(self.output))
|
||||
logger.debug('Creating footprints library: '+dir_pretty)
|
||||
os.makedirs(dir_pretty, exist_ok=True)
|
||||
for qr in self.qrs:
|
||||
|
|
|
|||
Loading…
Reference in New Issue