diff --git a/CHANGELOG.md b/CHANGELOG.md index 6638b98c..bbac6680 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/docs/source/configuration/sup_globals.rst b/docs/source/configuration/sup_globals.rst index 3331c2e7..c4490f16 100644 --- a/docs/source/configuration/sup_globals.rst +++ b/docs/source/configuration/sup_globals.rst @@ -171,6 +171,7 @@ which is used by the KiBot docker images, on other OSs *your mileage may vary*. - ``restore_project`` :index:`: ` [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:`: ` [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 diff --git a/kibot/globals.py b/kibot/globals.py index 31b82f13..daebc579 100644 --- a/kibot/globals.py +++ b/kibot/globals.py @@ -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 diff --git a/kibot/gs.py b/kibot/gs.py index 937da0a4..7623fff8 100644 --- a/kibot/gs.py +++ b/kibot/gs.py @@ -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():