[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)
- `include_components_from_pcb` to disable the new behavior that includes
components from the PCB in the filter/variants processing
- `restore_project` now also restores the PRL
- Schematic format:
- Support for *unit names* (#513)
- Internal templates:

View File

@ -171,6 +171,7 @@
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.
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.
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

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 """
self.restore_project = 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 """
self.set_text_variables_before_output = 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

View File

@ -243,17 +243,29 @@ class GS(object):
@staticmethod
def read_pro():
if GS.pro_file:
# Note: We use binary mode to preserve the original end of lines
# Otherwise git could see changes in the file
with open(GS.pro_file, 'rb') as f:
return f.read()
if not GS.pro_file:
return None
# Note: We use binary mode to preserve the original end of lines
# Otherwise git could see changes in the file
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
def write_pro(prj):
if GS.pro_file and prj:
with open(GS.pro_file, 'wb') as f:
f.write(prj)
def write_pro(data):
if not GS.pro_file or data is None:
return
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
def load_sch_title_block():