spreadsheet_intelligence.parsers.drawing.drawing_element_parser package#
Submodules#
spreadsheet_intelligence.parsers.drawing.drawing_element_parser.base_drawing_parser module#
- spreadsheet_intelligence.parsers.drawing.drawing_element_parser.base_drawing_parser.parse_anchor_point(element: Element, namespaces: Dict[str, str]) AnchorPoint[source]#
Parses an anchor point from the given XML element.
- Parameters:
element (ET.Element) – The XML element containing the anchor point.
namespaces (Dict[str, str]) – The XML namespaces.
- Returns:
The parsed anchor point.
- Return type:
- spreadsheet_intelligence.parsers.drawing.drawing_element_parser.base_drawing_parser.parse_anchor(element: Element, namespaces: Dict[str, str]) Anchor[source]#
Parses an anchor from the given XML element.
- Parameters:
element (ET.Element) – The XML element containing the anchor.
namespaces (Dict[str, str]) – The XML namespaces.
- Returns:
The parsed anchor.
- Return type:
- class spreadsheet_intelligence.parsers.drawing.drawing_element_parser.base_drawing_parser.BaseDrawingParser(namespaces: dict[str, str])[source]#
Bases:
BaseParser,ABC,Generic[TBaseAnchorRaw,TBaseDrawingRaw]- parse_anchor(twocellanchor_element: Element) Anchor[source]#
Parses an anchor and returns the model.
- Parameters:
twocellanchor_element (ET.Element) – The XML element containing the two-cell anchor.
- Returns:
The parsed anchor.
- Return type:
- parse_info(sp_el: Element, nv_tag_name: str) tuple[str, str][source]#
Parses drawing id and name.
- Parameters:
sp_el (ET.Element) – The XML element containing the drawing information.
nv_tag_name (str) – The tag name for the non-visual properties.
- Returns:
A tuple containing the id and name.
- Return type:
tuple[str, str]
- parse_style_ref_el(style_ref_el: Element) StyleBaseRef[source]#
Parses elements like <a:lnRef> and <a:fillRef> under <xdr:style> and returns a StyleBaseRef type.
- Parameters:
style_ref_el (ET.Element) – Elements like <a:lnRef> and <a:fillRef> under <xdr:style>.
- Raises:
ValueError – If neither schemeClr nor scrgbClr is present.
- Returns:
Returns schemeClr if both schemeClr and scrgbClr are present. Returns scrgbClr if only scrgbClr is present.
- Return type:
- parse_style_element(style_el: Element) StyleRefs[source]#
Parses the <xdr:style> element and returns a StyleRefs type.
- Parameters:
style_el (ET.Element) – The <xdr:style> element.
- Returns:
A class that consolidates the four elements: lnRef, fillRef, effectRef, and fontRef.
- Return type:
- parse_color(parent_el: Element) tuple[SchemeClr | None, SrgbClr | None][source]#
Parses color from xdr:spPr/a:ln or xdr:spPr(solidFill).
- abstractmethod _parse_drawing(twocellanchor_element: Element) TBaseDrawingRaw[source]#
Abstract method to parse a drawing element.
- Parameters:
twocellanchor_element (ET.Element) – The XML element containing the two-cell anchor.
- Returns:
The parsed drawing raw data.
- Return type:
TBaseDrawingRaw
- abstractmethod _create_anchor_raw(anchor: Anchor, drawing_raw: TBaseDrawingRaw) TBaseAnchorRaw[source]#
Abstract method to create an anchor raw model.
- Parameters:
anchor (Anchor) – The parsed anchor.
drawing_raw (TBaseDrawingRaw) – The parsed drawing raw data.
- Returns:
The created anchor raw model.
- Return type:
TBaseAnchorRaw
- parse(twocellanchor_element: Element) TBaseAnchorRaw[source]#
Parses an element and returns the model.
- Parameters:
twocellanchor_element (ET.Element) – The XML element containing the two-cell anchor.
- Returns:
The parsed anchor raw model.
- Return type:
TBaseAnchorRaw
- _abc_impl = <_abc._abc_data object>#
spreadsheet_intelligence.parsers.drawing.drawing_element_parser.connector_parser module#
- class spreadsheet_intelligence.parsers.drawing.drawing_element_parser.connector_parser.ConnectorParser(namespaces: dict[str, str])[source]#
Bases:
BaseDrawingParser[ConnectorAnchorRaw,ConnectorRaw]Parser for the connector element.
- parse_line_element(line_el: Element) ArrowLine[source]#
Parses the <a:ln> element and returns an ArrowLine type.
- Parameters:
line_el (ET.Element) – The <a:ln> element.
- Returns:
The ArrowLine type.
- Return type:
- parse_text(text_el: Element) str[source]#
Parses the <xdr:txBody> element and returns a text string.
- Parameters:
text_el (ET.Element) – The <xdr:txBody> element.
- Returns:
The text string.
- Return type:
str
- Raises:
ValueError – If the text element is not found.
TODO: - Text parsing is not implemented when the text contains multiple formats.
- _parse_drawing(element: Element) ConnectorRaw[source]#
Parses the drawing element and returns a ConnectorRaw object.
- Parameters:
element (ET.Element) – The drawing element.
- Returns:
The parsed ConnectorRaw object.
- Return type:
- _create_anchor_raw(anchor: Anchor, drawing_raw: ConnectorRaw) ConnectorAnchorRaw[source]#
Creates a ConnectorAnchorRaw object.
- Parameters:
anchor (Anchor) – The anchor object.
drawing_raw (ConnectorRaw) – The drawing raw object.
- Returns:
The created ConnectorAnchorRaw object.
- Return type:
- _abc_impl = <_abc._abc_data object>#
spreadsheet_intelligence.parsers.drawing.drawing_element_parser.picture_parser module#
- class spreadsheet_intelligence.parsers.drawing.drawing_element_parser.picture_parser.PictureParser(namespaces: dict[str, str])[source]#
Bases:
BaseDrawingParser- _parse_drawing(element: Element) PictureRaw[source]#
Parses the drawing element and returns a PictureRaw object.
- Parameters:
element (ET.Element) – The drawing element.
- Returns:
The parsed PictureRaw object.
- Return type:
- Raises:
NotImplementedError – If the method is not implemented.
- _create_anchor_raw(anchor: Anchor, drawing_raw: PictureRaw) PictureAnchorRaw[source]#
Creates a PictureAnchorRaw object.
- Parameters:
anchor (Anchor) – The anchor object.
drawing_raw (PictureRaw) – The drawing raw object.
- Returns:
The created PictureAnchorRaw object.
- Return type:
- Raises:
NotImplementedError – If the method is not implemented.
- _abc_impl = <_abc._abc_data object>#
spreadsheet_intelligence.parsers.drawing.drawing_element_parser.shape_parser module#
- class spreadsheet_intelligence.parsers.drawing.drawing_element_parser.shape_parser.ShapeParser(namespaces: dict[str, str])[source]#
Bases:
BaseDrawingParser[ShapeAnchorRaw,ShapeRaw]Parser for the shape element.
- _parse_text(text_el: Element) str[source]#
Parses the text element and returns the text string.
- Parameters:
text_el (ET.Element) – The text element.
- Returns:
The parsed text string.
- Return type:
str
- Raises:
ValueError – If the text element is not found.
TODO: - Text parsing is not implemented when the text contains multiple formats.
- _parse_drawing(element: Element) ShapeRaw[source]#
Parses the drawing element and returns a ShapeRaw object.
- Parameters:
element (ET.Element) – The drawing element.
- Returns:
The parsed ShapeRaw object.
- Return type:
- _create_anchor_raw(anchor: Anchor, drawing_raw: ShapeRaw) ShapeAnchorRaw[source]#
Creates a ShapeAnchorRaw object.
- Parameters:
- Returns:
The created ShapeAnchorRaw object.
- Return type:
- _abc_impl = <_abc._abc_data object>#