@@ -268,7 +268,7 @@ def _generate_json_map(
268268
269269 # Create initial node at top of .bob file
270270 current_node = JsonMap (
271- str (screen_path .relative_to (self ._write_directory )),
271+ str (screen_path .resolve (). relative_to (self ._write_directory . resolve () )),
272272 display_name = None ,
273273 )
274274
@@ -318,9 +318,7 @@ def _generate_json_map(
318318 macro_dict = self ._get_macros (open_display )
319319
320320 case "embedded" :
321- file_elem = self ._extract_action_button_file_from_embedded (
322- widget_elem .file , dest_path
323- )
321+ file_elem = widget_elem .file
324322 name_elem = widget_elem .name .text
325323 macro_dict = self ._get_macros (widget_elem )
326324
@@ -359,14 +357,23 @@ def _generate_json_map(
359357 )
360358 else :
361359 child_node = JsonMap (
362- str (file_path ), display_name , exists = ("IOC" in macro_dict )
360+ str (file_path ),
361+ display_name ,
362+ exists = ("IOC" in macro_dict or ("https:/" in str (file_path ))),
363363 )
364364
365- child_node .macros = macro_dict
366- # TODO: make this work for only list[JsonMap]
367- assert isinstance (current_node .children , list )
368- # TODO: fix typing
369- current_node .children .append (child_node )
365+ if widget_type == "embedded" :
366+ for embedded_child in child_node .children :
367+ embedded_child .macros = {** embedded_child .macros , ** macro_dict }
368+ embedded_child .display_name = display_name
369+ current_node .children .append (embedded_child )
370+
371+ else :
372+ child_node .macros = macro_dict
373+ # TODO: make this work for only list[JsonMap]
374+ assert isinstance (current_node .children , list )
375+ # TODO: fix typing
376+ current_node .children .append (child_node )
370377
371378 except etree .ParseError as e :
372379 current_node .error = f"XML parse error: { e } "
@@ -410,34 +417,6 @@ def _get_component_label(
410417 display_name = child_labels [name_elem ]
411418 return display_name
412419
413- def _extract_action_button_file_from_embedded (
414- self , file_elem : ObjectifiedElement , dest_path : Path
415- ) -> ObjectifiedElement :
416- file_path = Path (file_elem .text .strip () if file_elem .text else "" )
417- file_path = dest_path .joinpath (file_path )
418- if not file_path .exists ():
419- rel_file_path = Path (str (file_elem .base )).relative_to (
420- dest_path .absolute (), walk_up = True
421- )
422- file_path = dest_path .joinpath (rel_file_path )
423- tree = objectify .parse (file_path .absolute ())
424- root : ObjectifiedElement = tree .getroot ()
425-
426- # Find all <widget> elements
427- widgets = [
428- w
429- for w in root .findall (".//widget" )
430- if w .get ("type" , default = None ) == "action_button"
431- ]
432-
433- for widget_elem in widgets :
434- open_display = _get_action_group (widget_elem )
435- if open_display is None :
436- continue
437- file_elem = open_display .file
438- return file_elem
439- return file_elem
440-
441420 def _get_macros (self , element : ObjectifiedElement ):
442421 if hasattr (element , "macros" ):
443422 macros = element .macros .getchildren ()
0 commit comments