partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | XmlMappedEnumMember.add_to_enum | Compile XML mappings in addition to base add behavior. | docx/enum/base.py | def add_to_enum(self, clsdict):
"""
Compile XML mappings in addition to base add behavior.
"""
super(XmlMappedEnumMember, self).add_to_enum(clsdict)
self.register_xml_mapping(clsdict) | def add_to_enum(self, clsdict):
"""
Compile XML mappings in addition to base add behavior.
"""
super(XmlMappedEnumMember, self).add_to_enum(clsdict)
self.register_xml_mapping(clsdict) | [
"Compile",
"XML",
"mappings",
"in",
"addition",
"to",
"base",
"add",
"behavior",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/enum/base.py#L324-L329 | [
"def",
"add_to_enum",
"(",
"self",
",",
"clsdict",
")",
":",
"super",
"(",
"XmlMappedEnumMember",
",",
"self",
")",
".",
"add_to_enum",
"(",
"clsdict",
")",
"self",
".",
"register_xml_mapping",
"(",
"clsdict",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | XmlMappedEnumMember.register_xml_mapping | Add XML mappings to the enumeration class state for this member. | docx/enum/base.py | def register_xml_mapping(self, clsdict):
"""
Add XML mappings to the enumeration class state for this member.
"""
member_to_xml = self._get_or_add_member_to_xml(clsdict)
member_to_xml[self.value] = self.xml_value
xml_to_member = self._get_or_add_xml_to_member(clsdict)
... | def register_xml_mapping(self, clsdict):
"""
Add XML mappings to the enumeration class state for this member.
"""
member_to_xml = self._get_or_add_member_to_xml(clsdict)
member_to_xml[self.value] = self.xml_value
xml_to_member = self._get_or_add_xml_to_member(clsdict)
... | [
"Add",
"XML",
"mappings",
"to",
"the",
"enumeration",
"class",
"state",
"for",
"this",
"member",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/enum/base.py#L331-L338 | [
"def",
"register_xml_mapping",
"(",
"self",
",",
"clsdict",
")",
":",
"member_to_xml",
"=",
"self",
".",
"_get_or_add_member_to_xml",
"(",
"clsdict",
")",
"member_to_xml",
"[",
"self",
".",
"value",
"]",
"=",
"self",
".",
"xml_value",
"xml_to_member",
"=",
"se... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Document | Return a |Document| object loaded from *docx*, where *docx* can be
either a path to a ``.docx`` file (a string) or a file-like object. If
*docx* is missing or ``None``, the built-in default document "template"
is loaded. | docx/api.py | def Document(docx=None):
"""
Return a |Document| object loaded from *docx*, where *docx* can be
either a path to a ``.docx`` file (a string) or a file-like object. If
*docx* is missing or ``None``, the built-in default document "template"
is loaded.
"""
docx = _default_docx_path() if docx is... | def Document(docx=None):
"""
Return a |Document| object loaded from *docx*, where *docx* can be
either a path to a ``.docx`` file (a string) or a file-like object. If
*docx* is missing or ``None``, the built-in default document "template"
is loaded.
"""
docx = _default_docx_path() if docx is... | [
"Return",
"a",
"|Document|",
"object",
"loaded",
"from",
"*",
"docx",
"*",
"where",
"*",
"docx",
"*",
"can",
"be",
"either",
"a",
"path",
"to",
"a",
".",
"docx",
"file",
"(",
"a",
"string",
")",
"or",
"a",
"file",
"-",
"like",
"object",
".",
"If",
... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/api.py#L17-L29 | [
"def",
"Document",
"(",
"docx",
"=",
"None",
")",
":",
"docx",
"=",
"_default_docx_path",
"(",
")",
"if",
"docx",
"is",
"None",
"else",
"docx",
"document_part",
"=",
"Package",
".",
"open",
"(",
"docx",
")",
".",
"main_document_part",
"if",
"document_part"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _default_docx_path | Return the path to the built-in default .docx package. | docx/api.py | def _default_docx_path():
"""
Return the path to the built-in default .docx package.
"""
_thisdir = os.path.split(__file__)[0]
return os.path.join(_thisdir, 'templates', 'default-docx-template') | def _default_docx_path():
"""
Return the path to the built-in default .docx package.
"""
_thisdir = os.path.split(__file__)[0]
return os.path.join(_thisdir, 'templates', 'default-docx-template') | [
"Return",
"the",
"path",
"to",
"the",
"built",
"-",
"in",
"default",
".",
"docx",
"package",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/api.py#L32-L37 | [
"def",
"_default_docx_path",
"(",
")",
":",
"_thisdir",
"=",
"os",
".",
"path",
".",
"split",
"(",
"__file__",
")",
"[",
"0",
"]",
"return",
"os",
".",
"path",
".",
"join",
"(",
"_thisdir",
",",
"'templates'",
",",
"'default-docx-template'",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | ParagraphFormat.line_spacing | |float| or |Length| value specifying the space between baselines in
successive lines of the paragraph. A value of |None| indicates line
spacing is inherited from the style hierarchy. A float value, e.g.
``2.0`` or ``1.75``, indicates spacing is applied in multiples of
line heights. A |Le... | docx/text/parfmt.py | def line_spacing(self):
"""
|float| or |Length| value specifying the space between baselines in
successive lines of the paragraph. A value of |None| indicates line
spacing is inherited from the style hierarchy. A float value, e.g.
``2.0`` or ``1.75``, indicates spacing is applied... | def line_spacing(self):
"""
|float| or |Length| value specifying the space between baselines in
successive lines of the paragraph. A value of |None| indicates line
spacing is inherited from the style hierarchy. A float value, e.g.
``2.0`` or ``1.75``, indicates spacing is applied... | [
"|float|",
"or",
"|Length|",
"value",
"specifying",
"the",
"space",
"between",
"baselines",
"in",
"successive",
"lines",
"of",
"the",
"paragraph",
".",
"A",
"value",
"of",
"|None|",
"indicates",
"line",
"spacing",
"is",
"inherited",
"from",
"the",
"style",
"hi... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/text/parfmt.py#L114-L128 | [
"def",
"line_spacing",
"(",
"self",
")",
":",
"pPr",
"=",
"self",
".",
"_element",
".",
"pPr",
"if",
"pPr",
"is",
"None",
":",
"return",
"None",
"return",
"self",
".",
"_line_spacing",
"(",
"pPr",
".",
"spacing_line",
",",
"pPr",
".",
"spacing_lineRule",... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | ParagraphFormat.line_spacing_rule | A member of the :ref:`WdLineSpacing` enumeration indicating how the
value of :attr:`line_spacing` should be interpreted. Assigning any of
the :ref:`WdLineSpacing` members :attr:`SINGLE`, :attr:`DOUBLE`, or
:attr:`ONE_POINT_FIVE` will cause the value of :attr:`line_spacing`
to be updated ... | docx/text/parfmt.py | def line_spacing_rule(self):
"""
A member of the :ref:`WdLineSpacing` enumeration indicating how the
value of :attr:`line_spacing` should be interpreted. Assigning any of
the :ref:`WdLineSpacing` members :attr:`SINGLE`, :attr:`DOUBLE`, or
:attr:`ONE_POINT_FIVE` will cause the val... | def line_spacing_rule(self):
"""
A member of the :ref:`WdLineSpacing` enumeration indicating how the
value of :attr:`line_spacing` should be interpreted. Assigning any of
the :ref:`WdLineSpacing` members :attr:`SINGLE`, :attr:`DOUBLE`, or
:attr:`ONE_POINT_FIVE` will cause the val... | [
"A",
"member",
"of",
"the",
":",
"ref",
":",
"WdLineSpacing",
"enumeration",
"indicating",
"how",
"the",
"value",
"of",
":",
"attr",
":",
"line_spacing",
"should",
"be",
"interpreted",
".",
"Assigning",
"any",
"of",
"the",
":",
"ref",
":",
"WdLineSpacing",
... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/text/parfmt.py#L145-L158 | [
"def",
"line_spacing_rule",
"(",
"self",
")",
":",
"pPr",
"=",
"self",
".",
"_element",
".",
"pPr",
"if",
"pPr",
"is",
"None",
":",
"return",
"None",
"return",
"self",
".",
"_line_spacing_rule",
"(",
"pPr",
".",
"spacing_line",
",",
"pPr",
".",
"spacing_... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | ParagraphFormat._line_spacing | Return the line spacing value calculated from the combination of
*spacing_line* and *spacing_lineRule*. Returns a |float| number of
lines when *spacing_lineRule* is ``WD_LINE_SPACING.MULTIPLE``,
otherwise a |Length| object of absolute line height is returned.
Returns |None| when *spacing... | docx/text/parfmt.py | def _line_spacing(spacing_line, spacing_lineRule):
"""
Return the line spacing value calculated from the combination of
*spacing_line* and *spacing_lineRule*. Returns a |float| number of
lines when *spacing_lineRule* is ``WD_LINE_SPACING.MULTIPLE``,
otherwise a |Length| object of... | def _line_spacing(spacing_line, spacing_lineRule):
"""
Return the line spacing value calculated from the combination of
*spacing_line* and *spacing_lineRule*. Returns a |float| number of
lines when *spacing_lineRule* is ``WD_LINE_SPACING.MULTIPLE``,
otherwise a |Length| object of... | [
"Return",
"the",
"line",
"spacing",
"value",
"calculated",
"from",
"the",
"combination",
"of",
"*",
"spacing_line",
"*",
"and",
"*",
"spacing_lineRule",
"*",
".",
"Returns",
"a",
"|float|",
"number",
"of",
"lines",
"when",
"*",
"spacing_lineRule",
"*",
"is",
... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/text/parfmt.py#L274-L286 | [
"def",
"_line_spacing",
"(",
"spacing_line",
",",
"spacing_lineRule",
")",
":",
"if",
"spacing_line",
"is",
"None",
":",
"return",
"None",
"if",
"spacing_lineRule",
"==",
"WD_LINE_SPACING",
".",
"MULTIPLE",
":",
"return",
"spacing_line",
"/",
"Pt",
"(",
"12",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | ParagraphFormat._line_spacing_rule | Return the line spacing rule value calculated from the combination of
*line* and *lineRule*. Returns special members of the
:ref:`WdLineSpacing` enumeration when line spacing is single, double,
or 1.5 lines. | docx/text/parfmt.py | def _line_spacing_rule(line, lineRule):
"""
Return the line spacing rule value calculated from the combination of
*line* and *lineRule*. Returns special members of the
:ref:`WdLineSpacing` enumeration when line spacing is single, double,
or 1.5 lines.
"""
if lineR... | def _line_spacing_rule(line, lineRule):
"""
Return the line spacing rule value calculated from the combination of
*line* and *lineRule*. Returns special members of the
:ref:`WdLineSpacing` enumeration when line spacing is single, double,
or 1.5 lines.
"""
if lineR... | [
"Return",
"the",
"line",
"spacing",
"rule",
"value",
"calculated",
"from",
"the",
"combination",
"of",
"*",
"line",
"*",
"and",
"*",
"lineRule",
"*",
".",
"Returns",
"special",
"members",
"of",
"the",
":",
"ref",
":",
"WdLineSpacing",
"enumeration",
"when",
... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/text/parfmt.py#L289-L303 | [
"def",
"_line_spacing_rule",
"(",
"line",
",",
"lineRule",
")",
":",
"if",
"lineRule",
"==",
"WD_LINE_SPACING",
".",
"MULTIPLE",
":",
"if",
"line",
"==",
"Twips",
"(",
"240",
")",
":",
"return",
"WD_LINE_SPACING",
".",
"SINGLE",
"if",
"line",
"==",
"Twips"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_Num.new | Return a new ``<w:num>`` element having numId of *num_id* and having
a ``<w:abstractNumId>`` child with val attribute set to
*abstractNum_id*. | docx/oxml/numbering.py | def new(cls, num_id, abstractNum_id):
"""
Return a new ``<w:num>`` element having numId of *num_id* and having
a ``<w:abstractNumId>`` child with val attribute set to
*abstractNum_id*.
"""
num = OxmlElement('w:num')
num.numId = num_id
abstractNumId = CT_De... | def new(cls, num_id, abstractNum_id):
"""
Return a new ``<w:num>`` element having numId of *num_id* and having
a ``<w:abstractNumId>`` child with val attribute set to
*abstractNum_id*.
"""
num = OxmlElement('w:num')
num.numId = num_id
abstractNumId = CT_De... | [
"Return",
"a",
"new",
"<w",
":",
"num",
">",
"element",
"having",
"numId",
"of",
"*",
"num_id",
"*",
"and",
"having",
"a",
"<w",
":",
"abstractNumId",
">",
"child",
"with",
"val",
"attribute",
"set",
"to",
"*",
"abstractNum_id",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/numbering.py#L33-L45 | [
"def",
"new",
"(",
"cls",
",",
"num_id",
",",
"abstractNum_id",
")",
":",
"num",
"=",
"OxmlElement",
"(",
"'w:num'",
")",
"num",
".",
"numId",
"=",
"num_id",
"abstractNumId",
"=",
"CT_DecimalNumber",
".",
"new",
"(",
"'w:abstractNumId'",
",",
"abstractNum_id... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_Numbering.add_num | Return a newly added CT_Num (<w:num>) element referencing the
abstract numbering definition identified by *abstractNum_id*. | docx/oxml/numbering.py | def add_num(self, abstractNum_id):
"""
Return a newly added CT_Num (<w:num>) element referencing the
abstract numbering definition identified by *abstractNum_id*.
"""
next_num_id = self._next_numId
num = CT_Num.new(next_num_id, abstractNum_id)
return self._insert_... | def add_num(self, abstractNum_id):
"""
Return a newly added CT_Num (<w:num>) element referencing the
abstract numbering definition identified by *abstractNum_id*.
"""
next_num_id = self._next_numId
num = CT_Num.new(next_num_id, abstractNum_id)
return self._insert_... | [
"Return",
"a",
"newly",
"added",
"CT_Num",
"(",
"<w",
":",
"num",
">",
")",
"element",
"referencing",
"the",
"abstract",
"numbering",
"definition",
"identified",
"by",
"*",
"abstractNum_id",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/numbering.py#L99-L106 | [
"def",
"add_num",
"(",
"self",
",",
"abstractNum_id",
")",
":",
"next_num_id",
"=",
"self",
".",
"_next_numId",
"num",
"=",
"CT_Num",
".",
"new",
"(",
"next_num_id",
",",
"abstractNum_id",
")",
"return",
"self",
".",
"_insert_num",
"(",
"num",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_Numbering.num_having_numId | Return the ``<w:num>`` child element having ``numId`` attribute
matching *numId*. | docx/oxml/numbering.py | def num_having_numId(self, numId):
"""
Return the ``<w:num>`` child element having ``numId`` attribute
matching *numId*.
"""
xpath = './w:num[@w:numId="%d"]' % numId
try:
return self.xpath(xpath)[0]
except IndexError:
raise KeyError('no <w:... | def num_having_numId(self, numId):
"""
Return the ``<w:num>`` child element having ``numId`` attribute
matching *numId*.
"""
xpath = './w:num[@w:numId="%d"]' % numId
try:
return self.xpath(xpath)[0]
except IndexError:
raise KeyError('no <w:... | [
"Return",
"the",
"<w",
":",
"num",
">",
"child",
"element",
"having",
"numId",
"attribute",
"matching",
"*",
"numId",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/numbering.py#L108-L117 | [
"def",
"num_having_numId",
"(",
"self",
",",
"numId",
")",
":",
"xpath",
"=",
"'./w:num[@w:numId=\"%d\"]'",
"%",
"numId",
"try",
":",
"return",
"self",
".",
"xpath",
"(",
"xpath",
")",
"[",
"0",
"]",
"except",
"IndexError",
":",
"raise",
"KeyError",
"(",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_Numbering._next_numId | The first ``numId`` unused by a ``<w:num>`` element, starting at
1 and filling any gaps in numbering between existing ``<w:num>``
elements. | docx/oxml/numbering.py | def _next_numId(self):
"""
The first ``numId`` unused by a ``<w:num>`` element, starting at
1 and filling any gaps in numbering between existing ``<w:num>``
elements.
"""
numId_strs = self.xpath('./w:num/@w:numId')
num_ids = [int(numId_str) for numId_str in numId_... | def _next_numId(self):
"""
The first ``numId`` unused by a ``<w:num>`` element, starting at
1 and filling any gaps in numbering between existing ``<w:num>``
elements.
"""
numId_strs = self.xpath('./w:num/@w:numId')
num_ids = [int(numId_str) for numId_str in numId_... | [
"The",
"first",
"numId",
"unused",
"by",
"a",
"<w",
":",
"num",
">",
"element",
"starting",
"at",
"1",
"and",
"filling",
"any",
"gaps",
"in",
"numbering",
"between",
"existing",
"<w",
":",
"num",
">",
"elements",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/numbering.py#L120-L131 | [
"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",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Relationships.add_relationship | Return a newly added |_Relationship| instance. | docx/opc/rel.py | def add_relationship(self, reltype, target, rId, is_external=False):
"""
Return a newly added |_Relationship| instance.
"""
rel = _Relationship(rId, reltype, target, self._baseURI, is_external)
self[rId] = rel
if not is_external:
self._target_parts_by_rId[rId]... | def add_relationship(self, reltype, target, rId, is_external=False):
"""
Return a newly added |_Relationship| instance.
"""
rel = _Relationship(rId, reltype, target, self._baseURI, is_external)
self[rId] = rel
if not is_external:
self._target_parts_by_rId[rId]... | [
"Return",
"a",
"newly",
"added",
"|_Relationship|",
"instance",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/rel.py#L23-L31 | [
"def",
"add_relationship",
"(",
"self",
",",
"reltype",
",",
"target",
",",
"rId",
",",
"is_external",
"=",
"False",
")",
":",
"rel",
"=",
"_Relationship",
"(",
"rId",
",",
"reltype",
",",
"target",
",",
"self",
".",
"_baseURI",
",",
"is_external",
")",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Relationships.get_or_add | Return relationship of *reltype* to *target_part*, newly added if not
already present in collection. | docx/opc/rel.py | def get_or_add(self, reltype, target_part):
"""
Return relationship of *reltype* to *target_part*, newly added if not
already present in collection.
"""
rel = self._get_matching(reltype, target_part)
if rel is None:
rId = self._next_rId
rel = self.... | def get_or_add(self, reltype, target_part):
"""
Return relationship of *reltype* to *target_part*, newly added if not
already present in collection.
"""
rel = self._get_matching(reltype, target_part)
if rel is None:
rId = self._next_rId
rel = self.... | [
"Return",
"relationship",
"of",
"*",
"reltype",
"*",
"to",
"*",
"target_part",
"*",
"newly",
"added",
"if",
"not",
"already",
"present",
"in",
"collection",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/rel.py#L33-L42 | [
"def",
"get_or_add",
"(",
"self",
",",
"reltype",
",",
"target_part",
")",
":",
"rel",
"=",
"self",
".",
"_get_matching",
"(",
"reltype",
",",
"target_part",
")",
"if",
"rel",
"is",
"None",
":",
"rId",
"=",
"self",
".",
"_next_rId",
"rel",
"=",
"self",... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Relationships.get_or_add_ext_rel | Return rId of external relationship of *reltype* to *target_ref*,
newly added if not already present in collection. | docx/opc/rel.py | def get_or_add_ext_rel(self, reltype, target_ref):
"""
Return rId of external relationship of *reltype* to *target_ref*,
newly added if not already present in collection.
"""
rel = self._get_matching(reltype, target_ref, is_external=True)
if rel is None:
rId =... | def get_or_add_ext_rel(self, reltype, target_ref):
"""
Return rId of external relationship of *reltype* to *target_ref*,
newly added if not already present in collection.
"""
rel = self._get_matching(reltype, target_ref, is_external=True)
if rel is None:
rId =... | [
"Return",
"rId",
"of",
"external",
"relationship",
"of",
"*",
"reltype",
"*",
"to",
"*",
"target_ref",
"*",
"newly",
"added",
"if",
"not",
"already",
"present",
"in",
"collection",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/rel.py#L44-L55 | [
"def",
"get_or_add_ext_rel",
"(",
"self",
",",
"reltype",
",",
"target_ref",
")",
":",
"rel",
"=",
"self",
".",
"_get_matching",
"(",
"reltype",
",",
"target_ref",
",",
"is_external",
"=",
"True",
")",
"if",
"rel",
"is",
"None",
":",
"rId",
"=",
"self",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Relationships.xml | Serialize this relationship collection into XML suitable for storage
as a .rels file in an OPC package. | docx/opc/rel.py | def xml(self):
"""
Serialize this relationship collection into XML suitable for storage
as a .rels file in an OPC package.
"""
rels_elm = CT_Relationships.new()
for rel in self.values():
rels_elm.add_rel(
rel.rId, rel.reltype, rel.target_ref, r... | def xml(self):
"""
Serialize this relationship collection into XML suitable for storage
as a .rels file in an OPC package.
"""
rels_elm = CT_Relationships.new()
for rel in self.values():
rels_elm.add_rel(
rel.rId, rel.reltype, rel.target_ref, r... | [
"Serialize",
"this",
"relationship",
"collection",
"into",
"XML",
"suitable",
"for",
"storage",
"as",
"a",
".",
"rels",
"file",
"in",
"an",
"OPC",
"package",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/rel.py#L75-L85 | [
"def",
"xml",
"(",
"self",
")",
":",
"rels_elm",
"=",
"CT_Relationships",
".",
"new",
"(",
")",
"for",
"rel",
"in",
"self",
".",
"values",
"(",
")",
":",
"rels_elm",
".",
"add_rel",
"(",
"rel",
".",
"rId",
",",
"rel",
".",
"reltype",
",",
"rel",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Relationships._get_matching | Return relationship of matching *reltype*, *target*, and
*is_external* from collection, or None if not found. | docx/opc/rel.py | def _get_matching(self, reltype, target, is_external=False):
"""
Return relationship of matching *reltype*, *target*, and
*is_external* from collection, or None if not found.
"""
def matches(rel, reltype, target, is_external):
if rel.reltype != reltype:
... | def _get_matching(self, reltype, target, is_external=False):
"""
Return relationship of matching *reltype*, *target*, and
*is_external* from collection, or None if not found.
"""
def matches(rel, reltype, target, is_external):
if rel.reltype != reltype:
... | [
"Return",
"relationship",
"of",
"matching",
"*",
"reltype",
"*",
"*",
"target",
"*",
"and",
"*",
"is_external",
"*",
"from",
"collection",
"or",
"None",
"if",
"not",
"found",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/rel.py#L87-L105 | [
"def",
"_get_matching",
"(",
"self",
",",
"reltype",
",",
"target",
",",
"is_external",
"=",
"False",
")",
":",
"def",
"matches",
"(",
"rel",
",",
"reltype",
",",
"target",
",",
"is_external",
")",
":",
"if",
"rel",
".",
"reltype",
"!=",
"reltype",
":"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Relationships._get_rel_of_type | 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. | docx/opc/rel.py | def _get_rel_of_type(self, reltype):
"""
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.
"""
matching = [rel for rel in self.valu... | def _get_rel_of_type(self, reltype):
"""
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.
"""
matching = [rel for rel in self.valu... | [
"Return",
"single",
"relationship",
"of",
"type",
"*",
"reltype",
"*",
"from",
"the",
"collection",
".",
"Raises",
"|KeyError|",
"if",
"no",
"matching",
"relationship",
"is",
"found",
".",
"Raises",
"|ValueError|",
"if",
"more",
"than",
"one",
"matching",
"rel... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/rel.py#L107-L120 | [
"def",
"_get_rel_of_type",
"(",
"self",
",",
"reltype",
")",
":",
"matching",
"=",
"[",
"rel",
"for",
"rel",
"in",
"self",
".",
"values",
"(",
")",
"if",
"rel",
".",
"reltype",
"==",
"reltype",
"]",
"if",
"len",
"(",
"matching",
")",
"==",
"0",
":"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Relationships._next_rId | Next available rId in collection, starting from 'rId1' and making use
of any gaps in numbering, e.g. 'rId2' for rIds ['rId1', 'rId3']. | docx/opc/rel.py | def _next_rId(self):
"""
Next available rId in collection, starting from 'rId1' and making use
of any gaps in numbering, e.g. 'rId2' for rIds ['rId1', 'rId3'].
"""
for n in range(1, len(self)+2):
rId_candidate = 'rId%d' % n # like 'rId19'
if rId_candidate... | def _next_rId(self):
"""
Next available rId in collection, starting from 'rId1' and making use
of any gaps in numbering, e.g. 'rId2' for rIds ['rId1', 'rId3'].
"""
for n in range(1, len(self)+2):
rId_candidate = 'rId%d' % n # like 'rId19'
if rId_candidate... | [
"Next",
"available",
"rId",
"in",
"collection",
"starting",
"from",
"rId1",
"and",
"making",
"use",
"of",
"any",
"gaps",
"in",
"numbering",
"e",
".",
"g",
".",
"rId2",
"for",
"rIds",
"[",
"rId1",
"rId3",
"]",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/rel.py#L123-L131 | [
"def",
"_next_rId",
"(",
"self",
")",
":",
"for",
"n",
"in",
"range",
"(",
"1",
",",
"len",
"(",
"self",
")",
"+",
"2",
")",
":",
"rId_candidate",
"=",
"'rId%d'",
"%",
"n",
"# like 'rId19'",
"if",
"rId_candidate",
"not",
"in",
"self",
":",
"return",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_DecimalNumber.new | Return a new ``CT_DecimalNumber`` element having tagname *nsptagname*
and ``val`` attribute set to *val*. | docx/oxml/shared.py | def new(cls, nsptagname, val):
"""
Return a new ``CT_DecimalNumber`` element having tagname *nsptagname*
and ``val`` attribute set to *val*.
"""
return OxmlElement(nsptagname, attrs={qn('w:val'): str(val)}) | def new(cls, nsptagname, val):
"""
Return a new ``CT_DecimalNumber`` element having tagname *nsptagname*
and ``val`` attribute set to *val*.
"""
return OxmlElement(nsptagname, attrs={qn('w:val'): str(val)}) | [
"Return",
"a",
"new",
"CT_DecimalNumber",
"element",
"having",
"tagname",
"*",
"nsptagname",
"*",
"and",
"val",
"attribute",
"set",
"to",
"*",
"val",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/shared.py#L24-L29 | [
"def",
"new",
"(",
"cls",
",",
"nsptagname",
",",
"val",
")",
":",
"return",
"OxmlElement",
"(",
"nsptagname",
",",
"attrs",
"=",
"{",
"qn",
"(",
"'w:val'",
")",
":",
"str",
"(",
"val",
")",
"}",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_String.new | Return a new ``CT_String`` element with tagname *nsptagname* and
``val`` attribute set to *val*. | docx/oxml/shared.py | def new(cls, nsptagname, val):
"""
Return a new ``CT_String`` element with tagname *nsptagname* and
``val`` attribute set to *val*.
"""
elm = OxmlElement(nsptagname)
elm.val = val
return elm | def new(cls, nsptagname, val):
"""
Return a new ``CT_String`` element with tagname *nsptagname* and
``val`` attribute set to *val*.
"""
elm = OxmlElement(nsptagname)
elm.val = val
return elm | [
"Return",
"a",
"new",
"CT_String",
"element",
"with",
"tagname",
"*",
"nsptagname",
"*",
"and",
"val",
"attribute",
"set",
"to",
"*",
"val",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/shared.py#L48-L55 | [
"def",
"new",
"(",
"cls",
",",
"nsptagname",
",",
"val",
")",
":",
"elm",
"=",
"OxmlElement",
"(",
"nsptagname",
")",
"elm",
".",
"val",
"=",
"val",
"return",
"elm"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | StyleFactory | Return a style object of the appropriate |BaseStyle| subclass, according
to the type of *style_elm*. | docx/styles/style.py | def StyleFactory(style_elm):
"""
Return a style object of the appropriate |BaseStyle| subclass, according
to the type of *style_elm*.
"""
style_cls = {
WD_STYLE_TYPE.PARAGRAPH: _ParagraphStyle,
WD_STYLE_TYPE.CHARACTER: _CharacterStyle,
WD_STYLE_TYPE.TABLE: _TableStyle,
... | def StyleFactory(style_elm):
"""
Return a style object of the appropriate |BaseStyle| subclass, according
to the type of *style_elm*.
"""
style_cls = {
WD_STYLE_TYPE.PARAGRAPH: _ParagraphStyle,
WD_STYLE_TYPE.CHARACTER: _CharacterStyle,
WD_STYLE_TYPE.TABLE: _TableStyle,
... | [
"Return",
"a",
"style",
"object",
"of",
"the",
"appropriate",
"|BaseStyle|",
"subclass",
"according",
"to",
"the",
"type",
"of",
"*",
"style_elm",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/styles/style.py#L18-L30 | [
"def",
"StyleFactory",
"(",
"style_elm",
")",
":",
"style_cls",
"=",
"{",
"WD_STYLE_TYPE",
".",
"PARAGRAPH",
":",
"_ParagraphStyle",
",",
"WD_STYLE_TYPE",
".",
"CHARACTER",
":",
"_CharacterStyle",
",",
"WD_STYLE_TYPE",
".",
"TABLE",
":",
"_TableStyle",
",",
"WD_... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | BaseStyle.name | The UI name of this style. | docx/styles/style.py | def name(self):
"""
The UI name of this style.
"""
name = self._element.name_val
if name is None:
return None
return BabelFish.internal2ui(name) | def name(self):
"""
The UI name of this style.
"""
name = self._element.name_val
if name is None:
return None
return BabelFish.internal2ui(name) | [
"The",
"UI",
"name",
"of",
"this",
"style",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/styles/style.py#L93-L100 | [
"def",
"name",
"(",
"self",
")",
":",
"name",
"=",
"self",
".",
"_element",
".",
"name_val",
"if",
"name",
"is",
"None",
":",
"return",
"None",
"return",
"BabelFish",
".",
"internal2ui",
"(",
"name",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | BaseStyle.type | Member of :ref:`WdStyleType` corresponding to the type of this style,
e.g. ``WD_STYLE_TYPE.PARAGRAPH``. | docx/styles/style.py | def type(self):
"""
Member of :ref:`WdStyleType` corresponding to the type of this style,
e.g. ``WD_STYLE_TYPE.PARAGRAPH``.
"""
type = self._element.type
if type is None:
return WD_STYLE_TYPE.PARAGRAPH
return type | def type(self):
"""
Member of :ref:`WdStyleType` corresponding to the type of this style,
e.g. ``WD_STYLE_TYPE.PARAGRAPH``.
"""
type = self._element.type
if type is None:
return WD_STYLE_TYPE.PARAGRAPH
return type | [
"Member",
"of",
":",
"ref",
":",
"WdStyleType",
"corresponding",
"to",
"the",
"type",
"of",
"this",
"style",
"e",
".",
"g",
".",
"WD_STYLE_TYPE",
".",
"PARAGRAPH",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/styles/style.py#L146-L154 | [
"def",
"type",
"(",
"self",
")",
":",
"type",
"=",
"self",
".",
"_element",
".",
"type",
"if",
"type",
"is",
"None",
":",
"return",
"WD_STYLE_TYPE",
".",
"PARAGRAPH",
"return",
"type"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _ParagraphStyle.next_paragraph_style | |_ParagraphStyle| object representing the style to be applied
automatically to a new paragraph inserted after a paragraph of this
style. Returns self if no next paragraph style is defined. Assigning
|None| or *self* removes the setting such that new paragraphs are
created using this same... | docx/styles/style.py | def next_paragraph_style(self):
"""
|_ParagraphStyle| object representing the style to be applied
automatically to a new paragraph inserted after a paragraph of this
style. Returns self if no next paragraph style is defined. Assigning
|None| or *self* removes the setting such tha... | def next_paragraph_style(self):
"""
|_ParagraphStyle| object representing the style to be applied
automatically to a new paragraph inserted after a paragraph of this
style. Returns self if no next paragraph style is defined. Assigning
|None| or *self* removes the setting such tha... | [
"|_ParagraphStyle|",
"object",
"representing",
"the",
"style",
"to",
"be",
"applied",
"automatically",
"to",
"a",
"new",
"paragraph",
"inserted",
"after",
"a",
"paragraph",
"of",
"this",
"style",
".",
"Returns",
"self",
"if",
"no",
"next",
"paragraph",
"style",
... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/styles/style.py#L217-L230 | [
"def",
"next_paragraph_style",
"(",
"self",
")",
":",
"next_style_elm",
"=",
"self",
".",
"_element",
".",
"next_style",
"if",
"next_style_elm",
"is",
"None",
":",
"return",
"self",
"if",
"next_style_elm",
".",
"type",
"!=",
"WD_STYLE_TYPE",
".",
"PARAGRAPH",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_CoreProperties.revision_number | Integer value of revision property. | docx/oxml/coreprops.py | def revision_number(self):
"""
Integer value of revision property.
"""
revision = self.revision
if revision is None:
return 0
revision_str = revision.text
try:
revision = int(revision_str)
except ValueError:
# non-intege... | def revision_number(self):
"""
Integer value of revision property.
"""
revision = self.revision
if revision is None:
return 0
revision_str = revision.text
try:
revision = int(revision_str)
except ValueError:
# non-intege... | [
"Integer",
"value",
"of",
"revision",
"property",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/coreprops.py#L148-L164 | [
"def",
"revision_number",
"(",
"self",
")",
":",
"revision",
"=",
"self",
".",
"revision",
"if",
"revision",
"is",
"None",
":",
"return",
"0",
"revision_str",
"=",
"revision",
".",
"text",
"try",
":",
"revision",
"=",
"int",
"(",
"revision_str",
")",
"ex... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_CoreProperties.revision_number | Set revision property to string value of integer *value*. | docx/oxml/coreprops.py | def revision_number(self, value):
"""
Set revision property to string value of integer *value*.
"""
if not isinstance(value, int) or value < 1:
tmpl = "revision property requires positive int, got '%s'"
raise ValueError(tmpl % value)
revision = self.get_or... | def revision_number(self, value):
"""
Set revision property to string value of integer *value*.
"""
if not isinstance(value, int) or value < 1:
tmpl = "revision property requires positive int, got '%s'"
raise ValueError(tmpl % value)
revision = self.get_or... | [
"Set",
"revision",
"property",
"to",
"string",
"value",
"of",
"integer",
"*",
"value",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/coreprops.py#L167-L175 | [
"def",
"revision_number",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"int",
")",
"or",
"value",
"<",
"1",
":",
"tmpl",
"=",
"\"revision property requires positive int, got '%s'\"",
"raise",
"ValueError",
"(",
"tmpl",
"%"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_CoreProperties._get_or_add | Return element returned by 'get_or_add_' method for *prop_name*. | docx/oxml/coreprops.py | def _get_or_add(self, prop_name):
"""
Return element returned by 'get_or_add_' method for *prop_name*.
"""
get_or_add_method_name = 'get_or_add_%s' % prop_name
get_or_add_method = getattr(self, get_or_add_method_name)
element = get_or_add_method()
return element | def _get_or_add(self, prop_name):
"""
Return element returned by 'get_or_add_' method for *prop_name*.
"""
get_or_add_method_name = '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",
"element",
"returned",
"by",
"get_or_add_",
"method",
"for",
"*",
"prop_name",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/coreprops.py#L212-L219 | [
"def",
"_get_or_add",
"(",
"self",
",",
"prop_name",
")",
":",
"get_or_add_method_name",
"=",
"'get_or_add_%s'",
"%",
"prop_name",
"get_or_add_method",
"=",
"getattr",
"(",
"self",
",",
"get_or_add_method_name",
")",
"element",
"=",
"get_or_add_method",
"(",
")",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_CoreProperties._offset_dt | Return a |datetime| instance that is offset from datetime *dt* by
the timezone offset specified in *offset_str*, a string like
``'-07:00'``. | docx/oxml/coreprops.py | def _offset_dt(cls, dt, offset_str):
"""
Return a |datetime| instance that is offset from datetime *dt* by
the timezone offset specified in *offset_str*, a string like
``'-07:00'``.
"""
match = cls._offset_pattern.match(offset_str)
if match is None:
ra... | def _offset_dt(cls, dt, offset_str):
"""
Return a |datetime| instance that is offset from datetime *dt* by
the timezone offset specified in *offset_str*, a string like
``'-07:00'``.
"""
match = cls._offset_pattern.match(offset_str)
if match is None:
ra... | [
"Return",
"a",
"|datetime|",
"instance",
"that",
"is",
"offset",
"from",
"datetime",
"*",
"dt",
"*",
"by",
"the",
"timezone",
"offset",
"specified",
"in",
"*",
"offset_str",
"*",
"a",
"string",
"like",
"-",
"07",
":",
"00",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/coreprops.py#L222-L238 | [
"def",
"_offset_dt",
"(",
"cls",
",",
"dt",
",",
"offset_str",
")",
":",
"match",
"=",
"cls",
".",
"_offset_pattern",
".",
"match",
"(",
"offset_str",
")",
"if",
"match",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"'%s' is not a valid offset string\"",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_CoreProperties._set_element_datetime | Set date/time value of child element having *prop_name* to *value*. | docx/oxml/coreprops.py | def _set_element_datetime(self, prop_name, value):
"""
Set date/time value of child element having *prop_name* to *value*.
"""
if not isinstance(value, datetime):
tmpl = (
"property requires <type 'datetime.datetime'> object, got %s"
)
... | def _set_element_datetime(self, prop_name, value):
"""
Set date/time value of child element having *prop_name* to *value*.
"""
if not isinstance(value, datetime):
tmpl = (
"property requires <type 'datetime.datetime'> object, got %s"
)
... | [
"Set",
"date",
"/",
"time",
"value",
"of",
"child",
"element",
"having",
"*",
"prop_name",
"*",
"to",
"*",
"value",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/coreprops.py#L273-L292 | [
"def",
"_set_element_datetime",
"(",
"self",
",",
"prop_name",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"datetime",
")",
":",
"tmpl",
"=",
"(",
"\"property requires <type 'datetime.datetime'> object, got %s\"",
")",
"raise",
"ValueError"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_CoreProperties._set_element_text | Set string value of *name* property to *value*. | docx/oxml/coreprops.py | def _set_element_text(self, prop_name, value):
"""Set string value of *name* property to *value*."""
if not is_string(value):
value = str(value)
if len(value) > 255:
tmpl = (
"exceeded 255 char limit for property, got:\n\n'%s'"
)
r... | def _set_element_text(self, prop_name, value):
"""Set string value of *name* property to *value*."""
if not is_string(value):
value = str(value)
if len(value) > 255:
tmpl = (
"exceeded 255 char limit for property, got:\n\n'%s'"
)
r... | [
"Set",
"string",
"value",
"of",
"*",
"name",
"*",
"property",
"to",
"*",
"value",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/coreprops.py#L294-L305 | [
"def",
"_set_element_text",
"(",
"self",
",",
"prop_name",
",",
"value",
")",
":",
"if",
"not",
"is_string",
"(",
"value",
")",
":",
"value",
"=",
"str",
"(",
"value",
")",
"if",
"len",
"(",
"value",
")",
">",
"255",
":",
"tmpl",
"=",
"(",
"\"excee... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_CoreProperties._text_of_element | Return the text in the element matching *property_name*, or an empty
string if the element is not present or contains no text. | docx/oxml/coreprops.py | def _text_of_element(self, property_name):
"""
Return the text in the element matching *property_name*, or an empty
string if the element is not present or contains no text.
"""
element = getattr(self, property_name)
if element is None:
return ''
if el... | def _text_of_element(self, property_name):
"""
Return the text in the element matching *property_name*, or an empty
string if the element is not present or contains no text.
"""
element = getattr(self, property_name)
if element is None:
return ''
if el... | [
"Return",
"the",
"text",
"in",
"the",
"element",
"matching",
"*",
"property_name",
"*",
"or",
"an",
"empty",
"string",
"if",
"the",
"element",
"is",
"not",
"present",
"or",
"contains",
"no",
"text",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/coreprops.py#L307-L317 | [
"def",
"_text_of_element",
"(",
"self",
",",
"property_name",
")",
":",
"element",
"=",
"getattr",
"(",
"self",
",",
"property_name",
")",
"if",
"element",
"is",
"None",
":",
"return",
"''",
"if",
"element",
".",
"text",
"is",
"None",
":",
"return",
"''"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Gif.from_stream | Return |Gif| instance having header properties parsed from GIF image
in *stream*. | docx/image/gif.py | def from_stream(cls, stream):
"""
Return |Gif| instance having header properties parsed from GIF image
in *stream*.
"""
px_width, px_height = cls._dimensions_from_stream(stream)
return cls(px_width, px_height, 72, 72) | def from_stream(cls, stream):
"""
Return |Gif| instance having header properties parsed from GIF image
in *stream*.
"""
px_width, px_height = cls._dimensions_from_stream(stream)
return cls(px_width, px_height, 72, 72) | [
"Return",
"|Gif|",
"instance",
"having",
"header",
"properties",
"parsed",
"from",
"GIF",
"image",
"in",
"*",
"stream",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/gif.py#L18-L24 | [
"def",
"from_stream",
"(",
"cls",
",",
"stream",
")",
":",
"px_width",
",",
"px_height",
"=",
"cls",
".",
"_dimensions_from_stream",
"(",
"stream",
")",
"return",
"cls",
"(",
"px_width",
",",
"px_height",
",",
"72",
",",
"72",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _DirPkgReader.blob_for | Return contents of file corresponding to *pack_uri* in package
directory. | docx/opc/phys_pkg.py | def blob_for(self, pack_uri):
"""
Return contents of file corresponding to *pack_uri* in package
directory.
"""
path = os.path.join(self._path, pack_uri.membername)
with open(path, 'rb') as f:
blob = f.read()
return blob | def blob_for(self, pack_uri):
"""
Return contents of file corresponding to *pack_uri* in package
directory.
"""
path = os.path.join(self._path, pack_uri.membername)
with open(path, 'rb') as f:
blob = f.read()
return blob | [
"Return",
"contents",
"of",
"file",
"corresponding",
"to",
"*",
"pack_uri",
"*",
"in",
"package",
"directory",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/phys_pkg.py#L59-L67 | [
"def",
"blob_for",
"(",
"self",
",",
"pack_uri",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_path",
",",
"pack_uri",
".",
"membername",
")",
"with",
"open",
"(",
"path",
",",
"'rb'",
")",
"as",
"f",
":",
"blob",
"="... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _DirPkgReader.rels_xml_for | Return rels item XML for source with *source_uri*, or None if the
item has no rels item. | docx/opc/phys_pkg.py | def rels_xml_for(self, source_uri):
"""
Return rels item XML for source with *source_uri*, or None if the
item has no rels item.
"""
try:
rels_xml = self.blob_for(source_uri.rels_uri)
except IOError:
rels_xml = None
return rels_xml | def rels_xml_for(self, source_uri):
"""
Return rels item XML for source with *source_uri*, or None if the
item has no rels item.
"""
try:
rels_xml = self.blob_for(source_uri.rels_uri)
except IOError:
rels_xml = None
return rels_xml | [
"Return",
"rels",
"item",
"XML",
"for",
"source",
"with",
"*",
"source_uri",
"*",
"or",
"None",
"if",
"the",
"item",
"has",
"no",
"rels",
"item",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/phys_pkg.py#L83-L92 | [
"def",
"rels_xml_for",
"(",
"self",
",",
"source_uri",
")",
":",
"try",
":",
"rels_xml",
"=",
"self",
".",
"blob_for",
"(",
"source_uri",
".",
"rels_uri",
")",
"except",
"IOError",
":",
"rels_xml",
"=",
"None",
"return",
"rels_xml"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _ZipPkgReader.rels_xml_for | Return rels item XML for source with *source_uri* or None if no rels
item is present. | docx/opc/phys_pkg.py | def rels_xml_for(self, source_uri):
"""
Return rels item XML for source with *source_uri* or None if no rels
item is present.
"""
try:
rels_xml = self.blob_for(source_uri.rels_uri)
except KeyError:
rels_xml = None
return rels_xml | def rels_xml_for(self, source_uri):
"""
Return rels item XML for source with *source_uri* or None if no rels
item is present.
"""
try:
rels_xml = self.blob_for(source_uri.rels_uri)
except KeyError:
rels_xml = None
return rels_xml | [
"Return",
"rels",
"item",
"XML",
"for",
"source",
"with",
"*",
"source_uri",
"*",
"or",
"None",
"if",
"no",
"rels",
"item",
"is",
"present",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/phys_pkg.py#L123-L132 | [
"def",
"rels_xml_for",
"(",
"self",
",",
"source_uri",
")",
":",
"try",
":",
"rels_xml",
"=",
"self",
".",
"blob_for",
"(",
"source_uri",
".",
"rels_uri",
")",
"except",
"KeyError",
":",
"rels_xml",
"=",
"None",
"return",
"rels_xml"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _ZipPkgWriter.write | Write *blob* to this zip package with the membername corresponding to
*pack_uri*. | docx/opc/phys_pkg.py | def write(self, pack_uri, blob):
"""
Write *blob* to this zip package with the membername corresponding to
*pack_uri*.
"""
self._zipf.writestr(pack_uri.membername, blob) | def write(self, pack_uri, blob):
"""
Write *blob* to this zip package with the membername corresponding to
*pack_uri*.
"""
self._zipf.writestr(pack_uri.membername, blob) | [
"Write",
"*",
"blob",
"*",
"to",
"this",
"zip",
"package",
"with",
"the",
"membername",
"corresponding",
"to",
"*",
"pack_uri",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/phys_pkg.py#L150-L155 | [
"def",
"write",
"(",
"self",
",",
"pack_uri",
",",
"blob",
")",
":",
"self",
".",
"_zipf",
".",
"writestr",
"(",
"pack_uri",
".",
"membername",
",",
"blob",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Bmp.from_stream | Return |Bmp| instance having header properties parsed from the BMP
image in *stream*. | docx/image/bmp.py | def from_stream(cls, stream):
"""
Return |Bmp| instance having header properties parsed from the BMP
image in *stream*.
"""
stream_rdr = StreamReader(stream, LITTLE_ENDIAN)
px_width = stream_rdr.read_long(0x12)
px_height = stream_rdr.read_long(0x16)
horz... | def from_stream(cls, stream):
"""
Return |Bmp| instance having header properties parsed from the BMP
image in *stream*.
"""
stream_rdr = StreamReader(stream, LITTLE_ENDIAN)
px_width = stream_rdr.read_long(0x12)
px_height = stream_rdr.read_long(0x16)
horz... | [
"Return",
"|Bmp|",
"instance",
"having",
"header",
"properties",
"parsed",
"from",
"the",
"BMP",
"image",
"in",
"*",
"stream",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/bmp.py#L15-L31 | [
"def",
"from_stream",
"(",
"cls",
",",
"stream",
")",
":",
"stream_rdr",
"=",
"StreamReader",
"(",
"stream",
",",
"LITTLE_ENDIAN",
")",
"px_width",
"=",
"stream_rdr",
".",
"read_long",
"(",
"0x12",
")",
"px_height",
"=",
"stream_rdr",
".",
"read_long",
"(",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | qn | Stands for "qualified name", a utility function to turn a namespace
prefixed tag name into a Clark-notation qualified tag name for lxml. For
example, ``qn('p:cSld')`` returns ``'{http://schemas.../main}cSld'``. | docx/oxml/ns.py | def qn(tag):
"""
Stands for "qualified name", a utility function to turn a namespace
prefixed tag name into a Clark-notation qualified tag name for lxml. For
example, ``qn('p:cSld')`` returns ``'{http://schemas.../main}cSld'``.
"""
prefix, tagroot = tag.split(':')
uri = nsmap[prefix]
ret... | def qn(tag):
"""
Stands for "qualified name", a utility function to turn a namespace
prefixed tag name into a Clark-notation qualified tag name for lxml. For
example, ``qn('p:cSld')`` returns ``'{http://schemas.../main}cSld'``.
"""
prefix, tagroot = tag.split(':')
uri = nsmap[prefix]
ret... | [
"Stands",
"for",
"qualified",
"name",
"a",
"utility",
"function",
"to",
"turn",
"a",
"namespace",
"prefixed",
"tag",
"name",
"into",
"a",
"Clark",
"-",
"notation",
"qualified",
"tag",
"name",
"for",
"lxml",
".",
"For",
"example",
"qn",
"(",
"p",
":",
"cS... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/ns.py#L105-L113 | [
"def",
"qn",
"(",
"tag",
")",
":",
"prefix",
",",
"tagroot",
"=",
"tag",
".",
"split",
"(",
"':'",
")",
"uri",
"=",
"nsmap",
"[",
"prefix",
"]",
"return",
"'{%s}%s'",
"%",
"(",
"uri",
",",
"tagroot",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_P.clear_content | Remove all child elements, except the ``<w:pPr>`` element if present. | docx/oxml/text/paragraph.py | def clear_content(self):
"""
Remove all child elements, except the ``<w:pPr>`` element if present.
"""
for child in self[:]:
if child.tag == qn('w:pPr'):
continue
self.remove(child) | def clear_content(self):
"""
Remove all child elements, except the ``<w:pPr>`` element if present.
"""
for child in self[:]:
if child.tag == qn('w:pPr'):
continue
self.remove(child) | [
"Remove",
"all",
"child",
"elements",
"except",
"the",
"<w",
":",
"pPr",
">",
"element",
"if",
"present",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/text/paragraph.py#L46-L53 | [
"def",
"clear_content",
"(",
"self",
")",
":",
"for",
"child",
"in",
"self",
"[",
":",
"]",
":",
"if",
"child",
".",
"tag",
"==",
"qn",
"(",
"'w:pPr'",
")",
":",
"continue",
"self",
".",
"remove",
"(",
"child",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_P.set_sectPr | Unconditionally replace or add *sectPr* as a grandchild in the
correct sequence. | docx/oxml/text/paragraph.py | def set_sectPr(self, sectPr):
"""
Unconditionally replace or add *sectPr* as a grandchild in the
correct sequence.
"""
pPr = self.get_or_add_pPr()
pPr._remove_sectPr()
pPr._insert_sectPr(sectPr) | def set_sectPr(self, sectPr):
"""
Unconditionally replace or add *sectPr* as a grandchild in the
correct sequence.
"""
pPr = self.get_or_add_pPr()
pPr._remove_sectPr()
pPr._insert_sectPr(sectPr) | [
"Unconditionally",
"replace",
"or",
"add",
"*",
"sectPr",
"*",
"as",
"a",
"grandchild",
"in",
"the",
"correct",
"sequence",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/text/paragraph.py#L55-L62 | [
"def",
"set_sectPr",
"(",
"self",
",",
"sectPr",
")",
":",
"pPr",
"=",
"self",
".",
"get_or_add_pPr",
"(",
")",
"pPr",
".",
"_remove_sectPr",
"(",
")",
"pPr",
".",
"_insert_sectPr",
"(",
"sectPr",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | PackageReader.from_file | Return a |PackageReader| instance loaded with contents of *pkg_file*. | docx/opc/pkgreader.py | def from_file(pkg_file):
"""
Return a |PackageReader| instance loaded with contents of *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_U... | def from_file(pkg_file):
"""
Return a |PackageReader| instance loaded with contents of *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_U... | [
"Return",
"a",
"|PackageReader|",
"instance",
"loaded",
"with",
"contents",
"of",
"*",
"pkg_file",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/pkgreader.py#L28-L39 | [
"def",
"from_file",
"(",
"pkg_file",
")",
":",
"phys_reader",
"=",
"PhysPkgReader",
"(",
"pkg_file",
")",
"content_types",
"=",
"_ContentTypeMap",
".",
"from_xml",
"(",
"phys_reader",
".",
"content_types_xml",
")",
"pkg_srels",
"=",
"PackageReader",
".",
"_srels_f... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | PackageReader.iter_sparts | Generate a 4-tuple `(partname, content_type, reltype, blob)` for each
of the serialized parts in the package. | docx/opc/pkgreader.py | def iter_sparts(self):
"""
Generate a 4-tuple `(partname, content_type, reltype, blob)` for each
of the serialized parts in the package.
"""
for s in self._sparts:
yield (s.partname, s.content_type, s.reltype, s.blob) | def iter_sparts(self):
"""
Generate a 4-tuple `(partname, content_type, reltype, blob)` for each
of the serialized parts in the package.
"""
for s in self._sparts:
yield (s.partname, s.content_type, s.reltype, s.blob) | [
"Generate",
"a",
"4",
"-",
"tuple",
"(",
"partname",
"content_type",
"reltype",
"blob",
")",
"for",
"each",
"of",
"the",
"serialized",
"parts",
"in",
"the",
"package",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/pkgreader.py#L41-L47 | [
"def",
"iter_sparts",
"(",
"self",
")",
":",
"for",
"s",
"in",
"self",
".",
"_sparts",
":",
"yield",
"(",
"s",
".",
"partname",
",",
"s",
".",
"content_type",
",",
"s",
".",
"reltype",
",",
"s",
".",
"blob",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | PackageReader.iter_srels | Generate a 2-tuple `(source_uri, srel)` for each of the relationships
in the package. | docx/opc/pkgreader.py | def iter_srels(self):
"""
Generate a 2-tuple `(source_uri, srel)` for each of the relationships
in the package.
"""
for srel in self._pkg_srels:
yield (PACKAGE_URI, srel)
for spart in self._sparts:
for srel in spart.srels:
yield (sp... | def iter_srels(self):
"""
Generate a 2-tuple `(source_uri, srel)` for each of the relationships
in the package.
"""
for srel in self._pkg_srels:
yield (PACKAGE_URI, srel)
for spart in self._sparts:
for srel in spart.srels:
yield (sp... | [
"Generate",
"a",
"2",
"-",
"tuple",
"(",
"source_uri",
"srel",
")",
"for",
"each",
"of",
"the",
"relationships",
"in",
"the",
"package",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/pkgreader.py#L49-L58 | [
"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... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | PackageReader._srels_for | Return |_SerializedRelationships| instance populated with
relationships for source identified by *source_uri*. | docx/opc/pkgreader.py | def _srels_for(phys_reader, source_uri):
"""
Return |_SerializedRelationships| instance populated with
relationships for source identified by *source_uri*.
"""
rels_xml = phys_reader.rels_xml_for(source_uri)
return _SerializedRelationships.load_from_xml(
sourc... | def _srels_for(phys_reader, source_uri):
"""
Return |_SerializedRelationships| instance populated with
relationships for source identified by *source_uri*.
"""
rels_xml = phys_reader.rels_xml_for(source_uri)
return _SerializedRelationships.load_from_xml(
sourc... | [
"Return",
"|_SerializedRelationships|",
"instance",
"populated",
"with",
"relationships",
"for",
"source",
"identified",
"by",
"*",
"source_uri",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/pkgreader.py#L78-L85 | [
"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",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _ContentTypeMap.from_xml | Return a new |_ContentTypeMap| instance populated with the contents
of *content_types_xml*. | docx/opc/pkgreader.py | def from_xml(content_types_xml):
"""
Return a new |_ContentTypeMap| instance populated with the contents
of *content_types_xml*.
"""
types_elm = parse_xml(content_types_xml)
ct_map = _ContentTypeMap()
for o in types_elm.overrides:
ct_map._add_override(... | def from_xml(content_types_xml):
"""
Return a new |_ContentTypeMap| instance populated with the contents
of *content_types_xml*.
"""
types_elm = parse_xml(content_types_xml)
ct_map = _ContentTypeMap()
for o in types_elm.overrides:
ct_map._add_override(... | [
"Return",
"a",
"new",
"|_ContentTypeMap|",
"instance",
"populated",
"with",
"the",
"contents",
"of",
"*",
"content_types_xml",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/pkgreader.py#L139-L150 | [
"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",
"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _SerializedRelationship.target_partname | |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. | docx/opc/pkgreader.py | def target_partname(self):
"""
|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.
"""
if self.is_external:
msg = ('targ... | def target_partname(self):
"""
|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.
"""
if self.is_external:
msg = ('targ... | [
"|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",... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/pkgreader.py#L256-L270 | [
"def",
"target_partname",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_external",
":",
"msg",
"=",
"(",
"'target_partname attribute on Relationship is undefined w'",
"'here TargetMode == \"External\"'",
")",
"raise",
"ValueError",
"(",
"msg",
")",
"# lazy-load _target_pa... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _SerializedRelationships.load_from_xml | Return |_SerializedRelationships| instance loaded with the
relationships contained in *rels_item_xml*. Returns an empty
collection if *rels_item_xml* is |None|. | docx/opc/pkgreader.py | def load_from_xml(baseURI, rels_item_xml):
"""
Return |_SerializedRelationships| instance loaded with the
relationships contained in *rels_item_xml*. Returns an empty
collection if *rels_item_xml* is |None|.
"""
srels = _SerializedRelationships()
if rels_item_xml ... | def load_from_xml(baseURI, rels_item_xml):
"""
Return |_SerializedRelationships| instance loaded with the
relationships contained in *rels_item_xml*. Returns an empty
collection if *rels_item_xml* is |None|.
"""
srels = _SerializedRelationships()
if rels_item_xml ... | [
"Return",
"|_SerializedRelationships|",
"instance",
"loaded",
"with",
"the",
"relationships",
"contained",
"in",
"*",
"rels_item_xml",
"*",
".",
"Returns",
"an",
"empty",
"collection",
"if",
"*",
"rels_item_xml",
"*",
"is",
"|None|",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/pkgreader.py#L287-L298 | [
"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_... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | PackURI.from_rel_ref | Return a |PackURI| instance containing the absolute pack URI formed by
translating *relative_ref* onto *baseURI*. | docx/opc/packuri.py | def from_rel_ref(baseURI, relative_ref):
"""
Return a |PackURI| instance containing the absolute pack URI formed by
translating *relative_ref* onto *baseURI*.
"""
joined_uri = posixpath.join(baseURI, relative_ref)
abs_uri = posixpath.abspath(joined_uri)
return Pac... | def from_rel_ref(baseURI, relative_ref):
"""
Return a |PackURI| instance containing the absolute pack URI formed by
translating *relative_ref* onto *baseURI*.
"""
joined_uri = posixpath.join(baseURI, relative_ref)
abs_uri = posixpath.abspath(joined_uri)
return Pac... | [
"Return",
"a",
"|PackURI|",
"instance",
"containing",
"the",
"absolute",
"pack",
"URI",
"formed",
"by",
"translating",
"*",
"relative_ref",
"*",
"onto",
"*",
"baseURI",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/packuri.py#L26-L33 | [
"def",
"from_rel_ref",
"(",
"baseURI",
",",
"relative_ref",
")",
":",
"joined_uri",
"=",
"posixpath",
".",
"join",
"(",
"baseURI",
",",
"relative_ref",
")",
"abs_uri",
"=",
"posixpath",
".",
"abspath",
"(",
"joined_uri",
")",
"return",
"PackURI",
"(",
"abs_u... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | PackURI.ext | The extension portion of this pack URI, e.g. ``'xml'`` for
``'/word/document.xml'``. Note the period is not included. | docx/opc/packuri.py | def ext(self):
"""
The extension portion of this pack URI, e.g. ``'xml'`` for
``'/word/document.xml'``. Note the period is not included.
"""
# raw_ext is either empty string or starts with period, e.g. '.xml'
raw_ext = posixpath.splitext(self)[1]
return raw_ext[1:... | def ext(self):
"""
The extension portion of this pack URI, e.g. ``'xml'`` for
``'/word/document.xml'``. Note the period is not included.
"""
# raw_ext is either empty string or starts with period, e.g. '.xml'
raw_ext = posixpath.splitext(self)[1]
return raw_ext[1:... | [
"The",
"extension",
"portion",
"of",
"this",
"pack",
"URI",
"e",
".",
"g",
".",
"xml",
"for",
"/",
"word",
"/",
"document",
".",
"xml",
".",
"Note",
"the",
"period",
"is",
"not",
"included",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/packuri.py#L45-L52 | [
"def",
"ext",
"(",
"self",
")",
":",
"# raw_ext is either empty string or starts with period, e.g. '.xml'",
"raw_ext",
"=",
"posixpath",
".",
"splitext",
"(",
"self",
")",
"[",
"1",
"]",
"return",
"raw_ext",
"[",
"1",
":",
"]",
"if",
"raw_ext",
".",
"startswith"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | PackURI.idx | Return partname index as integer for tuple partname or None for
singleton partname, e.g. ``21`` for ``'/ppt/slides/slide21.xml'`` and
|None| for ``'/ppt/presentation.xml'``. | docx/opc/packuri.py | def idx(self):
"""
Return partname index as integer for tuple partname or None for
singleton partname, e.g. ``21`` for ``'/ppt/slides/slide21.xml'`` and
|None| for ``'/ppt/presentation.xml'``.
"""
filename = self.filename
if not filename:
return None
... | def idx(self):
"""
Return partname index as integer for tuple partname or None for
singleton partname, e.g. ``21`` for ``'/ppt/slides/slide21.xml'`` and
|None| for ``'/ppt/presentation.xml'``.
"""
filename = self.filename
if not filename:
return None
... | [
"Return",
"partname",
"index",
"as",
"integer",
"for",
"tuple",
"partname",
"or",
"None",
"for",
"singleton",
"partname",
"e",
".",
"g",
".",
"21",
"for",
"/",
"ppt",
"/",
"slides",
"/",
"slide21",
".",
"xml",
"and",
"|None|",
"for",
"/",
"ppt",
"/",
... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/packuri.py#L64-L79 | [
"def",
"idx",
"(",
"self",
")",
":",
"filename",
"=",
"self",
".",
"filename",
"if",
"not",
"filename",
":",
"return",
"None",
"name_part",
"=",
"posixpath",
".",
"splitext",
"(",
"filename",
")",
"[",
"0",
"]",
"# filename w/ext removed",
"match",
"=",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | PackURI.relative_ref | Return string containing relative reference to package item from
*baseURI*. E.g. PackURI('/ppt/slideLayouts/slideLayout1.xml') would
return '../slideLayouts/slideLayout1.xml' for baseURI '/ppt/slides'. | docx/opc/packuri.py | def relative_ref(self, baseURI):
"""
Return string containing relative reference to package item from
*baseURI*. E.g. PackURI('/ppt/slideLayouts/slideLayout1.xml') would
return '../slideLayouts/slideLayout1.xml' for baseURI '/ppt/slides'.
"""
# workaround for posixpath bu... | def relative_ref(self, baseURI):
"""
Return string containing relative reference to package item from
*baseURI*. E.g. PackURI('/ppt/slideLayouts/slideLayout1.xml') would
return '../slideLayouts/slideLayout1.xml' for baseURI '/ppt/slides'.
"""
# workaround for posixpath bu... | [
"Return",
"string",
"containing",
"relative",
"reference",
"to",
"package",
"item",
"from",
"*",
"baseURI",
"*",
".",
"E",
".",
"g",
".",
"PackURI",
"(",
"/",
"ppt",
"/",
"slideLayouts",
"/",
"slideLayout1",
".",
"xml",
")",
"would",
"return",
"..",
"/",... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/packuri.py#L90-L102 | [
"def",
"relative_ref",
"(",
"self",
",",
"baseURI",
")",
":",
"# workaround for posixpath bug in 2.6, doesn't generate correct",
"# relative path when *start* (second) parameter is root ('/')",
"if",
"baseURI",
"==",
"'/'",
":",
"relpath",
"=",
"self",
"[",
"1",
":",
"]",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | PackURI.rels_uri | The pack URI of the .rels part corresponding to the current pack URI.
Only produces sensible output if the pack URI is a partname or the
package pseudo-partname '/'. | docx/opc/packuri.py | def rels_uri(self):
"""
The pack URI of the .rels part corresponding to the current pack URI.
Only produces sensible output if the pack URI is a partname or the
package pseudo-partname '/'.
"""
rels_filename = '%s.rels' % self.filename
rels_uri_str = posixpath.joi... | def rels_uri(self):
"""
The pack URI of the .rels part corresponding to the current pack URI.
Only produces sensible output if the pack URI is a partname or the
package pseudo-partname '/'.
"""
rels_filename = '%s.rels' % self.filename
rels_uri_str = posixpath.joi... | [
"The",
"pack",
"URI",
"of",
"the",
".",
"rels",
"part",
"corresponding",
"to",
"the",
"current",
"pack",
"URI",
".",
"Only",
"produces",
"sensible",
"output",
"if",
"the",
"pack",
"URI",
"is",
"a",
"partname",
"or",
"the",
"package",
"pseudo",
"-",
"part... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/packuri.py#L105-L113 | [
"def",
"rels_uri",
"(",
"self",
")",
":",
"rels_filename",
"=",
"'%s.rels'",
"%",
"self",
".",
"filename",
"rels_uri_str",
"=",
"posixpath",
".",
"join",
"(",
"self",
".",
"baseURI",
",",
"'_rels'",
",",
"rels_filename",
")",
"return",
"PackURI",
"(",
"rel... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_Default.new | Return a new ``<Default>`` element with attributes set to parameter
values. | docx/opc/oxml.py | def new(ext, content_type):
"""
Return a new ``<Default>`` element with attributes set to parameter
values.
"""
xml = '<Default xmlns="%s"/>' % nsmap['ct']
default = parse_xml(xml)
default.set('Extension', ext)
default.set('ContentType', content_type)
... | def new(ext, content_type):
"""
Return a new ``<Default>`` element with attributes set to parameter
values.
"""
xml = '<Default xmlns="%s"/>' % nsmap['ct']
default = parse_xml(xml)
default.set('Extension', ext)
default.set('ContentType', content_type)
... | [
"Return",
"a",
"new",
"<Default",
">",
"element",
"with",
"attributes",
"set",
"to",
"parameter",
"values",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/oxml.py#L109-L118 | [
"def",
"new",
"(",
"ext",
",",
"content_type",
")",
":",
"xml",
"=",
"'<Default xmlns=\"%s\"/>'",
"%",
"nsmap",
"[",
"'ct'",
"]",
"default",
"=",
"parse_xml",
"(",
"xml",
")",
"default",
".",
"set",
"(",
"'Extension'",
",",
"ext",
")",
"default",
".",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_Override.new | Return a new ``<Override>`` element with attributes set to parameter
values. | docx/opc/oxml.py | def new(partname, content_type):
"""
Return a new ``<Override>`` element with attributes set to parameter
values.
"""
xml = '<Override xmlns="%s"/>' % nsmap['ct']
override = parse_xml(xml)
override.set('PartName', partname)
override.set('ContentType', cont... | def new(partname, content_type):
"""
Return a new ``<Override>`` element with attributes set to parameter
values.
"""
xml = '<Override xmlns="%s"/>' % nsmap['ct']
override = parse_xml(xml)
override.set('PartName', partname)
override.set('ContentType', cont... | [
"Return",
"a",
"new",
"<Override",
">",
"element",
"with",
"attributes",
"set",
"to",
"parameter",
"values",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/oxml.py#L135-L144 | [
"def",
"new",
"(",
"partname",
",",
"content_type",
")",
":",
"xml",
"=",
"'<Override xmlns=\"%s\"/>'",
"%",
"nsmap",
"[",
"'ct'",
"]",
"override",
"=",
"parse_xml",
"(",
"xml",
")",
"override",
".",
"set",
"(",
"'PartName'",
",",
"partname",
")",
"overrid... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_Relationship.new | Return a new ``<Relationship>`` element. | docx/opc/oxml.py | def new(rId, reltype, target, target_mode=RTM.INTERNAL):
"""
Return a new ``<Relationship>`` element.
"""
xml = '<Relationship xmlns="%s"/>' % nsmap['pr']
relationship = parse_xml(xml)
relationship.set('Id', rId)
relationship.set('Type', reltype)
relations... | def new(rId, reltype, target, target_mode=RTM.INTERNAL):
"""
Return a new ``<Relationship>`` element.
"""
xml = '<Relationship xmlns="%s"/>' % nsmap['pr']
relationship = parse_xml(xml)
relationship.set('Id', rId)
relationship.set('Type', reltype)
relations... | [
"Return",
"a",
"new",
"<Relationship",
">",
"element",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/oxml.py#L161-L172 | [
"def",
"new",
"(",
"rId",
",",
"reltype",
",",
"target",
",",
"target_mode",
"=",
"RTM",
".",
"INTERNAL",
")",
":",
"xml",
"=",
"'<Relationship xmlns=\"%s\"/>'",
"%",
"nsmap",
"[",
"'pr'",
"]",
"relationship",
"=",
"parse_xml",
"(",
"xml",
")",
"relationsh... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_Relationships.add_rel | Add a child ``<Relationship>`` element with attributes set according
to parameter values. | docx/opc/oxml.py | def add_rel(self, rId, reltype, target, is_external=False):
"""
Add a child ``<Relationship>`` element with attributes set according
to parameter values.
"""
target_mode = RTM.EXTERNAL if is_external else RTM.INTERNAL
relationship = CT_Relationship.new(rId, reltype, targe... | def add_rel(self, rId, reltype, target, is_external=False):
"""
Add a child ``<Relationship>`` element with attributes set according
to parameter values.
"""
target_mode = RTM.EXTERNAL if is_external else RTM.INTERNAL
relationship = CT_Relationship.new(rId, reltype, targe... | [
"Add",
"a",
"child",
"<Relationship",
">",
"element",
"with",
"attributes",
"set",
"according",
"to",
"parameter",
"values",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/oxml.py#L212-L219 | [
"def",
"add_rel",
"(",
"self",
",",
"rId",
",",
"reltype",
",",
"target",
",",
"is_external",
"=",
"False",
")",
":",
"target_mode",
"=",
"RTM",
".",
"EXTERNAL",
"if",
"is_external",
"else",
"RTM",
".",
"INTERNAL",
"relationship",
"=",
"CT_Relationship",
"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_Types.add_default | Add a child ``<Default>`` element with attributes set to parameter
values. | docx/opc/oxml.py | def add_default(self, ext, content_type):
"""
Add a child ``<Default>`` element with attributes set to parameter
values.
"""
default = CT_Default.new(ext, content_type)
self.append(default) | def add_default(self, ext, content_type):
"""
Add a child ``<Default>`` element with attributes set to parameter
values.
"""
default = CT_Default.new(ext, content_type)
self.append(default) | [
"Add",
"a",
"child",
"<Default",
">",
"element",
"with",
"attributes",
"set",
"to",
"parameter",
"values",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/oxml.py#L251-L257 | [
"def",
"add_default",
"(",
"self",
",",
"ext",
",",
"content_type",
")",
":",
"default",
"=",
"CT_Default",
".",
"new",
"(",
"ext",
",",
"content_type",
")",
"self",
".",
"append",
"(",
"default",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_Types.add_override | Add a child ``<Override>`` element with attributes set to parameter
values. | docx/opc/oxml.py | def add_override(self, partname, content_type):
"""
Add a child ``<Override>`` element with attributes set to parameter
values.
"""
override = CT_Override.new(partname, content_type)
self.append(override) | def add_override(self, partname, content_type):
"""
Add a child ``<Override>`` element with attributes set to parameter
values.
"""
override = CT_Override.new(partname, content_type)
self.append(override) | [
"Add",
"a",
"child",
"<Override",
">",
"element",
"with",
"attributes",
"set",
"to",
"parameter",
"values",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/oxml.py#L259-L265 | [
"def",
"add_override",
"(",
"self",
",",
"partname",
",",
"content_type",
")",
":",
"override",
"=",
"CT_Override",
".",
"new",
"(",
"partname",
",",
"content_type",
")",
"self",
".",
"append",
"(",
"override",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | BlockItemContainer.add_paragraph | Return a paragraph newly added to the end of the content in this
container, having *text* in a single run if present, and having
paragraph style *style*. If *style* is |None|, no paragraph style is
applied, which has the same effect as applying the 'Normal' style. | docx/blkcntnr.py | def add_paragraph(self, text='', style=None):
"""
Return a paragraph newly added to the end of the content in this
container, having *text* in a single run if present, and having
paragraph style *style*. If *style* is |None|, no paragraph style is
applied, which has the same effe... | def add_paragraph(self, text='', style=None):
"""
Return a paragraph newly added to the end of the content in this
container, having *text* in a single run if present, and having
paragraph style *style*. If *style* is |None|, no paragraph style is
applied, which has the same effe... | [
"Return",
"a",
"paragraph",
"newly",
"added",
"to",
"the",
"end",
"of",
"the",
"content",
"in",
"this",
"container",
"having",
"*",
"text",
"*",
"in",
"a",
"single",
"run",
"if",
"present",
"and",
"having",
"paragraph",
"style",
"*",
"style",
"*",
".",
... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/blkcntnr.py#L28-L40 | [
"def",
"add_paragraph",
"(",
"self",
",",
"text",
"=",
"''",
",",
"style",
"=",
"None",
")",
":",
"paragraph",
"=",
"self",
".",
"_add_paragraph",
"(",
")",
"if",
"text",
":",
"paragraph",
".",
"add_run",
"(",
"text",
")",
"if",
"style",
"is",
"not",... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | BlockItemContainer.add_table | Return a table of *width* having *rows* rows and *cols* columns,
newly appended to the content in this container. *width* is evenly
distributed between the table columns. | docx/blkcntnr.py | def add_table(self, rows, cols, width):
"""
Return a table of *width* having *rows* rows and *cols* columns,
newly appended to the content in this container. *width* is evenly
distributed between the table columns.
"""
from .table import Table
tbl = CT_Tbl.new_tbl... | def add_table(self, rows, cols, width):
"""
Return a table of *width* having *rows* rows and *cols* columns,
newly appended to the content in this container. *width* is evenly
distributed between the table columns.
"""
from .table import Table
tbl = CT_Tbl.new_tbl... | [
"Return",
"a",
"table",
"of",
"*",
"width",
"*",
"having",
"*",
"rows",
"*",
"rows",
"and",
"*",
"cols",
"*",
"columns",
"newly",
"appended",
"to",
"the",
"content",
"in",
"this",
"container",
".",
"*",
"width",
"*",
"is",
"evenly",
"distributed",
"bet... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/blkcntnr.py#L42-L51 | [
"def",
"add_table",
"(",
"self",
",",
"rows",
",",
"cols",
",",
"width",
")",
":",
"from",
".",
"table",
"import",
"Table",
"tbl",
"=",
"CT_Tbl",
".",
"new_tbl",
"(",
"rows",
",",
"cols",
",",
"width",
")",
"self",
".",
"_element",
".",
"_insert_tbl"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | BlockItemContainer.tables | A list containing the tables in this container, in document order.
Read-only. | docx/blkcntnr.py | def tables(self):
"""
A list containing the tables in this container, in document order.
Read-only.
"""
from .table import Table
return [Table(tbl, self) for tbl in self._element.tbl_lst] | def tables(self):
"""
A list containing the tables in this container, in document order.
Read-only.
"""
from .table import Table
return [Table(tbl, self) for tbl in self._element.tbl_lst] | [
"A",
"list",
"containing",
"the",
"tables",
"in",
"this",
"container",
"in",
"document",
"order",
".",
"Read",
"-",
"only",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/blkcntnr.py#L62-L68 | [
"def",
"tables",
"(",
"self",
")",
":",
"from",
".",
"table",
"import",
"Table",
"return",
"[",
"Table",
"(",
"tbl",
",",
"self",
")",
"for",
"tbl",
"in",
"self",
".",
"_element",
".",
"tbl_lst",
"]"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _ChunkFactory | Return a |_Chunk| subclass instance appropriate to *chunk_type* parsed
from *stream_rdr* at *offset*. | docx/image/png.py | def _ChunkFactory(chunk_type, stream_rdr, offset):
"""
Return a |_Chunk| subclass instance appropriate to *chunk_type* parsed
from *stream_rdr* at *offset*.
"""
chunk_cls_map = {
PNG_CHUNK_TYPE.IHDR: _IHDRChunk,
PNG_CHUNK_TYPE.pHYs: _pHYsChunk,
}
chunk_cls = chunk_cls_map.get... | def _ChunkFactory(chunk_type, stream_rdr, offset):
"""
Return a |_Chunk| subclass instance appropriate to *chunk_type* parsed
from *stream_rdr* at *offset*.
"""
chunk_cls_map = {
PNG_CHUNK_TYPE.IHDR: _IHDRChunk,
PNG_CHUNK_TYPE.pHYs: _pHYsChunk,
}
chunk_cls = chunk_cls_map.get... | [
"Return",
"a",
"|_Chunk|",
"subclass",
"instance",
"appropriate",
"to",
"*",
"chunk_type",
"*",
"parsed",
"from",
"*",
"stream_rdr",
"*",
"at",
"*",
"offset",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/png.py#L204-L214 | [
"def",
"_ChunkFactory",
"(",
"chunk_type",
",",
"stream_rdr",
",",
"offset",
")",
":",
"chunk_cls_map",
"=",
"{",
"PNG_CHUNK_TYPE",
".",
"IHDR",
":",
"_IHDRChunk",
",",
"PNG_CHUNK_TYPE",
".",
"pHYs",
":",
"_pHYsChunk",
",",
"}",
"chunk_cls",
"=",
"chunk_cls_ma... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _PngParser.horz_dpi | Integer dots per inch for the width of this image. Defaults to 72
when not present in the file, as is often the case. | docx/image/png.py | def horz_dpi(self):
"""
Integer dots per inch for the width of this image. Defaults to 72
when not present in the file, as is often the case.
"""
pHYs = self._chunks.pHYs
if pHYs is None:
return 72
return self._dpi(pHYs.units_specifier, pHYs.horz_px_pe... | def horz_dpi(self):
"""
Integer dots per inch for the width of this image. Defaults to 72
when not present in the file, as is often the case.
"""
pHYs = self._chunks.pHYs
if pHYs is None:
return 72
return self._dpi(pHYs.units_specifier, pHYs.horz_px_pe... | [
"Integer",
"dots",
"per",
"inch",
"for",
"the",
"width",
"of",
"this",
"image",
".",
"Defaults",
"to",
"72",
"when",
"not",
"present",
"in",
"the",
"file",
"as",
"is",
"often",
"the",
"case",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/png.py#L81-L89 | [
"def",
"horz_dpi",
"(",
"self",
")",
":",
"pHYs",
"=",
"self",
".",
"_chunks",
".",
"pHYs",
"if",
"pHYs",
"is",
"None",
":",
"return",
"72",
"return",
"self",
".",
"_dpi",
"(",
"pHYs",
".",
"units_specifier",
",",
"pHYs",
".",
"horz_px_per_unit",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _PngParser.vert_dpi | Integer dots per inch for the height of this image. Defaults to 72
when not present in the file, as is often the case. | docx/image/png.py | def vert_dpi(self):
"""
Integer dots per inch for the height of this image. Defaults to 72
when not present in the file, as is often the case.
"""
pHYs = self._chunks.pHYs
if pHYs is None:
return 72
return self._dpi(pHYs.units_specifier, pHYs.vert_px_p... | def vert_dpi(self):
"""
Integer dots per inch for the height of this image. Defaults to 72
when not present in the file, as is often the case.
"""
pHYs = self._chunks.pHYs
if pHYs is None:
return 72
return self._dpi(pHYs.units_specifier, pHYs.vert_px_p... | [
"Integer",
"dots",
"per",
"inch",
"for",
"the",
"height",
"of",
"this",
"image",
".",
"Defaults",
"to",
"72",
"when",
"not",
"present",
"in",
"the",
"file",
"as",
"is",
"often",
"the",
"case",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/png.py#L92-L100 | [
"def",
"vert_dpi",
"(",
"self",
")",
":",
"pHYs",
"=",
"self",
".",
"_chunks",
".",
"pHYs",
"if",
"pHYs",
"is",
"None",
":",
"return",
"72",
"return",
"self",
".",
"_dpi",
"(",
"pHYs",
".",
"units_specifier",
",",
"pHYs",
".",
"vert_px_per_unit",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _Chunks.from_stream | Return a |_Chunks| instance containing the PNG chunks in *stream*. | docx/image/png.py | def from_stream(cls, stream):
"""
Return a |_Chunks| instance containing the PNG chunks in *stream*.
"""
chunk_parser = _ChunkParser.from_stream(stream)
chunks = [chunk for chunk in chunk_parser.iter_chunks()]
return cls(chunks) | def from_stream(cls, stream):
"""
Return a |_Chunks| instance containing the PNG chunks in *stream*.
"""
chunk_parser = _ChunkParser.from_stream(stream)
chunks = [chunk for chunk in chunk_parser.iter_chunks()]
return cls(chunks) | [
"Return",
"a",
"|_Chunks|",
"instance",
"containing",
"the",
"PNG",
"chunks",
"in",
"*",
"stream",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/png.py#L122-L128 | [
"def",
"from_stream",
"(",
"cls",
",",
"stream",
")",
":",
"chunk_parser",
"=",
"_ChunkParser",
".",
"from_stream",
"(",
"stream",
")",
"chunks",
"=",
"[",
"chunk",
"for",
"chunk",
"in",
"chunk_parser",
".",
"iter_chunks",
"(",
")",
"]",
"return",
"cls",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _Chunks.IHDR | IHDR chunk in PNG image | docx/image/png.py | def IHDR(self):
"""
IHDR chunk in PNG image
"""
match = lambda chunk: chunk.type_name == PNG_CHUNK_TYPE.IHDR # noqa
IHDR = self._find_first(match)
if IHDR is None:
raise InvalidImageStreamError('no IHDR chunk in PNG image')
return IHDR | def IHDR(self):
"""
IHDR chunk in PNG image
"""
match = lambda chunk: chunk.type_name == PNG_CHUNK_TYPE.IHDR # noqa
IHDR = self._find_first(match)
if IHDR is None:
raise InvalidImageStreamError('no IHDR chunk in PNG image')
return IHDR | [
"IHDR",
"chunk",
"in",
"PNG",
"image"
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/png.py#L131-L139 | [
"def",
"IHDR",
"(",
"self",
")",
":",
"match",
"=",
"lambda",
"chunk",
":",
"chunk",
".",
"type_name",
"==",
"PNG_CHUNK_TYPE",
".",
"IHDR",
"# noqa",
"IHDR",
"=",
"self",
".",
"_find_first",
"(",
"match",
")",
"if",
"IHDR",
"is",
"None",
":",
"raise",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _Chunks.pHYs | pHYs chunk in PNG image, or |None| if not present | docx/image/png.py | def pHYs(self):
"""
pHYs chunk in PNG image, or |None| if not present
"""
match = lambda chunk: chunk.type_name == PNG_CHUNK_TYPE.pHYs # noqa
return self._find_first(match) | def pHYs(self):
"""
pHYs chunk in PNG image, or |None| if not present
"""
match = lambda chunk: chunk.type_name == PNG_CHUNK_TYPE.pHYs # noqa
return self._find_first(match) | [
"pHYs",
"chunk",
"in",
"PNG",
"image",
"or",
"|None|",
"if",
"not",
"present"
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/png.py#L142-L147 | [
"def",
"pHYs",
"(",
"self",
")",
":",
"match",
"=",
"lambda",
"chunk",
":",
"chunk",
".",
"type_name",
"==",
"PNG_CHUNK_TYPE",
".",
"pHYs",
"# noqa",
"return",
"self",
".",
"_find_first",
"(",
"match",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _ChunkParser.iter_chunks | Generate a |_Chunk| subclass instance for each chunk in this parser's
PNG stream, in the order encountered in the stream. | docx/image/png.py | def iter_chunks(self):
"""
Generate a |_Chunk| subclass instance for each chunk in this parser's
PNG stream, in the order encountered in the stream.
"""
for chunk_type, offset in self._iter_chunk_offsets():
chunk = _ChunkFactory(chunk_type, self._stream_rdr, offset)
... | def iter_chunks(self):
"""
Generate a |_Chunk| subclass instance for each chunk in this parser's
PNG stream, in the order encountered in the stream.
"""
for chunk_type, offset in self._iter_chunk_offsets():
chunk = _ChunkFactory(chunk_type, self._stream_rdr, offset)
... | [
"Generate",
"a",
"|_Chunk|",
"subclass",
"instance",
"for",
"each",
"chunk",
"in",
"this",
"parser",
"s",
"PNG",
"stream",
"in",
"the",
"order",
"encountered",
"in",
"the",
"stream",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/png.py#L177-L184 | [
"def",
"iter_chunks",
"(",
"self",
")",
":",
"for",
"chunk_type",
",",
"offset",
"in",
"self",
".",
"_iter_chunk_offsets",
"(",
")",
":",
"chunk",
"=",
"_ChunkFactory",
"(",
"chunk_type",
",",
"self",
".",
"_stream_rdr",
",",
"offset",
")",
"yield",
"chunk... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _ChunkParser._iter_chunk_offsets | Generate a (chunk_type, chunk_offset) 2-tuple for each of the chunks
in the PNG image stream. Iteration stops after the IEND chunk is
returned. | docx/image/png.py | def _iter_chunk_offsets(self):
"""
Generate a (chunk_type, chunk_offset) 2-tuple for each of the chunks
in the PNG image stream. Iteration stops after the IEND chunk is
returned.
"""
chunk_offset = 8
while True:
chunk_data_len = self._stream_rdr.read_l... | def _iter_chunk_offsets(self):
"""
Generate a (chunk_type, chunk_offset) 2-tuple for each of the chunks
in the PNG image stream. Iteration stops after the IEND chunk is
returned.
"""
chunk_offset = 8
while True:
chunk_data_len = self._stream_rdr.read_l... | [
"Generate",
"a",
"(",
"chunk_type",
"chunk_offset",
")",
"2",
"-",
"tuple",
"for",
"each",
"of",
"the",
"chunks",
"in",
"the",
"PNG",
"image",
"stream",
".",
"Iteration",
"stops",
"after",
"the",
"IEND",
"chunk",
"is",
"returned",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/png.py#L186-L201 | [
"def",
"_iter_chunk_offsets",
"(",
"self",
")",
":",
"chunk_offset",
"=",
"8",
"while",
"True",
":",
"chunk_data_len",
"=",
"self",
".",
"_stream_rdr",
".",
"read_long",
"(",
"chunk_offset",
")",
"chunk_type",
"=",
"self",
".",
"_stream_rdr",
".",
"read_str",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _IHDRChunk.from_offset | Return an _IHDRChunk instance containing the image dimensions
extracted from the IHDR chunk in *stream* at *offset*. | docx/image/png.py | def from_offset(cls, chunk_type, stream_rdr, offset):
"""
Return an _IHDRChunk instance containing the image dimensions
extracted from the IHDR chunk in *stream* at *offset*.
"""
px_width = stream_rdr.read_long(offset)
px_height = stream_rdr.read_long(offset, 4)
r... | def from_offset(cls, chunk_type, stream_rdr, offset):
"""
Return an _IHDRChunk instance containing the image dimensions
extracted from the IHDR chunk in *stream* at *offset*.
"""
px_width = stream_rdr.read_long(offset)
px_height = stream_rdr.read_long(offset, 4)
r... | [
"Return",
"an",
"_IHDRChunk",
"instance",
"containing",
"the",
"image",
"dimensions",
"extracted",
"from",
"the",
"IHDR",
"chunk",
"in",
"*",
"stream",
"*",
"at",
"*",
"offset",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/png.py#L251-L258 | [
"def",
"from_offset",
"(",
"cls",
",",
"chunk_type",
",",
"stream_rdr",
",",
"offset",
")",
":",
"px_width",
"=",
"stream_rdr",
".",
"read_long",
"(",
"offset",
")",
"px_height",
"=",
"stream_rdr",
".",
"read_long",
"(",
"offset",
",",
"4",
")",
"return",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _pHYsChunk.from_offset | Return a _pHYsChunk instance containing the image resolution
extracted from the pHYs chunk in *stream* at *offset*. | docx/image/png.py | def from_offset(cls, chunk_type, stream_rdr, offset):
"""
Return a _pHYsChunk instance containing the image resolution
extracted from the pHYs chunk in *stream* at *offset*.
"""
horz_px_per_unit = stream_rdr.read_long(offset)
vert_px_per_unit = stream_rdr.read_long(offset... | def from_offset(cls, chunk_type, stream_rdr, offset):
"""
Return a _pHYsChunk instance containing the image resolution
extracted from the pHYs chunk in *stream* at *offset*.
"""
horz_px_per_unit = stream_rdr.read_long(offset)
vert_px_per_unit = stream_rdr.read_long(offset... | [
"Return",
"a",
"_pHYsChunk",
"instance",
"containing",
"the",
"image",
"resolution",
"extracted",
"from",
"the",
"pHYs",
"chunk",
"in",
"*",
"stream",
"*",
"at",
"*",
"offset",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/png.py#L281-L291 | [
"def",
"from_offset",
"(",
"cls",
",",
"chunk_type",
",",
"stream_rdr",
",",
"offset",
")",
":",
"horz_px_per_unit",
"=",
"stream_rdr",
".",
"read_long",
"(",
"offset",
")",
"vert_px_per_unit",
"=",
"stream_rdr",
".",
"read_long",
"(",
"offset",
",",
"4",
")... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | StreamReader.read_byte | Return the int value of the byte at the file position defined by
self._base_offset + *base* + *offset*. If *base* is None, the byte is
read from the current position in the stream. | docx/image/helpers.py | def read_byte(self, base, offset=0):
"""
Return the int value of the byte at the file position defined by
self._base_offset + *base* + *offset*. If *base* is None, the byte is
read from the current position in the stream.
"""
fmt = 'B'
return self._read_int(fmt, b... | def read_byte(self, base, offset=0):
"""
Return the int value of the byte at the file position defined by
self._base_offset + *base* + *offset*. If *base* is None, the byte is
read from the current position in the stream.
"""
fmt = 'B'
return self._read_int(fmt, b... | [
"Return",
"the",
"int",
"value",
"of",
"the",
"byte",
"at",
"the",
"file",
"position",
"defined",
"by",
"self",
".",
"_base_offset",
"+",
"*",
"base",
"*",
"+",
"*",
"offset",
"*",
".",
"If",
"*",
"base",
"*",
"is",
"None",
"the",
"byte",
"is",
"re... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/helpers.py#L34-L41 | [
"def",
"read_byte",
"(",
"self",
",",
"base",
",",
"offset",
"=",
"0",
")",
":",
"fmt",
"=",
"'B'",
"return",
"self",
".",
"_read_int",
"(",
"fmt",
",",
"base",
",",
"offset",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | StreamReader.read_long | Return the int value of the four bytes at the file position defined by
self._base_offset + *base* + *offset*. If *base* is None, the long is
read from the current position in the stream. The endian setting of
this instance is used to interpret the byte layout of the long. | docx/image/helpers.py | def read_long(self, base, offset=0):
"""
Return the int value of the four bytes at the file position defined by
self._base_offset + *base* + *offset*. If *base* is None, the long is
read from the current position in the stream. The endian setting of
this instance is used to inter... | def read_long(self, base, offset=0):
"""
Return the int value of the four bytes at the file position defined by
self._base_offset + *base* + *offset*. If *base* is None, the long is
read from the current position in the stream. The endian setting of
this instance is used to inter... | [
"Return",
"the",
"int",
"value",
"of",
"the",
"four",
"bytes",
"at",
"the",
"file",
"position",
"defined",
"by",
"self",
".",
"_base_offset",
"+",
"*",
"base",
"*",
"+",
"*",
"offset",
"*",
".",
"If",
"*",
"base",
"*",
"is",
"None",
"the",
"long",
... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/helpers.py#L43-L51 | [
"def",
"read_long",
"(",
"self",
",",
"base",
",",
"offset",
"=",
"0",
")",
":",
"fmt",
"=",
"'<L'",
"if",
"self",
".",
"_byte_order",
"is",
"LITTLE_ENDIAN",
"else",
"'>L'",
"return",
"self",
".",
"_read_int",
"(",
"fmt",
",",
"base",
",",
"offset",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | StreamReader.read_short | Return the int value of the two bytes at the file position determined
by *base* and *offset*, similarly to ``read_long()`` above. | docx/image/helpers.py | def read_short(self, base, offset=0):
"""
Return the int value of the two bytes at the file position determined
by *base* and *offset*, similarly to ``read_long()`` above.
"""
fmt = b'<H' if self._byte_order is LITTLE_ENDIAN else b'>H'
return self._read_int(fmt, base, off... | def read_short(self, base, offset=0):
"""
Return the int value of the two bytes at the file position determined
by *base* and *offset*, similarly to ``read_long()`` above.
"""
fmt = b'<H' if self._byte_order is LITTLE_ENDIAN else b'>H'
return self._read_int(fmt, base, off... | [
"Return",
"the",
"int",
"value",
"of",
"the",
"two",
"bytes",
"at",
"the",
"file",
"position",
"determined",
"by",
"*",
"base",
"*",
"and",
"*",
"offset",
"*",
"similarly",
"to",
"read_long",
"()",
"above",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/helpers.py#L53-L59 | [
"def",
"read_short",
"(",
"self",
",",
"base",
",",
"offset",
"=",
"0",
")",
":",
"fmt",
"=",
"b'<H'",
"if",
"self",
".",
"_byte_order",
"is",
"LITTLE_ENDIAN",
"else",
"b'>H'",
"return",
"self",
".",
"_read_int",
"(",
"fmt",
",",
"base",
",",
"offset",... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | StreamReader.read_str | Return a string containing the *char_count* bytes at the file
position determined by self._base_offset + *base* + *offset*. | docx/image/helpers.py | def read_str(self, char_count, base, offset=0):
"""
Return a string containing the *char_count* bytes at the file
position determined by self._base_offset + *base* + *offset*.
"""
def str_struct(char_count):
format_ = '%ds' % char_count
return Struct(forma... | def read_str(self, char_count, base, offset=0):
"""
Return a string containing the *char_count* bytes at the file
position determined by self._base_offset + *base* + *offset*.
"""
def str_struct(char_count):
format_ = '%ds' % char_count
return Struct(forma... | [
"Return",
"a",
"string",
"containing",
"the",
"*",
"char_count",
"*",
"bytes",
"at",
"the",
"file",
"position",
"determined",
"by",
"self",
".",
"_base_offset",
"+",
"*",
"base",
"*",
"+",
"*",
"offset",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/helpers.py#L61-L72 | [
"def",
"read_str",
"(",
"self",
",",
"char_count",
",",
"base",
",",
"offset",
"=",
"0",
")",
":",
"def",
"str_struct",
"(",
"char_count",
")",
":",
"format_",
"=",
"'%ds'",
"%",
"char_count",
"return",
"Struct",
"(",
"format_",
")",
"struct",
"=",
"st... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Package._gather_image_parts | Load the image part collection with all the image parts in package. | docx/package.py | def _gather_image_parts(self):
"""Load the image part collection with all the image parts in package."""
for rel in self.iter_rels():
if rel.is_external:
continue
if rel.reltype != RT.IMAGE:
continue
if rel.target_part in self.image_par... | def _gather_image_parts(self):
"""Load the image part collection with all the image parts in package."""
for rel in self.iter_rels():
if rel.is_external:
continue
if rel.reltype != RT.IMAGE:
continue
if rel.target_part in self.image_par... | [
"Load",
"the",
"image",
"part",
"collection",
"with",
"all",
"the",
"image",
"parts",
"in",
"package",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/package.py#L38-L47 | [
"def",
"_gather_image_parts",
"(",
"self",
")",
":",
"for",
"rel",
"in",
"self",
".",
"iter_rels",
"(",
")",
":",
"if",
"rel",
".",
"is_external",
":",
"continue",
"if",
"rel",
".",
"reltype",
"!=",
"RT",
".",
"IMAGE",
":",
"continue",
"if",
"rel",
"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | ImageParts.get_or_add_image_part | Return |ImagePart| object containing image identified by *image_descriptor*.
The image-part is newly created if a matching one is not present in the
collection. | docx/package.py | def get_or_add_image_part(self, image_descriptor):
"""Return |ImagePart| object containing image identified by *image_descriptor*.
The image-part is newly created if a matching one is not present in the
collection.
"""
image = Image.from_file(image_descriptor)
matching_i... | def get_or_add_image_part(self, image_descriptor):
"""Return |ImagePart| object containing image identified by *image_descriptor*.
The image-part is newly created if a matching one is not present in the
collection.
"""
image = Image.from_file(image_descriptor)
matching_i... | [
"Return",
"|ImagePart|",
"object",
"containing",
"image",
"identified",
"by",
"*",
"image_descriptor",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/package.py#L68-L78 | [
"def",
"get_or_add_image_part",
"(",
"self",
",",
"image_descriptor",
")",
":",
"image",
"=",
"Image",
".",
"from_file",
"(",
"image_descriptor",
")",
"matching_image_part",
"=",
"self",
".",
"_get_by_sha1",
"(",
"image",
".",
"sha1",
")",
"if",
"matching_image_... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | ImageParts._add_image_part | Return an |ImagePart| instance newly created from image and appended
to the collection. | docx/package.py | def _add_image_part(self, image):
"""
Return an |ImagePart| instance newly created from image and appended
to the collection.
"""
partname = self._next_image_partname(image.ext)
image_part = ImagePart.from_image(image, partname)
self.append(image_part)
ret... | def _add_image_part(self, image):
"""
Return an |ImagePart| instance newly created from image and appended
to the collection.
"""
partname = self._next_image_partname(image.ext)
image_part = ImagePart.from_image(image, partname)
self.append(image_part)
ret... | [
"Return",
"an",
"|ImagePart|",
"instance",
"newly",
"created",
"from",
"image",
"and",
"appended",
"to",
"the",
"collection",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/package.py#L80-L88 | [
"def",
"_add_image_part",
"(",
"self",
",",
"image",
")",
":",
"partname",
"=",
"self",
".",
"_next_image_partname",
"(",
"image",
".",
"ext",
")",
"image_part",
"=",
"ImagePart",
".",
"from_image",
"(",
"image",
",",
"partname",
")",
"self",
".",
"append"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | ImageParts._get_by_sha1 | Return the image part in this collection having a SHA1 hash matching
*sha1*, or |None| if not found. | docx/package.py | def _get_by_sha1(self, sha1):
"""
Return the image part in this collection having a SHA1 hash matching
*sha1*, or |None| if not found.
"""
for image_part in self._image_parts:
if image_part.sha1 == sha1:
return image_part
return None | def _get_by_sha1(self, sha1):
"""
Return the image part in this collection having a SHA1 hash matching
*sha1*, or |None| if not found.
"""
for image_part in self._image_parts:
if image_part.sha1 == sha1:
return image_part
return None | [
"Return",
"the",
"image",
"part",
"in",
"this",
"collection",
"having",
"a",
"SHA1",
"hash",
"matching",
"*",
"sha1",
"*",
"or",
"|None|",
"if",
"not",
"found",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/package.py#L90-L98 | [
"def",
"_get_by_sha1",
"(",
"self",
",",
"sha1",
")",
":",
"for",
"image_part",
"in",
"self",
".",
"_image_parts",
":",
"if",
"image_part",
".",
"sha1",
"==",
"sha1",
":",
"return",
"image_part",
"return",
"None"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | ImageParts._next_image_partname | The next available image partname, starting from
``/word/media/image1.{ext}`` where unused numbers are reused. The
partname is unique by number, without regard to the extension. *ext*
does not include the leading period. | docx/package.py | def _next_image_partname(self, ext):
"""
The next available image partname, starting from
``/word/media/image1.{ext}`` where unused numbers are reused. The
partname is unique by number, without regard to the extension. *ext*
does not include the leading period.
"""
... | def _next_image_partname(self, ext):
"""
The next available image partname, starting from
``/word/media/image1.{ext}`` where unused numbers are reused. The
partname is unique by number, without regard to the extension. *ext*
does not include the leading period.
"""
... | [
"The",
"next",
"available",
"image",
"partname",
"starting",
"from",
"/",
"word",
"/",
"media",
"/",
"image1",
".",
"{",
"ext",
"}",
"where",
"unused",
"numbers",
"are",
"reused",
".",
"The",
"partname",
"is",
"unique",
"by",
"number",
"without",
"regard",... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/package.py#L100-L113 | [
"def",
"_next_image_partname",
"(",
"self",
",",
"ext",
")",
":",
"def",
"image_partname",
"(",
"n",
")",
":",
"return",
"PackURI",
"(",
"'/word/media/image%d.%s'",
"%",
"(",
"n",
",",
"ext",
")",
")",
"used_numbers",
"=",
"[",
"image_part",
".",
"partname... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _BaseHeaderFooter._get_or_add_definition | Return HeaderPart or FooterPart object for this section.
If this header/footer inherits its content, the part for the prior header/footer
is returned; this process continue recursively until a definition is found. If
the definition cannot be inherited (because the header/footer belongs to the
... | docx/section.py | def _get_or_add_definition(self):
"""Return HeaderPart or FooterPart object for this section.
If this header/footer inherits its content, the part for the prior header/footer
is returned; this process continue recursively until a definition is found. If
the definition cannot be inherite... | def _get_or_add_definition(self):
"""Return HeaderPart or FooterPart object for this section.
If this header/footer inherits its content, the part for the prior header/footer
is returned; this process continue recursively until a definition is found. If
the definition cannot be inherite... | [
"Return",
"HeaderPart",
"or",
"FooterPart",
"object",
"for",
"this",
"section",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/section.py#L325-L343 | [
"def",
"_get_or_add_definition",
"(",
"self",
")",
":",
"# ---note this method is called recursively to access inherited definitions---",
"# ---case-1: definition is not inherited---",
"if",
"self",
".",
"_has_definition",
":",
"return",
"self",
".",
"_definition",
"# ---case-2: de... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _Footer._add_definition | Return newly-added footer part. | docx/section.py | def _add_definition(self):
"""Return newly-added footer part."""
footer_part, rId = self._document_part.add_footer_part()
self._sectPr.add_footerReference(self._hdrftr_index, rId)
return footer_part | def _add_definition(self):
"""Return newly-added footer part."""
footer_part, rId = self._document_part.add_footer_part()
self._sectPr.add_footerReference(self._hdrftr_index, rId)
return footer_part | [
"Return",
"newly",
"-",
"added",
"footer",
"part",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/section.py#L369-L373 | [
"def",
"_add_definition",
"(",
"self",
")",
":",
"footer_part",
",",
"rId",
"=",
"self",
".",
"_document_part",
".",
"add_footer_part",
"(",
")",
"self",
".",
"_sectPr",
".",
"add_footerReference",
"(",
"self",
".",
"_hdrftr_index",
",",
"rId",
")",
"return"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _Footer._definition | |FooterPart| object containing content of this footer. | docx/section.py | def _definition(self):
"""|FooterPart| object containing content of this footer."""
footerReference = self._sectPr.get_footerReference(self._hdrftr_index)
return self._document_part.footer_part(footerReference.rId) | def _definition(self):
"""|FooterPart| object containing content of this footer."""
footerReference = self._sectPr.get_footerReference(self._hdrftr_index)
return self._document_part.footer_part(footerReference.rId) | [
"|FooterPart|",
"object",
"containing",
"content",
"of",
"this",
"footer",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/section.py#L376-L379 | [
"def",
"_definition",
"(",
"self",
")",
":",
"footerReference",
"=",
"self",
".",
"_sectPr",
".",
"get_footerReference",
"(",
"self",
".",
"_hdrftr_index",
")",
"return",
"self",
".",
"_document_part",
".",
"footer_part",
"(",
"footerReference",
".",
"rId",
")... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _Footer._drop_definition | Remove footer definition (footer part) associated with this section. | docx/section.py | def _drop_definition(self):
"""Remove footer definition (footer part) associated with this section."""
rId = self._sectPr.remove_footerReference(self._hdrftr_index)
self._document_part.drop_rel(rId) | def _drop_definition(self):
"""Remove footer definition (footer part) associated with this section."""
rId = self._sectPr.remove_footerReference(self._hdrftr_index)
self._document_part.drop_rel(rId) | [
"Remove",
"footer",
"definition",
"(",
"footer",
"part",
")",
"associated",
"with",
"this",
"section",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/section.py#L381-L384 | [
"def",
"_drop_definition",
"(",
"self",
")",
":",
"rId",
"=",
"self",
".",
"_sectPr",
".",
"remove_footerReference",
"(",
"self",
".",
"_hdrftr_index",
")",
"self",
".",
"_document_part",
".",
"drop_rel",
"(",
"rId",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _Footer._has_definition | True if a footer is defined for this section. | docx/section.py | def _has_definition(self):
"""True if a footer is defined for this section."""
footerReference = self._sectPr.get_footerReference(self._hdrftr_index)
return False if footerReference is None else True | def _has_definition(self):
"""True if a footer is defined for this section."""
footerReference = self._sectPr.get_footerReference(self._hdrftr_index)
return False if footerReference is None else True | [
"True",
"if",
"a",
"footer",
"is",
"defined",
"for",
"this",
"section",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/section.py#L387-L390 | [
"def",
"_has_definition",
"(",
"self",
")",
":",
"footerReference",
"=",
"self",
".",
"_sectPr",
".",
"get_footerReference",
"(",
"self",
".",
"_hdrftr_index",
")",
"return",
"False",
"if",
"footerReference",
"is",
"None",
"else",
"True"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _Footer._prior_headerfooter | |_Footer| proxy on prior sectPr element or None if this is first section. | docx/section.py | def _prior_headerfooter(self):
"""|_Footer| proxy on prior sectPr element or None if this is first section."""
preceding_sectPr = self._sectPr.preceding_sectPr
return (
None if preceding_sectPr is None
else _Footer(preceding_sectPr, self._document_part, self._hdrftr_index... | def _prior_headerfooter(self):
"""|_Footer| proxy on prior sectPr element or None if this is first section."""
preceding_sectPr = self._sectPr.preceding_sectPr
return (
None if preceding_sectPr is None
else _Footer(preceding_sectPr, self._document_part, self._hdrftr_index... | [
"|_Footer|",
"proxy",
"on",
"prior",
"sectPr",
"element",
"or",
"None",
"if",
"this",
"is",
"first",
"section",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/section.py#L393-L399 | [
"def",
"_prior_headerfooter",
"(",
"self",
")",
":",
"preceding_sectPr",
"=",
"self",
".",
"_sectPr",
".",
"preceding_sectPr",
"return",
"(",
"None",
"if",
"preceding_sectPr",
"is",
"None",
"else",
"_Footer",
"(",
"preceding_sectPr",
",",
"self",
".",
"_document... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _Header._add_definition | Return newly-added header part. | docx/section.py | def _add_definition(self):
"""Return newly-added header part."""
header_part, rId = self._document_part.add_header_part()
self._sectPr.add_headerReference(self._hdrftr_index, rId)
return header_part | def _add_definition(self):
"""Return newly-added header part."""
header_part, rId = self._document_part.add_header_part()
self._sectPr.add_headerReference(self._hdrftr_index, rId)
return header_part | [
"Return",
"newly",
"-",
"added",
"header",
"part",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/section.py#L412-L416 | [
"def",
"_add_definition",
"(",
"self",
")",
":",
"header_part",
",",
"rId",
"=",
"self",
".",
"_document_part",
".",
"add_header_part",
"(",
")",
"self",
".",
"_sectPr",
".",
"add_headerReference",
"(",
"self",
".",
"_hdrftr_index",
",",
"rId",
")",
"return"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _Header._definition | |HeaderPart| object containing content of this header. | docx/section.py | def _definition(self):
"""|HeaderPart| object containing content of this header."""
headerReference = self._sectPr.get_headerReference(self._hdrftr_index)
return self._document_part.header_part(headerReference.rId) | def _definition(self):
"""|HeaderPart| object containing content of this header."""
headerReference = self._sectPr.get_headerReference(self._hdrftr_index)
return self._document_part.header_part(headerReference.rId) | [
"|HeaderPart|",
"object",
"containing",
"content",
"of",
"this",
"header",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/section.py#L419-L422 | [
"def",
"_definition",
"(",
"self",
")",
":",
"headerReference",
"=",
"self",
".",
"_sectPr",
".",
"get_headerReference",
"(",
"self",
".",
"_hdrftr_index",
")",
"return",
"self",
".",
"_document_part",
".",
"header_part",
"(",
"headerReference",
".",
"rId",
")... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _Header._drop_definition | Remove header definition associated with this section. | docx/section.py | def _drop_definition(self):
"""Remove header definition associated with this section."""
rId = self._sectPr.remove_headerReference(self._hdrftr_index)
self._document_part.drop_header_part(rId) | def _drop_definition(self):
"""Remove header definition associated with this section."""
rId = self._sectPr.remove_headerReference(self._hdrftr_index)
self._document_part.drop_header_part(rId) | [
"Remove",
"header",
"definition",
"associated",
"with",
"this",
"section",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/section.py#L424-L427 | [
"def",
"_drop_definition",
"(",
"self",
")",
":",
"rId",
"=",
"self",
".",
"_sectPr",
".",
"remove_headerReference",
"(",
"self",
".",
"_hdrftr_index",
")",
"self",
".",
"_document_part",
".",
"drop_header_part",
"(",
"rId",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _Header._has_definition | True if a header is explicitly defined for this section. | docx/section.py | def _has_definition(self):
"""True if a header is explicitly defined for this section."""
headerReference = self._sectPr.get_headerReference(self._hdrftr_index)
return False if headerReference is None else True | def _has_definition(self):
"""True if a header is explicitly defined for this section."""
headerReference = self._sectPr.get_headerReference(self._hdrftr_index)
return False if headerReference is None else True | [
"True",
"if",
"a",
"header",
"is",
"explicitly",
"defined",
"for",
"this",
"section",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/section.py#L430-L433 | [
"def",
"_has_definition",
"(",
"self",
")",
":",
"headerReference",
"=",
"self",
".",
"_sectPr",
".",
"get_headerReference",
"(",
"self",
".",
"_hdrftr_index",
")",
"return",
"False",
"if",
"headerReference",
"is",
"None",
"else",
"True"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _Header._prior_headerfooter | |_Header| proxy on prior sectPr element or None if this is first section. | docx/section.py | def _prior_headerfooter(self):
"""|_Header| proxy on prior sectPr element or None if this is first section."""
preceding_sectPr = self._sectPr.preceding_sectPr
return (
None if preceding_sectPr is None
else _Header(preceding_sectPr, self._document_part, self._hdrftr_index... | def _prior_headerfooter(self):
"""|_Header| proxy on prior sectPr element or None if this is first section."""
preceding_sectPr = self._sectPr.preceding_sectPr
return (
None if preceding_sectPr is None
else _Header(preceding_sectPr, self._document_part, self._hdrftr_index... | [
"|_Header|",
"proxy",
"on",
"prior",
"sectPr",
"element",
"or",
"None",
"if",
"this",
"is",
"first",
"section",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/section.py#L436-L442 | [
"def",
"_prior_headerfooter",
"(",
"self",
")",
":",
"preceding_sectPr",
"=",
"self",
".",
"_sectPr",
".",
"preceding_sectPr",
"return",
"(",
"None",
"if",
"preceding_sectPr",
"is",
"None",
"else",
"_Header",
"(",
"preceding_sectPr",
",",
"self",
".",
"_document... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Document.add_heading | Return a heading paragraph newly added to the end of the document.
The heading paragraph will contain *text* and have 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 `Headin... | docx/document.py | def add_heading(self, text="", level=1):
"""Return a heading paragraph newly added to the end of the document.
The heading paragraph will contain *text* and have its paragraph style
determined by *level*. If *level* is 0, the style is set to `Title`. If *level*
is 1 (or omitted), `Headi... | def add_heading(self, text="", level=1):
"""Return a heading paragraph newly added to the end of the document.
The heading paragraph will contain *text* and have its paragraph style
determined by *level*. If *level* is 0, the style is set to `Title`. If *level*
is 1 (or omitted), `Headi... | [
"Return",
"a",
"heading",
"paragraph",
"newly",
"added",
"to",
"the",
"end",
"of",
"the",
"document",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/document.py#L28-L39 | [
"def",
"add_heading",
"(",
"self",
",",
"text",
"=",
"\"\"",
",",
"level",
"=",
"1",
")",
":",
"if",
"not",
"0",
"<=",
"level",
"<=",
"9",
":",
"raise",
"ValueError",
"(",
"\"level must be in range 0-9, got %d\"",
"%",
"level",
")",
"style",
"=",
"\"Titl... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Document.add_page_break | Return newly |Paragraph| object containing only a page break. | docx/document.py | def add_page_break(self):
"""Return newly |Paragraph| object containing only a page break."""
paragraph = self.add_paragraph()
paragraph.add_run().add_break(WD_BREAK.PAGE)
return paragraph | def add_page_break(self):
"""Return newly |Paragraph| object containing only a page break."""
paragraph = self.add_paragraph()
paragraph.add_run().add_break(WD_BREAK.PAGE)
return paragraph | [
"Return",
"newly",
"|Paragraph|",
"object",
"containing",
"only",
"a",
"page",
"break",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/document.py#L41-L45 | [
"def",
"add_page_break",
"(",
"self",
")",
":",
"paragraph",
"=",
"self",
".",
"add_paragraph",
"(",
")",
"paragraph",
".",
"add_run",
"(",
")",
".",
"add_break",
"(",
"WD_BREAK",
".",
"PAGE",
")",
"return",
"paragraph"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Document.add_picture | 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... | docx/document.py | def add_picture(self, image_path_or_stream, width=None, height=None):
"""
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 ... | def add_picture(self, image_path_or_stream, width=None, height=None):
"""
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 ... | [
"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... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/document.py#L58-L72 | [
"def",
"add_picture",
"(",
"self",
",",
"image_path_or_stream",
",",
"width",
"=",
"None",
",",
"height",
"=",
"None",
")",
":",
"run",
"=",
"self",
".",
"add_paragraph",
"(",
")",
".",
"add_run",
"(",
")",
"return",
"run",
".",
"add_picture",
"(",
"im... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Document.add_section | 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. | docx/document.py | def add_section(self, start_type=WD_SECTION.NEW_PAGE):
"""
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`` ... | def add_section(self, start_type=WD_SECTION.NEW_PAGE):
"""
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`` ... | [
"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",
":",
"WdS... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/document.py#L74-L83 | [
"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",
"Se... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Document.add_table | 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. | docx/document.py | def add_table(self, rows, cols, style=None):
"""
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 st... | def add_table(self, rows, cols, style=None):
"""
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 st... | [
"Add",
"a",
"table",
"having",
"row",
"and",
"column",
"counts",
"of",
"*",
"rows",
"*",
"and",
"*",
"cols",
"*",
"respectively",
"and",
"table",
"style",
"of",
"*",
"style",
"*",
".",
"*",
"style",
"*",
"may",
"be",
"a",
"paragraph",
"style",
"objec... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/document.py#L85-L94 | [
"def",
"add_table",
"(",
"self",
",",
"rows",
",",
"cols",
",",
"style",
"=",
"None",
")",
":",
"table",
"=",
"self",
".",
"_body",
".",
"add_table",
"(",
"rows",
",",
"cols",
",",
"self",
".",
"_block_width",
")",
"table",
".",
"style",
"=",
"styl... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Document._block_width | Return a |Length| object specifying the width of available "writing"
space between the margins of the last section of this document. | docx/document.py | def _block_width(self):
"""
Return a |Length| object specifying the width of available "writing"
space between the margins of the last section of this document.
"""
section = self.sections[-1]
return Emu(
section.page_width - section.left_margin - section.righ... | def _block_width(self):
"""
Return a |Length| object specifying the width of available "writing"
space between the margins of the last section of this document.
"""
section = self.sections[-1]
return Emu(
section.page_width - section.left_margin - section.righ... | [
"Return",
"a",
"|Length|",
"object",
"specifying",
"the",
"width",
"of",
"available",
"writing",
"space",
"between",
"the",
"margins",
"of",
"the",
"last",
"section",
"of",
"this",
"document",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/document.py#L169-L177 | [
"def",
"_block_width",
"(",
"self",
")",
":",
"section",
"=",
"self",
".",
"sections",
"[",
"-",
"1",
"]",
"return",
"Emu",
"(",
"section",
".",
"page_width",
"-",
"section",
".",
"left_margin",
"-",
"section",
".",
"right_margin",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Document._body | The |_Body| instance containing the content for this document. | docx/document.py | def _body(self):
"""
The |_Body| instance containing the content for this document.
"""
if self.__body is None:
self.__body = _Body(self._element.body, self)
return self.__body | def _body(self):
"""
The |_Body| instance containing the content for this document.
"""
if self.__body is None:
self.__body = _Body(self._element.body, self)
return self.__body | [
"The",
"|_Body|",
"instance",
"containing",
"the",
"content",
"for",
"this",
"document",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/document.py#L180-L186 | [
"def",
"_body",
"(",
"self",
")",
":",
"if",
"self",
".",
"__body",
"is",
"None",
":",
"self",
".",
"__body",
"=",
"_Body",
"(",
"self",
".",
"_element",
".",
"body",
",",
"self",
")",
"return",
"self",
".",
"__body"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | register_element_cls | Register *cls* to be constructed when the oxml parser encounters an
element with matching *tag*. *tag* is a string of the form
``nspfx:tagroot``, e.g. ``'w:document'``. | docx/oxml/__init__.py | def register_element_cls(tag, cls):
"""
Register *cls* to be constructed when the oxml parser encounters an
element with matching *tag*. *tag* is a string of the form
``nspfx:tagroot``, e.g. ``'w:document'``.
"""
nspfx, tagroot = tag.split(':')
namespace = element_class_lookup.get_namespace(... | def register_element_cls(tag, cls):
"""
Register *cls* to be constructed when the oxml parser encounters an
element with matching *tag*. *tag* is a string of the form
``nspfx:tagroot``, e.g. ``'w:document'``.
"""
nspfx, tagroot = tag.split(':')
namespace = element_class_lookup.get_namespace(... | [
"Register",
"*",
"cls",
"*",
"to",
"be",
"constructed",
"when",
"the",
"oxml",
"parser",
"encounters",
"an",
"element",
"with",
"matching",
"*",
"tag",
"*",
".",
"*",
"tag",
"*",
"is",
"a",
"string",
"of",
"the",
"form",
"nspfx",
":",
"tagroot",
"e",
... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/__init__.py#L32-L40 | [
"def",
"register_element_cls",
"(",
"tag",
",",
"cls",
")",
":",
"nspfx",
",",
"tagroot",
"=",
"tag",
".",
"split",
"(",
"':'",
")",
"namespace",
"=",
"element_class_lookup",
".",
"get_namespace",
"(",
"nsmap",
"[",
"nspfx",
"]",
")",
"namespace",
"[",
"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.