def _add_spread_elements_from_idml(self, idml_package, at, only, translation): """ Append idml_package spread elements into self.spread[0] <Spread> node. """ spread_dest_filename = self.get_spread_by_xpath(at) spread_dest = Spread(self, spread_dest_filename, self.working_copy_path) spread_dest_elt = spread_dest.dom.xpath("./Spread")[0] only_node = idml_package.xml_structure.xpath(only)[0] # Add spread elements on the same layer. We start by that because the order in the # Spread file is the z-position on the Layer. only_layer = idml_package.get_structure_element_layer_id(only_node) spread_elts_to_add = idml_package.get_spread_elements_by_layer(layer_id=only_layer, excluded_tags=["Guide"]) # Then add the tagged elements that may be on others layers. for node in only_node.iter(): if node.get("XMLContent") is None: continue spread_elt = idml_package.get_spread_elem_by_id(node.get("XMLContent")) # Image and EPS element are included in a Rectangle. if spread_elt.tag in ["Image", "EPS"]: spread_elt = spread_elt.getparent() if spread_elt not in spread_elts_to_add: spread_elts_to_add.append(spread_elt) def _add_spread_element(spread_dest_elt, spread_elt): spread_elt_copy = copy.deepcopy(spread_elt) self.apply_translation_to_element(spread_elt_copy, translation) spread_dest_elt.append(spread_elt_copy) map(lambda s: _add_spread_element(spread_dest_elt, s), spread_elts_to_add) spread_dest.synchronize() self.init_lazy_references()
def _add_spread_elements_from_idml(self, idml_package, at, only, translation): """ Append idml_package spread elements into self.spread[0] <Spread> node. """ spread_dest_filename = self.get_spread_by_xpath(at) spread_dest = Spread(self, spread_dest_filename, self.working_copy_path) spread_dest_elt = spread_dest.dom.xpath("./Spread")[0] only_node = idml_package.xml_structure.xpath(only)[0] # Add spread elements on the same layer. We start by that because the order in the # Spread file is the z-position on the Layer. only_layer = idml_package.get_structure_element_layer_id(only_node) spread_elts_to_add = idml_package.get_spread_elements_by_layer( layer_id=only_layer, excluded_tags=["Guide"]) # Then add the tagged elements that may be on others layers. for node in only_node.iter(): if node.get("XMLContent") is None: continue spread_elt = idml_package.get_spread_elem_by_id( node.get("XMLContent")) # Image and EPS element are included in a Rectangle. if spread_elt.tag in ["Image", "EPS"]: spread_elt = spread_elt.getparent() if spread_elt not in spread_elts_to_add: spread_elts_to_add.append(spread_elt) def _add_spread_element(spread_dest_elt, spread_elt): spread_elt_copy = copy.deepcopy(spread_elt) self.apply_translation_to_element(spread_elt_copy, translation) spread_dest_elt.append(spread_elt_copy) map(lambda s: _add_spread_element(spread_dest_elt, s), spread_elts_to_add) spread_dest.synchronize() self.init_lazy_references()