odio


Nameodio JSON
Version 0.0.23 PyPI version JSON
download
home_pageNone
SummaryA library for the import / export of ODF documents.
upload_time2024-05-22 12:38:33
maintainerNone
docs_urlNone
authorThe Contributors
requires_python>=3.8
licenseMIT No Attribution
keywords odf ods odt
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Odio

A pure-Python library for the import / export of
[ODF](http://en.wikipedia.org/wiki/OpenDocument) (`.ods` and `.odt`) documents.


# Installation

- Create a virtual environment: `python3 -m venv venv`
- Activate the virtual environment: `source venv/bin/activate`
- Install: `pip install odio`


# Quickstart

Create a spreadsheet:

```python
>>> import odio
>>> import datetime
>>> 
>>>
>>> # Create the spreadsheet.
>>> # Version is ODF version. Can be '1.1' or '1.2'. The default is '1.2'.
>>> # Default for 'compressed' is True.
>>> with open('test.ods', 'wb') as f, odio.create_spreadsheet(
...         f, version='1.2', compressed=True) as sheet:
...	
...	# Add a table (tab) to the spreadsheet
... 	sheet.append_table(
...         'Plan',
...         [
...             [
...                 "veni, vidi, vici", 0.3, 5, odio.Formula('=B1 + C1'),
...                 datetime.datetime(2015, 6, 30, 16, 38),
...             ],
...         ]
...     )
```


import the spreadsheet:

```python
>>> import odio
>>>
>>>
>>> # Parse the document we just created.
>>> # Version is ODF version. Can be '1.1' or '1.2'. The default is '1.2'.
>>> with open('test.ods', 'rb') as f:
...     sheet = odio.parse_spreadsheet(f)
>>>
>>> table = sheet.tables[0]
>>> print(table.name)
Plan
>>> for row in table.rows:
...     print(row)
['veni, vidi, vici', 0.3, 5.0, odio.Formula('=B1 + C1'), datetime.datetime(2015, 6, 30, 16, 38)]
```


Create a text document:

```python
>>> from odio import create_text, P, H, Span
>>> 
>>>
>>> # Create the text document. The ODF version string can be '1.2' or '1.1'
>>> with open('test.odt', 'wb') as f, create_text(f, '1.2') as txt:
...	
...     txt.append(
...         P("The Meditations", text_style_name='Title'),
...         H("Book One", text_style_name='Heading 1'),
...         P(
...             "From my grandfather ",
...             Span("Verus", text_style_name='Strong Emphasis'),
...             " I learned good morals and the government of my temper."
...         ),
...         P(
...             "From the reputation and remembrance of my father, "
...             "modesty and a ", Span("manly", text_style_name='Emphasis'),
...             " character."
...         )
...      )
```

parse the text document:

```python
>>> import odio
>>>
>>>
>>> # Parse the text document we just created. Can be ODF 1.1 or 1.2 format.
>>> txt = odio.parse_text(open('test.odt', "rb"))
>>> 
>>> # Find a subnode
>>> subnode = txt.nodes[2] 
>>> print(subnode.name)
text:p
>>> print(subnode.attributes['text_style_name'])
Text Body
>>> print(subnode)
odio.P(' From my grandfather ', odio.Span('Verus', text_style_name='Strong Emphasis'), ' I learned good morals and the government of my temper. ')
```

# Regression Tests

- Install `tox`: `pip install tox`
- Run `tox`: `tox`


# Doing A Release Of Odio

Run ``tox`` make sure all tests pass, then update the release notes and then do::

- `git tag -a x.y.z -m "version x.y.z"`
- `rm -r build; rm -r dist`
- `python -m build`
-  `twine upload --sign dist/*`


# Release Notes

## Version 0.0.23, 2024-05-22

- When writing out to a spreadsheet, interpret a `decimal.Decimal` as a number.


## Version 0.0.22, 2021-02-08

- Substitute `<text:line-break/>` for line breaks.


## Version 0.0.21, 2021-02-05

- Finding text should never result in a `None`.


## Version 0.0.20, 2021-02-04

- Text should appear in the content of a `<text:p>` element within a cell.


## Version 0.0.19, 2021-02-04

- Where line breaks appear in a text element's content, they are now replaced by a
  `<text:line-break/>` element. This means that line breaks appear in the
  spreadsheet, whereas before they didn't.


## Version 0.0.18, 2019-11-29

- Performance improvement: rather than use the `xml.sax.saxutils` versions of
  `escape` and `quoteattr` I've copied them into the source of Odio, but removing
  the code for entities that aren't needed.


## Version 0.0.17, 2018-08-19

- When parsing a spreadsheet cell of text type, if the value isn't contained in the
  attribute, recursively use the next nodes in the element contents.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "odio",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "odf, ods, odt",
    "author": "The Contributors",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/44/a0/a9d8aa8d3d0029774861c0c163ab0ed02e426640e7ffe6873bfab51bba22/odio-0.0.23.tar.gz",
    "platform": null,
    "description": "# Odio\n\nA pure-Python library for the import / export of\n[ODF](http://en.wikipedia.org/wiki/OpenDocument) (`.ods` and `.odt`) documents.\n\n\n# Installation\n\n- Create a virtual environment: `python3 -m venv venv`\n- Activate the virtual environment: `source venv/bin/activate`\n- Install: `pip install odio`\n\n\n# Quickstart\n\nCreate a spreadsheet:\n\n```python\n>>> import odio\n>>> import datetime\n>>> \n>>>\n>>> # Create the spreadsheet.\n>>> # Version is ODF version. Can be '1.1' or '1.2'. The default is '1.2'.\n>>> # Default for 'compressed' is True.\n>>> with open('test.ods', 'wb') as f, odio.create_spreadsheet(\n...         f, version='1.2', compressed=True) as sheet:\n...\t\n...\t# Add a table (tab) to the spreadsheet\n... \tsheet.append_table(\n...         'Plan',\n...         [\n...             [\n...                 \"veni, vidi, vici\", 0.3, 5, odio.Formula('=B1 + C1'),\n...                 datetime.datetime(2015, 6, 30, 16, 38),\n...             ],\n...         ]\n...     )\n```\n\n\nimport the spreadsheet:\n\n```python\n>>> import odio\n>>>\n>>>\n>>> # Parse the document we just created.\n>>> # Version is ODF version. Can be '1.1' or '1.2'. The default is '1.2'.\n>>> with open('test.ods', 'rb') as f:\n...     sheet = odio.parse_spreadsheet(f)\n>>>\n>>> table = sheet.tables[0]\n>>> print(table.name)\nPlan\n>>> for row in table.rows:\n...     print(row)\n['veni, vidi, vici', 0.3, 5.0, odio.Formula('=B1 + C1'), datetime.datetime(2015, 6, 30, 16, 38)]\n```\n\n\nCreate a text document:\n\n```python\n>>> from odio import create_text, P, H, Span\n>>> \n>>>\n>>> # Create the text document. The ODF version string can be '1.2' or '1.1'\n>>> with open('test.odt', 'wb') as f, create_text(f, '1.2') as txt:\n...\t\n...     txt.append(\n...         P(\"The Meditations\", text_style_name='Title'),\n...         H(\"Book One\", text_style_name='Heading 1'),\n...         P(\n...             \"From my grandfather \",\n...             Span(\"Verus\", text_style_name='Strong Emphasis'),\n...             \" I learned good morals and the government of my temper.\"\n...         ),\n...         P(\n...             \"From the reputation and remembrance of my father, \"\n...             \"modesty and a \", Span(\"manly\", text_style_name='Emphasis'),\n...             \" character.\"\n...         )\n...      )\n```\n\nparse the text document:\n\n```python\n>>> import odio\n>>>\n>>>\n>>> # Parse the text document we just created. Can be ODF 1.1 or 1.2 format.\n>>> txt = odio.parse_text(open('test.odt', \"rb\"))\n>>> \n>>> # Find a subnode\n>>> subnode = txt.nodes[2] \n>>> print(subnode.name)\ntext:p\n>>> print(subnode.attributes['text_style_name'])\nText Body\n>>> print(subnode)\nodio.P(' From my grandfather ', odio.Span('Verus', text_style_name='Strong Emphasis'), ' I learned good morals and the government of my temper. ')\n```\n\n# Regression Tests\n\n- Install `tox`: `pip install tox`\n- Run `tox`: `tox`\n\n\n# Doing A Release Of Odio\n\nRun ``tox`` make sure all tests pass, then update the release notes and then do::\n\n- `git tag -a x.y.z -m \"version x.y.z\"`\n- `rm -r build; rm -r dist`\n- `python -m build`\n-  `twine upload --sign dist/*`\n\n\n# Release Notes\n\n## Version 0.0.23, 2024-05-22\n\n- When writing out to a spreadsheet, interpret a `decimal.Decimal` as a number.\n\n\n## Version 0.0.22, 2021-02-08\n\n- Substitute `<text:line-break/>` for line breaks.\n\n\n## Version 0.0.21, 2021-02-05\n\n- Finding text should never result in a `None`.\n\n\n## Version 0.0.20, 2021-02-04\n\n- Text should appear in the content of a `<text:p>` element within a cell.\n\n\n## Version 0.0.19, 2021-02-04\n\n- Where line breaks appear in a text element's content, they are now replaced by a\n  `<text:line-break/>` element. This means that line breaks appear in the\n  spreadsheet, whereas before they didn't.\n\n\n## Version 0.0.18, 2019-11-29\n\n- Performance improvement: rather than use the `xml.sax.saxutils` versions of\n  `escape` and `quoteattr` I've copied them into the source of Odio, but removing\n  the code for entities that aren't needed.\n\n\n## Version 0.0.17, 2018-08-19\n\n- When parsing a spreadsheet cell of text type, if the value isn't contained in the\n  attribute, recursively use the next nodes in the element contents.\n",
    "bugtrack_url": null,
    "license": "MIT No Attribution",
    "summary": "A library for the import / export of ODF documents.",
    "version": "0.0.23",
    "project_urls": {
        "Homepage": "https://github.com/tlocke/odio"
    },
    "split_keywords": [
        "odf",
        " ods",
        " odt"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9b965a09ffff31bb728d5cff4cfffc46daf49026f1d8822fab3c7189cc789d75",
                "md5": "e058b503905624fb4cf452e376ab6d6c",
                "sha256": "15c923f35027da15051c977f256fa0891f2e0d74a8adf42dbcc620c3515a8f30"
            },
            "downloads": -1,
            "filename": "odio-0.0.23-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e058b503905624fb4cf452e376ab6d6c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 11218,
            "upload_time": "2024-05-22T12:38:31",
            "upload_time_iso_8601": "2024-05-22T12:38:31.950647Z",
            "url": "https://files.pythonhosted.org/packages/9b/96/5a09ffff31bb728d5cff4cfffc46daf49026f1d8822fab3c7189cc789d75/odio-0.0.23-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "44a0a9d8aa8d3d0029774861c0c163ab0ed02e426640e7ffe6873bfab51bba22",
                "md5": "337f8756b53cae5f6be991027183eb76",
                "sha256": "ffa0b977db3aa6af095c29bb48ebbeb109e807db634bc581bf5d162fd3b5a6e1"
            },
            "downloads": -1,
            "filename": "odio-0.0.23.tar.gz",
            "has_sig": false,
            "md5_digest": "337f8756b53cae5f6be991027183eb76",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 104126,
            "upload_time": "2024-05-22T12:38:33",
            "upload_time_iso_8601": "2024-05-22T12:38:33.925407Z",
            "url": "https://files.pythonhosted.org/packages/44/a0/a9d8aa8d3d0029774861c0c163ab0ed02e426640e7ffe6873bfab51bba22/odio-0.0.23.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-22 12:38:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tlocke",
    "github_project": "odio",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "odio"
}
        
Elapsed time: 4.02661s