ged2doc.odt_writer¶
Module which produces ODT output.
Functions
|
This is no-op function, only used to mark translatable strings, to extract all strings run |
Classes
|
Transforms GEDCOM file into nicely formatted OpenDocument Text (ODT). |
|
Class representing page layout, size and margins |
-
class
ged2doc.odt_writer.
OdtWriter
(flocator, output, tr, encoding=None, encoding_errors='strict', sort_order=<NameOrder.SURNAME_GIVEN: 'last+first'>, name_fmt=0, make_images=True, make_stat=True, make_toc=True, events_without_dates=True, page_width='6in', page_height='9in', margin_left='0.5in', margin_right='0.5in', margin_top='0.5in', margin_bottom='0.25in', image_width='2in', image_height='2in', tree_width=4, first_page=1, tree_format='emf')[source]¶ Bases:
ged2doc.writer.Writer
Transforms GEDCOM file into nicely formatted OpenDocument Text (ODT).
This is a sub-class of
Writer
class providing implementation for rendering methods which transform GEDCOM info into ODT structures. Constructor takes a large number of arguments which configure appearance of the resulting HTML page. After instantiating an object of this type one has to callsave
method to produce output file.- Parameters
- flocator
ged2doc.input.FileLocator
File locator instance.
- output
str
orio.TextIOBase
Name for the output file or file object.
- tr
ged2doc.i18n.I18N
Object supporting translation.
- encoding
str
, optional GEDCOM file encoding, if
None
then encoding is determined from file itself.- encoding_errors
str
, optional Controls error handling behavior during string decoding, one of “strict” (default), “ignore”, or “replace”.
- sort_order
ged4py.model.NameOrder
, optional Determines ordering of person in output file, one of the constants defined in
ged4py.model.NameOrder
enum.- name_fmt
int
, optional Bit mask with flags from
ged2doc.name
module.- make_images
bool
, optional If
True
(default) then generate images for persons.- make_stat
bool
, optional If
True
(default) then generate statistics section.- make_toc
bool
, optional If
True
(default) then generate Table of Contents.- events_without_dates
bool
, optional If
True
(default) then show events that have no associated dates.- page_width, page_height
ged2doc.size.Size
, optional Page size of the produced document.
- margin_left, margin_right, margin_top, margin_bottom
ged2doc.size.Size
, optional Page margins of the produced document.
- image_width, image_height
ged2doc.size.Size
, optional Size of the images.
- tree_width
int
Number of generations in ancestor tree.
- first_page
int
Number of the first generated page.
- tree_format
str
Image format for ancestor tree, “emf” or “svg”.
- flocator
Methods
save
()Produce output document.
-
_make_layout
(doc, layout, firstpage)[source]¶ Set paper dimensions.
- Parameters
- doc
OpenDocumentText
ODT document object.
- layout
PageLayout
ODT page layout.
- firstpage
int
Number of the first generated page.
- doc
-
_make_styles
(doc, layout)[source]¶ Generate set of styles for the document.
- Parameters
- doc
OpenDocumentText
ODT document object.
- layout
PageLayout
ODT page layout.
- doc
-
_interpolate
(text)[source]¶ Takes text with embedded references and returns text.
- Parameters
- text
str
Arbitrary text with references.
- text
- Returns
- text
str
Resulting text.
- text
-
_render_section
(level, ref_id, title, newpage=False)[source]¶ Produces new section in the output document.
This method should also save section reference so that TOC can be later produced when
_render_toc
method is called.- Parameters
- level
int
Section level (1, 2, 3, etc.).
- ref_id
str
Unique section identifier.
- title
str
Printable section name.
- newpage
bool
, optional If
True
then start new page (for documents that support pagination).
- level
-
_render_person
(person, image_data, attributes, families, events, notes)[source]¶ Output person information.
- Parameters
- person
ged4py.model.Individual
INDI record representation.
- image_data
bytes
orNone
Either
None
or binary image data (typically content of JPEG image).- attributes
list
[tuple
] List of (attr_name, text) tuples, may be empty.
- families
list
[str
] List of strings (possibly empty), each string contains description of one family and should be typically rendered as a separate paragraph.
- events
list
[tuple
] List of (date, text) tuples, may be empty. Date is properly formatted string and does not need any other formatting.
- notes
list
[str
] List of strings, each string should be rendered as separate paragraph.
- person
Notes
Textual information in parameters to this method can include references to other persons (e.g. mother/father). Such references are embedded into text in encoded format determined by
_person_ref
method. It is responsibility of the subclasses to extract these references from text and re-encode them using proper backend representation.
-
_render_name_stat
(n_total, n_females, n_males)[source]¶ Produces summary table.
Sum of male and female counters can be lower than total count due to individuals with unknown/unspecified gender.
- Parameters
- n_total
int
Total number of individuals.
- n_females
int
Number of female individuals.
- n_males
int
Number of male individuals.
- n_total
-
_render_name_freq
(freq_table)[source]¶ Produces name statistics table.
- Parameters
- freq_table
list
[tuple
] List of (name, count) tuples.
- freq_table
-
_render_toc
()[source]¶ Produce table of contents using info collected in
_render_section()
.
-
_get_image_fragment
(image_data)[source]¶ Adds Image to the document as person’s picture.
- Parameters
- image_data
bytes
Image data.
- image_data
- Returns
- frame
odf.draw.Frame
Frame containing image.
- frame
-
_make_ancestor_tree
(person)[source]¶ “Add a picture for ancestor tree.
- Parameters
- person
ged4py.model.Individual
INDI record
- person
-
_abc_impl
= <_abc_data object>¶