diff --git a/lymask/invocation.py b/lymask/invocation.py index c454680..18abf8a 100644 --- a/lymask/invocation.py +++ b/lymask/invocation.py @@ -10,8 +10,8 @@ from lymask import __version__ from lymask.utilities import gui_view, gui_active_layout, \ active_technology, set_active_technology, \ - tech_layer_properties, tech_dataprep_layer_properties, \ - lys, load_dataprep_layers + tech_layer_properties, \ + lys, reload_lys from lymask.steps import all_func_dict @@ -37,7 +37,7 @@ def _main(layout, ymlfile, tech_obj=None): # todo: reload lys using technology with open(ymlfile) as fx: step_list = yaml.load(fx) - load_dataprep_layers(tech_obj) + reload_lys(tech_obj, dataprep=True) for func_info in step_list: func = all_func_dict[func_info[0]] try: @@ -96,7 +96,6 @@ def batch_main(infile, ymlspec=None, technology=None, outfile=None): ymlspec += '.yml' ymlfile = tech_obj.eff_path(os.path.join('dataprep', ymlspec)) # Process it - # lys.appendFile(tech_dataprep_layer_properties(tech_obj)) processed = _main(layout, ymlfile=ymlfile, tech_obj=tech_obj) # Write it processed.write(outfile) diff --git a/lymask/menu.py b/lymask/menu.py index 37c4f34..1406d89 100644 --- a/lymask/menu.py +++ b/lymask/menu.py @@ -4,7 +4,7 @@ import os from lymask.invocation import gui_main -from lymask.utilities import load_dataprep_layers, tech_dataprep_layer_properties +from lymask.utilities import reload_lys DEFAULT_TECH = 'OLMAC' @@ -71,7 +71,7 @@ def reload_dataprep_menu(tech_name=None): dataprep_yml_to_menu(dataprep_file) # Now put in the layers refresh menu = pya.Application.instance().main_window().menu() - layer_action = _gen_new_action(load_dataprep_layers) + layer_action = _gen_new_action(lambda *args: reload_lys(*args, dataprep=True)) layer_action.title = 'Refresh layer display' layer_action.shortcut = 'Shift+Ctrl+P' menu.insert_separator('soen_menu.dataprep.begin', 'SEP2') diff --git a/lymask/steps.py b/lymask/steps.py index c5ba107..740f27b 100644 --- a/lymask/steps.py +++ b/lymask/steps.py @@ -2,7 +2,7 @@ from functools import wraps from lygadgets import pya, isGUI, message, message_loud -from lymask.utilities import lys, LayerSet, insert_layer_tab, gui_view +from lymask.utilities import lys, LayerSet, gui_view from lymask.library import dbu, as_region, fast_sized, fast_smoothed, set_threads diff --git a/lymask/utilities.py b/lymask/utilities.py index 19a128a..1d6574d 100644 --- a/lymask/utilities.py +++ b/lymask/utilities.py @@ -185,59 +185,34 @@ def source2pyaLayerInfo(source_str): return pya.LayerInfo(int(layer), int(datatype)) -def load_dataprep_layers(technology=None): - ''' Also updates lys, but if any of the layers are already there, it does nothing. - If lyp_file is None, creates an empty layer list or does nothing if not in GUI mode. +lys = LayerSet() +def reload_lys(technology=None, clear=False, dataprep=False): + ''' Updates lys from the lyp files. Also updates the layer display in GUI mode. + If any of the layers are already there, it does nothing. + If no lyp is found, does nothing ''' if technology is None: technology = active_technology() - reload_lys(technology, dataprep=True) + if isinstance(technology, str): + technology = Technology.technology_by_name(technology) + + if clear: lys.clear() + try: + lyp_file = tech_layer_properties(technology) if not dataprep else tech_dataprep_layer_properties(technology) + lys.appendFile(lyp_file, doubles_ok=True) + except (FileNotFoundError, AttributeError): + print('No lyp file found. Likely that technology hasn\'t loaded yet, or you don\'t have the standalone klayout') + if isGUI(): lv = gui_view() was_transacting = lv.is_transacting() if was_transacting: lv.commit() - lv.load_layer_props(tech_dataprep_layer_properties(technology)) + lv.load_layer_props(lyp_file) if was_transacting: lv.transaction('Bump transaction') lv.current_layer_list = 0 -def insert_layer_tab(lyp_file=None, tab_name=None): - if lyp_file is not None and lys is not None: - try: - lys.appendFile(lyp_file) - except ValueError as err: - if 'doubly defined' in err.args[0]: - return - else: - raise - if isGUI(): - lv = gui_view() - i_new_tab = lv.num_layer_lists() - lv.rename_layer_list(0, 'Designer') - lv.insert_layer_list(i_new_tab) - lv.current_layer_list = i_new_tab - if lyp_file is not None: - was_transacting = lv.is_transacting() - if was_transacting: lv.commit() - lv.load_layer_props(lyp_file) - if was_transacting: lv.transaction('Bump transaction') - if tab_name is not None: - lv.rename_layer_list(i_new_tab, tab_name) - - -lys = LayerSet() -def reload_lys(technology=None, clear=False, dataprep=False): - if isinstance(technology, str): - technology = Technology.technology_by_name(technology) - try: - lyp_file = tech_layer_properties(technology) if not dataprep else tech_dataprep_layer_properties(technology) - except (FileNotFoundError, AttributeError): - print('No lyp file found. Likely that technology hasn\'t loaded yet, or you don\'t have the standalone klayout') - if clear: lys.clear() - lys.appendFile(lyp_file, doubles_ok=True) - - # reload_lys()