berhoel.odf package

Give access to ods files.

class berhoel.odf.Odf(path: Union[str, pathlib.Path])[source]

Bases: berhoel.odf.OdfXml

Base class for OpenDocument Format files.

Methods

find(tag)

Find tag in this element.

findall(tag)

Find all of tag.

get(attrib)

Get atribute of this element, honors namespace.

class berhoel.odf.OdfXml(elem: lxml.etree._Element)[source]

Bases: object

Base XML handling class for ODF processing.

Methods

find(tag)

Find tag in this element.

findall(tag)

Find all of tag.

get(attrib)

Get atribute of this element, honors namespace.

_attrib_map(attrib: str)str[source]

Helper for get: provide namespace.

Parameters

attrib (str) – attribute name in the form of <namespace name>:<attr name>.

Returns

attribute name with extended namespace.

Return type

str

find(tag: str) → lxml.etree._Element[source]

Find tag in this element.

Parameters

tag (str) – XML tag to serarch for.

Returns

Element acc. to tag.

Return type

etree._Element

findall(tag: str) → List[lxml.etree._Element][source]

Find all of tag.

Parameters

tag (str) – XML tag to find.

Returns

Element acc. to tag.

Return type

List[etree._Element]

get(attrib: str)str[source]

Get atribute of this element, honors namespace.

Parameters

attrib (str) – Attrribute name.

Returns

Attribute value.

Return type

str

Submodules

berhoel.odf._version module

berhoel.odf.ods module

Processing ods (OpenDocument spreadsheets).

class berhoel.odf.ods.Cell(elem: lxml.etree._Element)[source]

Bases: berhoel.odf.OdfXml

Representing a cell in a table row.

Attributes
date

Return date value of cell if available.

float

Return float value of cell.

int

Return integer value of cell.

link

Provide Link information.

text

Return text associated with cell.

url

Return URL associated with cell from hyperlink function.

value

Return value of cell.

Methods

find(tag)

Find tag in this element.

findall(tag)

Find all of tag.

get(attrib)

Get atribute of this element, honors namespace.

property date

Return date value of cell if available.

Returns

Date value of cell if available.

Return type

datetime.date

property float

Return float value of cell.

Returns

float falue of cell if available.

Return type

float

property int

Return integer value of cell.

Returns

int value if cell if available.

Return type

int

Provide Link information.

This link information is information of values referenced from diffrent tables in formula.

Returns

Result of re.match.groupdict. Provided keys are sheet, row, and line.

Return type

dict

property text

Return text associated with cell.

Returns

Cell text if avaliable.

Return type

str

property url

Return URL associated with cell from hyperlink function.

Returns

url from HYPERLINK formula or cell hyperlink.

Return type

str

property value

Return value of cell.

Returns

Value of cell if available.

Return type

str

class berhoel.odf.ods.Ods(*args, **kw)[source]

Bases: berhoel.odf.Odf

Processing ODS files.

Methods

find(tag)

Find tag in this element.

findall(tag)

Find all of tag.

get(attrib)

Get atribute of this element, honors namespace.

property tables

Return all tables in spreadsheet.

Returns

Tables in OpenOffice spreadsheet.

Return type

List[Table]

class berhoel.odf.ods.P(elem: lxml.etree._Element)[source]

Bases: berhoel.odf.OdfXml

Representing a paragraph in a cell.

Attributes
text

Get text from paragraph.

Methods

find(tag)

Find tag in this element.

findall(tag)

Find all of tag.

get(attrib)

Get atribute of this element, honors namespace.

property text

Get text from paragraph.

Returns

Whole paragraph text if available.

Return type

str

class berhoel.odf.ods.Row(*args, **kw)[source]

Bases: berhoel.odf.OdfXml

Representing table row.

Methods

find(tag)

Find tag in this element.

findall(tag)

Find all of tag.

get(attrib)

Get atribute of this element, honors namespace.

property cells

Provide list of cells in row.

Empty cells are replaced by None, as are cells covered by merged cells.

Returns

The cells making up the current row.

Return type

List[Cell]

class berhoel.odf.ods.Table(elem: lxml.etree._Element)[source]

Bases: berhoel.odf.OdfXml

Representation of spreadsheet table.

Attributes
hidden

Return whether table is hidden.

Methods

find(tag)

Find tag in this element.

findall(tag)

Find all of tag.

get(attrib)

Get atribute of this element, honors namespace.

property hidden

Return whether table is hidden.

Returns

True if table is hidden.

Return type

bool

property name

Return name attriute of table.

Returns

table name.

Return type

str

property rows

Return rows in table.

Returns

list of Row intances.

Return type

List[Row]

property style_name

Return table style-name.

I Know of ta1 for ordinary tables, and ta2 for hidden tables.

Returns

style name of table.

Return type

str