Skip to content

Commit

Permalink
cleanups and working
Browse files Browse the repository at this point in the history
  • Loading branch information
atait committed Jun 21, 2019
1 parent 092ff50 commit 30c5902
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 48 deletions.
7 changes: 3 additions & 4 deletions lymask/invocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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:
Expand Down Expand Up @@ -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)
4 changes: 2 additions & 2 deletions lymask/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion lymask/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
57 changes: 16 additions & 41 deletions lymask/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 30c5902

Please sign in to comment.