In the meta module contains all classes to access the documents meta data, keywords and user defined tags.
Every ODF document class has an attribute called meta which is an instance of Meta class.
Warning
Don’t create instances of this class by yourself.
You always get/set strings, also for date and time values.
Set metatag name to value.
Get metatag name.
You got access to the documents metatags by the subscript operator:
# get values
value = document.meta['generator']
# set values
document.meta['description'] = "This is a text document."
At this time the supported metatags are:
Metatag | Description |
---|---|
generator | application or tool that was used to create or last modify the XML document. |
title | title of the document |
description | brief description of the document |
subject | subject of the document |
initial-creator | name of the person who created the document initially |
creator | name of the person who last modified the document |
creation-date | date and time when the document was created initially ISO format YYYY-MM-DDThh:mm:ss |
date | date and time when the document was last modified (ISO format) |
editing-cycles | number of editing cycles the document has been through. The value of this element is incremented every time the document is saved. |
language | the document language like 'en-US' or 'de-AT' |
Delete all metatags, keywords, user-defined tags and statistics.
Warning
Don’t create instances of this class by yourself.
Add keyword to the document meta data.
remove keyword from the document meta data.
Iterate over all keywords:
for keyword in document.meta.keywords:
pass # or do something
True if keyword is in the meta data else False.
This method is used by the in operator:
if 'text' in document.meta.keywords:
pass # or do something
Delete all keywords.
The Usertags class manages the <meta:user-defined> elements.
Warning
Don’t create instances of this class by yourself.
Set the usertag name the value and the type to value_type. The allowed meta types are 'float', 'date', 'time', 'boolean' and 'string'.
Set usertag name to value, type is 'string'.
Get usertag name.
Delete usertag name.
usage:
document.meta.usertags['mytag'] = 'text'
value = document.meta.usertags['mytag']
del document.meta.usertags['mytag']
Get type of user defined tag name. The allowed meta types are 'float', 'date', 'time', 'boolean' and 'string'.
True if the document has a usertag name else False.
This method is used by the in operator:
if 'mytag' in document.meta.usertags:
pass # or do something
Iterate over all usertags, returns 2-tuple (tagname, tagvalue):
for name, value in document.meta.usertags:
pass # or do something
# create a dict of user defined tags
d = dict(document.meta.usertags)
Set user defined tags from dict d.
Delete all user defined tags.
Warning
Don’t create instances of this class by yourself.
Get count of statistic element key as int, if key is not defined for the document the result is 0.
Set count of statistic element key to value.
usage:
if document.meta.count['page'] > 3:
pass # or do something
# or set values
document.meta.count['character'] = 4711
Iterate over all statistics, returns 2-tuple (element, value).
create a dict of all statistic values:
d = dict(document.meta.count)
Set statistics from dict d.
Clear all statistics.
Element | Description |
---|---|
page | Number of pages in a word processing document. This must be greater than zero. This attribute is not used in spreadsheets. The page-count for a spreadsheet is a calculated value that tells how many sheets have filled cells on them, and this can be zero for a totally empty spreadsheet. |
table | Number of tables in a word processing document, or number of sheets in a spreadsheet document. |
draw | Apparently unused in OpenOffice.org2.0 |
image | Number of images in a word processing document. |
object | Number of objects in a document. This attribute is used in drawing and presentation documents, but it does not bear any simple relationship to the number of items you see on the screen. |
ole-object | Apparently unused in OpenOffice.org2.0 |
paragraph | Number of paragraphs in a word processing document. |
word | Number of words in a word processing document. |
character | Number of characters in a word processing document. |
row | Apparently unused in OpenOffice.org2.0 |
frame | unknown |
sentence | Number of sentences in a word processing document. |
syllable | Number of syllables in a word processing document. |
non-whitespace-character | Number of non-whitespace-characters in a word processing document. |
cell | none empty cells in a spreadsheet document. |
Table from the online book OASIS OpenDocument Essentials.