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
CT_TabStops.insert_tab_in_order
Insert a newly created `w:tab` child element in *pos* order.
docx/oxml/text/parfmt.py
def insert_tab_in_order(self, pos, align, leader): """ Insert a newly created `w:tab` child element in *pos* order. """ new_tab = self._new_tab() new_tab.pos, new_tab.val, new_tab.leader = pos, align, leader for tab in self.tab_lst: if new_tab.pos < tab.pos: ...
def insert_tab_in_order(self, pos, align, leader): """ Insert a newly created `w:tab` child element in *pos* order. """ new_tab = self._new_tab() new_tab.pos, new_tab.val, new_tab.leader = pos, align, leader for tab in self.tab_lst: if new_tab.pos < tab.pos: ...
[ "Insert", "a", "newly", "created", "w", ":", "tab", "child", "element", "in", "*", "pos", "*", "order", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/text/parfmt.py#L337-L348
[ "def", "insert_tab_in_order", "(", "self", ",", "pos", ",", "align", ",", "leader", ")", ":", "new_tab", "=", "self", ".", "_new_tab", "(", ")", "new_tab", ".", "pos", ",", "new_tab", ".", "val", ",", "new_tab", ".", "leader", "=", "pos", ",", "align...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Inline.new
Return a new ``<wp:inline>`` element populated with the values passed as parameters.
docx/oxml/shape.py
def new(cls, cx, cy, shape_id, pic): """ Return a new ``<wp:inline>`` element populated with the values passed as parameters. """ inline = parse_xml(cls._inline_xml()) inline.extent.cx = cx inline.extent.cy = cy inline.docPr.id = shape_id inline.do...
def new(cls, cx, cy, shape_id, pic): """ Return a new ``<wp:inline>`` element populated with the values passed as parameters. """ inline = parse_xml(cls._inline_xml()) inline.extent.cx = cx inline.extent.cy = cy inline.docPr.id = shape_id inline.do...
[ "Return", "a", "new", "<wp", ":", "inline", ">", "element", "populated", "with", "the", "values", "passed", "as", "parameters", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/shape.py#L61-L75
[ "def", "new", "(", "cls", ",", "cx", ",", "cy", ",", "shape_id", ",", "pic", ")", ":", "inline", "=", "parse_xml", "(", "cls", ".", "_inline_xml", "(", ")", ")", "inline", ".", "extent", ".", "cx", "=", "cx", "inline", ".", "extent", ".", "cy", ...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Inline.new_pic_inline
Return a new `wp:inline` element containing the `pic:pic` element specified by the argument values.
docx/oxml/shape.py
def new_pic_inline(cls, shape_id, rId, filename, cx, cy): """ Return a new `wp:inline` element containing the `pic:pic` element specified by the argument values. """ pic_id = 0 # Word doesn't seem to use this, but does not omit it pic = CT_Picture.new(pic_id, filename, r...
def new_pic_inline(cls, shape_id, rId, filename, cx, cy): """ Return a new `wp:inline` element containing the `pic:pic` element specified by the argument values. """ pic_id = 0 # Word doesn't seem to use this, but does not omit it pic = CT_Picture.new(pic_id, filename, r...
[ "Return", "a", "new", "wp", ":", "inline", "element", "containing", "the", "pic", ":", "pic", "element", "specified", "by", "the", "argument", "values", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/shape.py#L78-L87
[ "def", "new_pic_inline", "(", "cls", ",", "shape_id", ",", "rId", ",", "filename", ",", "cx", ",", "cy", ")", ":", "pic_id", "=", "0", "# Word doesn't seem to use this, but does not omit it", "pic", "=", "CT_Picture", ".", "new", "(", "pic_id", ",", "filename"...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Picture.new
Return a new ``<pic:pic>`` element populated with the minimal contents required to define a viable picture element, based on the values passed as parameters.
docx/oxml/shape.py
def new(cls, pic_id, filename, rId, cx, cy): """ Return a new ``<pic:pic>`` element populated with the minimal contents required to define a viable picture element, based on the values passed as parameters. """ pic = parse_xml(cls._pic_xml()) pic.nvPicPr.cNvPr.id ...
def new(cls, pic_id, filename, rId, cx, cy): """ Return a new ``<pic:pic>`` element populated with the minimal contents required to define a viable picture element, based on the values passed as parameters. """ pic = parse_xml(cls._pic_xml()) pic.nvPicPr.cNvPr.id ...
[ "Return", "a", "new", "<pic", ":", "pic", ">", "element", "populated", "with", "the", "minimal", "contents", "required", "to", "define", "a", "viable", "picture", "element", "based", "on", "the", "values", "passed", "as", "parameters", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/shape.py#L130-L142
[ "def", "new", "(", "cls", ",", "pic_id", ",", "filename", ",", "rId", ",", "cx", ",", "cy", ")", ":", "pic", "=", "parse_xml", "(", "cls", ".", "_pic_xml", "(", ")", ")", "pic", ".", "nvPicPr", ".", "cNvPr", ".", "id", "=", "pic_id", "pic", "."...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
Styles.add_style
Return a newly added style object of *style_type* and identified by *name*. A builtin style can be defined by passing True for the optional *builtin* argument.
docx/styles/styles.py
def add_style(self, name, style_type, builtin=False): """ Return a newly added style object of *style_type* and identified by *name*. A builtin style can be defined by passing True for the optional *builtin* argument. """ style_name = BabelFish.ui2internal(name) i...
def add_style(self, name, style_type, builtin=False): """ Return a newly added style object of *style_type* and identified by *name*. A builtin style can be defined by passing True for the optional *builtin* argument. """ style_name = BabelFish.ui2internal(name) i...
[ "Return", "a", "newly", "added", "style", "object", "of", "*", "style_type", "*", "and", "identified", "by", "*", "name", "*", ".", "A", "builtin", "style", "can", "be", "defined", "by", "passing", "True", "for", "the", "optional", "*", "builtin", "*", ...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/styles/styles.py#L61-L73
[ "def", "add_style", "(", "self", ",", "name", ",", "style_type", ",", "builtin", "=", "False", ")", ":", "style_name", "=", "BabelFish", ".", "ui2internal", "(", "name", ")", "if", "style_name", "in", "self", ":", "raise", "ValueError", "(", "\"document al...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
Styles.default
Return the default style for *style_type* or |None| if no default is defined for that type (not common).
docx/styles/styles.py
def default(self, style_type): """ Return the default style for *style_type* or |None| if no default is defined for that type (not common). """ style = self._element.default_for(style_type) if style is None: return None return StyleFactory(style)
def default(self, style_type): """ Return the default style for *style_type* or |None| if no default is defined for that type (not common). """ style = self._element.default_for(style_type) if style is None: return None return StyleFactory(style)
[ "Return", "the", "default", "style", "for", "*", "style_type", "*", "or", "|None|", "if", "no", "default", "is", "defined", "for", "that", "type", "(", "not", "common", ")", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/styles/styles.py#L75-L83
[ "def", "default", "(", "self", ",", "style_type", ")", ":", "style", "=", "self", ".", "_element", ".", "default_for", "(", "style_type", ")", "if", "style", "is", "None", ":", "return", "None", "return", "StyleFactory", "(", "style", ")" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
Styles.get_by_id
Return the style of *style_type* matching *style_id*. Returns the default for *style_type* if *style_id* is not found or is |None|, or if the style having *style_id* is not of *style_type*.
docx/styles/styles.py
def get_by_id(self, style_id, style_type): """Return the style of *style_type* matching *style_id*. Returns the default for *style_type* if *style_id* is not found or is |None|, or if the style having *style_id* is not of *style_type*. """ if style_id is None: return...
def get_by_id(self, style_id, style_type): """Return the style of *style_type* matching *style_id*. Returns the default for *style_type* if *style_id* is not found or is |None|, or if the style having *style_id* is not of *style_type*. """ if style_id is None: return...
[ "Return", "the", "style", "of", "*", "style_type", "*", "matching", "*", "style_id", "*", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/styles/styles.py#L85-L93
[ "def", "get_by_id", "(", "self", ",", "style_id", ",", "style_type", ")", ":", "if", "style_id", "is", "None", ":", "return", "self", ".", "default", "(", "style_type", ")", "return", "self", ".", "_get_by_id", "(", "style_id", ",", "style_type", ")" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
Styles.get_style_id
Return the id of the style corresponding to *style_or_name*, or |None| if *style_or_name* is |None|. If *style_or_name* is not a style object, the style is looked up using *style_or_name* as a style name, raising |ValueError| if no style with that name is defined. Raises |ValueError| if ...
docx/styles/styles.py
def get_style_id(self, style_or_name, style_type): """ Return the id of the style corresponding to *style_or_name*, or |None| if *style_or_name* is |None|. If *style_or_name* is not a style object, the style is looked up using *style_or_name* as a style name, raising |ValueError|...
def get_style_id(self, style_or_name, style_type): """ Return the id of the style corresponding to *style_or_name*, or |None| if *style_or_name* is |None|. If *style_or_name* is not a style object, the style is looked up using *style_or_name* as a style name, raising |ValueError|...
[ "Return", "the", "id", "of", "the", "style", "corresponding", "to", "*", "style_or_name", "*", "or", "|None|", "if", "*", "style_or_name", "*", "is", "|None|", ".", "If", "*", "style_or_name", "*", "is", "not", "a", "style", "object", "the", "style", "is...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/styles/styles.py#L95-L109
[ "def", "get_style_id", "(", "self", ",", "style_or_name", ",", "style_type", ")", ":", "if", "style_or_name", "is", "None", ":", "return", "None", "elif", "isinstance", "(", "style_or_name", ",", "BaseStyle", ")", ":", "return", "self", ".", "_get_style_id_fro...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
Styles._get_by_id
Return the style of *style_type* matching *style_id*. Returns the default for *style_type* if *style_id* is not found or if the style having *style_id* is not of *style_type*.
docx/styles/styles.py
def _get_by_id(self, style_id, style_type): """ Return the style of *style_type* matching *style_id*. Returns the default for *style_type* if *style_id* is not found or if the style having *style_id* is not of *style_type*. """ style = self._element.get_by_id(style_id) ...
def _get_by_id(self, style_id, style_type): """ Return the style of *style_type* matching *style_id*. Returns the default for *style_type* if *style_id* is not found or if the style having *style_id* is not of *style_type*. """ style = self._element.get_by_id(style_id) ...
[ "Return", "the", "style", "of", "*", "style_type", "*", "matching", "*", "style_id", "*", ".", "Returns", "the", "default", "for", "*", "style_type", "*", "if", "*", "style_id", "*", "is", "not", "found", "or", "if", "the", "style", "having", "*", "sty...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/styles/styles.py#L121-L130
[ "def", "_get_by_id", "(", "self", ",", "style_id", ",", "style_type", ")", ":", "style", "=", "self", ".", "_element", ".", "get_by_id", "(", "style_id", ")", "if", "style", "is", "None", "or", "style", ".", "type", "!=", "style_type", ":", "return", "...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
Styles._get_style_id_from_style
Return the id of *style*, or |None| if it is the default style of *style_type*. Raises |ValueError| if style is not of *style_type*.
docx/styles/styles.py
def _get_style_id_from_style(self, style, style_type): """ Return the id of *style*, or |None| if it is the default style of *style_type*. Raises |ValueError| if style is not of *style_type*. """ if style.type != style_type: raise ValueError( "assigned...
def _get_style_id_from_style(self, style, style_type): """ Return the id of *style*, or |None| if it is the default style of *style_type*. Raises |ValueError| if style is not of *style_type*. """ if style.type != style_type: raise ValueError( "assigned...
[ "Return", "the", "id", "of", "*", "style", "*", "or", "|None|", "if", "it", "is", "the", "default", "style", "of", "*", "style_type", "*", ".", "Raises", "|ValueError|", "if", "style", "is", "not", "of", "*", "style_type", "*", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/styles/styles.py#L141-L153
[ "def", "_get_style_id_from_style", "(", "self", ",", "style", ",", "style_type", ")", ":", "if", "style", ".", "type", "!=", "style_type", ":", "raise", "ValueError", "(", "\"assigned style is type %s, need type %s\"", "%", "(", "style", ".", "type", ",", "style...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
RGBColor.from_string
Return a new instance from an RGB color hex string like ``'3C2F80'``.
docx/shared.py
def from_string(cls, rgb_hex_str): """ Return a new instance from an RGB color hex string like ``'3C2F80'``. """ r = int(rgb_hex_str[:2], 16) g = int(rgb_hex_str[2:4], 16) b = int(rgb_hex_str[4:], 16) return cls(r, g, b)
def from_string(cls, rgb_hex_str): """ Return a new instance from an RGB color hex string like ``'3C2F80'``. """ r = int(rgb_hex_str[:2], 16) g = int(rgb_hex_str[2:4], 16) b = int(rgb_hex_str[4:], 16) return cls(r, g, b)
[ "Return", "a", "new", "instance", "from", "an", "RGB", "color", "hex", "string", "like", "3C2F80", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/shared.py#L148-L155
[ "def", "from_string", "(", "cls", ",", "rgb_hex_str", ")", ":", "r", "=", "int", "(", "rgb_hex_str", "[", ":", "2", "]", ",", "16", ")", "g", "=", "int", "(", "rgb_hex_str", "[", "2", ":", "4", "]", ",", "16", ")", "b", "=", "int", "(", "rgb_...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
OpcPackage.iter_rels
Generate exactly one reference to each relationship in the package by performing a depth-first traversal of the rels graph.
docx/opc/package.py
def iter_rels(self): """ Generate exactly one reference to each relationship in the package by performing a depth-first traversal of the rels graph. """ def walk_rels(source, visited=None): visited = [] if visited is None else visited for rel in source.rel...
def iter_rels(self): """ Generate exactly one reference to each relationship in the package by performing a depth-first traversal of the rels graph. """ def walk_rels(source, visited=None): visited = [] if visited is None else visited for rel in source.rel...
[ "Generate", "exactly", "one", "reference", "to", "each", "relationship", "in", "the", "package", "by", "performing", "a", "depth", "-", "first", "traversal", "of", "the", "rels", "graph", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/package.py#L44-L64
[ "def", "iter_rels", "(", "self", ")", ":", "def", "walk_rels", "(", "source", ",", "visited", "=", "None", ")", ":", "visited", "=", "[", "]", "if", "visited", "is", "None", "else", "visited", "for", "rel", "in", "source", ".", "rels", ".", "values",...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
OpcPackage.iter_parts
Generate exactly one reference to each of the parts in the package by performing a depth-first traversal of the rels graph.
docx/opc/package.py
def iter_parts(self): """ Generate exactly one reference to each of the parts in the package by performing a depth-first traversal of the rels graph. """ def walk_parts(source, visited=list()): for rel in source.rels.values(): if rel.is_external: ...
def iter_parts(self): """ Generate exactly one reference to each of the parts in the package by performing a depth-first traversal of the rels graph. """ def walk_parts(source, visited=list()): for rel in source.rels.values(): if rel.is_external: ...
[ "Generate", "exactly", "one", "reference", "to", "each", "of", "the", "parts", "in", "the", "package", "by", "performing", "a", "depth", "-", "first", "traversal", "of", "the", "rels", "graph", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/package.py#L66-L85
[ "def", "iter_parts", "(", "self", ")", ":", "def", "walk_parts", "(", "source", ",", "visited", "=", "list", "(", ")", ")", ":", "for", "rel", "in", "source", ".", "rels", ".", "values", "(", ")", ":", "if", "rel", ".", "is_external", ":", "continu...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
OpcPackage.load_rel
Return newly added |_Relationship| instance of *reltype* between this part and *target* with key *rId*. Target mode is set to ``RTM.EXTERNAL`` if *is_external* is |True|. Intended for use during load from a serialized package, where the rId is well known. Other methods exist for adding a...
docx/opc/package.py
def load_rel(self, reltype, target, rId, is_external=False): """ Return newly added |_Relationship| instance of *reltype* between this part and *target* with key *rId*. Target mode is set to ``RTM.EXTERNAL`` if *is_external* is |True|. Intended for use during load from a serializ...
def load_rel(self, reltype, target, rId, is_external=False): """ Return newly added |_Relationship| instance of *reltype* between this part and *target* with key *rId*. Target mode is set to ``RTM.EXTERNAL`` if *is_external* is |True|. Intended for use during load from a serializ...
[ "Return", "newly", "added", "|_Relationship|", "instance", "of", "*", "reltype", "*", "between", "this", "part", "and", "*", "target", "*", "with", "key", "*", "rId", "*", ".", "Target", "mode", "is", "set", "to", "RTM", ".", "EXTERNAL", "if", "*", "is...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/package.py#L87-L96
[ "def", "load_rel", "(", "self", ",", "reltype", ",", "target", ",", "rId", ",", "is_external", "=", "False", ")", ":", "return", "self", ".", "rels", ".", "add_relationship", "(", "reltype", ",", "target", ",", "rId", ",", "is_external", ")" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
OpcPackage.next_partname
Return a |PackURI| instance representing partname matching *template*. The returned part-name has the next available numeric suffix to distinguish it from other parts of its type. *template* is a printf (%)-style template string containing a single replacement item, a '%d' to be used to insert ...
docx/opc/package.py
def next_partname(self, template): """Return a |PackURI| instance representing partname matching *template*. The returned part-name has the next available numeric suffix to distinguish it from other parts of its type. *template* is a printf (%)-style template string containing a single ...
def next_partname(self, template): """Return a |PackURI| instance representing partname matching *template*. The returned part-name has the next available numeric suffix to distinguish it from other parts of its type. *template* is a printf (%)-style template string containing a single ...
[ "Return", "a", "|PackURI|", "instance", "representing", "partname", "matching", "*", "template", "*", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/package.py#L108-L120
[ "def", "next_partname", "(", "self", ",", "template", ")", ":", "partnames", "=", "{", "part", ".", "partname", "for", "part", "in", "self", ".", "iter_parts", "(", ")", "}", "for", "n", "in", "range", "(", "1", ",", "len", "(", "partnames", ")", "...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
OpcPackage.open
Return an |OpcPackage| instance loaded with the contents of *pkg_file*.
docx/opc/package.py
def open(cls, pkg_file): """ Return an |OpcPackage| instance loaded with the contents of *pkg_file*. """ pkg_reader = PackageReader.from_file(pkg_file) package = cls() Unmarshaller.unmarshal(pkg_reader, package, PartFactory) return package
def open(cls, pkg_file): """ Return an |OpcPackage| instance loaded with the contents of *pkg_file*. """ pkg_reader = PackageReader.from_file(pkg_file) package = cls() Unmarshaller.unmarshal(pkg_reader, package, PartFactory) return package
[ "Return", "an", "|OpcPackage|", "instance", "loaded", "with", "the", "contents", "of", "*", "pkg_file", "*", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/package.py#L123-L131
[ "def", "open", "(", "cls", ",", "pkg_file", ")", ":", "pkg_reader", "=", "PackageReader", ".", "from_file", "(", "pkg_file", ")", "package", "=", "cls", "(", ")", "Unmarshaller", ".", "unmarshal", "(", "pkg_reader", ",", "package", ",", "PartFactory", ")",...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
OpcPackage.relate_to
Return rId key of relationship to *part*, from the existing relationship if there is one, otherwise a newly created one.
docx/opc/package.py
def relate_to(self, part, reltype): """ Return rId key of relationship to *part*, from the existing relationship if there is one, otherwise a newly created one. """ rel = self.rels.get_or_add(reltype, part) return rel.rId
def relate_to(self, part, reltype): """ Return rId key of relationship to *part*, from the existing relationship if there is one, otherwise a newly created one. """ rel = self.rels.get_or_add(reltype, part) return rel.rId
[ "Return", "rId", "key", "of", "relationship", "to", "*", "part", "*", "from", "the", "existing", "relationship", "if", "there", "is", "one", "otherwise", "a", "newly", "created", "one", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/package.py#L149-L155
[ "def", "relate_to", "(", "self", ",", "part", ",", "reltype", ")", ":", "rel", "=", "self", ".", "rels", ".", "get_or_add", "(", "reltype", ",", "part", ")", "return", "rel", ".", "rId" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
OpcPackage.save
Save this package to *pkg_file*, where *file* can be either a path to a file (a string) or a file-like object.
docx/opc/package.py
def save(self, pkg_file): """ Save this package to *pkg_file*, where *file* can be either a path to a file (a string) or a file-like object. """ for part in self.parts: part.before_marshal() PackageWriter.write(pkg_file, self.rels, self.parts)
def save(self, pkg_file): """ Save this package to *pkg_file*, where *file* can be either a path to a file (a string) or a file-like object. """ for part in self.parts: part.before_marshal() PackageWriter.write(pkg_file, self.rels, self.parts)
[ "Save", "this", "package", "to", "*", "pkg_file", "*", "where", "*", "file", "*", "can", "be", "either", "a", "path", "to", "a", "file", "(", "a", "string", ")", "or", "a", "file", "-", "like", "object", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/package.py#L165-L172
[ "def", "save", "(", "self", ",", "pkg_file", ")", ":", "for", "part", "in", "self", ".", "parts", ":", "part", ".", "before_marshal", "(", ")", "PackageWriter", ".", "write", "(", "pkg_file", ",", "self", ".", "rels", ",", "self", ".", "parts", ")" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
OpcPackage._core_properties_part
|CorePropertiesPart| object related to this package. Creates a default core properties part if one is not present (not common).
docx/opc/package.py
def _core_properties_part(self): """ |CorePropertiesPart| object related to this package. Creates a default core properties part if one is not present (not common). """ try: return self.part_related_by(RT.CORE_PROPERTIES) except KeyError: core_prop...
def _core_properties_part(self): """ |CorePropertiesPart| object related to this package. Creates a default core properties part if one is not present (not common). """ try: return self.part_related_by(RT.CORE_PROPERTIES) except KeyError: core_prop...
[ "|CorePropertiesPart|", "object", "related", "to", "this", "package", ".", "Creates", "a", "default", "core", "properties", "part", "if", "one", "is", "not", "present", "(", "not", "common", ")", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/package.py#L175-L185
[ "def", "_core_properties_part", "(", "self", ")", ":", "try", ":", "return", "self", ".", "part_related_by", "(", "RT", ".", "CORE_PROPERTIES", ")", "except", "KeyError", ":", "core_properties_part", "=", "CorePropertiesPart", ".", "default", "(", "self", ")", ...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
Unmarshaller.unmarshal
Construct graph of parts and realized relationships based on the contents of *pkg_reader*, delegating construction of each part to *part_factory*. Package relationships are added to *pkg*.
docx/opc/package.py
def unmarshal(pkg_reader, package, part_factory): """ Construct graph of parts and realized relationships based on the contents of *pkg_reader*, delegating construction of each part to *part_factory*. Package relationships are added to *pkg*. """ parts = Unmarshaller._unm...
def unmarshal(pkg_reader, package, part_factory): """ Construct graph of parts and realized relationships based on the contents of *pkg_reader*, delegating construction of each part to *part_factory*. Package relationships are added to *pkg*. """ parts = Unmarshaller._unm...
[ "Construct", "graph", "of", "parts", "and", "realized", "relationships", "based", "on", "the", "contents", "of", "*", "pkg_reader", "*", "delegating", "construction", "of", "each", "part", "to", "*", "part_factory", "*", ".", "Package", "relationships", "are", ...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/package.py#L192-L204
[ "def", "unmarshal", "(", "pkg_reader", ",", "package", ",", "part_factory", ")", ":", "parts", "=", "Unmarshaller", ".", "_unmarshal_parts", "(", "pkg_reader", ",", "package", ",", "part_factory", ")", "Unmarshaller", ".", "_unmarshal_relationships", "(", "pkg_rea...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
Unmarshaller._unmarshal_parts
Return a dictionary of |Part| instances unmarshalled from *pkg_reader*, keyed by partname. Side-effect is that each part in *pkg_reader* is constructed using *part_factory*.
docx/opc/package.py
def _unmarshal_parts(pkg_reader, package, part_factory): """ Return a dictionary of |Part| instances unmarshalled from *pkg_reader*, keyed by partname. Side-effect is that each part in *pkg_reader* is constructed using *part_factory*. """ parts = {} for partname, ...
def _unmarshal_parts(pkg_reader, package, part_factory): """ Return a dictionary of |Part| instances unmarshalled from *pkg_reader*, keyed by partname. Side-effect is that each part in *pkg_reader* is constructed using *part_factory*. """ parts = {} for partname, ...
[ "Return", "a", "dictionary", "of", "|Part|", "instances", "unmarshalled", "from", "*", "pkg_reader", "*", "keyed", "by", "partname", ".", "Side", "-", "effect", "is", "that", "each", "part", "in", "*", "pkg_reader", "*", "is", "constructed", "using", "*", ...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/package.py#L207-L218
[ "def", "_unmarshal_parts", "(", "pkg_reader", ",", "package", ",", "part_factory", ")", ":", "parts", "=", "{", "}", "for", "partname", ",", "content_type", ",", "reltype", ",", "blob", "in", "pkg_reader", ".", "iter_sparts", "(", ")", ":", "parts", "[", ...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
Unmarshaller._unmarshal_relationships
Add a relationship to the source object corresponding to each of the relationships in *pkg_reader* with its target_part set to the actual target part in *parts*.
docx/opc/package.py
def _unmarshal_relationships(pkg_reader, package, parts): """ Add a relationship to the source object corresponding to each of the relationships in *pkg_reader* with its target_part set to the actual target part in *parts*. """ for source_uri, srel in pkg_reader.iter_srel...
def _unmarshal_relationships(pkg_reader, package, parts): """ Add a relationship to the source object corresponding to each of the relationships in *pkg_reader* with its target_part set to the actual target part in *parts*. """ for source_uri, srel in pkg_reader.iter_srel...
[ "Add", "a", "relationship", "to", "the", "source", "object", "corresponding", "to", "each", "of", "the", "relationships", "in", "*", "pkg_reader", "*", "with", "its", "target_part", "set", "to", "the", "actual", "target", "part", "in", "*", "parts", "*", "...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/package.py#L221-L231
[ "def", "_unmarshal_relationships", "(", "pkg_reader", ",", "package", ",", "parts", ")", ":", "for", "source_uri", ",", "srel", "in", "pkg_reader", ".", "iter_srels", "(", ")", ":", "source", "=", "package", "if", "source_uri", "==", "'/'", "else", "parts", ...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
SettingsPart.default
Return a newly created settings part, containing a default `w:settings` element tree.
docx/parts/settings.py
def default(cls, package): """ Return a newly created settings part, containing a default `w:settings` element tree. """ partname = PackURI('/word/settings.xml') content_type = CT.WML_SETTINGS element = parse_xml(cls._default_settings_xml()) return cls(par...
def default(cls, package): """ Return a newly created settings part, containing a default `w:settings` element tree. """ partname = PackURI('/word/settings.xml') content_type = CT.WML_SETTINGS element = parse_xml(cls._default_settings_xml()) return cls(par...
[ "Return", "a", "newly", "created", "settings", "part", "containing", "a", "default", "w", ":", "settings", "element", "tree", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/parts/settings.py#L25-L33
[ "def", "default", "(", "cls", ",", "package", ")", ":", "partname", "=", "PackURI", "(", "'/word/settings.xml'", ")", "content_type", "=", "CT", ".", "WML_SETTINGS", "element", "=", "parse_xml", "(", "cls", ".", "_default_settings_xml", "(", ")", ")", "retur...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
LatentStyles.add_latent_style
Return a newly added |_LatentStyle| object to override the inherited defaults defined in this latent styles object for the built-in style having *name*.
docx/styles/latent.py
def add_latent_style(self, name): """ Return a newly added |_LatentStyle| object to override the inherited defaults defined in this latent styles object for the built-in style having *name*. """ lsdException = self._element.add_lsdException() lsdException.name = B...
def add_latent_style(self, name): """ Return a newly added |_LatentStyle| object to override the inherited defaults defined in this latent styles object for the built-in style having *name*. """ lsdException = self._element.add_lsdException() lsdException.name = B...
[ "Return", "a", "newly", "added", "|_LatentStyle|", "object", "to", "override", "the", "inherited", "defaults", "defined", "in", "this", "latent", "styles", "object", "for", "the", "built", "-", "in", "style", "having", "*", "name", "*", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/styles/latent.py#L40-L48
[ "def", "add_latent_style", "(", "self", ",", "name", ")", ":", "lsdException", "=", "self", ".", "_element", ".", "add_lsdException", "(", ")", "lsdException", ".", "name", "=", "BabelFish", ".", "ui2internal", "(", "name", ")", "return", "_LatentStyle", "("...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
Part.relate_to
Return rId key of relationship of *reltype* to *target*, from an existing relationship if there is one, otherwise a newly created one.
docx/opc/part.py
def relate_to(self, target, reltype, is_external=False): """ Return rId key of relationship of *reltype* to *target*, from an existing relationship if there is one, otherwise a newly created one. """ if is_external: return self.rels.get_or_add_ext_rel(reltype, target)...
def relate_to(self, target, reltype, is_external=False): """ Return rId key of relationship of *reltype* to *target*, from an existing relationship if there is one, otherwise a newly created one. """ if is_external: return self.rels.get_or_add_ext_rel(reltype, target)...
[ "Return", "rId", "key", "of", "relationship", "of", "*", "reltype", "*", "to", "*", "target", "*", "from", "an", "existing", "relationship", "if", "there", "is", "one", "otherwise", "a", "newly", "created", "one", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/part.py#L123-L132
[ "def", "relate_to", "(", "self", ",", "target", ",", "reltype", ",", "is_external", "=", "False", ")", ":", "if", "is_external", ":", "return", "self", ".", "rels", ".", "get_or_add_ext_rel", "(", "reltype", ",", "target", ")", "else", ":", "rel", "=", ...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
Part._rel_ref_count
Return the count of references in this part's XML to the relationship identified by *rId*.
docx/opc/part.py
def _rel_ref_count(self, rId): """ Return the count of references in this part's XML to the relationship identified by *rId*. """ rIds = self._element.xpath('//@r:id') return len([_rId for _rId in rIds if _rId == rId])
def _rel_ref_count(self, rId): """ Return the count of references in this part's XML to the relationship identified by *rId*. """ rIds = self._element.xpath('//@r:id') return len([_rId for _rId in rIds if _rId == rId])
[ "Return", "the", "count", "of", "references", "in", "this", "part", "s", "XML", "to", "the", "relationship", "identified", "by", "*", "rId", "*", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/part.py#L158-L164
[ "def", "_rel_ref_count", "(", "self", ",", "rId", ")", ":", "rIds", "=", "self", ".", "_element", ".", "xpath", "(", "'//@r:id'", ")", "return", "len", "(", "[", "_rId", "for", "_rId", "in", "rIds", "if", "_rId", "==", "rId", "]", ")" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
PartFactory._part_cls_for
Return the custom part class registered for *content_type*, or the default part class if no custom class is registered for *content_type*.
docx/opc/part.py
def _part_cls_for(cls, content_type): """ Return the custom part class registered for *content_type*, or the default part class if no custom class is registered for *content_type*. """ if content_type in cls.part_type_for: return cls.part_type_for[content_type...
def _part_cls_for(cls, content_type): """ Return the custom part class registered for *content_type*, or the default part class if no custom class is registered for *content_type*. """ if content_type in cls.part_type_for: return cls.part_type_for[content_type...
[ "Return", "the", "custom", "part", "class", "registered", "for", "*", "content_type", "*", "or", "the", "default", "part", "class", "if", "no", "custom", "class", "is", "registered", "for", "*", "content_type", "*", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/part.py#L194-L202
[ "def", "_part_cls_for", "(", "cls", ",", "content_type", ")", ":", "if", "content_type", "in", "cls", ".", "part_type_for", ":", "return", "cls", ".", "part_type_for", "[", "content_type", "]", "return", "cls", ".", "default_part_type" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_R.add_t
Return a newly added ``<w:t>`` element containing *text*.
docx/oxml/text/run.py
def add_t(self, text): """ Return a newly added ``<w:t>`` element containing *text*. """ t = self._add_t(text=text) if len(text.strip()) < len(text): t.set(qn('xml:space'), 'preserve') return t
def add_t(self, text): """ Return a newly added ``<w:t>`` element containing *text*. """ t = self._add_t(text=text) if len(text.strip()) < len(text): t.set(qn('xml:space'), 'preserve') return t
[ "Return", "a", "newly", "added", "<w", ":", "t", ">", "element", "containing", "*", "text", "*", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/text/run.py#L37-L44
[ "def", "add_t", "(", "self", ",", "text", ")", ":", "t", "=", "self", ".", "_add_t", "(", "text", "=", "text", ")", "if", "len", "(", "text", ".", "strip", "(", ")", ")", "<", "len", "(", "text", ")", ":", "t", ".", "set", "(", "qn", "(", ...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_R.add_drawing
Return a newly appended ``CT_Drawing`` (``<w:drawing>``) child element having *inline_or_anchor* as its child.
docx/oxml/text/run.py
def add_drawing(self, inline_or_anchor): """ Return a newly appended ``CT_Drawing`` (``<w:drawing>``) child element having *inline_or_anchor* as its child. """ drawing = self._add_drawing() drawing.append(inline_or_anchor) return drawing
def add_drawing(self, inline_or_anchor): """ Return a newly appended ``CT_Drawing`` (``<w:drawing>``) child element having *inline_or_anchor* as its child. """ drawing = self._add_drawing() drawing.append(inline_or_anchor) return drawing
[ "Return", "a", "newly", "appended", "CT_Drawing", "(", "<w", ":", "drawing", ">", ")", "child", "element", "having", "*", "inline_or_anchor", "*", "as", "its", "child", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/text/run.py#L46-L53
[ "def", "add_drawing", "(", "self", ",", "inline_or_anchor", ")", ":", "drawing", "=", "self", ".", "_add_drawing", "(", ")", "drawing", ".", "append", "(", "inline_or_anchor", ")", "return", "drawing" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_R.clear_content
Remove all child elements except the ``<w:rPr>`` element if present.
docx/oxml/text/run.py
def clear_content(self): """ Remove all child elements except the ``<w:rPr>`` element if present. """ content_child_elms = self[1:] if self.rPr is not None else self[:] for child in content_child_elms: self.remove(child)
def clear_content(self): """ Remove all child elements except the ``<w:rPr>`` element if present. """ content_child_elms = self[1:] if self.rPr is not None else self[:] for child in content_child_elms: self.remove(child)
[ "Remove", "all", "child", "elements", "except", "the", "<w", ":", "rPr", ">", "element", "if", "present", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/text/run.py#L55-L61
[ "def", "clear_content", "(", "self", ")", ":", "content_child_elms", "=", "self", "[", "1", ":", "]", "if", "self", ".", "rPr", "is", "not", "None", "else", "self", "[", ":", "]", "for", "child", "in", "content_child_elms", ":", "self", ".", "remove", ...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_R.text
A string representing the textual content of this run, with content child elements like ``<w:tab/>`` translated to their Python equivalent.
docx/oxml/text/run.py
def text(self): """ A string representing the textual content of this run, with content child elements like ``<w:tab/>`` translated to their Python equivalent. """ text = '' for child in self: if child.tag == qn('w:t'): t_text = child.t...
def text(self): """ A string representing the textual content of this run, with content child elements like ``<w:tab/>`` translated to their Python equivalent. """ text = '' for child in self: if child.tag == qn('w:t'): t_text = child.t...
[ "A", "string", "representing", "the", "textual", "content", "of", "this", "run", "with", "content", "child", "elements", "like", "<w", ":", "tab", "/", ">", "translated", "to", "their", "Python", "equivalent", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/text/run.py#L84-L99
[ "def", "text", "(", "self", ")", ":", "text", "=", "''", "for", "child", "in", "self", ":", "if", "child", ".", "tag", "==", "qn", "(", "'w:t'", ")", ":", "t_text", "=", "child", ".", "text", "text", "+=", "t_text", "if", "t_text", "is", "not", ...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_RunContentAppender.append_to_run_from_text
Create a "one-shot" ``_RunContentAppender`` instance and use it to append the run content elements corresponding to *text* to the ``<w:r>`` element *r*.
docx/oxml/text/run.py
def append_to_run_from_text(cls, r, text): """ Create a "one-shot" ``_RunContentAppender`` instance and use it to append the run content elements corresponding to *text* to the ``<w:r>`` element *r*. """ appender = cls(r) appender.add_text(text)
def append_to_run_from_text(cls, r, text): """ Create a "one-shot" ``_RunContentAppender`` instance and use it to append the run content elements corresponding to *text* to the ``<w:r>`` element *r*. """ appender = cls(r) appender.add_text(text)
[ "Create", "a", "one", "-", "shot", "_RunContentAppender", "instance", "and", "use", "it", "to", "append", "the", "run", "content", "elements", "corresponding", "to", "*", "text", "*", "to", "the", "<w", ":", "r", ">", "element", "*", "r", "*", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/text/run.py#L127-L134
[ "def", "append_to_run_from_text", "(", "cls", ",", "r", ",", "text", ")", ":", "appender", "=", "cls", "(", "r", ")", "appender", ".", "add_text", "(", "text", ")" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_RunContentAppender.add_text
Append the run content elements corresponding to *text* to the ``<w:r>`` element of this instance.
docx/oxml/text/run.py
def add_text(self, text): """ Append the run content elements corresponding to *text* to the ``<w:r>`` element of this instance. """ for char in text: self.add_char(char) self.flush()
def add_text(self, text): """ Append the run content elements corresponding to *text* to the ``<w:r>`` element of this instance. """ for char in text: self.add_char(char) self.flush()
[ "Append", "the", "run", "content", "elements", "corresponding", "to", "*", "text", "*", "to", "the", "<w", ":", "r", ">", "element", "of", "this", "instance", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/text/run.py#L136-L143
[ "def", "add_text", "(", "self", ",", "text", ")", ":", "for", "char", "in", "text", ":", "self", ".", "add_char", "(", "char", ")", "self", ".", "flush", "(", ")" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_RunContentAppender.add_char
Process the next character of input through the translation finite state maching (FSM). There are two possible states, buffer pending and not pending, but those are hidden behind the ``.flush()`` method which must be called at the end of text to ensure any pending ``<w:t>`` element is wr...
docx/oxml/text/run.py
def add_char(self, char): """ Process the next character of input through the translation finite state maching (FSM). There are two possible states, buffer pending and not pending, but those are hidden behind the ``.flush()`` method which must be called at the end of text to ensu...
def add_char(self, char): """ Process the next character of input through the translation finite state maching (FSM). There are two possible states, buffer pending and not pending, but those are hidden behind the ``.flush()`` method which must be called at the end of text to ensu...
[ "Process", "the", "next", "character", "of", "input", "through", "the", "translation", "finite", "state", "maching", "(", "FSM", ")", ".", "There", "are", "two", "possible", "states", "buffer", "pending", "and", "not", "pending", "but", "those", "are", "hidd...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/text/run.py#L145-L160
[ "def", "add_char", "(", "self", ",", "char", ")", ":", "if", "char", "==", "'\\t'", ":", "self", ".", "flush", "(", ")", "self", ".", "_r", ".", "add_tab", "(", ")", "elif", "char", "in", "'\\r\\n'", ":", "self", ".", "flush", "(", ")", "self", ...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CorePropertiesPart.default
Return a new |CorePropertiesPart| object initialized with default values for its base properties.
docx/opc/parts/coreprops.py
def default(cls, package): """ Return a new |CorePropertiesPart| object initialized with default values for its base properties. """ core_properties_part = cls._new(package) core_properties = core_properties_part.core_properties core_properties.title = 'Word Docum...
def default(cls, package): """ Return a new |CorePropertiesPart| object initialized with default values for its base properties. """ core_properties_part = cls._new(package) core_properties = core_properties_part.core_properties core_properties.title = 'Word Docum...
[ "Return", "a", "new", "|CorePropertiesPart|", "object", "initialized", "with", "default", "values", "for", "its", "base", "properties", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/parts/coreprops.py#L26-L37
[ "def", "default", "(", "cls", ",", "package", ")", ":", "core_properties_part", "=", "cls", ".", "_new", "(", "package", ")", "core_properties", "=", "core_properties_part", ".", "core_properties", "core_properties", ".", "title", "=", "'Word Document'", "core_pro...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
Font._get_bool_prop
Return the value of boolean child of `w:rPr` having *name*.
docx/text/font.py
def _get_bool_prop(self, name): """ Return the value of boolean child of `w:rPr` having *name*. """ rPr = self._element.rPr if rPr is None: return None return rPr._get_bool_val(name)
def _get_bool_prop(self, name): """ Return the value of boolean child of `w:rPr` having *name*. """ rPr = self._element.rPr if rPr is None: return None return rPr._get_bool_val(name)
[ "Return", "the", "value", "of", "boolean", "child", "of", "w", ":", "rPr", "having", "*", "name", "*", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/text/font.py#L397-L404
[ "def", "_get_bool_prop", "(", "self", ",", "name", ")", ":", "rPr", "=", "self", ".", "_element", ".", "rPr", "if", "rPr", "is", "None", ":", "return", "None", "return", "rPr", ".", "_get_bool_val", "(", "name", ")" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
Font._set_bool_prop
Assign *value* to the boolean child *name* of `w:rPr`.
docx/text/font.py
def _set_bool_prop(self, name, value): """ Assign *value* to the boolean child *name* of `w:rPr`. """ rPr = self._element.get_or_add_rPr() rPr._set_bool_val(name, value)
def _set_bool_prop(self, name, value): """ Assign *value* to the boolean child *name* of `w:rPr`. """ rPr = self._element.get_or_add_rPr() rPr._set_bool_val(name, value)
[ "Assign", "*", "value", "*", "to", "the", "boolean", "child", "*", "name", "*", "of", "w", ":", "rPr", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/text/font.py#L406-L411
[ "def", "_set_bool_prop", "(", "self", ",", "name", ",", "value", ")", ":", "rPr", "=", "self", ".", "_element", ".", "get_or_add_rPr", "(", ")", "rPr", ".", "_set_bool_val", "(", "name", ",", "value", ")" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
Table.add_column
Return a |_Column| object of *width*, newly added rightmost to the table.
docx/table.py
def add_column(self, width): """ Return a |_Column| object of *width*, newly added rightmost to the table. """ tblGrid = self._tbl.tblGrid gridCol = tblGrid.add_gridCol() gridCol.w = width for tr in self._tbl.tr_lst: tc = tr.add_tc() ...
def add_column(self, width): """ Return a |_Column| object of *width*, newly added rightmost to the table. """ tblGrid = self._tbl.tblGrid gridCol = tblGrid.add_gridCol() gridCol.w = width for tr in self._tbl.tr_lst: tc = tr.add_tc() ...
[ "Return", "a", "|_Column|", "object", "of", "*", "width", "*", "newly", "added", "rightmost", "to", "the", "table", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/table.py#L23-L34
[ "def", "add_column", "(", "self", ",", "width", ")", ":", "tblGrid", "=", "self", ".", "_tbl", ".", "tblGrid", "gridCol", "=", "tblGrid", ".", "add_gridCol", "(", ")", "gridCol", ".", "w", "=", "width", "for", "tr", "in", "self", ".", "_tbl", ".", ...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
Table.add_row
Return a |_Row| instance, newly added bottom-most to the table.
docx/table.py
def add_row(self): """ Return a |_Row| instance, newly added bottom-most to the table. """ tbl = self._tbl tr = tbl.add_tr() for gridCol in tbl.tblGrid.gridCol_lst: tc = tr.add_tc() tc.width = gridCol.w return _Row(tr, self)
def add_row(self): """ Return a |_Row| instance, newly added bottom-most to the table. """ tbl = self._tbl tr = tbl.add_tr() for gridCol in tbl.tblGrid.gridCol_lst: tc = tr.add_tc() tc.width = gridCol.w return _Row(tr, self)
[ "Return", "a", "|_Row|", "instance", "newly", "added", "bottom", "-", "most", "to", "the", "table", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/table.py#L36-L45
[ "def", "add_row", "(", "self", ")", ":", "tbl", "=", "self", ".", "_tbl", "tr", "=", "tbl", ".", "add_tr", "(", ")", "for", "gridCol", "in", "tbl", ".", "tblGrid", ".", "gridCol_lst", ":", "tc", "=", "tr", ".", "add_tc", "(", ")", "tc", ".", "w...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
Table.cell
Return |_Cell| instance correponding to table cell at *row_idx*, *col_idx* intersection, where (0, 0) is the top, left-most cell.
docx/table.py
def cell(self, row_idx, col_idx): """ Return |_Cell| instance correponding to table cell at *row_idx*, *col_idx* intersection, where (0, 0) is the top, left-most cell. """ cell_idx = col_idx + (row_idx * self._column_count) return self._cells[cell_idx]
def cell(self, row_idx, col_idx): """ Return |_Cell| instance correponding to table cell at *row_idx*, *col_idx* intersection, where (0, 0) is the top, left-most cell. """ cell_idx = col_idx + (row_idx * self._column_count) return self._cells[cell_idx]
[ "Return", "|_Cell|", "instance", "correponding", "to", "table", "cell", "at", "*", "row_idx", "*", "*", "col_idx", "*", "intersection", "where", "(", "0", "0", ")", "is", "the", "top", "left", "-", "most", "cell", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/table.py#L75-L81
[ "def", "cell", "(", "self", ",", "row_idx", ",", "col_idx", ")", ":", "cell_idx", "=", "col_idx", "+", "(", "row_idx", "*", "self", ".", "_column_count", ")", "return", "self", ".", "_cells", "[", "cell_idx", "]" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
Table.column_cells
Sequence of cells in the column at *column_idx* in this table.
docx/table.py
def column_cells(self, column_idx): """ Sequence of cells in the column at *column_idx* in this table. """ cells = self._cells idxs = range(column_idx, len(cells), self._column_count) return [cells[idx] for idx in idxs]
def column_cells(self, column_idx): """ Sequence of cells in the column at *column_idx* in this table. """ cells = self._cells idxs = range(column_idx, len(cells), self._column_count) return [cells[idx] for idx in idxs]
[ "Sequence", "of", "cells", "in", "the", "column", "at", "*", "column_idx", "*", "in", "this", "table", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/table.py#L83-L89
[ "def", "column_cells", "(", "self", ",", "column_idx", ")", ":", "cells", "=", "self", ".", "_cells", "idxs", "=", "range", "(", "column_idx", ",", "len", "(", "cells", ")", ",", "self", ".", "_column_count", ")", "return", "[", "cells", "[", "idx", ...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
Table.row_cells
Sequence of cells in the row at *row_idx* in this table.
docx/table.py
def row_cells(self, row_idx): """ Sequence of cells in the row at *row_idx* in this table. """ column_count = self._column_count start = row_idx * column_count end = start + column_count return self._cells[start:end]
def row_cells(self, row_idx): """ Sequence of cells in the row at *row_idx* in this table. """ column_count = self._column_count start = row_idx * column_count end = start + column_count return self._cells[start:end]
[ "Sequence", "of", "cells", "in", "the", "row", "at", "*", "row_idx", "*", "in", "this", "table", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/table.py#L99-L106
[ "def", "row_cells", "(", "self", ",", "row_idx", ")", ":", "column_count", "=", "self", ".", "_column_count", "start", "=", "row_idx", "*", "column_count", "end", "=", "start", "+", "column_count", "return", "self", ".", "_cells", "[", "start", ":", "end",...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
Table.style
Read/write. A |_TableStyle| object representing the style applied to this table. The default table style for the document (often `Normal Table`) is returned if the table has no directly-applied style. Assigning |None| to this property removes any directly-applied table style causing it t...
docx/table.py
def style(self): """ Read/write. A |_TableStyle| object representing the style applied to this table. The default table style for the document (often `Normal Table`) is returned if the table has no directly-applied style. Assigning |None| to this property removes any directly-app...
def style(self): """ Read/write. A |_TableStyle| object representing the style applied to this table. The default table style for the document (often `Normal Table`) is returned if the table has no directly-applied style. Assigning |None| to this property removes any directly-app...
[ "Read", "/", "write", ".", "A", "|_TableStyle|", "object", "representing", "the", "style", "applied", "to", "this", "table", ".", "The", "default", "table", "style", "for", "the", "document", "(", "often", "Normal", "Table", ")", "is", "returned", "if", "t...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/table.py#L116-L129
[ "def", "style", "(", "self", ")", ":", "style_id", "=", "self", ".", "_tbl", ".", "tblStyle_val", "return", "self", ".", "part", ".", "get_style", "(", "style_id", ",", "WD_STYLE_TYPE", ".", "TABLE", ")" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
Table._cells
A sequence of |_Cell| objects, one for each cell of the layout grid. If the table contains a span, one or more |_Cell| object references are repeated.
docx/table.py
def _cells(self): """ A sequence of |_Cell| objects, one for each cell of the layout grid. If the table contains a span, one or more |_Cell| object references are repeated. """ col_count = self._column_count cells = [] for tc in self._tbl.iter_tcs(): ...
def _cells(self): """ A sequence of |_Cell| objects, one for each cell of the layout grid. If the table contains a span, one or more |_Cell| object references are repeated. """ col_count = self._column_count cells = [] for tc in self._tbl.iter_tcs(): ...
[ "A", "sequence", "of", "|_Cell|", "objects", "one", "for", "each", "cell", "of", "the", "layout", "grid", ".", "If", "the", "table", "contains", "a", "span", "one", "or", "more", "|_Cell|", "object", "references", "are", "repeated", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/table.py#L162-L178
[ "def", "_cells", "(", "self", ")", ":", "col_count", "=", "self", ".", "_column_count", "cells", "=", "[", "]", "for", "tc", "in", "self", ".", "_tbl", ".", "iter_tcs", "(", ")", ":", "for", "grid_span_idx", "in", "range", "(", "tc", ".", "grid_span"...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_Cell.add_paragraph
Return a paragraph newly added to the end of the content in this cell. If present, *text* is added to the paragraph in a single run. If specified, the paragraph style *style* is applied. If *style* is not specified or is |None|, the result is as though the 'Normal' style was applied. Not...
docx/table.py
def add_paragraph(self, text='', style=None): """ Return a paragraph newly added to the end of the content in this cell. If present, *text* is added to the paragraph in a single run. If specified, the paragraph style *style* is applied. If *style* is not specified or is |None|, t...
def add_paragraph(self, text='', style=None): """ Return a paragraph newly added to the end of the content in this cell. If present, *text* is added to the paragraph in a single run. If specified, the paragraph style *style* is applied. If *style* is not specified or is |None|, t...
[ "Return", "a", "paragraph", "newly", "added", "to", "the", "end", "of", "the", "content", "in", "this", "cell", ".", "If", "present", "*", "text", "*", "is", "added", "to", "the", "paragraph", "in", "a", "single", "run", ".", "If", "specified", "the", ...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/table.py#L199-L211
[ "def", "add_paragraph", "(", "self", ",", "text", "=", "''", ",", "style", "=", "None", ")", ":", "return", "super", "(", "_Cell", ",", "self", ")", ".", "add_paragraph", "(", "text", ",", "style", ")" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_Cell.add_table
Return a table newly added to this cell after any existing cell content, having *rows* rows and *cols* columns. An empty paragraph is added after the table because Word requires a paragraph element as the last element in every cell.
docx/table.py
def add_table(self, rows, cols): """ Return a table newly added to this cell after any existing cell content, having *rows* rows and *cols* columns. An empty paragraph is added after the table because Word requires a paragraph element as the last element in every cell. ""...
def add_table(self, rows, cols): """ Return a table newly added to this cell after any existing cell content, having *rows* rows and *cols* columns. An empty paragraph is added after the table because Word requires a paragraph element as the last element in every cell. ""...
[ "Return", "a", "table", "newly", "added", "to", "this", "cell", "after", "any", "existing", "cell", "content", "having", "*", "rows", "*", "rows", "and", "*", "cols", "*", "columns", ".", "An", "empty", "paragraph", "is", "added", "after", "the", "table"...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/table.py#L213-L223
[ "def", "add_table", "(", "self", ",", "rows", ",", "cols", ")", ":", "width", "=", "self", ".", "width", "if", "self", ".", "width", "is", "not", "None", "else", "Inches", "(", "1", ")", "table", "=", "super", "(", "_Cell", ",", "self", ")", ".",...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_Cell.merge
Return a merged cell created by spanning the rectangular region having this cell and *other_cell* as diagonal corners. Raises |InvalidSpanError| if the cells do not define a rectangular region.
docx/table.py
def merge(self, other_cell): """ Return a merged cell created by spanning the rectangular region having this cell and *other_cell* as diagonal corners. Raises |InvalidSpanError| if the cells do not define a rectangular region. """ tc, tc_2 = self._tc, other_cell._tc ...
def merge(self, other_cell): """ Return a merged cell created by spanning the rectangular region having this cell and *other_cell* as diagonal corners. Raises |InvalidSpanError| if the cells do not define a rectangular region. """ tc, tc_2 = self._tc, other_cell._tc ...
[ "Return", "a", "merged", "cell", "created", "by", "spanning", "the", "rectangular", "region", "having", "this", "cell", "and", "*", "other_cell", "*", "as", "diagonal", "corners", ".", "Raises", "|InvalidSpanError|", "if", "the", "cells", "do", "not", "define"...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/table.py#L225-L233
[ "def", "merge", "(", "self", ",", "other_cell", ")", ":", "tc", ",", "tc_2", "=", "self", ".", "_tc", ",", "other_cell", ".", "_tc", "merged_tc", "=", "tc", ".", "merge", "(", "tc_2", ")", "return", "_Cell", "(", "merged_tc", ",", "self", ".", "_pa...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_Cell.text
Write-only. Set entire contents of cell to the string *text*. Any existing content or revisions are replaced.
docx/table.py
def text(self, text): """ Write-only. Set entire contents of cell to the string *text*. Any existing content or revisions are replaced. """ tc = self._tc tc.clear_content() p = tc.add_p() r = p.add_r() r.text = text
def text(self, text): """ Write-only. Set entire contents of cell to the string *text*. Any existing content or revisions are replaced. """ tc = self._tc tc.clear_content() p = tc.add_p() r = p.add_r() r.text = text
[ "Write", "-", "only", ".", "Set", "entire", "contents", "of", "cell", "to", "the", "string", "*", "text", "*", ".", "Any", "existing", "content", "or", "revisions", "are", "replaced", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/table.py#L261-L270
[ "def", "text", "(", "self", ",", "text", ")", ":", "tc", "=", "self", ".", "_tc", "tc", ".", "clear_content", "(", ")", "p", "=", "tc", ".", "add_p", "(", ")", "r", "=", "p", ".", "add_r", "(", ")", "r", ".", "text", "=", "text" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
BaseStoryPart.get_or_add_image
Return (rId, image) pair for image identified by *image_descriptor*. *rId* is the str key (often like "rId7") for the relationship between this story part and the image part, reused if already present, newly created if not. *image* is an |Image| instance providing access to the properties of th...
docx/parts/story.py
def get_or_add_image(self, image_descriptor): """Return (rId, image) pair for image identified by *image_descriptor*. *rId* is the str key (often like "rId7") for the relationship between this story part and the image part, reused if already present, newly created if not. *image* is an ...
def get_or_add_image(self, image_descriptor): """Return (rId, image) pair for image identified by *image_descriptor*. *rId* is the str key (often like "rId7") for the relationship between this story part and the image part, reused if already present, newly created if not. *image* is an ...
[ "Return", "(", "rId", "image", ")", "pair", "for", "image", "identified", "by", "*", "image_descriptor", "*", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/parts/story.py#L21-L31
[ "def", "get_or_add_image", "(", "self", ",", "image_descriptor", ")", ":", "image_part", "=", "self", ".", "_package", ".", "get_or_add_image_part", "(", "image_descriptor", ")", "rId", "=", "self", ".", "relate_to", "(", "image_part", ",", "RT", ".", "IMAGE",...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
BaseStoryPart.new_pic_inline
Return a newly-created `w:inline` element. The element contains the image specified by *image_descriptor* and is scaled based on the values of *width* and *height*.
docx/parts/story.py
def new_pic_inline(self, image_descriptor, width, height): """Return a newly-created `w:inline` element. The element contains the image specified by *image_descriptor* and is scaled based on the values of *width* and *height*. """ rId, image = self.get_or_add_image(image_descrip...
def new_pic_inline(self, image_descriptor, width, height): """Return a newly-created `w:inline` element. The element contains the image specified by *image_descriptor* and is scaled based on the values of *width* and *height*. """ rId, image = self.get_or_add_image(image_descrip...
[ "Return", "a", "newly", "-", "created", "w", ":", "inline", "element", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/parts/story.py#L50-L59
[ "def", "new_pic_inline", "(", "self", ",", "image_descriptor", ",", "width", ",", "height", ")", ":", "rId", ",", "image", "=", "self", ".", "get_or_add_image", "(", "image_descriptor", ")", "cx", ",", "cy", "=", "image", ".", "scaled_dimensions", "(", "wi...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
BaseStoryPart.next_id
Next available positive integer id value in this story XML document. The value is determined by incrementing the maximum existing id value. Gaps in the existing id sequence are not filled. The id attribute value is unique in the document, without regard to the element type it appears on.
docx/parts/story.py
def next_id(self): """Next available positive integer id value in this story XML document. The value is determined by incrementing the maximum existing id value. Gaps in the existing id sequence are not filled. The id attribute value is unique in the document, without regard to the elem...
def next_id(self): """Next available positive integer id value in this story XML document. The value is determined by incrementing the maximum existing id value. Gaps in the existing id sequence are not filled. The id attribute value is unique in the document, without regard to the elem...
[ "Next", "available", "positive", "integer", "id", "value", "in", "this", "story", "XML", "document", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/parts/story.py#L62-L73
[ "def", "next_id", "(", "self", ")", ":", "id_str_lst", "=", "self", ".", "_element", ".", "xpath", "(", "'//@id'", ")", "used_ids", "=", "[", "int", "(", "id_str", ")", "for", "id_str", "in", "id_str_lst", "if", "id_str", ".", "isdigit", "(", ")", "]...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_MarkerFactory
Return |_Marker| or subclass instance appropriate for marker at *offset* in *stream* having *marker_code*.
docx/image/jpeg.py
def _MarkerFactory(marker_code, stream, offset): """ Return |_Marker| or subclass instance appropriate for marker at *offset* in *stream* having *marker_code*. """ if marker_code == JPEG_MARKER_CODE.APP0: marker_cls = _App0Marker elif marker_code == JPEG_MARKER_CODE.APP1: marker_...
def _MarkerFactory(marker_code, stream, offset): """ Return |_Marker| or subclass instance appropriate for marker at *offset* in *stream* having *marker_code*. """ if marker_code == JPEG_MARKER_CODE.APP0: marker_cls = _App0Marker elif marker_code == JPEG_MARKER_CODE.APP1: marker_...
[ "Return", "|_Marker|", "or", "subclass", "instance", "appropriate", "for", "marker", "at", "*", "offset", "*", "in", "*", "stream", "*", "having", "*", "marker_code", "*", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/jpeg.py#L258-L271
[ "def", "_MarkerFactory", "(", "marker_code", ",", "stream", ",", "offset", ")", ":", "if", "marker_code", "==", "JPEG_MARKER_CODE", ".", "APP0", ":", "marker_cls", "=", "_App0Marker", "elif", "marker_code", "==", "JPEG_MARKER_CODE", ".", "APP1", ":", "marker_cls...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
Exif.from_stream
Return |Exif| instance having header properties parsed from Exif image in *stream*.
docx/image/jpeg.py
def from_stream(cls, stream): """ Return |Exif| instance having header properties parsed from Exif image in *stream*. """ markers = _JfifMarkers.from_stream(stream) # print('\n%s' % markers) px_width = markers.sof.px_width px_height = markers.sof.px_heigh...
def from_stream(cls, stream): """ Return |Exif| instance having header properties parsed from Exif image in *stream*. """ markers = _JfifMarkers.from_stream(stream) # print('\n%s' % markers) px_width = markers.sof.px_width px_height = markers.sof.px_heigh...
[ "Return", "|Exif|", "instance", "having", "header", "properties", "parsed", "from", "Exif", "image", "in", "*", "stream", "*", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/jpeg.py#L42-L55
[ "def", "from_stream", "(", "cls", ",", "stream", ")", ":", "markers", "=", "_JfifMarkers", ".", "from_stream", "(", "stream", ")", "# print('\\n%s' % markers)", "px_width", "=", "markers", ".", "sof", ".", "px_width", "px_height", "=", "markers", ".", "sof", ...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_JfifMarkers.from_stream
Return a |_JfifMarkers| instance containing a |_JfifMarker| subclass instance for each marker in *stream*.
docx/image/jpeg.py
def from_stream(cls, stream): """ Return a |_JfifMarkers| instance containing a |_JfifMarker| subclass instance for each marker in *stream*. """ marker_parser = _MarkerParser.from_stream(stream) markers = [] for marker in marker_parser.iter_markers(): ...
def from_stream(cls, stream): """ Return a |_JfifMarkers| instance containing a |_JfifMarker| subclass instance for each marker in *stream*. """ marker_parser = _MarkerParser.from_stream(stream) markers = [] for marker in marker_parser.iter_markers(): ...
[ "Return", "a", "|_JfifMarkers|", "instance", "containing", "a", "|_JfifMarker|", "subclass", "instance", "for", "each", "marker", "in", "*", "stream", "*", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/jpeg.py#L104-L115
[ "def", "from_stream", "(", "cls", ",", "stream", ")", ":", "marker_parser", "=", "_MarkerParser", ".", "from_stream", "(", "stream", ")", "markers", "=", "[", "]", "for", "marker", "in", "marker_parser", ".", "iter_markers", "(", ")", ":", "markers", ".", ...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_JfifMarkers.app0
First APP0 marker in image markers.
docx/image/jpeg.py
def app0(self): """ First APP0 marker in image markers. """ for m in self._markers: if m.marker_code == JPEG_MARKER_CODE.APP0: return m raise KeyError('no APP0 marker in image')
def app0(self): """ First APP0 marker in image markers. """ for m in self._markers: if m.marker_code == JPEG_MARKER_CODE.APP0: return m raise KeyError('no APP0 marker in image')
[ "First", "APP0", "marker", "in", "image", "markers", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/jpeg.py#L118-L125
[ "def", "app0", "(", "self", ")", ":", "for", "m", "in", "self", ".", "_markers", ":", "if", "m", ".", "marker_code", "==", "JPEG_MARKER_CODE", ".", "APP0", ":", "return", "m", "raise", "KeyError", "(", "'no APP0 marker in image'", ")" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_JfifMarkers.app1
First APP1 marker in image markers.
docx/image/jpeg.py
def app1(self): """ First APP1 marker in image markers. """ for m in self._markers: if m.marker_code == JPEG_MARKER_CODE.APP1: return m raise KeyError('no APP1 marker in image')
def app1(self): """ First APP1 marker in image markers. """ for m in self._markers: if m.marker_code == JPEG_MARKER_CODE.APP1: return m raise KeyError('no APP1 marker in image')
[ "First", "APP1", "marker", "in", "image", "markers", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/jpeg.py#L128-L135
[ "def", "app1", "(", "self", ")", ":", "for", "m", "in", "self", ".", "_markers", ":", "if", "m", ".", "marker_code", "==", "JPEG_MARKER_CODE", ".", "APP1", ":", "return", "m", "raise", "KeyError", "(", "'no APP1 marker in image'", ")" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_JfifMarkers.sof
First start of frame (SOFn) marker in this sequence.
docx/image/jpeg.py
def sof(self): """ First start of frame (SOFn) marker in this sequence. """ for m in self._markers: if m.marker_code in JPEG_MARKER_CODE.SOF_MARKER_CODES: return m raise KeyError('no start of frame (SOFn) marker in image')
def sof(self): """ First start of frame (SOFn) marker in this sequence. """ for m in self._markers: if m.marker_code in JPEG_MARKER_CODE.SOF_MARKER_CODES: return m raise KeyError('no start of frame (SOFn) marker in image')
[ "First", "start", "of", "frame", "(", "SOFn", ")", "marker", "in", "this", "sequence", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/jpeg.py#L138-L145
[ "def", "sof", "(", "self", ")", ":", "for", "m", "in", "self", ".", "_markers", ":", "if", "m", ".", "marker_code", "in", "JPEG_MARKER_CODE", ".", "SOF_MARKER_CODES", ":", "return", "m", "raise", "KeyError", "(", "'no start of frame (SOFn) marker in image'", "...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_MarkerParser.iter_markers
Generate a (marker_code, segment_offset) 2-tuple for each marker in the JPEG *stream*, in the order they occur in the stream.
docx/image/jpeg.py
def iter_markers(self): """ Generate a (marker_code, segment_offset) 2-tuple for each marker in the JPEG *stream*, in the order they occur in the stream. """ marker_finder = _MarkerFinder.from_stream(self._stream) start = 0 marker_code = None while marker_...
def iter_markers(self): """ Generate a (marker_code, segment_offset) 2-tuple for each marker in the JPEG *stream*, in the order they occur in the stream. """ marker_finder = _MarkerFinder.from_stream(self._stream) start = 0 marker_code = None while marker_...
[ "Generate", "a", "(", "marker_code", "segment_offset", ")", "2", "-", "tuple", "for", "each", "marker", "in", "the", "JPEG", "*", "stream", "*", "in", "the", "order", "they", "occur", "in", "the", "stream", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/jpeg.py#L166-L180
[ "def", "iter_markers", "(", "self", ")", ":", "marker_finder", "=", "_MarkerFinder", ".", "from_stream", "(", "self", ".", "_stream", ")", "start", "=", "0", "marker_code", "=", "None", "while", "marker_code", "!=", "JPEG_MARKER_CODE", ".", "EOI", ":", "mark...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_MarkerFinder.next
Return a (marker_code, segment_offset) 2-tuple identifying and locating the first marker in *stream* occuring after offset *start*. The returned *segment_offset* points to the position immediately following the 2-byte marker code, the start of the marker segment, for those markers that h...
docx/image/jpeg.py
def next(self, start): """ Return a (marker_code, segment_offset) 2-tuple identifying and locating the first marker in *stream* occuring after offset *start*. The returned *segment_offset* points to the position immediately following the 2-byte marker code, the start of the marke...
def next(self, start): """ Return a (marker_code, segment_offset) 2-tuple identifying and locating the first marker in *stream* occuring after offset *start*. The returned *segment_offset* points to the position immediately following the 2-byte marker code, the start of the marke...
[ "Return", "a", "(", "marker_code", "segment_offset", ")", "2", "-", "tuple", "identifying", "and", "locating", "the", "first", "marker", "in", "*", "stream", "*", "occuring", "after", "offset", "*", "start", "*", ".", "The", "returned", "*", "segment_offset"...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/jpeg.py#L198-L218
[ "def", "next", "(", "self", ",", "start", ")", ":", "position", "=", "start", "while", "True", ":", "# skip over any non-\\xFF bytes", "position", "=", "self", ".", "_offset_of_next_ff_byte", "(", "start", "=", "position", ")", "# skip over any \\xFF padding bytes",...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_MarkerFinder._next_non_ff_byte
Return an offset, byte 2-tuple for the next byte in *stream* that is not '\xFF', starting with the byte at offset *start*. If the byte at offset *start* is not '\xFF', *start* and the returned *offset* will be the same.
docx/image/jpeg.py
def _next_non_ff_byte(self, start): """ Return an offset, byte 2-tuple for the next byte in *stream* that is not '\xFF', starting with the byte at offset *start*. If the byte at offset *start* is not '\xFF', *start* and the returned *offset* will be the same. """ ...
def _next_non_ff_byte(self, start): """ Return an offset, byte 2-tuple for the next byte in *stream* that is not '\xFF', starting with the byte at offset *start*. If the byte at offset *start* is not '\xFF', *start* and the returned *offset* will be the same. """ ...
[ "Return", "an", "offset", "byte", "2", "-", "tuple", "for", "the", "next", "byte", "in", "*", "stream", "*", "that", "is", "not", "\\", "xFF", "starting", "with", "the", "byte", "at", "offset", "*", "start", "*", ".", "If", "the", "byte", "at", "of...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/jpeg.py#L220-L232
[ "def", "_next_non_ff_byte", "(", "self", ",", "start", ")", ":", "self", ".", "_stream", ".", "seek", "(", "start", ")", "byte_", "=", "self", ".", "_read_byte", "(", ")", "while", "byte_", "==", "b'\\xFF'", ":", "byte_", "=", "self", ".", "_read_byte"...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_MarkerFinder._offset_of_next_ff_byte
Return the offset of the next '\xFF' byte in *stream* starting with the byte at offset *start*. Returns *start* if the byte at that offset is a hex 255; it does not necessarily advance in the stream.
docx/image/jpeg.py
def _offset_of_next_ff_byte(self, start): """ Return the offset of the next '\xFF' byte in *stream* starting with the byte at offset *start*. Returns *start* if the byte at that offset is a hex 255; it does not necessarily advance in the stream. """ self._stream.seek(star...
def _offset_of_next_ff_byte(self, start): """ Return the offset of the next '\xFF' byte in *stream* starting with the byte at offset *start*. Returns *start* if the byte at that offset is a hex 255; it does not necessarily advance in the stream. """ self._stream.seek(star...
[ "Return", "the", "offset", "of", "the", "next", "\\", "xFF", "byte", "in", "*", "stream", "*", "starting", "with", "the", "byte", "at", "offset", "*", "start", "*", ".", "Returns", "*", "start", "*", "if", "the", "byte", "at", "that", "offset", "is",...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/jpeg.py#L234-L245
[ "def", "_offset_of_next_ff_byte", "(", "self", ",", "start", ")", ":", "self", ".", "_stream", ".", "seek", "(", "start", ")", "byte_", "=", "self", ".", "_read_byte", "(", ")", "while", "byte_", "!=", "b'\\xFF'", ":", "byte_", "=", "self", ".", "_read...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_Marker.from_stream
Return a generic |_Marker| instance for the marker at *offset* in *stream* having *marker_code*.
docx/image/jpeg.py
def from_stream(cls, stream, marker_code, offset): """ Return a generic |_Marker| instance for the marker at *offset* in *stream* having *marker_code*. """ if JPEG_MARKER_CODE.is_standalone(marker_code): segment_length = 0 else: segment_length = st...
def from_stream(cls, stream, marker_code, offset): """ Return a generic |_Marker| instance for the marker at *offset* in *stream* having *marker_code*. """ if JPEG_MARKER_CODE.is_standalone(marker_code): segment_length = 0 else: segment_length = st...
[ "Return", "a", "generic", "|_Marker|", "instance", "for", "the", "marker", "at", "*", "offset", "*", "in", "*", "stream", "*", "having", "*", "marker_code", "*", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/jpeg.py#L286-L295
[ "def", "from_stream", "(", "cls", ",", "stream", ",", "marker_code", ",", "offset", ")", ":", "if", "JPEG_MARKER_CODE", ".", "is_standalone", "(", "marker_code", ")", ":", "segment_length", "=", "0", "else", ":", "segment_length", "=", "stream", ".", "read_s...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_App0Marker._dpi
Return dots per inch corresponding to *density* value.
docx/image/jpeg.py
def _dpi(self, density): """ Return dots per inch corresponding to *density* value. """ if self._density_units == 1: dpi = density elif self._density_units == 2: dpi = int(round(density * 2.54)) else: dpi = 72 return dpi
def _dpi(self, density): """ Return dots per inch corresponding to *density* value. """ if self._density_units == 1: dpi = density elif self._density_units == 2: dpi = int(round(density * 2.54)) else: dpi = 72 return dpi
[ "Return", "dots", "per", "inch", "corresponding", "to", "*", "density", "*", "value", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/jpeg.py#L349-L359
[ "def", "_dpi", "(", "self", ",", "density", ")", ":", "if", "self", ".", "_density_units", "==", "1", ":", "dpi", "=", "density", "elif", "self", ".", "_density_units", "==", "2", ":", "dpi", "=", "int", "(", "round", "(", "density", "*", "2.54", "...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_App0Marker.from_stream
Return an |_App0Marker| instance for the APP0 marker at *offset* in *stream*.
docx/image/jpeg.py
def from_stream(cls, stream, marker_code, offset): """ Return an |_App0Marker| instance for the APP0 marker at *offset* in *stream*. """ # field off type notes # ------------------ --- ----- ------------------- # segment length 0 short ...
def from_stream(cls, stream, marker_code, offset): """ Return an |_App0Marker| instance for the APP0 marker at *offset* in *stream*. """ # field off type notes # ------------------ --- ----- ------------------- # segment length 0 short ...
[ "Return", "an", "|_App0Marker|", "instance", "for", "the", "APP0", "marker", "at", "*", "offset", "*", "in", "*", "stream", "*", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/jpeg.py#L362-L384
[ "def", "from_stream", "(", "cls", ",", "stream", ",", "marker_code", ",", "offset", ")", ":", "# field off type notes", "# ------------------ --- ----- -------------------", "# segment length 0 short", "# JFIF identifier 2 5 chr 'JFIF\\x00'", "# ma...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_App1Marker.from_stream
Extract the horizontal and vertical dots-per-inch value from the APP1 header at *offset* in *stream*.
docx/image/jpeg.py
def from_stream(cls, stream, marker_code, offset): """ Extract the horizontal and vertical dots-per-inch value from the APP1 header at *offset* in *stream*. """ # field off len type notes # -------------------- --- --- ----- -----------------------...
def from_stream(cls, stream, marker_code, offset): """ Extract the horizontal and vertical dots-per-inch value from the APP1 header at *offset* in *stream*. """ # field off len type notes # -------------------- --- --- ----- -----------------------...
[ "Extract", "the", "horizontal", "and", "vertical", "dots", "-", "per", "-", "inch", "value", "from", "the", "APP1", "header", "at", "*", "offset", "*", "in", "*", "stream", "*", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/jpeg.py#L397-L416
[ "def", "from_stream", "(", "cls", ",", "stream", ",", "marker_code", ",", "offset", ")", ":", "# field off len type notes", "# -------------------- --- --- ----- ----------------------------", "# segment length 0 2 short", "# Exif identifier ...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_App1Marker._is_non_Exif_APP1_segment
Return True if the APP1 segment at *offset* in *stream* is NOT an Exif segment, as determined by the ``'Exif\x00\x00'`` signature at offset 2 in the segment.
docx/image/jpeg.py
def _is_non_Exif_APP1_segment(cls, stream, offset): """ Return True if the APP1 segment at *offset* in *stream* is NOT an Exif segment, as determined by the ``'Exif\x00\x00'`` signature at offset 2 in the segment. """ stream.seek(offset+2) exif_signature = stream....
def _is_non_Exif_APP1_segment(cls, stream, offset): """ Return True if the APP1 segment at *offset* in *stream* is NOT an Exif segment, as determined by the ``'Exif\x00\x00'`` signature at offset 2 in the segment. """ stream.seek(offset+2) exif_signature = stream....
[ "Return", "True", "if", "the", "APP1", "segment", "at", "*", "offset", "*", "in", "*", "stream", "*", "is", "NOT", "an", "Exif", "segment", "as", "determined", "by", "the", "Exif", "\\", "x00", "\\", "x00", "signature", "at", "offset", "2", "in", "th...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/jpeg.py#L435-L443
[ "def", "_is_non_Exif_APP1_segment", "(", "cls", ",", "stream", ",", "offset", ")", ":", "stream", ".", "seek", "(", "offset", "+", "2", ")", "exif_signature", "=", "stream", ".", "read", "(", "6", ")", "return", "exif_signature", "!=", "b'Exif\\x00\\x00'" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_App1Marker._tiff_from_exif_segment
Return a |Tiff| instance parsed from the Exif APP1 segment of *segment_length* at *offset* in *stream*.
docx/image/jpeg.py
def _tiff_from_exif_segment(cls, stream, offset, segment_length): """ Return a |Tiff| instance parsed from the Exif APP1 segment of *segment_length* at *offset* in *stream*. """ # wrap full segment in its own stream and feed to Tiff() stream.seek(offset+8) segment...
def _tiff_from_exif_segment(cls, stream, offset, segment_length): """ Return a |Tiff| instance parsed from the Exif APP1 segment of *segment_length* at *offset* in *stream*. """ # wrap full segment in its own stream and feed to Tiff() stream.seek(offset+8) segment...
[ "Return", "a", "|Tiff|", "instance", "parsed", "from", "the", "Exif", "APP1", "segment", "of", "*", "segment_length", "*", "at", "*", "offset", "*", "in", "*", "stream", "*", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/jpeg.py#L446-L455
[ "def", "_tiff_from_exif_segment", "(", "cls", ",", "stream", ",", "offset", ",", "segment_length", ")", ":", "# wrap full segment in its own stream and feed to Tiff()", "stream", ".", "seek", "(", "offset", "+", "8", ")", "segment_bytes", "=", "stream", ".", "read",...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_SofMarker.from_stream
Return an |_SofMarker| instance for the SOFn marker at *offset* in stream.
docx/image/jpeg.py
def from_stream(cls, stream, marker_code, offset): """ Return an |_SofMarker| instance for the SOFn marker at *offset* in stream. """ # field off type notes # ------------------ --- ----- ---------------------------- # segment length 0 ...
def from_stream(cls, stream, marker_code, offset): """ Return an |_SofMarker| instance for the SOFn marker at *offset* in stream. """ # field off type notes # ------------------ --- ----- ---------------------------- # segment length 0 ...
[ "Return", "an", "|_SofMarker|", "instance", "for", "the", "SOFn", "marker", "at", "*", "offset", "*", "in", "stream", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/jpeg.py#L469-L484
[ "def", "from_stream", "(", "cls", ",", "stream", ",", "marker_code", ",", "offset", ")", ":", "# field off type notes", "# ------------------ --- ----- ----------------------------", "# segment length 0 short", "# Data precision 2 byte", "# Verti...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Row.tc_at_grid_col
The ``<w:tc>`` element appearing at grid column *idx*. Raises |ValueError| if no ``w:tc`` element begins at that grid column.
docx/oxml/table.py
def tc_at_grid_col(self, idx): """ The ``<w:tc>`` element appearing at grid column *idx*. Raises |ValueError| if no ``w:tc`` element begins at that grid column. """ grid_col = 0 for tc in self.tc_lst: if grid_col == idx: return tc g...
def tc_at_grid_col(self, idx): """ The ``<w:tc>`` element appearing at grid column *idx*. Raises |ValueError| if no ``w:tc`` element begins at that grid column. """ grid_col = 0 for tc in self.tc_lst: if grid_col == idx: return tc g...
[ "The", "<w", ":", "tc", ">", "element", "appearing", "at", "grid", "column", "*", "idx", "*", ".", "Raises", "|ValueError|", "if", "no", "w", ":", "tc", "element", "begins", "at", "that", "grid", "column", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L39-L51
[ "def", "tc_at_grid_col", "(", "self", ",", "idx", ")", ":", "grid_col", "=", "0", "for", "tc", "in", "self", ".", "tc_lst", ":", "if", "grid_col", "==", "idx", ":", "return", "tc", "grid_col", "+=", "tc", ".", "grid_span", "if", "grid_col", ">", "idx...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Tbl.new_tbl
Return a new `w:tbl` element having *rows* rows and *cols* columns with *width* distributed evenly between the columns.
docx/oxml/table.py
def new_tbl(cls, rows, cols, width): """ Return a new `w:tbl` element having *rows* rows and *cols* columns with *width* distributed evenly between the columns. """ return parse_xml(cls._tbl_xml(rows, cols, width))
def new_tbl(cls, rows, cols, width): """ Return a new `w:tbl` element having *rows* rows and *cols* columns with *width* distributed evenly between the columns. """ return parse_xml(cls._tbl_xml(rows, cols, width))
[ "Return", "a", "new", "w", ":", "tbl", "element", "having", "*", "rows", "*", "rows", "and", "*", "cols", "*", "columns", "with", "*", "width", "*", "distributed", "evenly", "between", "the", "columns", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L153-L158
[ "def", "new_tbl", "(", "cls", ",", "rows", ",", "cols", ",", "width", ")", ":", "return", "parse_xml", "(", "cls", ".", "_tbl_xml", "(", "rows", ",", "cols", ",", "width", ")", ")" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Tbl.tblStyle_val
Set the value of `w:tblPr/w:tblStyle/@w:val` (a table style id) to *styleId*. If *styleId* is None, remove the `w:tblStyle` element.
docx/oxml/table.py
def tblStyle_val(self, styleId): """ Set the value of `w:tblPr/w:tblStyle/@w:val` (a table style id) to *styleId*. If *styleId* is None, remove the `w:tblStyle` element. """ tblPr = self.tblPr tblPr._remove_tblStyle() if styleId is None: return ...
def tblStyle_val(self, styleId): """ Set the value of `w:tblPr/w:tblStyle/@w:val` (a table style id) to *styleId*. If *styleId* is None, remove the `w:tblStyle` element. """ tblPr = self.tblPr tblPr._remove_tblStyle() if styleId is None: return ...
[ "Set", "the", "value", "of", "w", ":", "tblPr", "/", "w", ":", "tblStyle", "/" ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L172-L181
[ "def", "tblStyle_val", "(", "self", ",", "styleId", ")", ":", "tblPr", "=", "self", ".", "tblPr", "tblPr", ".", "_remove_tblStyle", "(", ")", "if", "styleId", "is", "None", ":", "return", "tblPr", ".", "_add_tblStyle", "(", ")", ".", "val", "=", "style...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_TblPr.autofit
Return |False| if there is a ``<w:tblLayout>`` child with ``w:type`` attribute set to ``'fixed'``. Otherwise return |True|.
docx/oxml/table.py
def autofit(self): """ Return |False| if there is a ``<w:tblLayout>`` child with ``w:type`` attribute set to ``'fixed'``. Otherwise return |True|. """ tblLayout = self.tblLayout if tblLayout is None: return True return False if tblLayout.type == 'fixed...
def autofit(self): """ Return |False| if there is a ``<w:tblLayout>`` child with ``w:type`` attribute set to ``'fixed'``. Otherwise return |True|. """ tblLayout = self.tblLayout if tblLayout is None: return True return False if tblLayout.type == 'fixed...
[ "Return", "|False|", "if", "there", "is", "a", "<w", ":", "tblLayout", ">", "child", "with", "w", ":", "type", "attribute", "set", "to", "fixed", ".", "Otherwise", "return", "|True|", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L308-L316
[ "def", "autofit", "(", "self", ")", ":", "tblLayout", "=", "self", ".", "tblLayout", "if", "tblLayout", "is", "None", ":", "return", "True", "return", "False", "if", "tblLayout", ".", "type", "==", "'fixed'", "else", "True" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Tc.bottom
The row index that marks the bottom extent of the vertical span of this cell. This is one greater than the index of the bottom-most row of the span, similar to how a slice of the cell's rows would be specified.
docx/oxml/table.py
def bottom(self): """ The row index that marks the bottom extent of the vertical span of this cell. This is one greater than the index of the bottom-most row of the span, similar to how a slice of the cell's rows would be specified. """ if self.vMerge is not None:...
def bottom(self): """ The row index that marks the bottom extent of the vertical span of this cell. This is one greater than the index of the bottom-most row of the span, similar to how a slice of the cell's rows would be specified. """ if self.vMerge is not None:...
[ "The", "row", "index", "that", "marks", "the", "bottom", "extent", "of", "the", "vertical", "span", "of", "this", "cell", ".", "This", "is", "one", "greater", "than", "the", "index", "of", "the", "bottom", "-", "most", "row", "of", "the", "span", "simi...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L377-L388
[ "def", "bottom", "(", "self", ")", ":", "if", "self", ".", "vMerge", "is", "not", "None", ":", "tc_below", "=", "self", ".", "_tc_below", "if", "tc_below", "is", "not", "None", "and", "tc_below", ".", "vMerge", "==", "ST_Merge", ".", "CONTINUE", ":", ...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Tc.clear_content
Remove all content child elements, preserving the ``<w:tcPr>`` element if present. Note that this leaves the ``<w:tc>`` element in an invalid state because it doesn't contain at least one block-level element. It's up to the caller to add a ``<w:p>``child element as the last content eleme...
docx/oxml/table.py
def clear_content(self): """ Remove all content child elements, preserving the ``<w:tcPr>`` element if present. Note that this leaves the ``<w:tc>`` element in an invalid state because it doesn't contain at least one block-level element. It's up to the caller to add a ``<w:p>``ch...
def clear_content(self): """ Remove all content child elements, preserving the ``<w:tcPr>`` element if present. Note that this leaves the ``<w:tc>`` element in an invalid state because it doesn't contain at least one block-level element. It's up to the caller to add a ``<w:p>``ch...
[ "Remove", "all", "content", "child", "elements", "preserving", "the", "<w", ":", "tcPr", ">", "element", "if", "present", ".", "Note", "that", "this", "leaves", "the", "<w", ":", "tc", ">", "element", "in", "an", "invalid", "state", "because", "it", "doe...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L390-L402
[ "def", "clear_content", "(", "self", ")", ":", "new_children", "=", "[", "]", "tcPr", "=", "self", ".", "tcPr", "if", "tcPr", "is", "not", "None", ":", "new_children", ".", "append", "(", "tcPr", ")", "self", "[", ":", "]", "=", "new_children" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Tc.iter_block_items
Generate a reference to each of the block-level content elements in this cell, in the order they appear.
docx/oxml/table.py
def iter_block_items(self): """ Generate a reference to each of the block-level content elements in this cell, in the order they appear. """ block_item_tags = (qn('w:p'), qn('w:tbl'), qn('w:sdt')) for child in self: if child.tag in block_item_tags: ...
def iter_block_items(self): """ Generate a reference to each of the block-level content elements in this cell, in the order they appear. """ block_item_tags = (qn('w:p'), qn('w:tbl'), qn('w:sdt')) for child in self: if child.tag in block_item_tags: ...
[ "Generate", "a", "reference", "to", "each", "of", "the", "block", "-", "level", "content", "elements", "in", "this", "cell", "in", "the", "order", "they", "appear", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L420-L428
[ "def", "iter_block_items", "(", "self", ")", ":", "block_item_tags", "=", "(", "qn", "(", "'w:p'", ")", ",", "qn", "(", "'w:tbl'", ")", ",", "qn", "(", "'w:sdt'", ")", ")", "for", "child", "in", "self", ":", "if", "child", ".", "tag", "in", "block_...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Tc.merge
Return the top-left ``<w:tc>`` element of a new span formed by merging the rectangular region defined by using this tc element and *other_tc* as diagonal corners.
docx/oxml/table.py
def merge(self, other_tc): """ Return the top-left ``<w:tc>`` element of a new span formed by merging the rectangular region defined by using this tc element and *other_tc* as diagonal corners. """ top, left, height, width = self._span_dimensions(other_tc) top_tc ...
def merge(self, other_tc): """ Return the top-left ``<w:tc>`` element of a new span formed by merging the rectangular region defined by using this tc element and *other_tc* as diagonal corners. """ top, left, height, width = self._span_dimensions(other_tc) top_tc ...
[ "Return", "the", "top", "-", "left", "<w", ":", "tc", ">", "element", "of", "a", "new", "span", "formed", "by", "merging", "the", "rectangular", "region", "defined", "by", "using", "this", "tc", "element", "and", "*", "other_tc", "*", "as", "diagonal", ...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L437-L446
[ "def", "merge", "(", "self", ",", "other_tc", ")", ":", "top", ",", "left", ",", "height", ",", "width", "=", "self", ".", "_span_dimensions", "(", "other_tc", ")", "top_tc", "=", "self", ".", "_tbl", ".", "tr_lst", "[", "top", "]", ".", "tc_at_grid_...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Tc.top
The top-most row index in the vertical span of this cell.
docx/oxml/table.py
def top(self): """ The top-most row index in the vertical span of this cell. """ if self.vMerge is None or self.vMerge == ST_Merge.RESTART: return self._tr_idx return self._tc_above.top
def top(self): """ The top-most row index in the vertical span of this cell. """ if self.vMerge is None or self.vMerge == ST_Merge.RESTART: return self._tr_idx return self._tc_above.top
[ "The", "top", "-", "most", "row", "index", "in", "the", "vertical", "span", "of", "this", "cell", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L471-L477
[ "def", "top", "(", "self", ")", ":", "if", "self", ".", "vMerge", "is", "None", "or", "self", ".", "vMerge", "==", "ST_Merge", ".", "RESTART", ":", "return", "self", ".", "_tr_idx", "return", "self", ".", "_tc_above", ".", "top" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Tc._add_width_of
Add the width of *other_tc* to this cell. Does nothing if either this tc or *other_tc* does not have a specified width.
docx/oxml/table.py
def _add_width_of(self, other_tc): """ Add the width of *other_tc* to this cell. Does nothing if either this tc or *other_tc* does not have a specified width. """ if self.width and other_tc.width: self.width += other_tc.width
def _add_width_of(self, other_tc): """ Add the width of *other_tc* to this cell. Does nothing if either this tc or *other_tc* does not have a specified width. """ if self.width and other_tc.width: self.width += other_tc.width
[ "Add", "the", "width", "of", "*", "other_tc", "*", "to", "this", "cell", ".", "Does", "nothing", "if", "either", "this", "tc", "or", "*", "other_tc", "*", "does", "not", "have", "a", "specified", "width", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L511-L517
[ "def", "_add_width_of", "(", "self", ",", "other_tc", ")", ":", "if", "self", ".", "width", "and", "other_tc", ".", "width", ":", "self", ".", "width", "+=", "other_tc", ".", "width" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Tc._grid_col
The grid column at which this cell begins.
docx/oxml/table.py
def _grid_col(self): """ The grid column at which this cell begins. """ tr = self._tr idx = tr.tc_lst.index(self) preceding_tcs = tr.tc_lst[:idx] return sum(tc.grid_span for tc in preceding_tcs)
def _grid_col(self): """ The grid column at which this cell begins. """ tr = self._tr idx = tr.tc_lst.index(self) preceding_tcs = tr.tc_lst[:idx] return sum(tc.grid_span for tc in preceding_tcs)
[ "The", "grid", "column", "at", "which", "this", "cell", "begins", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L520-L527
[ "def", "_grid_col", "(", "self", ")", ":", "tr", "=", "self", ".", "_tr", "idx", "=", "tr", ".", "tc_lst", ".", "index", "(", "self", ")", "preceding_tcs", "=", "tr", ".", "tc_lst", "[", ":", "idx", "]", "return", "sum", "(", "tc", ".", "grid_spa...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Tc._grow_to
Grow this cell to *width* grid columns and *height* rows by expanding horizontal spans and creating continuation cells to form vertical spans.
docx/oxml/table.py
def _grow_to(self, width, height, top_tc=None): """ Grow this cell to *width* grid columns and *height* rows by expanding horizontal spans and creating continuation cells to form vertical spans. """ def vMerge_val(top_tc): if top_tc is not self: ...
def _grow_to(self, width, height, top_tc=None): """ Grow this cell to *width* grid columns and *height* rows by expanding horizontal spans and creating continuation cells to form vertical spans. """ def vMerge_val(top_tc): if top_tc is not self: ...
[ "Grow", "this", "cell", "to", "*", "width", "*", "grid", "columns", "and", "*", "height", "*", "rows", "by", "expanding", "horizontal", "spans", "and", "creating", "continuation", "cells", "to", "form", "vertical", "spans", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L529-L545
[ "def", "_grow_to", "(", "self", ",", "width", ",", "height", ",", "top_tc", "=", "None", ")", ":", "def", "vMerge_val", "(", "top_tc", ")", ":", "if", "top_tc", "is", "not", "self", ":", "return", "ST_Merge", ".", "CONTINUE", "if", "height", "==", "1...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Tc._is_empty
True if this cell contains only a single empty ``<w:p>`` element.
docx/oxml/table.py
def _is_empty(self): """ True if this cell contains only a single empty ``<w:p>`` element. """ block_items = list(self.iter_block_items()) if len(block_items) > 1: return False p = block_items[0] # cell must include at least one <w:p> element if len(p...
def _is_empty(self): """ True if this cell contains only a single empty ``<w:p>`` element. """ block_items = list(self.iter_block_items()) if len(block_items) > 1: return False p = block_items[0] # cell must include at least one <w:p> element if len(p...
[ "True", "if", "this", "cell", "contains", "only", "a", "single", "empty", "<w", ":", "p", ">", "element", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L557-L567
[ "def", "_is_empty", "(", "self", ")", ":", "block_items", "=", "list", "(", "self", ".", "iter_block_items", "(", ")", ")", "if", "len", "(", "block_items", ")", ">", "1", ":", "return", "False", "p", "=", "block_items", "[", "0", "]", "# cell must inc...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Tc._move_content_to
Append the content of this cell to *other_tc*, leaving this cell with a single empty ``<w:p>`` element.
docx/oxml/table.py
def _move_content_to(self, other_tc): """ Append the content of this cell to *other_tc*, leaving this cell with a single empty ``<w:p>`` element. """ if other_tc is self: return if self._is_empty: return other_tc._remove_trailing_empty_p() ...
def _move_content_to(self, other_tc): """ Append the content of this cell to *other_tc*, leaving this cell with a single empty ``<w:p>`` element. """ if other_tc is self: return if self._is_empty: return other_tc._remove_trailing_empty_p() ...
[ "Append", "the", "content", "of", "this", "cell", "to", "*", "other_tc", "*", "leaving", "this", "cell", "with", "a", "single", "empty", "<w", ":", "p", ">", "element", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L569-L583
[ "def", "_move_content_to", "(", "self", ",", "other_tc", ")", ":", "if", "other_tc", "is", "self", ":", "return", "if", "self", ".", "_is_empty", ":", "return", "other_tc", ".", "_remove_trailing_empty_p", "(", ")", "# appending moves each element from self to other...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Tc._remove_trailing_empty_p
Remove the last content element from this cell if it is an empty ``<w:p>`` element.
docx/oxml/table.py
def _remove_trailing_empty_p(self): """ Remove the last content element from this cell if it is an empty ``<w:p>`` element. """ block_items = list(self.iter_block_items()) last_content_elm = block_items[-1] if last_content_elm.tag != qn('w:p'): return ...
def _remove_trailing_empty_p(self): """ Remove the last content element from this cell if it is an empty ``<w:p>`` element. """ block_items = list(self.iter_block_items()) last_content_elm = block_items[-1] if last_content_elm.tag != qn('w:p'): return ...
[ "Remove", "the", "last", "content", "element", "from", "this", "cell", "if", "it", "is", "an", "empty", "<w", ":", "p", ">", "element", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L603-L615
[ "def", "_remove_trailing_empty_p", "(", "self", ")", ":", "block_items", "=", "list", "(", "self", ".", "iter_block_items", "(", ")", ")", "last_content_elm", "=", "block_items", "[", "-", "1", "]", "if", "last_content_elm", ".", "tag", "!=", "qn", "(", "'...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Tc._span_dimensions
Return a (top, left, height, width) 4-tuple specifying the extents of the merged cell formed by using this tc and *other_tc* as opposite corner extents.
docx/oxml/table.py
def _span_dimensions(self, other_tc): """ Return a (top, left, height, width) 4-tuple specifying the extents of the merged cell formed by using this tc and *other_tc* as opposite corner extents. """ def raise_on_inverted_L(a, b): if a.top == b.top and a.bottom...
def _span_dimensions(self, other_tc): """ Return a (top, left, height, width) 4-tuple specifying the extents of the merged cell formed by using this tc and *other_tc* as opposite corner extents. """ def raise_on_inverted_L(a, b): if a.top == b.top and a.bottom...
[ "Return", "a", "(", "top", "left", "height", "width", ")", "4", "-", "tuple", "specifying", "the", "extents", "of", "the", "merged", "cell", "formed", "by", "using", "this", "tc", "and", "*", "other_tc", "*", "as", "opposite", "corner", "extents", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L617-L646
[ "def", "_span_dimensions", "(", "self", ",", "other_tc", ")", ":", "def", "raise_on_inverted_L", "(", "a", ",", "b", ")", ":", "if", "a", ".", "top", "==", "b", ".", "top", "and", "a", ".", "bottom", "!=", "b", ".", "bottom", ":", "raise", "Invalid...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Tc._span_to_width
Incorporate and then remove `w:tc` elements to the right of this one until this cell spans *grid_width*. Raises |ValueError| if *grid_width* cannot be exactly achieved, such as when a merged cell would drive the span width greater than *grid_width* or if not enough grid columns are avail...
docx/oxml/table.py
def _span_to_width(self, grid_width, top_tc, vMerge): """ Incorporate and then remove `w:tc` elements to the right of this one until this cell spans *grid_width*. Raises |ValueError| if *grid_width* cannot be exactly achieved, such as when a merged cell would drive the span width...
def _span_to_width(self, grid_width, top_tc, vMerge): """ Incorporate and then remove `w:tc` elements to the right of this one until this cell spans *grid_width*. Raises |ValueError| if *grid_width* cannot be exactly achieved, such as when a merged cell would drive the span width...
[ "Incorporate", "and", "then", "remove", "w", ":", "tc", "elements", "to", "the", "right", "of", "this", "one", "until", "this", "cell", "spans", "*", "grid_width", "*", ".", "Raises", "|ValueError|", "if", "*", "grid_width", "*", "cannot", "be", "exactly",...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L648-L662
[ "def", "_span_to_width", "(", "self", ",", "grid_width", ",", "top_tc", ",", "vMerge", ")", ":", "self", ".", "_move_content_to", "(", "top_tc", ")", "while", "self", ".", "grid_span", "<", "grid_width", ":", "self", ".", "_swallow_next_tc", "(", "grid_width...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Tc._swallow_next_tc
Extend the horizontal span of this `w:tc` element to incorporate the following `w:tc` element in the row and then delete that following `w:tc` element. Any content in the following `w:tc` element is appended to the content of *top_tc*. The width of the following `w:tc` element is added t...
docx/oxml/table.py
def _swallow_next_tc(self, grid_width, top_tc): """ Extend the horizontal span of this `w:tc` element to incorporate the following `w:tc` element in the row and then delete that following `w:tc` element. Any content in the following `w:tc` element is appended to the content of *t...
def _swallow_next_tc(self, grid_width, top_tc): """ Extend the horizontal span of this `w:tc` element to incorporate the following `w:tc` element in the row and then delete that following `w:tc` element. Any content in the following `w:tc` element is appended to the content of *t...
[ "Extend", "the", "horizontal", "span", "of", "this", "w", ":", "tc", "element", "to", "incorporate", "the", "following", "w", ":", "tc", "element", "in", "the", "row", "and", "then", "delete", "that", "following", "w", ":", "tc", "element", ".", "Any", ...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L664-L685
[ "def", "_swallow_next_tc", "(", "self", ",", "grid_width", ",", "top_tc", ")", ":", "def", "raise_on_invalid_swallow", "(", "next_tc", ")", ":", "if", "next_tc", "is", "None", ":", "raise", "InvalidSpanError", "(", "'not enough grid columns'", ")", "if", "self",...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Tc._tc_below
The tc element immediately below this one in its grid column.
docx/oxml/table.py
def _tc_below(self): """ The tc element immediately below this one in its grid column. """ tr_below = self._tr_below if tr_below is None: return None return tr_below.tc_at_grid_col(self._grid_col)
def _tc_below(self): """ The tc element immediately below this one in its grid column. """ tr_below = self._tr_below if tr_below is None: return None return tr_below.tc_at_grid_col(self._grid_col)
[ "The", "tc", "element", "immediately", "below", "this", "one", "in", "its", "grid", "column", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L702-L709
[ "def", "_tc_below", "(", "self", ")", ":", "tr_below", "=", "self", ".", "_tr_below", "if", "tr_below", "is", "None", ":", "return", "None", "return", "tr_below", ".", "tc_at_grid_col", "(", "self", ".", "_grid_col", ")" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Tc._tr_above
The tr element prior in sequence to the tr this cell appears in. Raises |ValueError| if called on a cell in the top-most row.
docx/oxml/table.py
def _tr_above(self): """ The tr element prior in sequence to the tr this cell appears in. Raises |ValueError| if called on a cell in the top-most row. """ tr_lst = self._tbl.tr_lst tr_idx = tr_lst.index(self._tr) if tr_idx == 0: raise ValueError('no tr...
def _tr_above(self): """ The tr element prior in sequence to the tr this cell appears in. Raises |ValueError| if called on a cell in the top-most row. """ tr_lst = self._tbl.tr_lst tr_idx = tr_lst.index(self._tr) if tr_idx == 0: raise ValueError('no tr...
[ "The", "tr", "element", "prior", "in", "sequence", "to", "the", "tr", "this", "cell", "appears", "in", ".", "Raises", "|ValueError|", "if", "called", "on", "a", "cell", "in", "the", "top", "-", "most", "row", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L719-L728
[ "def", "_tr_above", "(", "self", ")", ":", "tr_lst", "=", "self", ".", "_tbl", ".", "tr_lst", "tr_idx", "=", "tr_lst", ".", "index", "(", "self", ".", "_tr", ")", "if", "tr_idx", "==", "0", ":", "raise", "ValueError", "(", "'no tr above topmost tr'", "...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
CT_Tc._tr_below
The tr element next in sequence after the tr this cell appears in, or |None| if this cell appears in the last row.
docx/oxml/table.py
def _tr_below(self): """ The tr element next in sequence after the tr this cell appears in, or |None| if this cell appears in the last row. """ tr_lst = self._tbl.tr_lst tr_idx = tr_lst.index(self._tr) try: return tr_lst[tr_idx+1] except IndexE...
def _tr_below(self): """ The tr element next in sequence after the tr this cell appears in, or |None| if this cell appears in the last row. """ tr_lst = self._tbl.tr_lst tr_idx = tr_lst.index(self._tr) try: return tr_lst[tr_idx+1] except IndexE...
[ "The", "tr", "element", "next", "in", "sequence", "after", "the", "tr", "this", "cell", "appears", "in", "or", "|None|", "if", "this", "cell", "appears", "in", "the", "last", "row", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L731-L741
[ "def", "_tr_below", "(", "self", ")", ":", "tr_lst", "=", "self", ".", "_tbl", ".", "tr_lst", "tr_idx", "=", "tr_lst", ".", "index", "(", "self", ".", "_tr", ")", "try", ":", "return", "tr_lst", "[", "tr_idx", "+", "1", "]", "except", "IndexError", ...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
alias
Decorating a class with @alias('FOO', 'BAR', ..) allows the class to be referenced by each of the names provided as arguments.
docx/enum/base.py
def alias(*aliases): """ Decorating a class with @alias('FOO', 'BAR', ..) allows the class to be referenced by each of the names provided as arguments. """ def decorator(cls): # alias must be set in globals from caller's frame caller = sys._getframe(1) globals_dict = caller.f...
def alias(*aliases): """ Decorating a class with @alias('FOO', 'BAR', ..) allows the class to be referenced by each of the names provided as arguments. """ def decorator(cls): # alias must be set in globals from caller's frame caller = sys._getframe(1) globals_dict = caller.f...
[ "Decorating", "a", "class", "with" ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/enum/base.py#L15-L27
[ "def", "alias", "(", "*", "aliases", ")", ":", "def", "decorator", "(", "cls", ")", ":", "# alias must be set in globals from caller's frame", "caller", "=", "sys", ".", "_getframe", "(", "1", ")", "globals_dict", "=", "caller", ".", "f_globals", "for", "alias...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_DocsPageFormatter.page_str
The RestructuredText documentation page for the enumeration. This is the only API member for the class.
docx/enum/base.py
def page_str(self): """ The RestructuredText documentation page for the enumeration. This is the only API member for the class. """ tmpl = '.. _%s:\n\n%s\n\n%s\n\n----\n\n%s' components = ( self._ms_name, self._page_title, self._intro_text, self._m...
def page_str(self): """ The RestructuredText documentation page for the enumeration. This is the only API member for the class. """ tmpl = '.. _%s:\n\n%s\n\n%s\n\n----\n\n%s' components = ( self._ms_name, self._page_title, self._intro_text, self._m...
[ "The", "RestructuredText", "documentation", "page", "for", "the", "enumeration", ".", "This", "is", "the", "only", "API", "member", "for", "the", "class", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/enum/base.py#L43-L53
[ "def", "page_str", "(", "self", ")", ":", "tmpl", "=", "'.. _%s:\\n\\n%s\\n\\n%s\\n\\n----\\n\\n%s'", "components", "=", "(", "self", ".", "_ms_name", ",", "self", ".", "_page_title", ",", "self", ".", "_intro_text", ",", "self", ".", "_member_defs", ")", "ret...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_DocsPageFormatter._intro_text
Docstring of the enumeration, formatted for documentation page.
docx/enum/base.py
def _intro_text(self): """Docstring of the enumeration, formatted for documentation page.""" try: cls_docstring = self._clsdict['__doc__'] except KeyError: cls_docstring = '' if cls_docstring is None: return '' return textwrap.dedent(cls_docs...
def _intro_text(self): """Docstring of the enumeration, formatted for documentation page.""" try: cls_docstring = self._clsdict['__doc__'] except KeyError: cls_docstring = '' if cls_docstring is None: return '' return textwrap.dedent(cls_docs...
[ "Docstring", "of", "the", "enumeration", "formatted", "for", "documentation", "page", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/enum/base.py#L56-L66
[ "def", "_intro_text", "(", "self", ")", ":", "try", ":", "cls_docstring", "=", "self", ".", "_clsdict", "[", "'__doc__'", "]", "except", "KeyError", ":", "cls_docstring", "=", "''", "if", "cls_docstring", "is", "None", ":", "return", "''", "return", "textw...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_DocsPageFormatter._member_def
Return an individual member definition formatted as an RST glossary entry, wrapped to fit within 78 columns.
docx/enum/base.py
def _member_def(self, member): """ Return an individual member definition formatted as an RST glossary entry, wrapped to fit within 78 columns. """ member_docstring = textwrap.dedent(member.docstring).strip() member_docstring = textwrap.fill( member_docstring,...
def _member_def(self, member): """ Return an individual member definition formatted as an RST glossary entry, wrapped to fit within 78 columns. """ member_docstring = textwrap.dedent(member.docstring).strip() member_docstring = textwrap.fill( member_docstring,...
[ "Return", "an", "individual", "member", "definition", "formatted", "as", "an", "RST", "glossary", "entry", "wrapped", "to", "fit", "within", "78", "columns", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/enum/base.py#L68-L78
[ "def", "_member_def", "(", "self", ",", "member", ")", ":", "member_docstring", "=", "textwrap", ".", "dedent", "(", "member", ".", "docstring", ")", ".", "strip", "(", ")", "member_docstring", "=", "textwrap", ".", "fill", "(", "member_docstring", ",", "w...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
_DocsPageFormatter._member_defs
A single string containing the aggregated member definitions section of the documentation page
docx/enum/base.py
def _member_defs(self): """ A single string containing the aggregated member definitions section of the documentation page """ members = self._clsdict['__members__'] member_defs = [ self._member_def(member) for member in members if member.name is n...
def _member_defs(self): """ A single string containing the aggregated member definitions section of the documentation page """ members = self._clsdict['__members__'] member_defs = [ self._member_def(member) for member in members if member.name is n...
[ "A", "single", "string", "containing", "the", "aggregated", "member", "definitions", "section", "of", "the", "documentation", "page" ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/enum/base.py#L81-L91
[ "def", "_member_defs", "(", "self", ")", ":", "members", "=", "self", ".", "_clsdict", "[", "'__members__'", "]", "member_defs", "=", "[", "self", ".", "_member_def", "(", "member", ")", "for", "member", "in", "members", "if", "member", ".", "name", "is"...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
MetaEnumeration._add_enum_members
Dispatch ``.add_to_enum()`` call to each member so it can do its thing to properly add itself to the enumeration class. This delegation allows member sub-classes to add specialized behaviors.
docx/enum/base.py
def _add_enum_members(meta, clsdict): """ Dispatch ``.add_to_enum()`` call to each member so it can do its thing to properly add itself to the enumeration class. This delegation allows member sub-classes to add specialized behaviors. """ enum_members = clsdict['__members_...
def _add_enum_members(meta, clsdict): """ Dispatch ``.add_to_enum()`` call to each member so it can do its thing to properly add itself to the enumeration class. This delegation allows member sub-classes to add specialized behaviors. """ enum_members = clsdict['__members_...
[ "Dispatch", ".", "add_to_enum", "()", "call", "to", "each", "member", "so", "it", "can", "do", "its", "thing", "to", "properly", "add", "itself", "to", "the", "enumeration", "class", ".", "This", "delegation", "allows", "member", "sub", "-", "classes", "to...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/enum/base.py#L123-L131
[ "def", "_add_enum_members", "(", "meta", ",", "clsdict", ")", ":", "enum_members", "=", "clsdict", "[", "'__members__'", "]", "for", "member", "in", "enum_members", ":", "member", ".", "add_to_enum", "(", "clsdict", ")" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
MetaEnumeration._collect_valid_settings
Return a sequence containing the enumeration values that are valid assignment values. Return-only values are excluded.
docx/enum/base.py
def _collect_valid_settings(meta, clsdict): """ Return a sequence containing the enumeration values that are valid assignment values. Return-only values are excluded. """ enum_members = clsdict['__members__'] valid_settings = [] for member in enum_members: ...
def _collect_valid_settings(meta, clsdict): """ Return a sequence containing the enumeration values that are valid assignment values. Return-only values are excluded. """ enum_members = clsdict['__members__'] valid_settings = [] for member in enum_members: ...
[ "Return", "a", "sequence", "containing", "the", "enumeration", "values", "that", "are", "valid", "assignment", "values", ".", "Return", "-", "only", "values", "are", "excluded", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/enum/base.py#L134-L143
[ "def", "_collect_valid_settings", "(", "meta", ",", "clsdict", ")", ":", "enum_members", "=", "clsdict", "[", "'__members__'", "]", "valid_settings", "=", "[", "]", "for", "member", "in", "enum_members", ":", "valid_settings", ".", "extend", "(", "member", "."...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
EnumerationBase.validate
Raise |ValueError| if *value* is not an assignable value.
docx/enum/base.py
def validate(cls, value): """ Raise |ValueError| if *value* is not an assignable value. """ if value not in cls._valid_settings: raise ValueError( "%s not a member of %s enumeration" % (value, cls.__name__) )
def validate(cls, value): """ Raise |ValueError| if *value* is not an assignable value. """ if value not in cls._valid_settings: raise ValueError( "%s not a member of %s enumeration" % (value, cls.__name__) )
[ "Raise", "|ValueError|", "if", "*", "value", "*", "is", "not", "an", "assignable", "value", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/enum/base.py#L165-L172
[ "def", "validate", "(", "cls", ",", "value", ")", ":", "if", "value", "not", "in", "cls", ".", "_valid_settings", ":", "raise", "ValueError", "(", "\"%s not a member of %s enumeration\"", "%", "(", "value", ",", "cls", ".", "__name__", ")", ")" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
XmlEnumeration.from_xml
Return the enumeration member corresponding to the XML value *xml_val*.
docx/enum/base.py
def from_xml(cls, xml_val): """ Return the enumeration member corresponding to the XML value *xml_val*. """ if xml_val not in cls._xml_to_member: raise InvalidXmlError( "attribute value '%s' not valid for this type" % xml_val ) retu...
def from_xml(cls, xml_val): """ Return the enumeration member corresponding to the XML value *xml_val*. """ if xml_val not in cls._xml_to_member: raise InvalidXmlError( "attribute value '%s' not valid for this type" % xml_val ) retu...
[ "Return", "the", "enumeration", "member", "corresponding", "to", "the", "XML", "value", "*", "xml_val", "*", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/enum/base.py#L189-L198
[ "def", "from_xml", "(", "cls", ",", "xml_val", ")", ":", "if", "xml_val", "not", "in", "cls", ".", "_xml_to_member", ":", "raise", "InvalidXmlError", "(", "\"attribute value '%s' not valid for this type\"", "%", "xml_val", ")", "return", "cls", ".", "_xml_to_membe...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
XmlEnumeration.to_xml
Return the XML value of the enumeration value *enum_val*.
docx/enum/base.py
def to_xml(cls, enum_val): """ Return the XML value of the enumeration value *enum_val*. """ if enum_val not in cls._member_to_xml: raise ValueError( "value '%s' not in enumeration %s" % (enum_val, cls.__name__) ) return cls._member_to_xml[...
def to_xml(cls, enum_val): """ Return the XML value of the enumeration value *enum_val*. """ if enum_val not in cls._member_to_xml: raise ValueError( "value '%s' not in enumeration %s" % (enum_val, cls.__name__) ) return cls._member_to_xml[...
[ "Return", "the", "XML", "value", "of", "the", "enumeration", "value", "*", "enum_val", "*", "." ]
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/enum/base.py#L201-L209
[ "def", "to_xml", "(", "cls", ",", "enum_val", ")", ":", "if", "enum_val", "not", "in", "cls", ".", "_member_to_xml", ":", "raise", "ValueError", "(", "\"value '%s' not in enumeration %s\"", "%", "(", "enum_val", ",", "cls", ".", "__name__", ")", ")", "return...
6756f6cd145511d3eb6d1d188beea391b1ddfd53
train
EnumMember.register_name
Add a member name to the class dict *clsdict* containing the value of this member object. Where the name of this object is None, do nothing; this allows out-of-band values to be defined without adding a name to the class dict.
docx/enum/base.py
def register_name(self, clsdict): """ Add a member name to the class dict *clsdict* containing the value of this member object. Where the name of this object is None, do nothing; this allows out-of-band values to be defined without adding a name to the class dict. """ ...
def register_name(self, clsdict): """ Add a member name to the class dict *clsdict* containing the value of this member object. Where the name of this object is None, do nothing; this allows out-of-band values to be defined without adding a name to the class dict. """ ...
[ "Add", "a", "member", "name", "to", "the", "class", "dict", "*", "clsdict", "*", "containing", "the", "value", "of", "this", "member", "object", ".", "Where", "the", "name", "of", "this", "object", "is", "None", "do", "nothing", ";", "this", "allows", ...
python-openxml/python-docx
python
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/enum/base.py#L247-L256
[ "def", "register_name", "(", "self", ",", "clsdict", ")", ":", "if", "self", ".", "name", "is", "None", ":", "return", "clsdict", "[", "self", ".", "name", "]", "=", "self", ".", "value" ]
6756f6cd145511d3eb6d1d188beea391b1ddfd53