[Global options][Added] `restore_project` now also restores the PRL

This commit is contained in:
Salvador E. Tropea 2023-12-05 08:20:49 -03:00
parent 83e15f8209
commit a8c865b921
4 changed files with 25 additions and 10 deletions

View File

@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `layer_defaults` to specify the default suffix and description. (#504) - `layer_defaults` to specify the default suffix and description. (#504)
- `include_components_from_pcb` to disable the new behavior that includes - `include_components_from_pcb` to disable the new behavior that includes
components from the PCB in the filter/variants processing components from the PCB in the filter/variants processing
- `restore_project` now also restores the PRL
- Schematic format: - Schematic format:
- Support for *unit names* (#513) - Support for *unit names* (#513)
- Internal templates: - Internal templates:

View File

@ -171,6 +171,7 @@
which is used by the KiBot docker images, on other OSs *your mileage may vary*. which is used by the KiBot docker images, on other OSs *your mileage may vary*.
- ``restore_project`` :index:`: <pair: global options; restore_project>` [boolean=false] Restore the KiCad project after execution. - ``restore_project`` :index:`: <pair: global options; restore_project>` [boolean=false] Restore the KiCad project after execution.
Note that this option will undo operations like `set_text_variables`. Note that this option will undo operations like `set_text_variables`.
Starting with 1.6.4 it also restores the PRL (Project Local Settings) file.
- ``set_text_variables_before_output`` :index:`: <pair: global options; set_text_variables_before_output>` [boolean=false] Run the `set_text_variables` preflight before running each output that involves variants. - ``set_text_variables_before_output`` :index:`: <pair: global options; set_text_variables_before_output>` [boolean=false] Run the `set_text_variables` preflight before running each output that involves variants.
This can be used when a text variable uses the variant and you want to create more than This can be used when a text variable uses the variant and you want to create more than
one variant in the same run. Note that this could be slow because it forces a board one variant in the same run. Note that this could be slow because it forces a board

View File

@ -238,7 +238,8 @@ class Globals(FiltersOptions):
""" When applying filters and variants remove the solder mask apertures for components that won't be included """ """ When applying filters and variants remove the solder mask apertures for components that won't be included """
self.restore_project = False self.restore_project = False
""" Restore the KiCad project after execution. """ Restore the KiCad project after execution.
Note that this option will undo operations like `set_text_variables` """ Note that this option will undo operations like `set_text_variables`.
Starting with 1.6.4 it also restores the PRL (Project Local Settings) file """
self.set_text_variables_before_output = False self.set_text_variables_before_output = False
""" Run the `set_text_variables` preflight before running each output that involves variants. """ Run the `set_text_variables` preflight before running each output that involves variants.
This can be used when a text variable uses the variant and you want to create more than This can be used when a text variable uses the variant and you want to create more than

View File

@ -243,17 +243,29 @@ class GS(object):
@staticmethod @staticmethod
def read_pro(): def read_pro():
if GS.pro_file: if not GS.pro_file:
# Note: We use binary mode to preserve the original end of lines return None
# Otherwise git could see changes in the file # Note: We use binary mode to preserve the original end of lines
with open(GS.pro_file, 'rb') as f: # Otherwise git could see changes in the file
return f.read() with open(GS.pro_file, 'rb') as f:
pro = f.read()
prl_name = GS.pro_file[:-3]+'prl'
prl = None
if os.path.isfile(prl_name):
with open(prl_name, 'rb') as f:
prl = f.read()
return (pro, prl)
@staticmethod @staticmethod
def write_pro(prj): def write_pro(data):
if GS.pro_file and prj: if not GS.pro_file or data is None:
with open(GS.pro_file, 'wb') as f: return
f.write(prj) with open(GS.pro_file, 'wb') as f:
f.write(data[0])
if data[1] is None:
return
with open(GS.pro_file[:-3]+'prl', 'wb') as f:
f.write(data[1])
@staticmethod @staticmethod
def load_sch_title_block(): def load_sch_title_block():