desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'The first ``numId`` unused by a ``<w:num>`` element, starting at 1 and filling any gaps in numbering between existing ``<w:num>`` elements.'
@property def _next_numId(self):
numId_strs = self.xpath('./w:num/@w:numId') num_ids = [int(numId_str) for numId_str in numId_strs] for num in range(1, (len(num_ids) + 2)): if (num not in num_ids): break return num
'Return a new ``<cp:coreProperties>`` element'
@classmethod def new(cls):
xml = cls._coreProperties_tmpl coreProperties = parse_xml(xml) return coreProperties
'The text in the `dc:creator` child element.'
@property def author_text(self):
return self._text_of_element(u'creator')
'Integer value of revision property.'
@property def revision_number(self):
revision = self.revision if (revision is None): return 0 revision_str = revision.text try: revision = int(revision_str) except ValueError: revision = 0 if (revision < 0): revision = 0 return revision
'Set revision property to string value of integer *value*.'
@revision_number.setter def revision_number(self, value):
if ((not isinstance(value, int)) or (value < 1)): tmpl = u"revision property requires positive int, got '%s'" raise ValueError((tmpl % value)) revision = self.get_or_add_revision() revision.text = str(value)
'Return element returned by \'get_or_add_\' method for *prop_name*.'
def _get_or_add(self, prop_name):
get_or_add_method_name = (u'get_or_add_%s' % prop_name) get_or_add_method = getattr(self, get_or_add_method_name) element = get_or_add_method() return element
'Return a |datetime| instance that is offset from datetime *dt* by the timezone offset specified in *offset_str*, a string like ``\'-07:00\'``.'
@classmethod def _offset_dt(cls, dt, offset_str):
match = cls._offset_pattern.match(offset_str) if (match is None): raise ValueError((u"'%s' is not a valid offset string" % offset_str)) (sign, hours_str, minutes_str) = match.groups() sign_factor = ((-1) if (sign == u'+') else 1) hours = (int(hours_str) * sign_factor) minutes = (int(minutes_str) * sign_factor) td = timedelta(hours=hours, minutes=minutes) return (dt + td)
'Set date/time value of child element having *prop_name* to *value*.'
def _set_element_datetime(self, prop_name, value):
if (not isinstance(value, datetime)): tmpl = u"property requires <type 'datetime.datetime'> object, got %s" raise ValueError((tmpl % type(value))) element = self._get_or_add(prop_name) dt_str = value.strftime(u'%Y-%m-%dT%H:%M:%SZ') element.text = dt_str if (prop_name in (u'created', u'modified')): self.set(qn(u'xsi:foo'), u'bar') element.set(qn(u'xsi:type'), u'dcterms:W3CDTF') del self.attrib[qn(u'xsi:foo')]
'Set string value of *name* property to *value*.'
def _set_element_text(self, prop_name, value):
value = str(value) if (len(value) > 255): tmpl = u"exceeded 255 char limit for property, got:\n\n'%s'" raise ValueError((tmpl % value)) element = self._get_or_add(prop_name) element.text = value
'Return the text in the element matching *property_name*, or an empty string if the element is not present or contains no text.'
def _text_of_element(self, property_name):
element = getattr(self, property_name) if (element is None): return u'' if (element.text is None): return u'' return element.text
'The value of the ``w:bottom`` attribute in the ``<w:pgMar>`` child element, as a |Length| object, or |None| if either the element or the attribute is not present.'
@property def bottom_margin(self):
pgMar = self.pgMar if (pgMar is None): return None return pgMar.bottom
'Return an exact duplicate of this ``<w:sectPr>`` element tree suitable for use in adding a section break. All rsid* attributes are removed from the root ``<w:sectPr>`` element.'
def clone(self):
clone_sectPr = deepcopy(self) clone_sectPr.attrib.clear() return clone_sectPr
'The value of the ``w:footer`` attribute in the ``<w:pgMar>`` child element, as a |Length| object, or |None| if either the element or the attribute is not present.'
@property def footer(self):
pgMar = self.pgMar if (pgMar is None): return None return pgMar.footer
'The value of the ``w:gutter`` attribute in the ``<w:pgMar>`` child element, as a |Length| object, or |None| if either the element or the attribute is not present.'
@property def gutter(self):
pgMar = self.pgMar if (pgMar is None): return None return pgMar.gutter
'The value of the ``w:header`` attribute in the ``<w:pgMar>`` child element, as a |Length| object, or |None| if either the element or the attribute is not present.'
@property def header(self):
pgMar = self.pgMar if (pgMar is None): return None return pgMar.header
'The value of the ``w:left`` attribute in the ``<w:pgMar>`` child element, as a |Length| object, or |None| if either the element or the attribute is not present.'
@property def left_margin(self):
pgMar = self.pgMar if (pgMar is None): return None return pgMar.left
'The value of the ``w:right`` attribute in the ``<w:pgMar>`` child element, as a |Length| object, or |None| if either the element or the attribute is not present.'
@property def right_margin(self):
pgMar = self.pgMar if (pgMar is None): return None return pgMar.right
'The member of the ``WD_ORIENTATION`` enumeration corresponding to the value of the ``orient`` attribute of the ``<w:pgSz>`` child element, or ``WD_ORIENTATION.PORTRAIT`` if not present.'
@property def orientation(self):
pgSz = self.pgSz if (pgSz is None): return WD_ORIENTATION.PORTRAIT return pgSz.orient
'Value in EMU of the ``h`` attribute of the ``<w:pgSz>`` child element, or |None| if not present.'
@property def page_height(self):
pgSz = self.pgSz if (pgSz is None): return None return pgSz.h
'Value in EMU of the ``w`` attribute of the ``<w:pgSz>`` child element, or |None| if not present.'
@property def page_width(self):
pgSz = self.pgSz if (pgSz is None): return None return pgSz.w
'The member of the ``WD_SECTION_START`` enumeration corresponding to the value of the ``val`` attribute of the ``<w:type>`` child element, or ``WD_SECTION_START.NEW_PAGE`` if not present.'
@property def start_type(self):
type = self.type if ((type is None) or (type.val is None)): return WD_SECTION_START.NEW_PAGE return type.val
'The value of the ``w:top`` attribute in the ``<w:pgMar>`` child element, as a |Length| object, or |None| if either the element or the attribute is not present.'
@property def top_margin(self):
pgMar = self.pgMar if (pgMar is None): return None return pgMar.top
'Return a new ``CT_DecimalNumber`` element having tagname *nsptagname* and ``val`` attribute set to *val*.'
@classmethod def new(cls, nsptagname, val):
return OxmlElement(nsptagname, attrs={qn('w:val'): str(val)})
'Return a new ``CT_String`` element with tagname *nsptagname* and ``val`` attribute set to *val*.'
@classmethod def new(cls, nsptagname, val):
elm = OxmlElement(nsptagname) elm.val = val return elm
'Return the boolean value of the attribute having *attr_name*, or |False| if not present.'
def bool_prop(self, attr_name):
value = getattr(self, attr_name) if (value is None): return False return value
'Return the `w:lsdException` child having *name*, or |None| if not found.'
def get_by_name(self, name):
found = self.xpath(('w:lsdException[@w:name="%s"]' % name)) if (not found): return None return found[0]
'Set the on/off attribute having *attr_name* to *value*.'
def set_bool_prop(self, attr_name, value):
setattr(self, attr_name, bool(value))
'Remove this `w:lsdException` element from the XML document.'
def delete(self):
self.getparent().remove(self)
'Return the boolean value of the attribute having *attr_name*, or |None| if not present.'
def on_off_prop(self, attr_name):
return getattr(self, attr_name)
'Set the on/off attribute having *attr_name* to *value*.'
def set_on_off_prop(self, attr_name, value):
setattr(self, attr_name, value)
'Value of `w:basedOn/@w:val` or |None| if not present.'
@property def basedOn_val(self):
basedOn = self.basedOn if (basedOn is None): return None return basedOn.val
'Sibling CT_Style element this style is based on or |None| if no base style or base style not found.'
@property def base_style(self):
basedOn = self.basedOn if (basedOn is None): return None styles = self.getparent() base_style = styles.get_by_id(basedOn.val) if (base_style is None): return None return base_style
'Remove this `w:style` element from its parent `w:styles` element.'
def delete(self):
self.getparent().remove(self)
'Value of `w:locked/@w:val` or |False| if not present.'
@property def locked_val(self):
locked = self.locked if (locked is None): return False return locked.val
'Value of ``<w:name>`` child or |None| if not present.'
@property def name_val(self):
name = self.name if (name is None): return None return name.val
'Sibling CT_Style element identified by the value of `w:name/@w:val` or |None| if no value is present or no style with that style id is found.'
@property def next_style(self):
next = self.next if (next is None): return None styles = self.getparent() return styles.get_by_id(next.val)
'Value of `w:qFormat/@w:val` or |False| if not present.'
@property def qFormat_val(self):
qFormat = self.qFormat if (qFormat is None): return False return qFormat.val
'Value of ``<w:semiHidden>`` child or |False| if not present.'
@property def semiHidden_val(self):
semiHidden = self.semiHidden if (semiHidden is None): return False return semiHidden.val
'Value of ``<w:uiPriority>`` child or |None| if not present.'
@property def uiPriority_val(self):
uiPriority = self.uiPriority if (uiPriority is None): return None return uiPriority.val
'Value of `w:unhideWhenUsed/@w:val` or |False| if not present.'
@property def unhideWhenUsed_val(self):
unhideWhenUsed = self.unhideWhenUsed if (unhideWhenUsed is None): return False return unhideWhenUsed.val
'Return a newly added `w:style` element having *name* and *style_type*. `w:style/@customStyle` is set based on the value of *builtin*.'
def add_style_of_type(self, name, style_type, builtin):
style = self.add_style() style.type = style_type style.customStyle = (None if builtin else True) style.styleId = styleId_from_name(name) style.name_val = name return style
'Return `w:style[@w:type="*{style_type}*][-1]` or |None| if not found.'
def default_for(self, style_type):
default_styles_for_type = [s for s in self._iter_styles() if ((s.type == style_type) and s.default)] if (not default_styles_for_type): return None return default_styles_for_type[(-1)]
'Return the ``<w:style>`` child element having ``styleId`` attribute matching *styleId*, or |None| if not found.'
def get_by_id(self, styleId):
xpath = ('w:style[@w:styleId="%s"]' % styleId) try: return self.xpath(xpath)[0] except IndexError: return None
'Return the ``<w:style>`` child element having ``<w:name>`` child element with value *name*, or |None| if not found.'
def get_by_name(self, name):
xpath = ('w:style[w:name/@w:val="%s"]' % name) try: return self.xpath(xpath)[0] except IndexError: return None
'Generate each of the `w:style` child elements in document order.'
def _iter_styles(self):
return (style for style in self.xpath('w:style'))
'Return a sequence of attribute strings parsed from *attrs*. Each attribute string is stripped of whitespace on both ends.'
def _attr_seq(self, attrs):
attrs = attrs.strip() attr_lst = attrs.split() return sorted(attr_lst)
'Return True if the element in *line_2* is XML equivalent to the element in *line*.'
def _eq_elm_strs(self, line, line_2):
(front, attrs, close, text) = self._parse_line(line) (front_2, attrs_2, close_2, text_2) = self._parse_line(line_2) if (front != front_2): return False if (self._attr_seq(attrs) != self._attr_seq(attrs_2)): return False if (close != close_2): return False if (text != text_2): return False return True
'Return front, attrs, close, text 4-tuple result of parsing XML element string *line*.'
@classmethod def _parse_line(cls, line):
match = cls._xml_elm_line_patt.match(line) (front, attrs, close, text) = [match.group(n) for n in range(1, 5)] return (front, attrs, close, text)
'Add the appropriate methods to *element_cls*.'
def populate_class_members(self, element_cls, prop_name):
self._element_cls = element_cls self._prop_name = prop_name self._add_attr_property()
'Add a read/write ``{prop_name}`` property to the element class that returns the interpreted value of this attribute on access and changes the attribute value to its ST_* counterpart on assignment.'
def _add_attr_property(self):
property_ = property(self._getter, self._setter, None) setattr(self._element_cls, self._prop_name, property_)
'Return a function object suitable for the "get" side of the attribute property descriptor.'
@property def _getter(self):
def get_attr_value(obj): attr_str_value = obj.get(self._clark_name) if (attr_str_value is None): return self._default return self._simple_type.from_xml(attr_str_value) get_attr_value.__doc__ = self._docstring return get_attr_value
'Return the string to use as the ``__doc__`` attribute of the property for this attribute.'
@property def _docstring(self):
return ('%s type-converted value of ``%s`` attribute, or |None| (or specified default value) if not present. Assigning the default value causes the attribute to be removed from the element.' % (self._simple_type.__name__, self._attr_name))
'Return a function object suitable for the "set" side of the attribute property descriptor.'
@property def _setter(self):
def set_attr_value(obj, value): if ((value is None) or (value == self._default)): if (self._clark_name in obj.attrib): del obj.attrib[self._clark_name] return str_value = self._simple_type.to_xml(value) obj.set(self._clark_name, str_value) return set_attr_value
'Return a function object suitable for the "get" side of the attribute property descriptor.'
@property def _getter(self):
def get_attr_value(obj): attr_str_value = obj.get(self._clark_name) if (attr_str_value is None): raise InvalidXmlError(("required '%s' attribute not present on element %s" % (self._attr_name, obj.tag))) return self._simple_type.from_xml(attr_str_value) get_attr_value.__doc__ = self._docstring return get_attr_value
'Return the string to use as the ``__doc__`` attribute of the property for this attribute.'
@property def _docstring(self):
return ('%s type-converted value of ``%s`` attribute.' % (self._simple_type.__name__, self._attr_name))
'Return a function object suitable for the "set" side of the attribute property descriptor.'
@property def _setter(self):
def set_attr_value(obj, value): str_value = self._simple_type.to_xml(value) obj.set(self._clark_name, str_value) return set_attr_value
'Baseline behavior for adding the appropriate methods to *element_cls*.'
def populate_class_members(self, element_cls, prop_name):
self._element_cls = element_cls self._prop_name = prop_name
'Add an ``_add_x()`` method to the element class for this child element.'
def _add_adder(self):
def _add_child(obj, **attrs): new_method = getattr(obj, self._new_method_name) child = new_method() for (key, value) in attrs.items(): setattr(child, key, value) insert_method = getattr(obj, self._insert_method_name) insert_method(child) return child _add_child.__doc__ = ('Add a new ``<%s>`` child element unconditionally, inserted in the correct sequence.' % self._nsptagname) self._add_to_class(self._add_method_name, _add_child)
'Add a ``_new_{prop_name}()`` method to the element class that creates a new, empty element of the correct type, having no attributes.'
def _add_creator(self):
creator = self._creator creator.__doc__ = ('Return a "loose", newly created ``<%s>`` element having no attributes, text, or children.' % self._nsptagname) self._add_to_class(self._new_method_name, creator)
'Add a read-only ``{prop_name}`` property to the element class for this child element.'
def _add_getter(self):
property_ = property(self._getter, None, None) setattr(self._element_cls, self._prop_name, property_)
'Add an ``_insert_x()`` method to the element class for this child element.'
def _add_inserter(self):
def _insert_child(obj, child): obj.insert_element_before(child, *self._successors) return child _insert_child.__doc__ = ('Return the passed ``<%s>`` element after inserting it as a child in the correct sequence.' % self._nsptagname) self._add_to_class(self._insert_method_name, _insert_child)
'Add a read-only ``{prop_name}_lst`` property to the element class to retrieve a list of child elements matching this type.'
def _add_list_getter(self):
prop_name = ('%s_lst' % self._prop_name) property_ = property(self._list_getter, None, None) setattr(self._element_cls, prop_name, property_)
'Add a public ``add_x()`` method to the parent element class.'
def _add_public_adder(self):
def add_child(obj): private_add_method = getattr(obj, self._add_method_name) child = private_add_method() return child add_child.__doc__ = ('Add a new ``<%s>`` child element unconditionally, inserted in the correct sequence.' % self._nsptagname) self._add_to_class(self._public_add_method_name, add_child)
'Add *method* to the target class as *name*, unless *name* is already defined on the class.'
def _add_to_class(self, name, method):
if hasattr(self._element_cls, name): return setattr(self._element_cls, name, method)
'Return a function object that creates a new, empty element of the right type, having no attributes.'
@property def _creator(self):
def new_child_element(obj): return OxmlElement(self._nsptagname) return new_child_element
'Return a function object suitable for the "get" side of the property descriptor. This default getter returns the child element with matching tag name or |None| if not present.'
@property def _getter(self):
def get_child_element(obj): return obj.find(qn(self._nsptagname)) get_child_element.__doc__ = ('``<%s>`` child element or |None| if not present.' % self._nsptagname) return get_child_element
'Return a function object suitable for the "get" side of a list property descriptor.'
@property def _list_getter(self):
def get_child_element_list(obj): return obj.findall(qn(self._nsptagname)) get_child_element_list.__doc__ = ('A list containing each of the ``<%s>`` child elements, in the order they appear.' % self._nsptagname) return get_child_element_list
'add_childElement() is public API for a repeating element, allowing new elements to be added to the sequence. May be overridden to provide a friendlier API to clients having domain appropriate parameter names for required attributes.'
@lazyproperty def _public_add_method_name(self):
return ('add_%s' % self._prop_name)
'Add the appropriate methods to *element_cls*.'
def populate_class_members(self, element_cls, group_prop_name, successors):
self._element_cls = element_cls self._group_prop_name = group_prop_name self._successors = successors self._add_getter() self._add_creator() self._add_inserter() self._add_adder() self._add_get_or_change_to_method()
'Add a ``get_or_change_to_x()`` method to the element class for this child element.'
def _add_get_or_change_to_method(self):
def get_or_change_to_child(obj): child = getattr(obj, self._prop_name) if (child is not None): return child remove_group_method = getattr(obj, self._remove_group_method_name) remove_group_method() add_method = getattr(obj, self._add_method_name) child = add_method() return child get_or_change_to_child.__doc__ = ('Return the ``<%s>`` child, replacing any other group element if found.' % self._nsptagname) self._add_to_class(self._get_or_change_to_method_name, get_or_change_to_child)
'Calculate property name from tag name, e.g. a:schemeClr -> schemeClr.'
@property def _prop_name(self):
if (':' in self._nsptagname): start = (self._nsptagname.index(':') + 1) else: start = 0 return self._nsptagname[start:]
'Add the appropriate methods to *element_cls*.'
def populate_class_members(self, element_cls, prop_name):
super(OneAndOnlyOne, self).populate_class_members(element_cls, prop_name) self._add_getter()
'Return a function object suitable for the "get" side of the property descriptor.'
@property def _getter(self):
def get_child_element(obj): child = obj.find(qn(self._nsptagname)) if (child is None): raise InvalidXmlError(('required ``<%s>`` child element not present' % self._nsptagname)) return child get_child_element.__doc__ = ('Required ``<%s>`` child element.' % self._nsptagname) return get_child_element
'Add the appropriate methods to *element_cls*.'
def populate_class_members(self, element_cls, prop_name):
super(OneOrMore, self).populate_class_members(element_cls, prop_name) self._add_list_getter() self._add_creator() self._add_inserter() self._add_adder() self._add_public_adder() delattr(element_cls, prop_name)
'Add the appropriate methods to *element_cls*.'
def populate_class_members(self, element_cls, prop_name):
super(ZeroOrMore, self).populate_class_members(element_cls, prop_name) self._add_list_getter() self._add_creator() self._add_inserter() self._add_adder() self._add_public_adder() delattr(element_cls, prop_name)
'Add the appropriate methods to *element_cls*.'
def populate_class_members(self, element_cls, prop_name):
super(ZeroOrOne, self).populate_class_members(element_cls, prop_name) self._add_getter() self._add_creator() self._add_inserter() self._add_adder() self._add_get_or_adder() self._add_remover()
'Add a ``get_or_add_x()`` method to the element class for this child element.'
def _add_get_or_adder(self):
def get_or_add_child(obj): child = getattr(obj, self._prop_name) if (child is None): add_method = getattr(obj, self._add_method_name) child = add_method() return child get_or_add_child.__doc__ = ('Return the ``<%s>`` child element, newly added if not present.' % self._nsptagname) self._add_to_class(self._get_or_add_method_name, get_or_add_child)
'Add a ``_remove_x()`` method to the element class for this child element.'
def _add_remover(self):
def _remove_child(obj): obj.remove_all(self._nsptagname) _remove_child.__doc__ = ('Remove all ``<%s>`` child elements.' % self._nsptagname) self._add_to_class(self._remove_method_name, _remove_child)
'Add the appropriate methods to *element_cls*.'
def populate_class_members(self, element_cls, prop_name):
super(ZeroOrOneChoice, self).populate_class_members(element_cls, prop_name) self._add_choice_getter() for choice in self._choices: choice.populate_class_members(element_cls, self._prop_name, self._successors) self._add_group_remover()
'Add a read-only ``{prop_name}`` property to the element class that returns the present member of this group, or |None| if none are present.'
def _add_choice_getter(self):
property_ = property(self._choice_getter, None, None) setattr(self._element_cls, self._prop_name, property_)
'Add a ``_remove_eg_x()`` method to the element class for this choice group.'
def _add_group_remover(self):
def _remove_choice_group(obj): for tagname in self._member_nsptagnames: obj.remove_all(tagname) _remove_choice_group.__doc__ = 'Remove the current choice group child element if present.' self._add_to_class(self._remove_choice_group_method_name, _remove_choice_group)
'Return a function object suitable for the "get" side of the property descriptor.'
@property def _choice_getter(self):
def get_group_member_element(obj): return obj.first_child_found_in(*self._member_nsptagnames) get_group_member_element.__doc__ = 'Return the child element belonging to this element group, or |None| if no member child is present.' return get_group_member_element
'Sequence of namespace-prefixed tagnames, one for each of the member elements of this choice group.'
@lazyproperty def _member_nsptagnames(self):
return [choice.nsptagname for choice in self._choices]
'Return the first child found with tag in *tagnames*, or None if not found.'
def first_child_found_in(self, *tagnames):
for tagname in tagnames: child = self.find(qn(tagname)) if (child is not None): return child return None
'Remove all child elements whose tagname (e.g. \'a:p\') appears in *tagnames*.'
def remove_all(self, *tagnames):
for tagname in tagnames: matching = self.findall(qn(tagname)) for child in matching: self.remove(child)
'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)
'Override of ``lxml`` _Element.xpath() method to provide standard Open XML namespace mapping (``nsmap``) in centralized location.'
def xpath(self, xpath_str):
return super(BaseOxmlElement, self).xpath(xpath_str, namespaces=nsmap)
'Return a new ``<w:p>`` element inserted directly prior to this one.'
def add_p_before(self):
new_p = OxmlElement('w:p') self.addprevious(new_p) return new_p
'The value of the ``<w:jc>`` grandchild element or |None| if not present.'
@property def alignment(self):
pPr = self.pPr if (pPr is None): return None return pPr.jc_val
'Remove all child elements, except the ``<w:pPr>`` element if present.'
def clear_content(self):
for child in self[:]: if (child.tag == qn('w:pPr')): continue self.remove(child)
'Unconditionally replace or add *sectPr* as a grandchild in the correct sequence.'
def set_sectPr(self, sectPr):
pPr = self.get_or_add_pPr() pPr._remove_sectPr() pPr._insert_sectPr(sectPr)
'String contained in w:val attribute of ./w:pPr/w:pStyle grandchild, or |None| if not present.'
@property def style(self):
pPr = self.pPr if (pPr is None): return None return pPr.style
'Override metaclass method to set `w:color/@val` to RGB black on create.'
def _new_color(self):
return parse_xml(('<w:color %s w:val="000000"/>' % nsdecls('w')))
'Value of `w:highlight/@val` attribute, specifying a font\'s highlight color, or `None` if the text is not highlighted.'
@property def highlight_val(self):
highlight = self.highlight if (highlight is None): return None return highlight.val
'The value of `w:rFonts/@w:ascii` or |None| if not present. Represents the assigned typeface name. The rFonts element also specifies other special-case typeface names; this method handles the case where just the common name is required.'
@property def rFonts_ascii(self):
rFonts = self.rFonts if (rFonts is None): return None return rFonts.ascii
'The value of `w:rFonts/@w:hAnsi` or |None| if not present.'
@property def rFonts_hAnsi(self):
rFonts = self.rFonts if (rFonts is None): return None return rFonts.hAnsi
'String contained in <w:rStyle> child, or None if that element is not present.'
@property def style(self):
rStyle = self.rStyle if (rStyle is None): return None return rStyle.val
'Set val attribute of <w:rStyle> child element to *style*, adding a new element if necessary. If *style* is |None|, remove the <w:rStyle> element if present.'
@style.setter def style(self, style):
if (style is None): self._remove_rStyle() elif (self.rStyle is None): self._add_rStyle(val=style) else: self.rStyle.val = style
'|True| if `w:vertAlign/@w:val` is \'subscript\'. |False| if `w:vertAlign/@w:val` contains any other value. |None| if `w:vertAlign` is not present.'
@property def subscript(self):
vertAlign = self.vertAlign if (vertAlign is None): return None if (vertAlign.val == ST_VerticalAlignRun.SUBSCRIPT): return True return False
'|True| if `w:vertAlign/@w:val` is \'superscript\'. |False| if `w:vertAlign/@w:val` contains any other value. |None| if `w:vertAlign` is not present.'
@property def superscript(self):
vertAlign = self.vertAlign if (vertAlign is None): return None if (vertAlign.val == ST_VerticalAlignRun.SUPERSCRIPT): return True return False