desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'dict mapping rIds to target parts for all the internal relationships in the collection.'
@property def related_parts(self):
return self._target_parts_by_rId
'Serialize this relationship collection into XML suitable for storage as a .rels file in an OPC package.'
@property def xml(self):
rels_elm = CT_Relationships.new() for rel in self.values(): rels_elm.add_rel(rel.rId, rel.reltype, rel.target_ref, rel.is_external) return rels_elm.xml
'Return relationship of matching *reltype*, *target*, and *is_external* from collection, or None if not found.'
def _get_matching(self, reltype, target, is_external=False):
def matches(rel, reltype, target, is_external): if (rel.reltype != reltype): return False if (rel.is_external != is_external): return False rel_target = (rel.target_ref if rel.is_external else rel.target_part) if (rel_target != target): return False return True for rel in self.values(): if matches(rel, reltype, target, is_external): return rel return None
'Return single relationship of type *reltype* from the collection. Raises |KeyError| if no matching relationship is found. Raises |ValueError| if more than one matching relationship is found.'
def _get_rel_of_type(self, reltype):
matching = [rel for rel in self.values() if (rel.reltype == reltype)] if (len(matching) == 0): tmpl = u"no relationship of type '%s' in collection" raise KeyError((tmpl % reltype)) if (len(matching) > 1): tmpl = u"multiple relationships of type '%s' in collection" raise ValueError((tmpl % reltype)) return matching[0]
'Next available rId in collection, starting from \'rId1\' and making use of any gaps in numbering, e.g. \'rId2\' for rIds [\'rId1\', \'rId3\'].'
@property def _next_rId(self):
for n in range(1, (len(self) + 2)): rId_candidate = (u'rId%d' % n) if (rId_candidate not in self): return rId_candidate
'Entry point for any post-unmarshaling processing. May be overridden by subclasses without forwarding call to super.'
def after_unmarshal(self):
pass
'|CoreProperties| object providing read/write access to the Dublin Core properties for this document.'
@property def core_properties(self):
return self._core_properties_part.core_properties
'Generate exactly one reference to each relationship in the package by performing a depth-first traversal of the rels graph.'
def iter_rels(self):
def walk_rels(source, visited=None): visited = ([] if (visited is None) else visited) for rel in source.rels.values(): (yield rel) if rel.is_external: continue part = rel.target_part if (part in visited): continue visited.append(part) new_source = part for rel in walk_rels(new_source, visited): (yield rel) for rel in walk_rels(self): (yield rel)
'Generate exactly one reference to each of the parts in the package by performing a depth-first traversal of the rels graph.'
def iter_parts(self):
def walk_parts(source, visited=list()): for rel in source.rels.values(): if rel.is_external: continue part = rel.target_part if (part in visited): continue visited.append(part) (yield part) new_source = part for part in walk_parts(new_source, visited): (yield part) for part in walk_parts(self): (yield part)
'Return newly added |_Relationship| instance of *reltype* between this part and *target* with key *rId*. Target mode is set to ``RTM.EXTERNAL`` if *is_external* is |True|. Intended for use during load from a serialized package, where the rId is well known. Other methods exist for adding a new relationship to the package during processing.'
def load_rel(self, reltype, target, rId, is_external=False):
return self.rels.add_relationship(reltype, target, rId, is_external)
'Return a reference to the main document part for this package. Examples include a document part for a WordprocessingML package, a presentation part for a PresentationML package, or a workbook part for a SpreadsheetML package.'
@property def main_document_part(self):
return self.part_related_by(RT.OFFICE_DOCUMENT)
'Return an |OpcPackage| instance loaded with the contents of *pkg_file*.'
@classmethod def open(cls, pkg_file):
pkg_reader = PackageReader.from_file(pkg_file) package = cls() Unmarshaller.unmarshal(pkg_reader, package, PartFactory) return package
'Return part to which this package has a relationship of *reltype*. Raises |KeyError| if no such relationship is found and |ValueError| if more than one such relationship is found.'
def part_related_by(self, reltype):
return self.rels.part_with_reltype(reltype)
'Return a list containing a reference to each of the parts in this package.'
@property def parts(self):
return [part for part in self.iter_parts()]
'Return rId key of relationship to *part*, from the existing relationship if there is one, otherwise a newly created one.'
def relate_to(self, part, reltype):
rel = self.rels.get_or_add(reltype, part) return rel.rId
'Return a reference to the |Relationships| instance holding the collection of relationships for this package.'
@lazyproperty def rels(self):
return Relationships(PACKAGE_URI.baseURI)
'Save this package to *pkg_file*, where *file* can be either a path to a file (a string) or a file-like object.'
def save(self, pkg_file):
for part in self.parts: part.before_marshal() PackageWriter.write(pkg_file, self.rels, self.parts)
'|CorePropertiesPart| object related to this package. Creates a default core properties part if one is not present (not common).'
@property def _core_properties_part(self):
try: return self.part_related_by(RT.CORE_PROPERTIES) except KeyError: core_properties_part = CorePropertiesPart.default(self) self.relate_to(core_properties_part, RT.CORE_PROPERTIES) return core_properties_part
'Construct graph of parts and realized relationships based on the contents of *pkg_reader*, delegating construction of each part to *part_factory*. Package relationships are added to *pkg*.'
@staticmethod def unmarshal(pkg_reader, package, part_factory):
parts = Unmarshaller._unmarshal_parts(pkg_reader, package, part_factory) Unmarshaller._unmarshal_relationships(pkg_reader, package, parts) for part in parts.values(): part.after_unmarshal() package.after_unmarshal()
'Return a dictionary of |Part| instances unmarshalled from *pkg_reader*, keyed by partname. Side-effect is that each part in *pkg_reader* is constructed using *part_factory*.'
@staticmethod def _unmarshal_parts(pkg_reader, package, part_factory):
parts = {} for (partname, content_type, reltype, blob) in pkg_reader.iter_sparts(): parts[partname] = part_factory(partname, content_type, reltype, blob, package) return parts
'Add a relationship to the source object corresponding to each of the relationships in *pkg_reader* with its target_part set to the actual target part in *parts*.'
@staticmethod def _unmarshal_relationships(pkg_reader, package, parts):
for (source_uri, srel) in pkg_reader.iter_srels(): source = (package if (source_uri == u'/') else parts[source_uri]) target = (srel.target_ref if srel.is_external else parts[srel.target_partname]) source.load_rel(srel.reltype, target, srel.rId, srel.is_external)
'Entry point for post-unmarshaling processing, for example to parse the part XML. May be overridden by subclasses without forwarding call to super.'
def after_unmarshal(self):
pass
'Entry point for pre-serialization processing, for example to finalize part naming if necessary. May be overridden by subclasses without forwarding call to super.'
def before_marshal(self):
pass
'Contents of this package part as a sequence of bytes. May be text or binary. Intended to be overridden by subclasses. Default behavior is to return load blob.'
@property def blob(self):
return self._blob
'Content type of this part.'
@property def content_type(self):
return self._content_type
'Remove the relationship identified by *rId* if its reference count is less than 2. Relationships with a reference count of 0 are implicit relationships.'
def drop_rel(self, rId):
if (self._rel_ref_count(rId) < 2): del self.rels[rId]
'Return newly added |_Relationship| instance of *reltype* between this part and *target* with key *rId*. Target mode is set to ``RTM.EXTERNAL`` if *is_external* is |True|. Intended for use during load from a serialized package, where the rId is well-known. Other methods exist for adding a new relationship to a part when manipulating a part.'
def load_rel(self, reltype, target, rId, is_external=False):
return self.rels.add_relationship(reltype, target, rId, is_external)
'|OpcPackage| instance this part belongs to.'
@property def package(self):
return self._package
'|PackURI| instance holding partname of this part, e.g. \'/ppt/slides/slide1.xml\''
@property def partname(self):
return self._partname
'Return part to which this part has a relationship of *reltype*. Raises |KeyError| if no such relationship is found and |ValueError| if more than one such relationship is found. Provides ability to resolve implicitly related part, such as Slide -> SlideLayout.'
def part_related_by(self, reltype):
return self.rels.part_with_reltype(reltype)
'Return rId key of relationship of *reltype* to *target*, from an existing relationship if there is one, otherwise a newly created one.'
def relate_to(self, target, reltype, is_external=False):
if is_external: return self.rels.get_or_add_ext_rel(reltype, target) else: rel = self.rels.get_or_add(reltype, target) return rel.rId
'Dictionary mapping related parts by rId, so child objects can resolve explicit relationships present in the part XML, e.g. sldIdLst to a specific |Slide| instance.'
@property def related_parts(self):
return self.rels.related_parts
'|Relationships| instance holding the relationships for this part.'
@lazyproperty def rels(self):
return Relationships(self._partname.baseURI)
'Return URL contained in target ref of relationship identified by *rId*.'
def target_ref(self, rId):
rel = self.rels[rId] return rel.target_ref
'Return the count of references in this part\'s XML to the relationship identified by *rId*.'
def _rel_ref_count(self, rId):
rIds = self._element.xpath(u'//@r:id') return len([_rId for _rId in rIds if (_rId == rId)])
'Return the custom part class registered for *content_type*, or the default part class if no custom class is registered for *content_type*.'
@classmethod def _part_cls_for(cls, content_type):
if (content_type in cls.part_type_for): return cls.part_type_for[content_type] return cls.default_part_type
'The root XML element of this XML part.'
@property def element(self):
return self._element
'Part of the parent protocol, "children" of the document will not know the part that contains them so must ask their parent object. That chain of delegation ends here for child objects.'
@property def part(self):
return self
'Write a physical package (.pptx file) to *pkg_file* containing *pkg_rels* and *parts* and a content types stream based on the content types of the parts.'
@staticmethod def write(pkg_file, pkg_rels, parts):
phys_writer = PhysPkgWriter(pkg_file) PackageWriter._write_content_types_stream(phys_writer, parts) PackageWriter._write_pkg_rels(phys_writer, pkg_rels) PackageWriter._write_parts(phys_writer, parts) phys_writer.close()
'Write ``[Content_Types].xml`` part to the physical package with an appropriate content type lookup target for each part in *parts*.'
@staticmethod def _write_content_types_stream(phys_writer, parts):
cti = _ContentTypesItem.from_parts(parts) phys_writer.write(CONTENT_TYPES_URI, cti.blob)
'Write the blob of each part in *parts* to the package, along with a rels item for its relationships if and only if it has any.'
@staticmethod def _write_parts(phys_writer, parts):
for part in parts: phys_writer.write(part.partname, part.blob) if len(part._rels): phys_writer.write(part.partname.rels_uri, part._rels.xml)
'Write the XML rels item for *pkg_rels* (\'/_rels/.rels\') to the package.'
@staticmethod def _write_pkg_rels(phys_writer, pkg_rels):
phys_writer.write(PACKAGE_URI.rels_uri, pkg_rels.xml)
'Return XML form of this content types item, suitable for storage as ``[Content_Types].xml`` in an OPC package.'
@property def blob(self):
return serialize_part_xml(self._element)
'Return content types XML mapping each part in *parts* to the appropriate content type and suitable for storage as ``[Content_Types].xml`` in an OPC package.'
@classmethod def from_parts(cls, parts):
cti = cls() cti._defaults['rels'] = CT.OPC_RELATIONSHIPS cti._defaults['xml'] = CT.XML for part in parts: cti._add_content_type(part.partname, part.content_type) return cti
'Add a content type for the part with *partname* and *content_type*, using a default or override as appropriate.'
def _add_content_type(self, partname, content_type):
ext = partname.ext if ((ext.lower(), content_type) in default_content_types): self._defaults[ext] = content_type else: self._overrides[partname] = content_type
'Return XML form of this content types item, suitable for storage as ``[Content_Types].xml`` in an OPC package. Although the sequence of elements is not strictly significant, as an aid to testing and readability Default elements are sorted by extension and Override elements are sorted by partname.'
@property def _element(self):
_types_elm = CT_Types.new() for ext in sorted(self._defaults.keys()): _types_elm.add_default(ext, self._defaults[ext]) for partname in sorted(self._overrides.keys()): _types_elm.add_override(partname, self._overrides[partname]) return _types_elm
'Return a |PackageReader| instance loaded with contents of *pkg_file*.'
@staticmethod def from_file(pkg_file):
phys_reader = PhysPkgReader(pkg_file) content_types = _ContentTypeMap.from_xml(phys_reader.content_types_xml) pkg_srels = PackageReader._srels_for(phys_reader, PACKAGE_URI) sparts = PackageReader._load_serialized_parts(phys_reader, pkg_srels, content_types) phys_reader.close() return PackageReader(content_types, pkg_srels, sparts)
'Generate a 4-tuple `(partname, content_type, reltype, blob)` for each of the serialized parts in the package.'
def iter_sparts(self):
for s in self._sparts: (yield (s.partname, s.content_type, s.reltype, s.blob))
'Generate a 2-tuple `(source_uri, srel)` for each of the relationships in the package.'
def iter_srels(self):
for srel in self._pkg_srels: (yield (PACKAGE_URI, srel)) for spart in self._sparts: for srel in spart.srels: (yield (spart.partname, srel))
'Return a list of |_SerializedPart| instances corresponding to the parts in *phys_reader* accessible by walking the relationship graph starting with *pkg_srels*.'
@staticmethod def _load_serialized_parts(phys_reader, pkg_srels, content_types):
sparts = [] part_walker = PackageReader._walk_phys_parts(phys_reader, pkg_srels) for (partname, blob, reltype, srels) in part_walker: content_type = content_types[partname] spart = _SerializedPart(partname, content_type, reltype, blob, srels) sparts.append(spart) return tuple(sparts)
'Return |_SerializedRelationships| instance populated with relationships for source identified by *source_uri*.'
@staticmethod def _srels_for(phys_reader, source_uri):
rels_xml = phys_reader.rels_xml_for(source_uri) return _SerializedRelationships.load_from_xml(source_uri.baseURI, rels_xml)
'Generate a 4-tuple `(partname, blob, reltype, srels)` for each of the parts in *phys_reader* by walking the relationship graph rooted at srels.'
@staticmethod def _walk_phys_parts(phys_reader, srels, visited_partnames=None):
if (visited_partnames is None): visited_partnames = [] for srel in srels: if srel.is_external: continue partname = srel.target_partname if (partname in visited_partnames): continue visited_partnames.append(partname) reltype = srel.reltype part_srels = PackageReader._srels_for(phys_reader, partname) blob = phys_reader.blob_for(partname) (yield (partname, blob, reltype, part_srels)) next_walker = PackageReader._walk_phys_parts(phys_reader, part_srels, visited_partnames) for (partname, blob, reltype, srels) in next_walker: (yield (partname, blob, reltype, srels))
'Return content type for part identified by *partname*.'
def __getitem__(self, partname):
if (not isinstance(partname, PackURI)): tmpl = "_ContentTypeMap key must be <type 'PackURI'>, got %s" raise KeyError((tmpl % type(partname))) if (partname in self._overrides): return self._overrides[partname] if (partname.ext in self._defaults): return self._defaults[partname.ext] tmpl = "no content type for partname '%s' in [Content_Types].xml" raise KeyError((tmpl % partname))
'Return a new |_ContentTypeMap| instance populated with the contents of *content_types_xml*.'
@staticmethod def from_xml(content_types_xml):
types_elm = parse_xml(content_types_xml) ct_map = _ContentTypeMap() for o in types_elm.overrides: ct_map._add_override(o.partname, o.content_type) for d in types_elm.defaults: ct_map._add_default(d.extension, d.content_type) return ct_map
'Add the default mapping of *extension* to *content_type* to this content type mapping.'
def _add_default(self, extension, content_type):
self._defaults[extension] = content_type
'Add the default mapping of *partname* to *content_type* to this content type mapping.'
def _add_override(self, partname, content_type):
self._overrides[partname] = content_type
'The referring relationship type of this part.'
@property def reltype(self):
return self._reltype
'True if target_mode is ``RTM.EXTERNAL``'
@property def is_external(self):
return (self._target_mode == RTM.EXTERNAL)
'Relationship type, like ``RT.OFFICE_DOCUMENT``'
@property def reltype(self):
return self._reltype
'Relationship id, like \'rId9\', corresponds to the ``Id`` attribute on the ``CT_Relationship`` element.'
@property def rId(self):
return self._rId
'String in ``TargetMode`` attribute of ``CT_Relationship`` element, one of ``RTM.INTERNAL`` or ``RTM.EXTERNAL``.'
@property def target_mode(self):
return self._target_mode
'String in ``Target`` attribute of ``CT_Relationship`` element, a relative part reference for internal target mode or an arbitrary URI, e.g. an HTTP URL, for external target mode.'
@property def target_ref(self):
return self._target_ref
'|PackURI| instance containing partname targeted by this relationship. Raises ``ValueError`` on reference if target_mode is ``\'External\'``. Use :attr:`target_mode` to check before referencing.'
@property def target_partname(self):
if self.is_external: msg = 'target_partname attribute on Relationship is undefined where TargetMode == "External"' raise ValueError(msg) if (not hasattr(self, '_target_partname')): self._target_partname = PackURI.from_rel_ref(self._baseURI, self.target_ref) return self._target_partname
'Support iteration, e.g. \'for x in srels:\''
def __iter__(self):
return self._srels.__iter__()
'Return |_SerializedRelationships| instance loaded with the relationships contained in *rels_item_xml*. Returns an empty collection if *rels_item_xml* is |None|.'
@staticmethod def load_from_xml(baseURI, rels_item_xml):
srels = _SerializedRelationships() if (rels_item_xml is not None): rels_elm = parse_xml(rels_item_xml) for rel_elm in rels_elm.Relationship_lst: srels._srels.append(_SerializedRelationship(baseURI, rel_elm)) return srels
'Return XML string for this element, suitable for testing purposes. Pretty printed for readability and without an XML declaration at the top.'
@property def xml(self):
return serialize_for_reading(self)
'String held in the ``ContentType`` attribute of this ``<Default>`` element.'
@property def content_type(self):
return self.get(u'ContentType')
'String held in the ``Extension`` attribute of this ``<Default>`` element.'
@property def extension(self):
return self.get(u'Extension')
'Return a new ``<Default>`` element with attributes set to parameter values.'
@staticmethod def new(ext, content_type):
xml = (u'<Default xmlns="%s"/>' % nsmap[u'ct']) default = parse_xml(xml) default.set(u'Extension', ext) default.set(u'ContentType', content_type) return default
'String held in the ``ContentType`` attribute of this ``<Override>`` element.'
@property def content_type(self):
return self.get(u'ContentType')
'Return a new ``<Override>`` element with attributes set to parameter values.'
@staticmethod def new(partname, content_type):
xml = (u'<Override xmlns="%s"/>' % nsmap[u'ct']) override = parse_xml(xml) override.set(u'PartName', partname) override.set(u'ContentType', content_type) return override
'String held in the ``PartName`` attribute of this ``<Override>`` element.'
@property def partname(self):
return self.get(u'PartName')
'Return a new ``<Relationship>`` element.'
@staticmethod def new(rId, reltype, target, target_mode=RTM.INTERNAL):
xml = (u'<Relationship xmlns="%s"/>' % nsmap[u'pr']) relationship = parse_xml(xml) relationship.set(u'Id', rId) relationship.set(u'Type', reltype) relationship.set(u'Target', target) if (target_mode == RTM.EXTERNAL): relationship.set(u'TargetMode', RTM.EXTERNAL) return relationship
'String held in the ``Id`` attribute of this ``<Relationship>`` element.'
@property def rId(self):
return self.get(u'Id')
'String held in the ``Type`` attribute of this ``<Relationship>`` element.'
@property def reltype(self):
return self.get(u'Type')
'String held in the ``Target`` attribute of this ``<Relationship>`` element.'
@property def target_ref(self):
return self.get(u'Target')
'String held in the ``TargetMode`` attribute of this ``<Relationship>`` element, either ``Internal`` or ``External``. Defaults to ``Internal``.'
@property def target_mode(self):
return self.get(u'TargetMode', RTM.INTERNAL)
'Add a child ``<Relationship>`` element with attributes set according to parameter values.'
def add_rel(self, rId, reltype, target, is_external=False):
target_mode = (RTM.EXTERNAL if is_external else RTM.INTERNAL) relationship = CT_Relationship.new(rId, reltype, target, target_mode) self.append(relationship)
'Return a new ``<Relationships>`` element.'
@staticmethod def new():
xml = (u'<Relationships xmlns="%s"/>' % nsmap[u'pr']) relationships = parse_xml(xml) return relationships
'Return a list containing all the ``<Relationship>`` child elements.'
@property def Relationship_lst(self):
return self.findall(qn(u'pr:Relationship'))
'Return XML string for this element, suitable for saving in a .rels stream, not pretty printed and with an XML declaration at the top.'
@property def xml(self):
return serialize_part_xml(self)
'Add a child ``<Default>`` element with attributes set to parameter values.'
def add_default(self, ext, content_type):
default = CT_Default.new(ext, content_type) self.append(default)
'Add a child ``<Override>`` element with attributes set to parameter values.'
def add_override(self, partname, content_type):
override = CT_Override.new(partname, content_type) self.append(override)
'Return a new ``<Types>`` element.'
@staticmethod def new():
xml = (u'<Types xmlns="%s"/>' % nsmap[u'ct']) types = parse_xml(xml) return types
'Return a heading paragraph newly added to the end of the document, containing *text* and having its paragraph style determined by *level*. If *level* is 0, the style is set to `Title`. If *level* is 1 (or omitted), `Heading 1` is used. Otherwise the style is set to `Heading {level}`. Raises |ValueError| if *level* is outside the range 0-9.'
def add_heading(self, text=u'', level=1):
if (not (0 <= level <= 9)): raise ValueError((u'level must be in range 0-9, got %d' % level)) style = (u'Title' if (level == 0) else (u'Heading %d' % level)) return self.add_paragraph(text, style)
'Return a paragraph newly added to the end of the document and containing only a page break.'
def add_page_break(self):
paragraph = self.add_paragraph() paragraph.add_run().add_break(WD_BREAK.PAGE) return paragraph
'Return a paragraph newly added to the end of the document, populated with *text* and having paragraph style *style*. *text* can contain tab (``\t``) characters, which are converted to the appropriate XML form for a tab. *text* can also include newline (``\n``) or carriage return (``\r``) characters, each of which is converted to a line break.'
def add_paragraph(self, text=u'', style=None):
return self._body.add_paragraph(text, style)
'Return a new picture shape added in its own paragraph at the end of the document. The picture contains the image at *image_path_or_stream*, scaled based on *width* and *height*. If neither width nor height is specified, the picture appears at its native size. If only one is specified, it is used to compute a scaling factor that is then applied to the unspecified dimension, preserving the aspect ratio of the image. The native size of the picture is calculated using the dots-per-inch (dpi) value specified in the image file, defaulting to 72 dpi if no value is specified, as is often the case.'
def add_picture(self, image_path_or_stream, width=None, height=None):
run = self.add_paragraph().add_run() return run.add_picture(image_path_or_stream, width, height)
'Return a |Section| object representing a new section added at the end of the document. The optional *start_type* argument must be a member of the :ref:`WdSectionStart` enumeration, and defaults to ``WD_SECTION.NEW_PAGE`` if not provided.'
def add_section(self, start_type=WD_SECTION.NEW_PAGE):
new_sectPr = self._element.body.add_section_break() new_sectPr.start_type = start_type return Section(new_sectPr)
'Add a table having row and column counts of *rows* and *cols* respectively and table style of *style*. *style* may be a paragraph style object or a paragraph style name. If *style* is |None|, the table inherits the default table style of the document.'
def add_table(self, rows, cols, style=None):
table = self._body.add_table(rows, cols, self._block_width) table.style = style return table
'A |CoreProperties| object providing read/write access to the core properties of this document.'
@property def core_properties(self):
return self._part.core_properties
'An |InlineShapes| object providing access to the inline shapes in this document. An inline shape is a graphical object, such as a picture, contained in a run of text and behaving like a character glyph, being flowed like other text in a paragraph.'
@property def inline_shapes(self):
return self._part.inline_shapes
'A list of |Paragraph| instances corresponding to the paragraphs in the document, in document order. Note that paragraphs within revision marks such as ``<w:ins>`` or ``<w:del>`` do not appear in this list.'
@property def paragraphs(self):
return self._body.paragraphs
'The |DocumentPart| object of this document.'
@property def part(self):
return self._part
'Save this document to *path_or_stream*, which can be either a path to a filesystem location (a string) or a file-like object.'
def save(self, path_or_stream):
self._part.save(path_or_stream)
'A |Sections| object providing access to each section in this document.'
@property def sections(self):
return Sections(self._element)
'A |Settings| object providing access to the document-level settings for this document.'
@property def settings(self):
return self._part.settings
'A |Styles| object providing access to the styles in this document.'
@property def styles(self):
return self._part.styles
'A list of |Table| instances corresponding to the tables in the document, in document order. Note that only tables appearing at the top level of the document appear in this list; a table nested inside a table cell does not appear. A table within revision marks such as ``<w:ins>`` or ``<w:del>`` will also not appear in the list.'
@property def tables(self):
return self._body.tables
'Return a |Length| object specifying the width of available "writing" space between the margins of the last section of this document.'
@property def _block_width(self):
section = self.sections[(-1)] return Emu(((section.page_width - section.left_margin) - section.right_margin))