spreadsheet_intelligence.parsers.drawing package#

Subpackages#

Submodules#

spreadsheet_intelligence.parsers.drawing.drawing_xml_parser module#

class spreadsheet_intelligence.parsers.drawing.drawing_xml_parser.DrawingXMLParser(drawing_root: Element)[source]#

Bases: BaseXMLParser

Parses XML elements related to drawing objects in a spreadsheet.

This class is responsible for parsing XML elements that represent drawing objects such as connectors and shapes in a spreadsheet.

namespaces#

XML namespaces used in the drawing XML.

Type:

dict

xml_root#

Root element of the drawing XML.

Type:

ET.Element

connector_list#

List of parsed connector anchors.

Type:

List[ConnectorAnchorRaw]

shape_list#

List of parsed shape anchors.

Type:

List[ShapeAnchorRaw]

namespaces: dict[str, str]#
connector_list: List[ConnectorAnchorRaw]#
shape_list: List[ShapeAnchorRaw]#
parse() Tuple[List[ConnectorAnchorRaw], List[ShapeAnchorRaw]][source]#

Parses the drawing XML to extract connectors and shapes.

Iterates over the XML elements to find and parse connectors and shapes, storing them in their respective lists.

Returns:

A tuple containing lists of parsed connector and shape anchors.

Return type:

Tuple[List[ConnectorAnchorRaw], List[ShapeAnchorRaw]]

_abc_impl = <_abc._abc_data object>#

Module contents#

class spreadsheet_intelligence.parsers.drawing.DrawingXMLParser(drawing_root: Element)[source]#

Bases: BaseXMLParser

Parses XML elements related to drawing objects in a spreadsheet.

This class is responsible for parsing XML elements that represent drawing objects such as connectors and shapes in a spreadsheet.

namespaces#

XML namespaces used in the drawing XML.

Type:

dict

xml_root#

Root element of the drawing XML.

Type:

ET.Element

connector_list#

List of parsed connector anchors.

Type:

List[ConnectorAnchorRaw]

shape_list#

List of parsed shape anchors.

Type:

List[ShapeAnchorRaw]

_abc_impl = <_abc._abc_data object>#
parse() Tuple[List[ConnectorAnchorRaw], List[ShapeAnchorRaw]][source]#

Parses the drawing XML to extract connectors and shapes.

Iterates over the XML elements to find and parse connectors and shapes, storing them in their respective lists.

Returns:

A tuple containing lists of parsed connector and shape anchors.

Return type:

Tuple[List[ConnectorAnchorRaw], List[ShapeAnchorRaw]]

connector_list: List[ConnectorAnchorRaw]#
shape_list: List[ShapeAnchorRaw]#
namespaces: dict[str, str]#
class spreadsheet_intelligence.parsers.drawing.ConnectorParser(namespaces: dict[str, str])[source]#

Bases: BaseDrawingParser[ConnectorAnchorRaw, ConnectorRaw]

Parser for the connector element.

_abc_impl = <_abc._abc_data object>#
_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:

ConnectorAnchorRaw

_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:

ConnectorRaw

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:

ArrowLine

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.

class spreadsheet_intelligence.parsers.drawing.ShapeParser(namespaces: dict[str, str])[source]#

Bases: BaseDrawingParser[ShapeAnchorRaw, ShapeRaw]

Parser for the shape element.

_abc_impl = <_abc._abc_data object>#
_create_anchor_raw(anchor: Anchor, drawing_raw: ShapeRaw) ShapeAnchorRaw[source]#

Creates a ShapeAnchorRaw object.

Parameters:
  • anchor (Anchor) – The anchor object.

  • drawing_raw (ShapeRaw) – The drawing raw object.

Returns:

The created ShapeAnchorRaw object.

Return type:

ShapeAnchorRaw

_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:

ShapeRaw

_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.