berhoel.odf package

Give access to ods files.

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

Bases: object

Base XML handling class for ODF processing.

__init__(elem: _Element)[source]
Parameters

element (etree._Element) – XML Element

find(tag: str) _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[_Element][source]

Find all of tag.

Parameters

tag (str) – XML tag to find.

Returns

Element acc. to tag.

Return type

List[etree._Element]

_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

get(attrib: str) str[source]

Get atribute of this element, honors namespace.

Parameters

attrib (str) – Attrribute name.

Returns

Attribute value.

Return type

str

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

Bases: OdfXml

Base class for OpenDocument Format files.

__init__(path: Union[str, Path])[source]

Open ODF file from path.

Parameters

path ([str,Path]) – Location of OpenOffice file.

Submodules

berhoel.odf.ods module

Processing ods (OpenDocument spreadsheets).

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

Bases: OdfXml

Representing a paragraph in a cell.

property text: Optional[str]

Get text from paragraph.

Returns

Whole paragraph text if available.

Return type

str

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

Bases: OdfXml

Representing a cell in a table row.

property text: Optional[str]

Return text associated with cell.

Returns

Cell text if avaliable.

Return type

str

property date: Optional[date]

Return date value of cell if available.

Returns

Date value of cell if available.

Return type

datetime.date

property value: Optional[str]

Return value of cell.

Returns

Value of cell if available.

Return type

str

property float: Optional[float]

Return float value of cell.

Returns

float falue of cell if available.

Return type

float

property int: Optional[int]

Return integer value of cell.

Returns

int value if cell if available.

Return type

int

property url: Optional[str]

Return URL associated with cell from hyperlink function.

Returns

url from HYPERLINK formula or cell hyperlink.

Return type

str

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

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

Bases: OdfXml

Representing table row.

__init__(*args, **kw)[source]
Parameters

element (etree._Element) – XML Element

property cells: List[Optional[Cell]]

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: _Element)[source]

Bases: OdfXml

Representation of spreadsheet table.

property name: str

Return name attriute of table.

Returns

table name.

Return type

str

property rows: List[Row]

Return rows in table.

Returns

list of Row intances.

Return type

List[Row]

property style_name: str

Return table style-name.

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

Returns

style name of table.

Return type

str

property hidden: bool

Return whether table is hidden.

Returns

True if table is hidden.

Return type

bool

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

Bases: Odf

Processing ODS files.

__init__(*args, **kw)[source]

Open ODF spreadsheet file.

property tables: List[Table]

Return all tables in spreadsheet.

Returns

Tables in OpenOffice spreadsheet.

Return type

List[Table]