Skip to content

Commit

Permalink
[Changed] Now we keep a copy of the global options tree
Browse files Browse the repository at this point in the history
  • Loading branch information
set-soft committed Aug 20, 2024
1 parent f39ec89 commit 4a5053c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 1 addition & 2 deletions kibot/config_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,7 @@ def _parse_global(self, gb):
update_dict(gb, self.imported_globals)
logger.debug("Global options + imported: {}".format(gb))
# Parse all keys inside it
glb = GS.class_for_global_opts()
glb.set_tree(gb)
glb = GS.set_global_options_tree(gb)
try:
glb.config(None)
except KiPlotConfigurationError as e:
Expand Down
10 changes: 10 additions & 0 deletions kibot/gs.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ class GS(object):
def_global_output = '%f-%i%I%v.%x'
# The class that controls the global options
class_for_global_opts = None
# The last tree we used to configure it
globals_tree = {}
# Global options
global_allow_component_ranges = None
global_always_warn_about_paste_pads = None
global_cache_3d_resistors = None
Expand Down Expand Up @@ -981,3 +984,10 @@ def tmp_file(content=None, prefix=None, suffix=None, dir=None, what=None, a_logg
@staticmethod
def mkdtemp(mod):
return tempfile.mkdtemp(prefix='tmp-kibot-'+mod+'-')

@staticmethod
def set_global_options_tree(tree):
glb = GS.class_for_global_opts()
glb.set_tree(tree)
GS.globals_tree = tree
return glb
3 changes: 1 addition & 2 deletions kibot/kiplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1242,8 +1242,7 @@ def generate_examples(start_dir, dry, types):
if not os.path.isdir(start_dir):
GS.exit_with_error(f'Invalid dir {start_dir} to quick start', WRONG_ARGUMENTS)
# Set default global options
glb = GS.class_for_global_opts()
glb.set_tree({})
glb = GS.set_global_options_tree({})
glb.config(None)
# Install the resources
setup_resources()
Expand Down

0 comments on commit 4a5053c

Please sign in to comment.