Skip to content

Commit

Permalink
lyp loading handles multiple tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
atait committed Jun 21, 2019
1 parent d9e48ff commit 2d5b015
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lygadgets/markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,18 @@ def xml_to_dict(xml_content):


def lyp_to_layerlist(lyp_file):
''' Now works with multiple tabs. It ignores the tab names '''
with open(lyp_file, 'r') as fx:
lyp_dict = xmltodict.parse(fx.read(), process_namespaces=True)
all_layers = lyp_dict['layer-properties']['properties']
if not isinstance(all_layers, list):
all_layers = [all_layers]
all_layers = []
if 'layer-properties-tabs' in lyp_dict.keys():
all_layer_tabs = lyp_dict['layer-properties-tabs']['layer-properties']
else:
all_layer_tabs = [lyp_dict['layer-properties']]

for tab in all_layer_tabs:
tab_layers = tab['properties']
if not isinstance(tab_layers, list):
tab_layers = [tab_layers]
all_layers.extend(tab_layers)
return all_layers

0 comments on commit 2d5b015

Please sign in to comment.