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 | OxmlElement | Return a 'loose' lxml element having the tag specified by *nsptag_str*.
*nsptag_str* must contain the standard namespace prefix, e.g. 'a:tbl'.
The resulting element is an instance of the custom element class for this
tag name if one is defined. A dictionary of attribute values may be
provided as *attrs*... | docx/oxml/__init__.py | def OxmlElement(nsptag_str, attrs=None, nsdecls=None):
"""
Return a 'loose' lxml element having the tag specified by *nsptag_str*.
*nsptag_str* must contain the standard namespace prefix, e.g. 'a:tbl'.
The resulting element is an instance of the custom element class for this
tag name if one is defin... | def OxmlElement(nsptag_str, attrs=None, nsdecls=None):
"""
Return a 'loose' lxml element having the tag specified by *nsptag_str*.
*nsptag_str* must contain the standard namespace prefix, e.g. 'a:tbl'.
The resulting element is an instance of the custom element class for this
tag name if one is defin... | [
"Return",
"a",
"loose",
"lxml",
"element",
"having",
"the",
"tag",
"specified",
"by",
"*",
"nsptag_str",
"*",
".",
"*",
"nsptag_str",
"*",
"must",
"contain",
"the",
"standard",
"namespace",
"prefix",
"e",
".",
"g",
".",
"a",
":",
"tbl",
".",
"The",
"re... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/__init__.py#L43-L60 | [
"def",
"OxmlElement",
"(",
"nsptag_str",
",",
"attrs",
"=",
"None",
",",
"nsdecls",
"=",
"None",
")",
":",
"nsptag",
"=",
"NamespacePrefixedTag",
"(",
"nsptag_str",
")",
"if",
"nsdecls",
"is",
"None",
":",
"nsdecls",
"=",
"nsptag",
".",
"nsmap",
"return",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _IfdEntryFactory | Return an |_IfdEntry| subclass instance containing the value of the
directory entry at *offset* in *stream_rdr*. | docx/image/tiff.py | def _IfdEntryFactory(stream_rdr, offset):
"""
Return an |_IfdEntry| subclass instance containing the value of the
directory entry at *offset* in *stream_rdr*.
"""
ifd_entry_classes = {
TIFF_FLD.ASCII: _AsciiIfdEntry,
TIFF_FLD.SHORT: _ShortIfdEntry,
TIFF_FLD.LONG: _L... | def _IfdEntryFactory(stream_rdr, offset):
"""
Return an |_IfdEntry| subclass instance containing the value of the
directory entry at *offset* in *stream_rdr*.
"""
ifd_entry_classes = {
TIFF_FLD.ASCII: _AsciiIfdEntry,
TIFF_FLD.SHORT: _ShortIfdEntry,
TIFF_FLD.LONG: _L... | [
"Return",
"an",
"|_IfdEntry|",
"subclass",
"instance",
"containing",
"the",
"value",
"of",
"the",
"directory",
"entry",
"at",
"*",
"offset",
"*",
"in",
"*",
"stream_rdr",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/tiff.py#L215-L231 | [
"def",
"_IfdEntryFactory",
"(",
"stream_rdr",
",",
"offset",
")",
":",
"ifd_entry_classes",
"=",
"{",
"TIFF_FLD",
".",
"ASCII",
":",
"_AsciiIfdEntry",
",",
"TIFF_FLD",
".",
"SHORT",
":",
"_ShortIfdEntry",
",",
"TIFF_FLD",
".",
"LONG",
":",
"_LongIfdEntry",
","... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Tiff.from_stream | Return a |Tiff| instance containing the properties of the TIFF image
in *stream*. | docx/image/tiff.py | def from_stream(cls, stream):
"""
Return a |Tiff| instance containing the properties of the TIFF image
in *stream*.
"""
parser = _TiffParser.parse(stream)
px_width = parser.px_width
px_height = parser.px_height
horz_dpi = parser.horz_dpi
vert_dpi ... | def from_stream(cls, stream):
"""
Return a |Tiff| instance containing the properties of the TIFF image
in *stream*.
"""
parser = _TiffParser.parse(stream)
px_width = parser.px_width
px_height = parser.px_height
horz_dpi = parser.horz_dpi
vert_dpi ... | [
"Return",
"a",
"|Tiff|",
"instance",
"containing",
"the",
"properties",
"of",
"the",
"TIFF",
"image",
"in",
"*",
"stream",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/tiff.py#L31-L43 | [
"def",
"from_stream",
"(",
"cls",
",",
"stream",
")",
":",
"parser",
"=",
"_TiffParser",
".",
"parse",
"(",
"stream",
")",
"px_width",
"=",
"parser",
".",
"px_width",
"px_height",
"=",
"parser",
".",
"px_height",
"horz_dpi",
"=",
"parser",
".",
"horz_dpi",... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _TiffParser.parse | Return an instance of |_TiffParser| containing the properties parsed
from the TIFF image in *stream*. | docx/image/tiff.py | def parse(cls, stream):
"""
Return an instance of |_TiffParser| containing the properties parsed
from the TIFF image in *stream*.
"""
stream_rdr = cls._make_stream_reader(stream)
ifd0_offset = stream_rdr.read_long(4)
ifd_entries = _IfdEntries.from_stream(stream_rd... | def parse(cls, stream):
"""
Return an instance of |_TiffParser| containing the properties parsed
from the TIFF image in *stream*.
"""
stream_rdr = cls._make_stream_reader(stream)
ifd0_offset = stream_rdr.read_long(4)
ifd_entries = _IfdEntries.from_stream(stream_rd... | [
"Return",
"an",
"instance",
"of",
"|_TiffParser|",
"containing",
"the",
"properties",
"parsed",
"from",
"the",
"TIFF",
"image",
"in",
"*",
"stream",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/tiff.py#L56-L64 | [
"def",
"parse",
"(",
"cls",
",",
"stream",
")",
":",
"stream_rdr",
"=",
"cls",
".",
"_make_stream_reader",
"(",
"stream",
")",
"ifd0_offset",
"=",
"stream_rdr",
".",
"read_long",
"(",
"4",
")",
"ifd_entries",
"=",
"_IfdEntries",
".",
"from_stream",
"(",
"s... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _TiffParser._detect_endian | Return either BIG_ENDIAN or LITTLE_ENDIAN depending on the endian
indicator found in the TIFF *stream* header, either 'MM' or 'II'. | docx/image/tiff.py | def _detect_endian(cls, stream):
"""
Return either BIG_ENDIAN or LITTLE_ENDIAN depending on the endian
indicator found in the TIFF *stream* header, either 'MM' or 'II'.
"""
stream.seek(0)
endian_str = stream.read(2)
return BIG_ENDIAN if endian_str == b'MM' else LI... | def _detect_endian(cls, stream):
"""
Return either BIG_ENDIAN or LITTLE_ENDIAN depending on the endian
indicator found in the TIFF *stream* header, either 'MM' or 'II'.
"""
stream.seek(0)
endian_str = stream.read(2)
return BIG_ENDIAN if endian_str == b'MM' else LI... | [
"Return",
"either",
"BIG_ENDIAN",
"or",
"LITTLE_ENDIAN",
"depending",
"on",
"the",
"endian",
"indicator",
"found",
"in",
"the",
"TIFF",
"*",
"stream",
"*",
"header",
"either",
"MM",
"or",
"II",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/tiff.py#L103-L110 | [
"def",
"_detect_endian",
"(",
"cls",
",",
"stream",
")",
":",
"stream",
".",
"seek",
"(",
"0",
")",
"endian_str",
"=",
"stream",
".",
"read",
"(",
"2",
")",
"return",
"BIG_ENDIAN",
"if",
"endian_str",
"==",
"b'MM'",
"else",
"LITTLE_ENDIAN"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _TiffParser._dpi | Return the dpi value calculated for *resolution_tag*, which can be
either TIFF_TAG.X_RESOLUTION or TIFF_TAG.Y_RESOLUTION. The
calculation is based on the values of both that tag and the
TIFF_TAG.RESOLUTION_UNIT tag in this parser's |_IfdEntries| instance. | docx/image/tiff.py | def _dpi(self, resolution_tag):
"""
Return the dpi value calculated for *resolution_tag*, which can be
either TIFF_TAG.X_RESOLUTION or TIFF_TAG.Y_RESOLUTION. The
calculation is based on the values of both that tag and the
TIFF_TAG.RESOLUTION_UNIT tag in this parser's |_IfdEntries... | def _dpi(self, resolution_tag):
"""
Return the dpi value calculated for *resolution_tag*, which can be
either TIFF_TAG.X_RESOLUTION or TIFF_TAG.Y_RESOLUTION. The
calculation is based on the values of both that tag and the
TIFF_TAG.RESOLUTION_UNIT tag in this parser's |_IfdEntries... | [
"Return",
"the",
"dpi",
"value",
"calculated",
"for",
"*",
"resolution_tag",
"*",
"which",
"can",
"be",
"either",
"TIFF_TAG",
".",
"X_RESOLUTION",
"or",
"TIFF_TAG",
".",
"Y_RESOLUTION",
".",
"The",
"calculation",
"is",
"based",
"on",
"the",
"values",
"of",
"... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/tiff.py#L112-L135 | [
"def",
"_dpi",
"(",
"self",
",",
"resolution_tag",
")",
":",
"ifd_entries",
"=",
"self",
".",
"_ifd_entries",
"if",
"resolution_tag",
"not",
"in",
"ifd_entries",
":",
"return",
"72",
"# resolution unit defaults to inches (2)",
"resolution_unit",
"=",
"(",
"ifd_entri... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _TiffParser._make_stream_reader | Return a |StreamReader| instance with wrapping *stream* and having
"endian-ness" determined by the 'MM' or 'II' indicator in the TIFF
stream header. | docx/image/tiff.py | def _make_stream_reader(cls, stream):
"""
Return a |StreamReader| instance with wrapping *stream* and having
"endian-ness" determined by the 'MM' or 'II' indicator in the TIFF
stream header.
"""
endian = cls._detect_endian(stream)
return StreamReader(stream, endia... | def _make_stream_reader(cls, stream):
"""
Return a |StreamReader| instance with wrapping *stream* and having
"endian-ness" determined by the 'MM' or 'II' indicator in the TIFF
stream header.
"""
endian = cls._detect_endian(stream)
return StreamReader(stream, endia... | [
"Return",
"a",
"|StreamReader|",
"instance",
"with",
"wrapping",
"*",
"stream",
"*",
"and",
"having",
"endian",
"-",
"ness",
"determined",
"by",
"the",
"MM",
"or",
"II",
"indicator",
"in",
"the",
"TIFF",
"stream",
"header",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/tiff.py#L138-L145 | [
"def",
"_make_stream_reader",
"(",
"cls",
",",
"stream",
")",
":",
"endian",
"=",
"cls",
".",
"_detect_endian",
"(",
"stream",
")",
"return",
"StreamReader",
"(",
"stream",
",",
"endian",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _IfdEntries.from_stream | Return a new |_IfdEntries| instance parsed from *stream* starting at
*offset*. | docx/image/tiff.py | def from_stream(cls, stream, offset):
"""
Return a new |_IfdEntries| instance parsed from *stream* starting at
*offset*.
"""
ifd_parser = _IfdParser(stream, offset)
entries = dict((e.tag, e.value) for e in ifd_parser.iter_entries())
return cls(entries) | def from_stream(cls, stream, offset):
"""
Return a new |_IfdEntries| instance parsed from *stream* starting at
*offset*.
"""
ifd_parser = _IfdParser(stream, offset)
entries = dict((e.tag, e.value) for e in ifd_parser.iter_entries())
return cls(entries) | [
"Return",
"a",
"new",
"|_IfdEntries|",
"instance",
"parsed",
"from",
"*",
"stream",
"*",
"starting",
"at",
"*",
"offset",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/tiff.py#L170-L177 | [
"def",
"from_stream",
"(",
"cls",
",",
"stream",
",",
"offset",
")",
":",
"ifd_parser",
"=",
"_IfdParser",
"(",
"stream",
",",
"offset",
")",
"entries",
"=",
"dict",
"(",
"(",
"e",
".",
"tag",
",",
"e",
".",
"value",
")",
"for",
"e",
"in",
"ifd_par... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _IfdParser.iter_entries | Generate an |_IfdEntry| instance corresponding to each entry in the
directory. | docx/image/tiff.py | def iter_entries(self):
"""
Generate an |_IfdEntry| instance corresponding to each entry in the
directory.
"""
for idx in range(self._entry_count):
dir_entry_offset = self._offset + 2 + (idx*12)
ifd_entry = _IfdEntryFactory(self._stream_rdr, dir_entry_offs... | def iter_entries(self):
"""
Generate an |_IfdEntry| instance corresponding to each entry in the
directory.
"""
for idx in range(self._entry_count):
dir_entry_offset = self._offset + 2 + (idx*12)
ifd_entry = _IfdEntryFactory(self._stream_rdr, dir_entry_offs... | [
"Generate",
"an",
"|_IfdEntry|",
"instance",
"corresponding",
"to",
"each",
"entry",
"in",
"the",
"directory",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/tiff.py#L197-L205 | [
"def",
"iter_entries",
"(",
"self",
")",
":",
"for",
"idx",
"in",
"range",
"(",
"self",
".",
"_entry_count",
")",
":",
"dir_entry_offset",
"=",
"self",
".",
"_offset",
"+",
"2",
"+",
"(",
"idx",
"*",
"12",
")",
"ifd_entry",
"=",
"_IfdEntryFactory",
"("... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _IfdEntry.from_stream | Return an |_IfdEntry| subclass instance containing the tag and value
of the tag parsed from *stream_rdr* at *offset*. Note this method is
common to all subclasses. Override the ``_parse_value()`` method to
provide distinctive behavior based on field type. | docx/image/tiff.py | def from_stream(cls, stream_rdr, offset):
"""
Return an |_IfdEntry| subclass instance containing the tag and value
of the tag parsed from *stream_rdr* at *offset*. Note this method is
common to all subclasses. Override the ``_parse_value()`` method to
provide distinctive behavior... | def from_stream(cls, stream_rdr, offset):
"""
Return an |_IfdEntry| subclass instance containing the tag and value
of the tag parsed from *stream_rdr* at *offset*. Note this method is
common to all subclasses. Override the ``_parse_value()`` method to
provide distinctive behavior... | [
"Return",
"an",
"|_IfdEntry|",
"subclass",
"instance",
"containing",
"the",
"tag",
"and",
"value",
"of",
"the",
"tag",
"parsed",
"from",
"*",
"stream_rdr",
"*",
"at",
"*",
"offset",
"*",
".",
"Note",
"this",
"method",
"is",
"common",
"to",
"all",
"subclass... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/tiff.py#L245-L258 | [
"def",
"from_stream",
"(",
"cls",
",",
"stream_rdr",
",",
"offset",
")",
":",
"tag_code",
"=",
"stream_rdr",
".",
"read_short",
"(",
"offset",
",",
"0",
")",
"value_count",
"=",
"stream_rdr",
".",
"read_long",
"(",
"offset",
",",
"4",
")",
"value_offset",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _AsciiIfdEntry._parse_value | Return the ASCII string parsed from *stream_rdr* at *value_offset*.
The length of the string, including a terminating '\x00' (NUL)
character, is in *value_count*. | docx/image/tiff.py | def _parse_value(cls, stream_rdr, offset, value_count, value_offset):
"""
Return the ASCII string parsed from *stream_rdr* at *value_offset*.
The length of the string, including a terminating '\x00' (NUL)
character, is in *value_count*.
"""
return stream_rdr.read_str(valu... | def _parse_value(cls, stream_rdr, offset, value_count, value_offset):
"""
Return the ASCII string parsed from *stream_rdr* at *value_offset*.
The length of the string, including a terminating '\x00' (NUL)
character, is in *value_count*.
"""
return stream_rdr.read_str(valu... | [
"Return",
"the",
"ASCII",
"string",
"parsed",
"from",
"*",
"stream_rdr",
"*",
"at",
"*",
"value_offset",
"*",
".",
"The",
"length",
"of",
"the",
"string",
"including",
"a",
"terminating",
"\\",
"x00",
"(",
"NUL",
")",
"character",
"is",
"in",
"*",
"value... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/tiff.py#L288-L294 | [
"def",
"_parse_value",
"(",
"cls",
",",
"stream_rdr",
",",
"offset",
",",
"value_count",
",",
"value_offset",
")",
":",
"return",
"stream_rdr",
".",
"read_str",
"(",
"value_count",
"-",
"1",
",",
"value_offset",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _ShortIfdEntry._parse_value | Return the short int value contained in the *value_offset* field of
this entry. Only supports single values at present. | docx/image/tiff.py | def _parse_value(cls, stream_rdr, offset, value_count, value_offset):
"""
Return the short int value contained in the *value_offset* field of
this entry. Only supports single values at present.
"""
if value_count == 1:
return stream_rdr.read_short(offset, 8)
e... | def _parse_value(cls, stream_rdr, offset, value_count, value_offset):
"""
Return the short int value contained in the *value_offset* field of
this entry. Only supports single values at present.
"""
if value_count == 1:
return stream_rdr.read_short(offset, 8)
e... | [
"Return",
"the",
"short",
"int",
"value",
"contained",
"in",
"the",
"*",
"value_offset",
"*",
"field",
"of",
"this",
"entry",
".",
"Only",
"supports",
"single",
"values",
"at",
"present",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/tiff.py#L302-L310 | [
"def",
"_parse_value",
"(",
"cls",
",",
"stream_rdr",
",",
"offset",
",",
"value_count",
",",
"value_offset",
")",
":",
"if",
"value_count",
"==",
"1",
":",
"return",
"stream_rdr",
".",
"read_short",
"(",
"offset",
",",
"8",
")",
"else",
":",
"# pragma: no... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _LongIfdEntry._parse_value | Return the long int value contained in the *value_offset* field of
this entry. Only supports single values at present. | docx/image/tiff.py | def _parse_value(cls, stream_rdr, offset, value_count, value_offset):
"""
Return the long int value contained in the *value_offset* field of
this entry. Only supports single values at present.
"""
if value_count == 1:
return stream_rdr.read_long(offset, 8)
els... | def _parse_value(cls, stream_rdr, offset, value_count, value_offset):
"""
Return the long int value contained in the *value_offset* field of
this entry. Only supports single values at present.
"""
if value_count == 1:
return stream_rdr.read_long(offset, 8)
els... | [
"Return",
"the",
"long",
"int",
"value",
"contained",
"in",
"the",
"*",
"value_offset",
"*",
"field",
"of",
"this",
"entry",
".",
"Only",
"supports",
"single",
"values",
"at",
"present",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/tiff.py#L318-L326 | [
"def",
"_parse_value",
"(",
"cls",
",",
"stream_rdr",
",",
"offset",
",",
"value_count",
",",
"value_offset",
")",
":",
"if",
"value_count",
"==",
"1",
":",
"return",
"stream_rdr",
".",
"read_long",
"(",
"offset",
",",
"8",
")",
"else",
":",
"# pragma: no ... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _RationalIfdEntry._parse_value | Return the rational (numerator / denominator) value at *value_offset*
in *stream_rdr* as a floating-point number. Only supports single
values at present. | docx/image/tiff.py | def _parse_value(cls, stream_rdr, offset, value_count, value_offset):
"""
Return the rational (numerator / denominator) value at *value_offset*
in *stream_rdr* as a floating-point number. Only supports single
values at present.
"""
if value_count == 1:
numerat... | def _parse_value(cls, stream_rdr, offset, value_count, value_offset):
"""
Return the rational (numerator / denominator) value at *value_offset*
in *stream_rdr* as a floating-point number. Only supports single
values at present.
"""
if value_count == 1:
numerat... | [
"Return",
"the",
"rational",
"(",
"numerator",
"/",
"denominator",
")",
"value",
"at",
"*",
"value_offset",
"*",
"in",
"*",
"stream_rdr",
"*",
"as",
"a",
"floating",
"-",
"point",
"number",
".",
"Only",
"supports",
"single",
"values",
"at",
"present",
"."
... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/tiff.py#L334-L345 | [
"def",
"_parse_value",
"(",
"cls",
",",
"stream_rdr",
",",
"offset",
",",
"value_count",
",",
"value_offset",
")",
":",
"if",
"value_count",
"==",
"1",
":",
"numerator",
"=",
"stream_rdr",
".",
"read_long",
"(",
"value_offset",
")",
"denominator",
"=",
"stre... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | DocumentPart.add_footer_part | Return (footer_part, rId) pair for newly-created footer part. | docx/parts/document.py | def add_footer_part(self):
"""Return (footer_part, rId) pair for newly-created footer part."""
footer_part = FooterPart.new(self.package)
rId = self.relate_to(footer_part, RT.FOOTER)
return footer_part, rId | def add_footer_part(self):
"""Return (footer_part, rId) pair for newly-created footer part."""
footer_part = FooterPart.new(self.package)
rId = self.relate_to(footer_part, RT.FOOTER)
return footer_part, rId | [
"Return",
"(",
"footer_part",
"rId",
")",
"pair",
"for",
"newly",
"-",
"created",
"footer",
"part",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/parts/document.py#L27-L31 | [
"def",
"add_footer_part",
"(",
"self",
")",
":",
"footer_part",
"=",
"FooterPart",
".",
"new",
"(",
"self",
".",
"package",
")",
"rId",
"=",
"self",
".",
"relate_to",
"(",
"footer_part",
",",
"RT",
".",
"FOOTER",
")",
"return",
"footer_part",
",",
"rId"
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | DocumentPart.add_header_part | Return (header_part, rId) pair for newly-created header part. | docx/parts/document.py | def add_header_part(self):
"""Return (header_part, rId) pair for newly-created header part."""
header_part = HeaderPart.new(self.package)
rId = self.relate_to(header_part, RT.HEADER)
return header_part, rId | def add_header_part(self):
"""Return (header_part, rId) pair for newly-created header part."""
header_part = HeaderPart.new(self.package)
rId = self.relate_to(header_part, RT.HEADER)
return header_part, rId | [
"Return",
"(",
"header_part",
"rId",
")",
"pair",
"for",
"newly",
"-",
"created",
"header",
"part",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/parts/document.py#L33-L37 | [
"def",
"add_header_part",
"(",
"self",
")",
":",
"header_part",
"=",
"HeaderPart",
".",
"new",
"(",
"self",
".",
"package",
")",
"rId",
"=",
"self",
".",
"relate_to",
"(",
"header_part",
",",
"RT",
".",
"HEADER",
")",
"return",
"header_part",
",",
"rId"
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | DocumentPart.numbering_part | A |NumberingPart| object providing access to the numbering
definitions for this document. Creates an empty numbering part if one
is not present. | docx/parts/document.py | def numbering_part(self):
"""
A |NumberingPart| object providing access to the numbering
definitions for this document. Creates an empty numbering part if one
is not present.
"""
try:
return self.part_related_by(RT.NUMBERING)
except KeyError:
... | def numbering_part(self):
"""
A |NumberingPart| object providing access to the numbering
definitions for this document. Creates an empty numbering part if one
is not present.
"""
try:
return self.part_related_by(RT.NUMBERING)
except KeyError:
... | [
"A",
"|NumberingPart|",
"object",
"providing",
"access",
"to",
"the",
"numbering",
"definitions",
"for",
"this",
"document",
".",
"Creates",
"an",
"empty",
"numbering",
"part",
"if",
"one",
"is",
"not",
"present",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/parts/document.py#L93-L104 | [
"def",
"numbering_part",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"part_related_by",
"(",
"RT",
".",
"NUMBERING",
")",
"except",
"KeyError",
":",
"numbering_part",
"=",
"NumberingPart",
".",
"new",
"(",
")",
"self",
".",
"relate_to",
"(",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | DocumentPart._settings_part | A |SettingsPart| object providing access to the document-level
settings for this document. Creates a default settings part if one is
not present. | docx/parts/document.py | def _settings_part(self):
"""
A |SettingsPart| object providing access to the document-level
settings for this document. Creates a default settings part if one is
not present.
"""
try:
return self.part_related_by(RT.SETTINGS)
except KeyError:
... | def _settings_part(self):
"""
A |SettingsPart| object providing access to the document-level
settings for this document. Creates a default settings part if one is
not present.
"""
try:
return self.part_related_by(RT.SETTINGS)
except KeyError:
... | [
"A",
"|SettingsPart|",
"object",
"providing",
"access",
"to",
"the",
"document",
"-",
"level",
"settings",
"for",
"this",
"document",
".",
"Creates",
"a",
"default",
"settings",
"part",
"if",
"one",
"is",
"not",
"present",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/parts/document.py#L130-L141 | [
"def",
"_settings_part",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"part_related_by",
"(",
"RT",
".",
"SETTINGS",
")",
"except",
"KeyError",
":",
"settings_part",
"=",
"SettingsPart",
".",
"default",
"(",
"self",
".",
"package",
")",
"self"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | DocumentPart._styles_part | Instance of |StylesPart| for this document. Creates an empty styles
part if one is not present. | docx/parts/document.py | def _styles_part(self):
"""
Instance of |StylesPart| for this document. Creates an empty styles
part if one is not present.
"""
try:
return self.part_related_by(RT.STYLES)
except KeyError:
styles_part = StylesPart.default(self.package)
... | def _styles_part(self):
"""
Instance of |StylesPart| for this document. Creates an empty styles
part if one is not present.
"""
try:
return self.part_related_by(RT.STYLES)
except KeyError:
styles_part = StylesPart.default(self.package)
... | [
"Instance",
"of",
"|StylesPart|",
"for",
"this",
"document",
".",
"Creates",
"an",
"empty",
"styles",
"part",
"if",
"one",
"is",
"not",
"present",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/parts/document.py#L144-L154 | [
"def",
"_styles_part",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"part_related_by",
"(",
"RT",
".",
"STYLES",
")",
"except",
"KeyError",
":",
"styles_part",
"=",
"StylesPart",
".",
"default",
"(",
"self",
".",
"package",
")",
"self",
".",... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | text_of | Return string containing the contents of the file at *relpath* relative to
this file. | setup.py | def text_of(relpath):
"""
Return string containing the contents of the file at *relpath* relative to
this file.
"""
thisdir = os.path.dirname(__file__)
file_path = os.path.join(thisdir, os.path.normpath(relpath))
with open(file_path) as f:
text = f.read()
return text | def text_of(relpath):
"""
Return string containing the contents of the file at *relpath* relative to
this file.
"""
thisdir = os.path.dirname(__file__)
file_path = os.path.join(thisdir, os.path.normpath(relpath))
with open(file_path) as f:
text = f.read()
return text | [
"Return",
"string",
"containing",
"the",
"contents",
"of",
"the",
"file",
"at",
"*",
"relpath",
"*",
"relative",
"to",
"this",
"file",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/setup.py#L9-L18 | [
"def",
"text_of",
"(",
"relpath",
")",
":",
"thisdir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
"file_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"thisdir",
",",
"os",
".",
"path",
".",
"normpath",
"(",
"relpath",
")",
")"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | PackageWriter.write | Write a physical package (.pptx file) to *pkg_file* containing
*pkg_rels* and *parts* and a content types stream based on the
content types of the parts. | docx/opc/pkgwriter.py | def write(pkg_file, pkg_rels, parts):
"""
Write a physical package (.pptx file) to *pkg_file* containing
*pkg_rels* and *parts* and a content types stream based on the
content types of the parts.
"""
phys_writer = PhysPkgWriter(pkg_file)
PackageWriter._write_conte... | def write(pkg_file, pkg_rels, parts):
"""
Write a physical package (.pptx file) to *pkg_file* containing
*pkg_rels* and *parts* and a content types stream based on the
content types of the parts.
"""
phys_writer = PhysPkgWriter(pkg_file)
PackageWriter._write_conte... | [
"Write",
"a",
"physical",
"package",
"(",
".",
"pptx",
"file",
")",
"to",
"*",
"pkg_file",
"*",
"containing",
"*",
"pkg_rels",
"*",
"and",
"*",
"parts",
"*",
"and",
"a",
"content",
"types",
"stream",
"based",
"on",
"the",
"content",
"types",
"of",
"the... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/pkgwriter.py#L26-L36 | [
"def",
"write",
"(",
"pkg_file",
",",
"pkg_rels",
",",
"parts",
")",
":",
"phys_writer",
"=",
"PhysPkgWriter",
"(",
"pkg_file",
")",
"PackageWriter",
".",
"_write_content_types_stream",
"(",
"phys_writer",
",",
"parts",
")",
"PackageWriter",
".",
"_write_pkg_rels"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | PackageWriter._write_content_types_stream | Write ``[Content_Types].xml`` part to the physical package with an
appropriate content type lookup target for each part in *parts*. | docx/opc/pkgwriter.py | def _write_content_types_stream(phys_writer, parts):
"""
Write ``[Content_Types].xml`` part to the physical package with an
appropriate content type lookup target for each part in *parts*.
"""
cti = _ContentTypesItem.from_parts(parts)
phys_writer.write(CONTENT_TYPES_URI, ... | def _write_content_types_stream(phys_writer, parts):
"""
Write ``[Content_Types].xml`` part to the physical package with an
appropriate content type lookup target for each part in *parts*.
"""
cti = _ContentTypesItem.from_parts(parts)
phys_writer.write(CONTENT_TYPES_URI, ... | [
"Write",
"[",
"Content_Types",
"]",
".",
"xml",
"part",
"to",
"the",
"physical",
"package",
"with",
"an",
"appropriate",
"content",
"type",
"lookup",
"target",
"for",
"each",
"part",
"in",
"*",
"parts",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/pkgwriter.py#L39-L45 | [
"def",
"_write_content_types_stream",
"(",
"phys_writer",
",",
"parts",
")",
":",
"cti",
"=",
"_ContentTypesItem",
".",
"from_parts",
"(",
"parts",
")",
"phys_writer",
".",
"write",
"(",
"CONTENT_TYPES_URI",
",",
"cti",
".",
"blob",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | PackageWriter._write_parts | Write the blob of each part in *parts* to the package, along with a
rels item for its relationships if and only if it has any. | docx/opc/pkgwriter.py | def _write_parts(phys_writer, parts):
"""
Write the blob of each part in *parts* to the package, along with a
rels item for its relationships if and only if it has any.
"""
for part in parts:
phys_writer.write(part.partname, part.blob)
if len(part._rels):
... | def _write_parts(phys_writer, parts):
"""
Write the blob of each part in *parts* to the package, along with a
rels item for its relationships if and only if it has any.
"""
for part in parts:
phys_writer.write(part.partname, part.blob)
if len(part._rels):
... | [
"Write",
"the",
"blob",
"of",
"each",
"part",
"in",
"*",
"parts",
"*",
"to",
"the",
"package",
"along",
"with",
"a",
"rels",
"item",
"for",
"its",
"relationships",
"if",
"and",
"only",
"if",
"it",
"has",
"any",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/pkgwriter.py#L48-L56 | [
"def",
"_write_parts",
"(",
"phys_writer",
",",
"parts",
")",
":",
"for",
"part",
"in",
"parts",
":",
"phys_writer",
".",
"write",
"(",
"part",
".",
"partname",
",",
"part",
".",
"blob",
")",
"if",
"len",
"(",
"part",
".",
"_rels",
")",
":",
"phys_wr... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _ContentTypesItem.from_parts | Return content types XML mapping each part in *parts* to the
appropriate content type and suitable for storage as
``[Content_Types].xml`` in an OPC package. | docx/opc/pkgwriter.py | def from_parts(cls, parts):
"""
Return content types XML mapping each part in *parts* to the
appropriate content type and suitable for storage as
``[Content_Types].xml`` in an OPC package.
"""
cti = cls()
cti._defaults['rels'] = CT.OPC_RELATIONSHIPS
cti._d... | def from_parts(cls, parts):
"""
Return content types XML mapping each part in *parts* to the
appropriate content type and suitable for storage as
``[Content_Types].xml`` in an OPC package.
"""
cti = cls()
cti._defaults['rels'] = CT.OPC_RELATIONSHIPS
cti._d... | [
"Return",
"content",
"types",
"XML",
"mapping",
"each",
"part",
"in",
"*",
"parts",
"*",
"to",
"the",
"appropriate",
"content",
"type",
"and",
"suitable",
"for",
"storage",
"as",
"[",
"Content_Types",
"]",
".",
"xml",
"in",
"an",
"OPC",
"package",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/pkgwriter.py#L87-L98 | [
"def",
"from_parts",
"(",
"cls",
",",
"parts",
")",
":",
"cti",
"=",
"cls",
"(",
")",
"cti",
".",
"_defaults",
"[",
"'rels'",
"]",
"=",
"CT",
".",
"OPC_RELATIONSHIPS",
"cti",
".",
"_defaults",
"[",
"'xml'",
"]",
"=",
"CT",
".",
"XML",
"for",
"part"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _ContentTypesItem._add_content_type | Add a content type for the part with *partname* and *content_type*,
using a default or override as appropriate. | docx/opc/pkgwriter.py | def _add_content_type(self, partname, content_type):
"""
Add a content type for the part with *partname* and *content_type*,
using a default or override as appropriate.
"""
ext = partname.ext
if (ext.lower(), content_type) in default_content_types:
self._defau... | def _add_content_type(self, partname, content_type):
"""
Add a content type for the part with *partname* and *content_type*,
using a default or override as appropriate.
"""
ext = partname.ext
if (ext.lower(), content_type) in default_content_types:
self._defau... | [
"Add",
"a",
"content",
"type",
"for",
"the",
"part",
"with",
"*",
"partname",
"*",
"and",
"*",
"content_type",
"*",
"using",
"a",
"default",
"or",
"override",
"as",
"appropriate",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/pkgwriter.py#L100-L109 | [
"def",
"_add_content_type",
"(",
"self",
",",
"partname",
",",
"content_type",
")",
":",
"ext",
"=",
"partname",
".",
"ext",
"if",
"(",
"ext",
".",
"lower",
"(",
")",
",",
"content_type",
")",
"in",
"default_content_types",
":",
"self",
".",
"_defaults",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _ContentTypesItem._element | Return XML form of this content types item, suitable for storage as
``[Content_Types].xml`` in an OPC package. Although the sequence of
elements is not strictly significant, as an aid to testing and
readability Default elements are sorted by extension and Override
elements are sorted by ... | docx/opc/pkgwriter.py | def _element(self):
"""
Return XML form of this content types item, suitable for storage as
``[Content_Types].xml`` in an OPC package. Although the sequence of
elements is not strictly significant, as an aid to testing and
readability Default elements are sorted by extension and ... | def _element(self):
"""
Return XML form of this content types item, suitable for storage as
``[Content_Types].xml`` in an OPC package. Although the sequence of
elements is not strictly significant, as an aid to testing and
readability Default elements are sorted by extension and ... | [
"Return",
"XML",
"form",
"of",
"this",
"content",
"types",
"item",
"suitable",
"for",
"storage",
"as",
"[",
"Content_Types",
"]",
".",
"xml",
"in",
"an",
"OPC",
"package",
".",
"Although",
"the",
"sequence",
"of",
"elements",
"is",
"not",
"strictly",
"sign... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/pkgwriter.py#L112-L125 | [
"def",
"_element",
"(",
"self",
")",
":",
"_types_elm",
"=",
"CT_Types",
".",
"new",
"(",
")",
"for",
"ext",
"in",
"sorted",
"(",
"self",
".",
"_defaults",
".",
"keys",
"(",
")",
")",
":",
"_types_elm",
".",
"add_default",
"(",
"ext",
",",
"self",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | given_a_run_having_mixed_text_content | Mixed here meaning it contains ``<w:tab/>``, ``<w:cr/>``, etc. elements. | features/steps/text.py | def given_a_run_having_mixed_text_content(context):
"""
Mixed here meaning it contains ``<w:tab/>``, ``<w:cr/>``, etc. elements.
"""
r_xml = """\
<w:r %s>
<w:t>abc</w:t>
<w:tab/>
<w:t>def</w:t>
<w:cr/>
<w:t>ghi</w:t>
<w:drawing/>
... | def given_a_run_having_mixed_text_content(context):
"""
Mixed here meaning it contains ``<w:tab/>``, ``<w:cr/>``, etc. elements.
"""
r_xml = """\
<w:r %s>
<w:t>abc</w:t>
<w:tab/>
<w:t>def</w:t>
<w:cr/>
<w:t>ghi</w:t>
<w:drawing/>
... | [
"Mixed",
"here",
"meaning",
"it",
"contains",
"<w",
":",
"tab",
"/",
">",
"<w",
":",
"cr",
"/",
">",
"etc",
".",
"elements",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/features/steps/text.py#L49-L65 | [
"def",
"given_a_run_having_mixed_text_content",
"(",
"context",
")",
":",
"r_xml",
"=",
"\"\"\"\\\n <w:r %s>\n <w:t>abc</w:t>\n <w:tab/>\n <w:t>def</w:t>\n <w:cr/>\n <w:t>ghi</w:t>\n <w:drawing/>\n <w:br/>\n <w:t>jkl</w:t... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_Body.add_section_break | Return `w:sectPr` element for new section added at end of document.
The last `w:sectPr` becomes the second-to-last, with the new `w:sectPr` being an
exact clone of the previous one, except that all header and footer references
are removed (and are therefore now "inherited" from the prior sectio... | docx/oxml/document.py | def add_section_break(self):
"""Return `w:sectPr` element for new section added at end of document.
The last `w:sectPr` becomes the second-to-last, with the new `w:sectPr` being an
exact clone of the previous one, except that all header and footer references
are removed (and are therefo... | def add_section_break(self):
"""Return `w:sectPr` element for new section added at end of document.
The last `w:sectPr` becomes the second-to-last, with the new `w:sectPr` being an
exact clone of the previous one, except that all header and footer references
are removed (and are therefo... | [
"Return",
"w",
":",
"sectPr",
"element",
"for",
"new",
"section",
"added",
"at",
"end",
"of",
"document",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/document.py#L35-L55 | [
"def",
"add_section_break",
"(",
"self",
")",
":",
"# ---get the sectPr at file-end, which controls last section (sections[-1])---",
"sentinel_sectPr",
"=",
"self",
".",
"get_or_add_sectPr",
"(",
")",
"# ---add exact copy to new `w:p` element; that is now second-to last section---",
"s... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | CT_Body.clear_content | Remove all content child elements from this <w:body> element. Leave
the <w:sectPr> element if it is present. | docx/oxml/document.py | def clear_content(self):
"""
Remove all content child elements from this <w:body> element. Leave
the <w:sectPr> element if it is present.
"""
if self.sectPr is not None:
content_elms = self[:-1]
else:
content_elms = self[:]
for content_elm ... | def clear_content(self):
"""
Remove all content child elements from this <w:body> element. Leave
the <w:sectPr> element if it is present.
"""
if self.sectPr is not None:
content_elms = self[:-1]
else:
content_elms = self[:]
for content_elm ... | [
"Remove",
"all",
"content",
"child",
"elements",
"from",
"this",
"<w",
":",
"body",
">",
"element",
".",
"Leave",
"the",
"<w",
":",
"sectPr",
">",
"element",
"if",
"it",
"is",
"present",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/document.py#L57-L67 | [
"def",
"clear_content",
"(",
"self",
")",
":",
"if",
"self",
".",
"sectPr",
"is",
"not",
"None",
":",
"content_elms",
"=",
"self",
"[",
":",
"-",
"1",
"]",
"else",
":",
"content_elms",
"=",
"self",
"[",
":",
"]",
"for",
"content_elm",
"in",
"content_... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _ImageHeaderFactory | Return a |BaseImageHeader| subclass instance that knows how to parse the
headers of the image in *stream*. | docx/image/image.py | def _ImageHeaderFactory(stream):
"""
Return a |BaseImageHeader| subclass instance that knows how to parse the
headers of the image in *stream*.
"""
from docx.image import SIGNATURES
def read_32(stream):
stream.seek(0)
return stream.read(32)
header = read_32(stream)
for ... | def _ImageHeaderFactory(stream):
"""
Return a |BaseImageHeader| subclass instance that knows how to parse the
headers of the image in *stream*.
"""
from docx.image import SIGNATURES
def read_32(stream):
stream.seek(0)
return stream.read(32)
header = read_32(stream)
for ... | [
"Return",
"a",
"|BaseImageHeader|",
"subclass",
"instance",
"that",
"knows",
"how",
"to",
"parse",
"the",
"headers",
"of",
"the",
"image",
"in",
"*",
"stream",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/image.py#L182-L199 | [
"def",
"_ImageHeaderFactory",
"(",
"stream",
")",
":",
"from",
"docx",
".",
"image",
"import",
"SIGNATURES",
"def",
"read_32",
"(",
"stream",
")",
":",
"stream",
".",
"seek",
"(",
"0",
")",
"return",
"stream",
".",
"read",
"(",
"32",
")",
"header",
"="... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Image.from_blob | Return a new |Image| subclass instance parsed from the image binary
contained in *blob*. | docx/image/image.py | def from_blob(cls, blob):
"""
Return a new |Image| subclass instance parsed from the image binary
contained in *blob*.
"""
stream = BytesIO(blob)
return cls._from_stream(stream, blob) | def from_blob(cls, blob):
"""
Return a new |Image| subclass instance parsed from the image binary
contained in *blob*.
"""
stream = BytesIO(blob)
return cls._from_stream(stream, blob) | [
"Return",
"a",
"new",
"|Image|",
"subclass",
"instance",
"parsed",
"from",
"the",
"image",
"binary",
"contained",
"in",
"*",
"blob",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/image.py#L30-L36 | [
"def",
"from_blob",
"(",
"cls",
",",
"blob",
")",
":",
"stream",
"=",
"BytesIO",
"(",
"blob",
")",
"return",
"cls",
".",
"_from_stream",
"(",
"stream",
",",
"blob",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Image.from_file | Return a new |Image| subclass instance loaded from the image file
identified by *image_descriptor*, a path or file-like object. | docx/image/image.py | def from_file(cls, image_descriptor):
"""
Return a new |Image| subclass instance loaded from the image file
identified by *image_descriptor*, a path or file-like object.
"""
if is_string(image_descriptor):
path = image_descriptor
with open(path, 'rb') as f... | def from_file(cls, image_descriptor):
"""
Return a new |Image| subclass instance loaded from the image file
identified by *image_descriptor*, a path or file-like object.
"""
if is_string(image_descriptor):
path = image_descriptor
with open(path, 'rb') as f... | [
"Return",
"a",
"new",
"|Image|",
"subclass",
"instance",
"loaded",
"from",
"the",
"image",
"file",
"identified",
"by",
"*",
"image_descriptor",
"*",
"a",
"path",
"or",
"file",
"-",
"like",
"object",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/image.py#L39-L55 | [
"def",
"from_file",
"(",
"cls",
",",
"image_descriptor",
")",
":",
"if",
"is_string",
"(",
"image_descriptor",
")",
":",
"path",
"=",
"image_descriptor",
"with",
"open",
"(",
"path",
",",
"'rb'",
")",
"as",
"f",
":",
"blob",
"=",
"f",
".",
"read",
"(",... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Image.scaled_dimensions | Return a (cx, cy) 2-tuple representing the native dimensions of this
image scaled by applying the following rules to *width* and *height*.
If both *width* and *height* are specified, the return value is
(*width*, *height*); no scaling is performed. If only one is
specified, it is used to... | docx/image/image.py | def scaled_dimensions(self, width=None, height=None):
"""
Return a (cx, cy) 2-tuple representing the native dimensions of this
image scaled by applying the following rules to *width* and *height*.
If both *width* and *height* are specified, the return value is
(*width*, *height*)... | def scaled_dimensions(self, width=None, height=None):
"""
Return a (cx, cy) 2-tuple representing the native dimensions of this
image scaled by applying the following rules to *width* and *height*.
If both *width* and *height* are specified, the return value is
(*width*, *height*)... | [
"Return",
"a",
"(",
"cx",
"cy",
")",
"2",
"-",
"tuple",
"representing",
"the",
"native",
"dimensions",
"of",
"this",
"image",
"scaled",
"by",
"applying",
"the",
"following",
"rules",
"to",
"*",
"width",
"*",
"and",
"*",
"height",
"*",
".",
"If",
"both"... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/image.py#L136-L161 | [
"def",
"scaled_dimensions",
"(",
"self",
",",
"width",
"=",
"None",
",",
"height",
"=",
"None",
")",
":",
"if",
"width",
"is",
"None",
"and",
"height",
"is",
"None",
":",
"return",
"self",
".",
"width",
",",
"self",
".",
"height",
"if",
"width",
"is"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Image._from_stream | Return an instance of the |Image| subclass corresponding to the
format of the image in *stream*. | docx/image/image.py | def _from_stream(cls, stream, blob, filename=None):
"""
Return an instance of the |Image| subclass corresponding to the
format of the image in *stream*.
"""
image_header = _ImageHeaderFactory(stream)
if filename is None:
filename = 'image.%s' % image_header.de... | def _from_stream(cls, stream, blob, filename=None):
"""
Return an instance of the |Image| subclass corresponding to the
format of the image in *stream*.
"""
image_header = _ImageHeaderFactory(stream)
if filename is None:
filename = 'image.%s' % image_header.de... | [
"Return",
"an",
"instance",
"of",
"the",
"|Image|",
"subclass",
"corresponding",
"to",
"the",
"format",
"of",
"the",
"image",
"in",
"*",
"stream",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/image.py#L171-L179 | [
"def",
"_from_stream",
"(",
"cls",
",",
"stream",
",",
"blob",
",",
"filename",
"=",
"None",
")",
":",
"image_header",
"=",
"_ImageHeaderFactory",
"(",
"stream",
")",
"if",
"filename",
"is",
"None",
":",
"filename",
"=",
"'image.%s'",
"%",
"image_header",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Paragraph.add_run | Append a run to this paragraph containing *text* and having character
style identified by style ID *style*. *text* can contain tab
(``\\t``) characters, which are converted to the appropriate XML form
for a tab. *text* can also include newline (``\\n``) or carriage
return (``\\r``) chara... | docx/text/paragraph.py | def add_run(self, text=None, style=None):
"""
Append a run to this paragraph containing *text* and having character
style identified by style ID *style*. *text* can contain tab
(``\\t``) characters, which are converted to the appropriate XML form
for a tab. *text* can also includ... | def add_run(self, text=None, style=None):
"""
Append a run to this paragraph containing *text* and having character
style identified by style ID *style*. *text* can contain tab
(``\\t``) characters, which are converted to the appropriate XML form
for a tab. *text* can also includ... | [
"Append",
"a",
"run",
"to",
"this",
"paragraph",
"containing",
"*",
"text",
"*",
"and",
"having",
"character",
"style",
"identified",
"by",
"style",
"ID",
"*",
"style",
"*",
".",
"*",
"text",
"*",
"can",
"contain",
"tab",
"(",
"\\\\",
"t",
")",
"charac... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/text/paragraph.py#L25-L40 | [
"def",
"add_run",
"(",
"self",
",",
"text",
"=",
"None",
",",
"style",
"=",
"None",
")",
":",
"r",
"=",
"self",
".",
"_p",
".",
"add_r",
"(",
")",
"run",
"=",
"Run",
"(",
"r",
",",
"self",
")",
"if",
"text",
":",
"run",
".",
"text",
"=",
"t... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Paragraph.insert_paragraph_before | Return a newly created paragraph, inserted directly before this
paragraph. If *text* is supplied, the new paragraph contains that
text in a single run. If *style* is provided, that style is assigned
to the new paragraph. | docx/text/paragraph.py | def insert_paragraph_before(self, text=None, style=None):
"""
Return a newly created paragraph, inserted directly before this
paragraph. If *text* is supplied, the new paragraph contains that
text in a single run. If *style* is provided, that style is assigned
to the new paragrap... | def insert_paragraph_before(self, text=None, style=None):
"""
Return a newly created paragraph, inserted directly before this
paragraph. If *text* is supplied, the new paragraph contains that
text in a single run. If *style* is provided, that style is assigned
to the new paragrap... | [
"Return",
"a",
"newly",
"created",
"paragraph",
"inserted",
"directly",
"before",
"this",
"paragraph",
".",
"If",
"*",
"text",
"*",
"is",
"supplied",
"the",
"new",
"paragraph",
"contains",
"that",
"text",
"in",
"a",
"single",
"run",
".",
"If",
"*",
"style"... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/text/paragraph.py#L65-L77 | [
"def",
"insert_paragraph_before",
"(",
"self",
",",
"text",
"=",
"None",
",",
"style",
"=",
"None",
")",
":",
"paragraph",
"=",
"self",
".",
"_insert_paragraph_before",
"(",
")",
"if",
"text",
":",
"paragraph",
".",
"add_run",
"(",
"text",
")",
"if",
"st... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Paragraph.style | Read/Write. |_ParagraphStyle| object representing the style assigned
to this paragraph. If no explicit style is assigned to this
paragraph, its value is the default paragraph style for the document.
A paragraph style name can be assigned in lieu of a paragraph style
object. Assigning |No... | docx/text/paragraph.py | def style(self):
"""
Read/Write. |_ParagraphStyle| object representing the style assigned
to this paragraph. If no explicit style is assigned to this
paragraph, its value is the default paragraph style for the document.
A paragraph style name can be assigned in lieu of a paragrap... | def style(self):
"""
Read/Write. |_ParagraphStyle| object representing the style assigned
to this paragraph. If no explicit style is assigned to this
paragraph, its value is the default paragraph style for the document.
A paragraph style name can be assigned in lieu of a paragrap... | [
"Read",
"/",
"Write",
".",
"|_ParagraphStyle|",
"object",
"representing",
"the",
"style",
"assigned",
"to",
"this",
"paragraph",
".",
"If",
"no",
"explicit",
"style",
"is",
"assigned",
"to",
"this",
"paragraph",
"its",
"value",
"is",
"the",
"default",
"paragra... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/text/paragraph.py#L96-L106 | [
"def",
"style",
"(",
"self",
")",
":",
"style_id",
"=",
"self",
".",
"_p",
".",
"style",
"return",
"self",
".",
"part",
".",
"get_style",
"(",
"style_id",
",",
"WD_STYLE_TYPE",
".",
"PARAGRAPH",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Paragraph.text | String formed by concatenating the text of each run in the paragraph.
Tabs and line breaks in the XML are mapped to ``\\t`` and ``\\n``
characters respectively.
Assigning text to this property causes all existing paragraph content
to be replaced with a single run containing the assigned... | docx/text/paragraph.py | def text(self):
"""
String formed by concatenating the text of each run in the paragraph.
Tabs and line breaks in the XML are mapped to ``\\t`` and ``\\n``
characters respectively.
Assigning text to this property causes all existing paragraph content
to be replaced with ... | def text(self):
"""
String formed by concatenating the text of each run in the paragraph.
Tabs and line breaks in the XML are mapped to ``\\t`` and ``\\n``
characters respectively.
Assigning text to this property causes all existing paragraph content
to be replaced with ... | [
"String",
"formed",
"by",
"concatenating",
"the",
"text",
"of",
"each",
"run",
"in",
"the",
"paragraph",
".",
"Tabs",
"and",
"line",
"breaks",
"in",
"the",
"XML",
"are",
"mapped",
"to",
"\\\\",
"t",
"and",
"\\\\",
"n",
"characters",
"respectively",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/text/paragraph.py#L116-L132 | [
"def",
"text",
"(",
"self",
")",
":",
"text",
"=",
"''",
"for",
"run",
"in",
"self",
".",
"runs",
":",
"text",
"+=",
"run",
".",
"text",
"return",
"text"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Paragraph._insert_paragraph_before | Return a newly created paragraph, inserted directly before this
paragraph. | docx/text/paragraph.py | def _insert_paragraph_before(self):
"""
Return a newly created paragraph, inserted directly before this
paragraph.
"""
p = self._p.add_p_before()
return Paragraph(p, self._parent) | def _insert_paragraph_before(self):
"""
Return a newly created paragraph, inserted directly before this
paragraph.
"""
p = self._p.add_p_before()
return Paragraph(p, self._parent) | [
"Return",
"a",
"newly",
"created",
"paragraph",
"inserted",
"directly",
"before",
"this",
"paragraph",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/text/paragraph.py#L139-L145 | [
"def",
"_insert_paragraph_before",
"(",
"self",
")",
":",
"p",
"=",
"self",
".",
"_p",
".",
"add_p_before",
"(",
")",
"return",
"Paragraph",
"(",
"p",
",",
"self",
".",
"_parent",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | serialize_for_reading | Serialize *element* to human-readable XML suitable for tests. No XML
declaration. | docx/oxml/xmlchemy.py | def serialize_for_reading(element):
"""
Serialize *element* to human-readable XML suitable for tests. No XML
declaration.
"""
xml = etree.tostring(element, encoding='unicode', pretty_print=True)
return XmlString(xml) | def serialize_for_reading(element):
"""
Serialize *element* to human-readable XML suitable for tests. No XML
declaration.
"""
xml = etree.tostring(element, encoding='unicode', pretty_print=True)
return XmlString(xml) | [
"Serialize",
"*",
"element",
"*",
"to",
"human",
"-",
"readable",
"XML",
"suitable",
"for",
"tests",
".",
"No",
"XML",
"declaration",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L21-L27 | [
"def",
"serialize_for_reading",
"(",
"element",
")",
":",
"xml",
"=",
"etree",
".",
"tostring",
"(",
"element",
",",
"encoding",
"=",
"'unicode'",
",",
"pretty_print",
"=",
"True",
")",
"return",
"XmlString",
"(",
"xml",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | XmlString._attr_seq | Return a sequence of attribute strings parsed from *attrs*. Each
attribute string is stripped of whitespace on both ends. | docx/oxml/xmlchemy.py | def _attr_seq(self, attrs):
"""
Return a sequence of attribute strings parsed from *attrs*. Each
attribute string is stripped of whitespace on both ends.
"""
attrs = attrs.strip()
attr_lst = attrs.split()
return sorted(attr_lst) | def _attr_seq(self, attrs):
"""
Return a sequence of attribute strings parsed from *attrs*. Each
attribute string is stripped of whitespace on both ends.
"""
attrs = attrs.strip()
attr_lst = attrs.split()
return sorted(attr_lst) | [
"Return",
"a",
"sequence",
"of",
"attribute",
"strings",
"parsed",
"from",
"*",
"attrs",
"*",
".",
"Each",
"attribute",
"string",
"is",
"stripped",
"of",
"whitespace",
"on",
"both",
"ends",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L57-L64 | [
"def",
"_attr_seq",
"(",
"self",
",",
"attrs",
")",
":",
"attrs",
"=",
"attrs",
".",
"strip",
"(",
")",
"attr_lst",
"=",
"attrs",
".",
"split",
"(",
")",
"return",
"sorted",
"(",
"attr_lst",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | XmlString._eq_elm_strs | Return True if the element in *line_2* is XML equivalent to the
element in *line*. | docx/oxml/xmlchemy.py | def _eq_elm_strs(self, line, line_2):
"""
Return True if the element in *line_2* is XML equivalent to the
element in *line*.
"""
front, attrs, close, text = self._parse_line(line)
front_2, attrs_2, close_2, text_2 = self._parse_line(line_2)
if front != front_2:
... | def _eq_elm_strs(self, line, line_2):
"""
Return True if the element in *line_2* is XML equivalent to the
element in *line*.
"""
front, attrs, close, text = self._parse_line(line)
front_2, attrs_2, close_2, text_2 = self._parse_line(line_2)
if front != front_2:
... | [
"Return",
"True",
"if",
"the",
"element",
"in",
"*",
"line_2",
"*",
"is",
"XML",
"equivalent",
"to",
"the",
"element",
"in",
"*",
"line",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L66-L81 | [
"def",
"_eq_elm_strs",
"(",
"self",
",",
"line",
",",
"line_2",
")",
":",
"front",
",",
"attrs",
",",
"close",
",",
"text",
"=",
"self",
".",
"_parse_line",
"(",
"line",
")",
"front_2",
",",
"attrs_2",
",",
"close_2",
",",
"text_2",
"=",
"self",
".",... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | XmlString._parse_line | Return front, attrs, close, text 4-tuple result of parsing XML element
string *line*. | docx/oxml/xmlchemy.py | def _parse_line(cls, line):
"""
Return front, attrs, close, text 4-tuple result of parsing XML element
string *line*.
"""
match = cls._xml_elm_line_patt.match(line)
front, attrs, close, text = [match.group(n) for n in range(1, 5)]
return front, attrs, close, text | def _parse_line(cls, line):
"""
Return front, attrs, close, text 4-tuple result of parsing XML element
string *line*.
"""
match = cls._xml_elm_line_patt.match(line)
front, attrs, close, text = [match.group(n) for n in range(1, 5)]
return front, attrs, close, text | [
"Return",
"front",
"attrs",
"close",
"text",
"4",
"-",
"tuple",
"result",
"of",
"parsing",
"XML",
"element",
"string",
"*",
"line",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L84-L91 | [
"def",
"_parse_line",
"(",
"cls",
",",
"line",
")",
":",
"match",
"=",
"cls",
".",
"_xml_elm_line_patt",
".",
"match",
"(",
"line",
")",
"front",
",",
"attrs",
",",
"close",
",",
"text",
"=",
"[",
"match",
".",
"group",
"(",
"n",
")",
"for",
"n",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | BaseAttribute.populate_class_members | Add the appropriate methods to *element_cls*. | docx/oxml/xmlchemy.py | def populate_class_members(self, element_cls, prop_name):
"""
Add the appropriate methods to *element_cls*.
"""
self._element_cls = element_cls
self._prop_name = prop_name
self._add_attr_property() | def populate_class_members(self, element_cls, prop_name):
"""
Add the appropriate methods to *element_cls*.
"""
self._element_cls = element_cls
self._prop_name = prop_name
self._add_attr_property() | [
"Add",
"the",
"appropriate",
"methods",
"to",
"*",
"element_cls",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L118-L125 | [
"def",
"populate_class_members",
"(",
"self",
",",
"element_cls",
",",
"prop_name",
")",
":",
"self",
".",
"_element_cls",
"=",
"element_cls",
"self",
".",
"_prop_name",
"=",
"prop_name",
"self",
".",
"_add_attr_property",
"(",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | BaseAttribute._add_attr_property | Add a read/write ``{prop_name}`` property to the element class that
returns the interpreted value of this attribute on access and changes
the attribute value to its ST_* counterpart on assignment. | docx/oxml/xmlchemy.py | def _add_attr_property(self):
"""
Add a read/write ``{prop_name}`` property to the element class that
returns the interpreted value of this attribute on access and changes
the attribute value to its ST_* counterpart on assignment.
"""
property_ = property(self._getter, se... | def _add_attr_property(self):
"""
Add a read/write ``{prop_name}`` property to the element class that
returns the interpreted value of this attribute on access and changes
the attribute value to its ST_* counterpart on assignment.
"""
property_ = property(self._getter, se... | [
"Add",
"a",
"read",
"/",
"write",
"{",
"prop_name",
"}",
"property",
"to",
"the",
"element",
"class",
"that",
"returns",
"the",
"interpreted",
"value",
"of",
"this",
"attribute",
"on",
"access",
"and",
"changes",
"the",
"attribute",
"value",
"to",
"its",
"... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L127-L135 | [
"def",
"_add_attr_property",
"(",
"self",
")",
":",
"property_",
"=",
"property",
"(",
"self",
".",
"_getter",
",",
"self",
".",
"_setter",
",",
"None",
")",
"# assign unconditionally to overwrite element name definition",
"setattr",
"(",
"self",
".",
"_element_cls"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | OptionalAttribute._getter | Return a function object suitable for the "get" side of the attribute
property descriptor. | docx/oxml/xmlchemy.py | def _getter(self):
"""
Return a function object suitable for the "get" side of the attribute
property descriptor.
"""
def get_attr_value(obj):
attr_str_value = obj.get(self._clark_name)
if attr_str_value is None:
return self._default
... | def _getter(self):
"""
Return a function object suitable for the "get" side of the attribute
property descriptor.
"""
def get_attr_value(obj):
attr_str_value = obj.get(self._clark_name)
if attr_str_value is None:
return self._default
... | [
"Return",
"a",
"function",
"object",
"suitable",
"for",
"the",
"get",
"side",
"of",
"the",
"attribute",
"property",
"descriptor",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L155-L166 | [
"def",
"_getter",
"(",
"self",
")",
":",
"def",
"get_attr_value",
"(",
"obj",
")",
":",
"attr_str_value",
"=",
"obj",
".",
"get",
"(",
"self",
".",
"_clark_name",
")",
"if",
"attr_str_value",
"is",
"None",
":",
"return",
"self",
".",
"_default",
"return"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | OptionalAttribute._setter | Return a function object suitable for the "set" side of the attribute
property descriptor. | docx/oxml/xmlchemy.py | def _setter(self):
"""
Return a function object suitable for the "set" side of the attribute
property descriptor.
"""
def set_attr_value(obj, value):
if value is None or value == self._default:
if self._clark_name in obj.attrib:
del... | def _setter(self):
"""
Return a function object suitable for the "set" side of the attribute
property descriptor.
"""
def set_attr_value(obj, value):
if value is None or value == self._default:
if self._clark_name in obj.attrib:
del... | [
"Return",
"a",
"function",
"object",
"suitable",
"for",
"the",
"set",
"side",
"of",
"the",
"attribute",
"property",
"descriptor",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L182-L194 | [
"def",
"_setter",
"(",
"self",
")",
":",
"def",
"set_attr_value",
"(",
"obj",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
"or",
"value",
"==",
"self",
".",
"_default",
":",
"if",
"self",
".",
"_clark_name",
"in",
"obj",
".",
"attrib",
":",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | RequiredAttribute._getter | Return a function object suitable for the "get" side of the attribute
property descriptor. | docx/oxml/xmlchemy.py | def _getter(self):
"""
Return a function object suitable for the "get" side of the attribute
property descriptor.
"""
def get_attr_value(obj):
attr_str_value = obj.get(self._clark_name)
if attr_str_value is None:
raise InvalidXmlError(
... | def _getter(self):
"""
Return a function object suitable for the "get" side of the attribute
property descriptor.
"""
def get_attr_value(obj):
attr_str_value = obj.get(self._clark_name)
if attr_str_value is None:
raise InvalidXmlError(
... | [
"Return",
"a",
"function",
"object",
"suitable",
"for",
"the",
"get",
"side",
"of",
"the",
"attribute",
"property",
"descriptor",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L207-L221 | [
"def",
"_getter",
"(",
"self",
")",
":",
"def",
"get_attr_value",
"(",
"obj",
")",
":",
"attr_str_value",
"=",
"obj",
".",
"get",
"(",
"self",
".",
"_clark_name",
")",
"if",
"attr_str_value",
"is",
"None",
":",
"raise",
"InvalidXmlError",
"(",
"\"required ... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | RequiredAttribute._setter | Return a function object suitable for the "set" side of the attribute
property descriptor. | docx/oxml/xmlchemy.py | def _setter(self):
"""
Return a function object suitable for the "set" side of the attribute
property descriptor.
"""
def set_attr_value(obj, value):
str_value = self._simple_type.to_xml(value)
obj.set(self._clark_name, str_value)
return set_attr_v... | def _setter(self):
"""
Return a function object suitable for the "set" side of the attribute
property descriptor.
"""
def set_attr_value(obj, value):
str_value = self._simple_type.to_xml(value)
obj.set(self._clark_name, str_value)
return set_attr_v... | [
"Return",
"a",
"function",
"object",
"suitable",
"for",
"the",
"set",
"side",
"of",
"the",
"attribute",
"property",
"descriptor",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L235-L243 | [
"def",
"_setter",
"(",
"self",
")",
":",
"def",
"set_attr_value",
"(",
"obj",
",",
"value",
")",
":",
"str_value",
"=",
"self",
".",
"_simple_type",
".",
"to_xml",
"(",
"value",
")",
"obj",
".",
"set",
"(",
"self",
".",
"_clark_name",
",",
"str_value",... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _BaseChildElement._add_adder | Add an ``_add_x()`` method to the element class for this child
element. | docx/oxml/xmlchemy.py | def _add_adder(self):
"""
Add an ``_add_x()`` method to the element class for this child
element.
"""
def _add_child(obj, **attrs):
new_method = getattr(obj, self._new_method_name)
child = new_method()
for key, value in attrs.items():
... | def _add_adder(self):
"""
Add an ``_add_x()`` method to the element class for this child
element.
"""
def _add_child(obj, **attrs):
new_method = getattr(obj, self._new_method_name)
child = new_method()
for key, value in attrs.items():
... | [
"Add",
"an",
"_add_x",
"()",
"method",
"to",
"the",
"element",
"class",
"for",
"this",
"child",
"element",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L264-L282 | [
"def",
"_add_adder",
"(",
"self",
")",
":",
"def",
"_add_child",
"(",
"obj",
",",
"*",
"*",
"attrs",
")",
":",
"new_method",
"=",
"getattr",
"(",
"obj",
",",
"self",
".",
"_new_method_name",
")",
"child",
"=",
"new_method",
"(",
")",
"for",
"key",
",... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _BaseChildElement._add_creator | Add a ``_new_{prop_name}()`` method to the element class that creates
a new, empty element of the correct type, having no attributes. | docx/oxml/xmlchemy.py | def _add_creator(self):
"""
Add a ``_new_{prop_name}()`` method to the element class that creates
a new, empty element of the correct type, having no attributes.
"""
creator = self._creator
creator.__doc__ = (
'Return a "loose", newly created ``<%s>`` element ... | def _add_creator(self):
"""
Add a ``_new_{prop_name}()`` method to the element class that creates
a new, empty element of the correct type, having no attributes.
"""
creator = self._creator
creator.__doc__ = (
'Return a "loose", newly created ``<%s>`` element ... | [
"Add",
"a",
"_new_",
"{",
"prop_name",
"}",
"()",
"method",
"to",
"the",
"element",
"class",
"that",
"creates",
"a",
"new",
"empty",
"element",
"of",
"the",
"correct",
"type",
"having",
"no",
"attributes",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L284-L294 | [
"def",
"_add_creator",
"(",
"self",
")",
":",
"creator",
"=",
"self",
".",
"_creator",
"creator",
".",
"__doc__",
"=",
"(",
"'Return a \"loose\", newly created ``<%s>`` element having no attri'",
"'butes, text, or children.'",
"%",
"self",
".",
"_nsptagname",
")",
"self... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _BaseChildElement._add_getter | Add a read-only ``{prop_name}`` property to the element class for
this child element. | docx/oxml/xmlchemy.py | def _add_getter(self):
"""
Add a read-only ``{prop_name}`` property to the element class for
this child element.
"""
property_ = property(self._getter, None, None)
# assign unconditionally to overwrite element name definition
setattr(self._element_cls, self._prop_... | def _add_getter(self):
"""
Add a read-only ``{prop_name}`` property to the element class for
this child element.
"""
property_ = property(self._getter, None, None)
# assign unconditionally to overwrite element name definition
setattr(self._element_cls, self._prop_... | [
"Add",
"a",
"read",
"-",
"only",
"{",
"prop_name",
"}",
"property",
"to",
"the",
"element",
"class",
"for",
"this",
"child",
"element",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L296-L303 | [
"def",
"_add_getter",
"(",
"self",
")",
":",
"property_",
"=",
"property",
"(",
"self",
".",
"_getter",
",",
"None",
",",
"None",
")",
"# assign unconditionally to overwrite element name definition",
"setattr",
"(",
"self",
".",
"_element_cls",
",",
"self",
".",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _BaseChildElement._add_inserter | Add an ``_insert_x()`` method to the element class for this child
element. | docx/oxml/xmlchemy.py | def _add_inserter(self):
"""
Add an ``_insert_x()`` method to the element class for this child
element.
"""
def _insert_child(obj, child):
obj.insert_element_before(child, *self._successors)
return child
_insert_child.__doc__ = (
'Retu... | def _add_inserter(self):
"""
Add an ``_insert_x()`` method to the element class for this child
element.
"""
def _insert_child(obj, child):
obj.insert_element_before(child, *self._successors)
return child
_insert_child.__doc__ = (
'Retu... | [
"Add",
"an",
"_insert_x",
"()",
"method",
"to",
"the",
"element",
"class",
"for",
"this",
"child",
"element",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L305-L318 | [
"def",
"_add_inserter",
"(",
"self",
")",
":",
"def",
"_insert_child",
"(",
"obj",
",",
"child",
")",
":",
"obj",
".",
"insert_element_before",
"(",
"child",
",",
"*",
"self",
".",
"_successors",
")",
"return",
"child",
"_insert_child",
".",
"__doc__",
"="... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _BaseChildElement._add_list_getter | Add a read-only ``{prop_name}_lst`` property to the element class to
retrieve a list of child elements matching this type. | docx/oxml/xmlchemy.py | def _add_list_getter(self):
"""
Add a read-only ``{prop_name}_lst`` property to the element class to
retrieve a list of child elements matching this type.
"""
prop_name = '%s_lst' % self._prop_name
property_ = property(self._list_getter, None, None)
setattr(self._... | def _add_list_getter(self):
"""
Add a read-only ``{prop_name}_lst`` property to the element class to
retrieve a list of child elements matching this type.
"""
prop_name = '%s_lst' % self._prop_name
property_ = property(self._list_getter, None, None)
setattr(self._... | [
"Add",
"a",
"read",
"-",
"only",
"{",
"prop_name",
"}",
"_lst",
"property",
"to",
"the",
"element",
"class",
"to",
"retrieve",
"a",
"list",
"of",
"child",
"elements",
"matching",
"this",
"type",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L320-L327 | [
"def",
"_add_list_getter",
"(",
"self",
")",
":",
"prop_name",
"=",
"'%s_lst'",
"%",
"self",
".",
"_prop_name",
"property_",
"=",
"property",
"(",
"self",
".",
"_list_getter",
",",
"None",
",",
"None",
")",
"setattr",
"(",
"self",
".",
"_element_cls",
",",... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _BaseChildElement._add_public_adder | Add a public ``add_x()`` method to the parent element class. | docx/oxml/xmlchemy.py | def _add_public_adder(self):
"""
Add a public ``add_x()`` method to the parent element class.
"""
def add_child(obj):
private_add_method = getattr(obj, self._add_method_name)
child = private_add_method()
return child
add_child.__doc__ = (
... | def _add_public_adder(self):
"""
Add a public ``add_x()`` method to the parent element class.
"""
def add_child(obj):
private_add_method = getattr(obj, self._add_method_name)
child = private_add_method()
return child
add_child.__doc__ = (
... | [
"Add",
"a",
"public",
"add_x",
"()",
"method",
"to",
"the",
"parent",
"element",
"class",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L333-L346 | [
"def",
"_add_public_adder",
"(",
"self",
")",
":",
"def",
"add_child",
"(",
"obj",
")",
":",
"private_add_method",
"=",
"getattr",
"(",
"obj",
",",
"self",
".",
"_add_method_name",
")",
"child",
"=",
"private_add_method",
"(",
")",
"return",
"child",
"add_ch... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _BaseChildElement._add_to_class | Add *method* to the target class as *name*, unless *name* is already
defined on the class. | docx/oxml/xmlchemy.py | def _add_to_class(self, name, method):
"""
Add *method* to the target class as *name*, unless *name* is already
defined on the class.
"""
if hasattr(self._element_cls, name):
return
setattr(self._element_cls, name, method) | def _add_to_class(self, name, method):
"""
Add *method* to the target class as *name*, unless *name* is already
defined on the class.
"""
if hasattr(self._element_cls, name):
return
setattr(self._element_cls, name, method) | [
"Add",
"*",
"method",
"*",
"to",
"the",
"target",
"class",
"as",
"*",
"name",
"*",
"unless",
"*",
"name",
"*",
"is",
"already",
"defined",
"on",
"the",
"class",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L348-L355 | [
"def",
"_add_to_class",
"(",
"self",
",",
"name",
",",
"method",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"_element_cls",
",",
"name",
")",
":",
"return",
"setattr",
"(",
"self",
".",
"_element_cls",
",",
"name",
",",
"method",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _BaseChildElement._getter | Return a function object suitable for the "get" side of the property
descriptor. This default getter returns the child element with
matching tag name or |None| if not present. | docx/oxml/xmlchemy.py | def _getter(self):
"""
Return a function object suitable for the "get" side of the property
descriptor. This default getter returns the child element with
matching tag name or |None| if not present.
"""
def get_child_element(obj):
return obj.find(qn(self._nspt... | def _getter(self):
"""
Return a function object suitable for the "get" side of the property
descriptor. This default getter returns the child element with
matching tag name or |None| if not present.
"""
def get_child_element(obj):
return obj.find(qn(self._nspt... | [
"Return",
"a",
"function",
"object",
"suitable",
"for",
"the",
"get",
"side",
"of",
"the",
"property",
"descriptor",
".",
"This",
"default",
"getter",
"returns",
"the",
"child",
"element",
"with",
"matching",
"tag",
"name",
"or",
"|None|",
"if",
"not",
"pres... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L368-L380 | [
"def",
"_getter",
"(",
"self",
")",
":",
"def",
"get_child_element",
"(",
"obj",
")",
":",
"return",
"obj",
".",
"find",
"(",
"qn",
"(",
"self",
".",
"_nsptagname",
")",
")",
"get_child_element",
".",
"__doc__",
"=",
"(",
"'``<%s>`` child element or |None| i... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _BaseChildElement._list_getter | Return a function object suitable for the "get" side of a list
property descriptor. | docx/oxml/xmlchemy.py | def _list_getter(self):
"""
Return a function object suitable for the "get" side of a list
property descriptor.
"""
def get_child_element_list(obj):
return obj.findall(qn(self._nsptagname))
get_child_element_list.__doc__ = (
'A list containing each... | def _list_getter(self):
"""
Return a function object suitable for the "get" side of a list
property descriptor.
"""
def get_child_element_list(obj):
return obj.findall(qn(self._nsptagname))
get_child_element_list.__doc__ = (
'A list containing each... | [
"Return",
"a",
"function",
"object",
"suitable",
"for",
"the",
"get",
"side",
"of",
"a",
"list",
"property",
"descriptor",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L387-L398 | [
"def",
"_list_getter",
"(",
"self",
")",
":",
"def",
"get_child_element_list",
"(",
"obj",
")",
":",
"return",
"obj",
".",
"findall",
"(",
"qn",
"(",
"self",
".",
"_nsptagname",
")",
")",
"get_child_element_list",
".",
"__doc__",
"=",
"(",
"'A list containin... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Choice.populate_class_members | Add the appropriate methods to *element_cls*. | docx/oxml/xmlchemy.py | def populate_class_members(
self, element_cls, group_prop_name, successors):
"""
Add the appropriate methods to *element_cls*.
"""
self._element_cls = element_cls
self._group_prop_name = group_prop_name
self._successors = successors
self._add_getter()... | def populate_class_members(
self, element_cls, group_prop_name, successors):
"""
Add the appropriate methods to *element_cls*.
"""
self._element_cls = element_cls
self._group_prop_name = group_prop_name
self._successors = successors
self._add_getter()... | [
"Add",
"the",
"appropriate",
"methods",
"to",
"*",
"element_cls",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L428-L441 | [
"def",
"populate_class_members",
"(",
"self",
",",
"element_cls",
",",
"group_prop_name",
",",
"successors",
")",
":",
"self",
".",
"_element_cls",
"=",
"element_cls",
"self",
".",
"_group_prop_name",
"=",
"group_prop_name",
"self",
".",
"_successors",
"=",
"succe... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Choice._add_get_or_change_to_method | Add a ``get_or_change_to_x()`` method to the element class for this
child element. | docx/oxml/xmlchemy.py | def _add_get_or_change_to_method(self):
"""
Add a ``get_or_change_to_x()`` method to the element class for this
child element.
"""
def get_or_change_to_child(obj):
child = getattr(obj, self._prop_name)
if child is not None:
return child
... | def _add_get_or_change_to_method(self):
"""
Add a ``get_or_change_to_x()`` method to the element class for this
child element.
"""
def get_or_change_to_child(obj):
child = getattr(obj, self._prop_name)
if child is not None:
return child
... | [
"Add",
"a",
"get_or_change_to_x",
"()",
"method",
"to",
"the",
"element",
"class",
"for",
"this",
"child",
"element",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L443-L466 | [
"def",
"_add_get_or_change_to_method",
"(",
"self",
")",
":",
"def",
"get_or_change_to_child",
"(",
"obj",
")",
":",
"child",
"=",
"getattr",
"(",
"obj",
",",
"self",
".",
"_prop_name",
")",
"if",
"child",
"is",
"not",
"None",
":",
"return",
"child",
"remo... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | Choice._prop_name | Calculate property name from tag name, e.g. a:schemeClr -> schemeClr. | docx/oxml/xmlchemy.py | def _prop_name(self):
"""
Calculate property name from tag name, e.g. a:schemeClr -> schemeClr.
"""
if ':' in self._nsptagname:
start = self._nsptagname.index(':') + 1
else:
start = 0
return self._nsptagname[start:] | def _prop_name(self):
"""
Calculate property name from tag name, e.g. a:schemeClr -> schemeClr.
"""
if ':' in self._nsptagname:
start = self._nsptagname.index(':') + 1
else:
start = 0
return self._nsptagname[start:] | [
"Calculate",
"property",
"name",
"from",
"tag",
"name",
"e",
".",
"g",
".",
"a",
":",
"schemeClr",
"-",
">",
"schemeClr",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L469-L477 | [
"def",
"_prop_name",
"(",
"self",
")",
":",
"if",
"':'",
"in",
"self",
".",
"_nsptagname",
":",
"start",
"=",
"self",
".",
"_nsptagname",
".",
"index",
"(",
"':'",
")",
"+",
"1",
"else",
":",
"start",
"=",
"0",
"return",
"self",
".",
"_nsptagname",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | OneAndOnlyOne.populate_class_members | Add the appropriate methods to *element_cls*. | docx/oxml/xmlchemy.py | def populate_class_members(self, element_cls, prop_name):
"""
Add the appropriate methods to *element_cls*.
"""
super(OneAndOnlyOne, self).populate_class_members(
element_cls, prop_name
)
self._add_getter() | def populate_class_members(self, element_cls, prop_name):
"""
Add the appropriate methods to *element_cls*.
"""
super(OneAndOnlyOne, self).populate_class_members(
element_cls, prop_name
)
self._add_getter() | [
"Add",
"the",
"appropriate",
"methods",
"to",
"*",
"element_cls",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L495-L502 | [
"def",
"populate_class_members",
"(",
"self",
",",
"element_cls",
",",
"prop_name",
")",
":",
"super",
"(",
"OneAndOnlyOne",
",",
"self",
")",
".",
"populate_class_members",
"(",
"element_cls",
",",
"prop_name",
")",
"self",
".",
"_add_getter",
"(",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | OneOrMore.populate_class_members | Add the appropriate methods to *element_cls*. | docx/oxml/xmlchemy.py | def populate_class_members(self, element_cls, prop_name):
"""
Add the appropriate methods to *element_cls*.
"""
super(OneOrMore, self).populate_class_members(
element_cls, prop_name
)
self._add_list_getter()
self._add_creator()
self._add_insert... | def populate_class_members(self, element_cls, prop_name):
"""
Add the appropriate methods to *element_cls*.
"""
super(OneOrMore, self).populate_class_members(
element_cls, prop_name
)
self._add_list_getter()
self._add_creator()
self._add_insert... | [
"Add",
"the",
"appropriate",
"methods",
"to",
"*",
"element_cls",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L531-L543 | [
"def",
"populate_class_members",
"(",
"self",
",",
"element_cls",
",",
"prop_name",
")",
":",
"super",
"(",
"OneOrMore",
",",
"self",
")",
".",
"populate_class_members",
"(",
"element_cls",
",",
"prop_name",
")",
"self",
".",
"_add_list_getter",
"(",
")",
"sel... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | ZeroOrOne.populate_class_members | Add the appropriate methods to *element_cls*. | docx/oxml/xmlchemy.py | def populate_class_members(self, element_cls, prop_name):
"""
Add the appropriate methods to *element_cls*.
"""
super(ZeroOrOne, self).populate_class_members(element_cls, prop_name)
self._add_getter()
self._add_creator()
self._add_inserter()
self._add_adde... | def populate_class_members(self, element_cls, prop_name):
"""
Add the appropriate methods to *element_cls*.
"""
super(ZeroOrOne, self).populate_class_members(element_cls, prop_name)
self._add_getter()
self._add_creator()
self._add_inserter()
self._add_adde... | [
"Add",
"the",
"appropriate",
"methods",
"to",
"*",
"element_cls",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L569-L579 | [
"def",
"populate_class_members",
"(",
"self",
",",
"element_cls",
",",
"prop_name",
")",
":",
"super",
"(",
"ZeroOrOne",
",",
"self",
")",
".",
"populate_class_members",
"(",
"element_cls",
",",
"prop_name",
")",
"self",
".",
"_add_getter",
"(",
")",
"self",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | ZeroOrOne._add_get_or_adder | Add a ``get_or_add_x()`` method to the element class for this
child element. | docx/oxml/xmlchemy.py | def _add_get_or_adder(self):
"""
Add a ``get_or_add_x()`` method to the element class for this
child element.
"""
def get_or_add_child(obj):
child = getattr(obj, self._prop_name)
if child is None:
add_method = getattr(obj, self._add_method_... | def _add_get_or_adder(self):
"""
Add a ``get_or_add_x()`` method to the element class for this
child element.
"""
def get_or_add_child(obj):
child = getattr(obj, self._prop_name)
if child is None:
add_method = getattr(obj, self._add_method_... | [
"Add",
"a",
"get_or_add_x",
"()",
"method",
"to",
"the",
"element",
"class",
"for",
"this",
"child",
"element",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L581-L595 | [
"def",
"_add_get_or_adder",
"(",
"self",
")",
":",
"def",
"get_or_add_child",
"(",
"obj",
")",
":",
"child",
"=",
"getattr",
"(",
"obj",
",",
"self",
".",
"_prop_name",
")",
"if",
"child",
"is",
"None",
":",
"add_method",
"=",
"getattr",
"(",
"obj",
",... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | ZeroOrOne._add_remover | Add a ``_remove_x()`` method to the element class for this child
element. | docx/oxml/xmlchemy.py | def _add_remover(self):
"""
Add a ``_remove_x()`` method to the element class for this child
element.
"""
def _remove_child(obj):
obj.remove_all(self._nsptagname)
_remove_child.__doc__ = (
'Remove all ``<%s>`` child elements.'
) % self._nsp... | def _add_remover(self):
"""
Add a ``_remove_x()`` method to the element class for this child
element.
"""
def _remove_child(obj):
obj.remove_all(self._nsptagname)
_remove_child.__doc__ = (
'Remove all ``<%s>`` child elements.'
) % self._nsp... | [
"Add",
"a",
"_remove_x",
"()",
"method",
"to",
"the",
"element",
"class",
"for",
"this",
"child",
"element",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L597-L607 | [
"def",
"_add_remover",
"(",
"self",
")",
":",
"def",
"_remove_child",
"(",
"obj",
")",
":",
"obj",
".",
"remove_all",
"(",
"self",
".",
"_nsptagname",
")",
"_remove_child",
".",
"__doc__",
"=",
"(",
"'Remove all ``<%s>`` child elements.'",
")",
"%",
"self",
... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | ZeroOrOneChoice.populate_class_members | Add the appropriate methods to *element_cls*. | docx/oxml/xmlchemy.py | def populate_class_members(self, element_cls, prop_name):
"""
Add the appropriate methods to *element_cls*.
"""
super(ZeroOrOneChoice, self).populate_class_members(
element_cls, prop_name
)
self._add_choice_getter()
for choice in self._choices:
... | def populate_class_members(self, element_cls, prop_name):
"""
Add the appropriate methods to *element_cls*.
"""
super(ZeroOrOneChoice, self).populate_class_members(
element_cls, prop_name
)
self._add_choice_getter()
for choice in self._choices:
... | [
"Add",
"the",
"appropriate",
"methods",
"to",
"*",
"element_cls",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L623-L635 | [
"def",
"populate_class_members",
"(",
"self",
",",
"element_cls",
",",
"prop_name",
")",
":",
"super",
"(",
"ZeroOrOneChoice",
",",
"self",
")",
".",
"populate_class_members",
"(",
"element_cls",
",",
"prop_name",
")",
"self",
".",
"_add_choice_getter",
"(",
")"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | ZeroOrOneChoice._add_choice_getter | Add a read-only ``{prop_name}`` property to the element class that
returns the present member of this group, or |None| if none are
present. | docx/oxml/xmlchemy.py | def _add_choice_getter(self):
"""
Add a read-only ``{prop_name}`` property to the element class that
returns the present member of this group, or |None| if none are
present.
"""
property_ = property(self._choice_getter, None, None)
# assign unconditionally to over... | def _add_choice_getter(self):
"""
Add a read-only ``{prop_name}`` property to the element class that
returns the present member of this group, or |None| if none are
present.
"""
property_ = property(self._choice_getter, None, None)
# assign unconditionally to over... | [
"Add",
"a",
"read",
"-",
"only",
"{",
"prop_name",
"}",
"property",
"to",
"the",
"element",
"class",
"that",
"returns",
"the",
"present",
"member",
"of",
"this",
"group",
"or",
"|None|",
"if",
"none",
"are",
"present",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L637-L645 | [
"def",
"_add_choice_getter",
"(",
"self",
")",
":",
"property_",
"=",
"property",
"(",
"self",
".",
"_choice_getter",
",",
"None",
",",
"None",
")",
"# assign unconditionally to overwrite element name definition",
"setattr",
"(",
"self",
".",
"_element_cls",
",",
"s... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | ZeroOrOneChoice._add_group_remover | Add a ``_remove_eg_x()`` method to the element class for this choice
group. | docx/oxml/xmlchemy.py | def _add_group_remover(self):
"""
Add a ``_remove_eg_x()`` method to the element class for this choice
group.
"""
def _remove_choice_group(obj):
for tagname in self._member_nsptagnames:
obj.remove_all(tagname)
_remove_choice_group.__doc__ = (
... | def _add_group_remover(self):
"""
Add a ``_remove_eg_x()`` method to the element class for this choice
group.
"""
def _remove_choice_group(obj):
for tagname in self._member_nsptagnames:
obj.remove_all(tagname)
_remove_choice_group.__doc__ = (
... | [
"Add",
"a",
"_remove_eg_x",
"()",
"method",
"to",
"the",
"element",
"class",
"for",
"this",
"choice",
"group",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L647-L661 | [
"def",
"_add_group_remover",
"(",
"self",
")",
":",
"def",
"_remove_choice_group",
"(",
"obj",
")",
":",
"for",
"tagname",
"in",
"self",
".",
"_member_nsptagnames",
":",
"obj",
".",
"remove_all",
"(",
"tagname",
")",
"_remove_choice_group",
".",
"__doc__",
"="... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | ZeroOrOneChoice._choice_getter | Return a function object suitable for the "get" side of the property
descriptor. | docx/oxml/xmlchemy.py | def _choice_getter(self):
"""
Return a function object suitable for the "get" side of the property
descriptor.
"""
def get_group_member_element(obj):
return obj.first_child_found_in(*self._member_nsptagnames)
get_group_member_element.__doc__ = (
'R... | def _choice_getter(self):
"""
Return a function object suitable for the "get" side of the property
descriptor.
"""
def get_group_member_element(obj):
return obj.first_child_found_in(*self._member_nsptagnames)
get_group_member_element.__doc__ = (
'R... | [
"Return",
"a",
"function",
"object",
"suitable",
"for",
"the",
"get",
"side",
"of",
"the",
"property",
"descriptor",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L664-L675 | [
"def",
"_choice_getter",
"(",
"self",
")",
":",
"def",
"get_group_member_element",
"(",
"obj",
")",
":",
"return",
"obj",
".",
"first_child_found_in",
"(",
"*",
"self",
".",
"_member_nsptagnames",
")",
"get_group_member_element",
".",
"__doc__",
"=",
"(",
"'Retu... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _OxmlElementBase.first_child_found_in | Return the first child found with tag in *tagnames*, or None if
not found. | docx/oxml/xmlchemy.py | def first_child_found_in(self, *tagnames):
"""
Return the first child found with tag in *tagnames*, or None if
not found.
"""
for tagname in tagnames:
child = self.find(qn(tagname))
if child is not None:
return child
return None | def first_child_found_in(self, *tagnames):
"""
Return the first child found with tag in *tagnames*, or None if
not found.
"""
for tagname in tagnames:
child = self.find(qn(tagname))
if child is not None:
return child
return None | [
"Return",
"the",
"first",
"child",
"found",
"with",
"tag",
"in",
"*",
"tagnames",
"*",
"or",
"None",
"if",
"not",
"found",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L705-L714 | [
"def",
"first_child_found_in",
"(",
"self",
",",
"*",
"tagnames",
")",
":",
"for",
"tagname",
"in",
"tagnames",
":",
"child",
"=",
"self",
".",
"find",
"(",
"qn",
"(",
"tagname",
")",
")",
"if",
"child",
"is",
"not",
"None",
":",
"return",
"child",
"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _OxmlElementBase.remove_all | Remove all child elements whose tagname (e.g. 'a:p') appears in
*tagnames*. | docx/oxml/xmlchemy.py | def remove_all(self, *tagnames):
"""
Remove all child elements whose tagname (e.g. 'a:p') appears in
*tagnames*.
"""
for tagname in tagnames:
matching = self.findall(qn(tagname))
for child in matching:
self.remove(child) | def remove_all(self, *tagnames):
"""
Remove all child elements whose tagname (e.g. 'a:p') appears in
*tagnames*.
"""
for tagname in tagnames:
matching = self.findall(qn(tagname))
for child in matching:
self.remove(child) | [
"Remove",
"all",
"child",
"elements",
"whose",
"tagname",
"(",
"e",
".",
"g",
".",
"a",
":",
"p",
")",
"appears",
"in",
"*",
"tagnames",
"*",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L724-L732 | [
"def",
"remove_all",
"(",
"self",
",",
"*",
"tagnames",
")",
":",
"for",
"tagname",
"in",
"tagnames",
":",
"matching",
"=",
"self",
".",
"findall",
"(",
"qn",
"(",
"tagname",
")",
")",
"for",
"child",
"in",
"matching",
":",
"self",
".",
"remove",
"("... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | _OxmlElementBase.xpath | Override of ``lxml`` _Element.xpath() method to provide standard Open
XML namespace mapping (``nsmap``) in centralized location. | docx/oxml/xmlchemy.py | def xpath(self, xpath_str):
"""
Override of ``lxml`` _Element.xpath() method to provide standard Open
XML namespace mapping (``nsmap``) in centralized location.
"""
return super(BaseOxmlElement, self).xpath(
xpath_str, namespaces=nsmap
) | def xpath(self, xpath_str):
"""
Override of ``lxml`` _Element.xpath() method to provide standard Open
XML namespace mapping (``nsmap``) in centralized location.
"""
return super(BaseOxmlElement, self).xpath(
xpath_str, namespaces=nsmap
) | [
"Override",
"of",
"lxml",
"_Element",
".",
"xpath",
"()",
"method",
"to",
"provide",
"standard",
"Open",
"XML",
"namespace",
"mapping",
"(",
"nsmap",
")",
"in",
"centralized",
"location",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L743-L750 | [
"def",
"xpath",
"(",
"self",
",",
"xpath_str",
")",
":",
"return",
"super",
"(",
"BaseOxmlElement",
",",
"self",
")",
".",
"xpath",
"(",
"xpath_str",
",",
"namespaces",
"=",
"nsmap",
")"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | ColorFormat.rgb | An |RGBColor| value or |None| if no RGB color is specified.
When :attr:`type` is `MSO_COLOR_TYPE.RGB`, the value of this property
will always be an |RGBColor| value. It may also be an |RGBColor|
value if :attr:`type` is `MSO_COLOR_TYPE.THEME`, as Word writes the
current value of a theme... | docx/dml/color.py | def rgb(self):
"""
An |RGBColor| value or |None| if no RGB color is specified.
When :attr:`type` is `MSO_COLOR_TYPE.RGB`, the value of this property
will always be an |RGBColor| value. It may also be an |RGBColor|
value if :attr:`type` is `MSO_COLOR_TYPE.THEME`, as Word writes t... | def rgb(self):
"""
An |RGBColor| value or |None| if no RGB color is specified.
When :attr:`type` is `MSO_COLOR_TYPE.RGB`, the value of this property
will always be an |RGBColor| value. It may also be an |RGBColor|
value if :attr:`type` is `MSO_COLOR_TYPE.THEME`, as Word writes t... | [
"An",
"|RGBColor|",
"value",
"or",
"|None|",
"if",
"no",
"RGB",
"color",
"is",
"specified",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/dml/color.py#L28-L51 | [
"def",
"rgb",
"(",
"self",
")",
":",
"color",
"=",
"self",
".",
"_color",
"if",
"color",
"is",
"None",
":",
"return",
"None",
"if",
"color",
".",
"val",
"==",
"ST_HexColorAuto",
".",
"AUTO",
":",
"return",
"None",
"return",
"color",
".",
"val"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | ColorFormat.theme_color | A member of :ref:`MsoThemeColorIndex` or |None| if no theme color is
specified. When :attr:`type` is `MSO_COLOR_TYPE.THEME`, the value of
this property will always be a member of :ref:`MsoThemeColorIndex`.
When :attr:`type` has any other value, the value of this property is
|None|.
... | docx/dml/color.py | def theme_color(self):
"""
A member of :ref:`MsoThemeColorIndex` or |None| if no theme color is
specified. When :attr:`type` is `MSO_COLOR_TYPE.THEME`, the value of
this property will always be a member of :ref:`MsoThemeColorIndex`.
When :attr:`type` has any other value, the valu... | def theme_color(self):
"""
A member of :ref:`MsoThemeColorIndex` or |None| if no theme color is
specified. When :attr:`type` is `MSO_COLOR_TYPE.THEME`, the value of
this property will always be a member of :ref:`MsoThemeColorIndex`.
When :attr:`type` has any other value, the valu... | [
"A",
"member",
"of",
":",
"ref",
":",
"MsoThemeColorIndex",
"or",
"|None|",
"if",
"no",
"theme",
"color",
"is",
"specified",
".",
"When",
":",
"attr",
":",
"type",
"is",
"MSO_COLOR_TYPE",
".",
"THEME",
"the",
"value",
"of",
"this",
"property",
"will",
"a... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/dml/color.py#L63-L80 | [
"def",
"theme_color",
"(",
"self",
")",
":",
"color",
"=",
"self",
".",
"_color",
"if",
"color",
"is",
"None",
"or",
"color",
".",
"themeColor",
"is",
"None",
":",
"return",
"None",
"return",
"color",
".",
"themeColor"
] | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | ColorFormat.type | Read-only. A member of :ref:`MsoColorType`, one of RGB, THEME, or
AUTO, corresponding to the way this color is defined. Its value is
|None| if no color is applied at this level, which causes the
effective color to be inherited from the style hierarchy. | docx/dml/color.py | def type(self):
"""
Read-only. A member of :ref:`MsoColorType`, one of RGB, THEME, or
AUTO, corresponding to the way this color is defined. Its value is
|None| if no color is applied at this level, which causes the
effective color to be inherited from the style hierarchy.
... | def type(self):
"""
Read-only. A member of :ref:`MsoColorType`, one of RGB, THEME, or
AUTO, corresponding to the way this color is defined. Its value is
|None| if no color is applied at this level, which causes the
effective color to be inherited from the style hierarchy.
... | [
"Read",
"-",
"only",
".",
"A",
"member",
"of",
":",
"ref",
":",
"MsoColorType",
"one",
"of",
"RGB",
"THEME",
"or",
"AUTO",
"corresponding",
"to",
"the",
"way",
"this",
"color",
"is",
"defined",
".",
"Its",
"value",
"is",
"|None|",
"if",
"no",
"color",
... | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/dml/color.py#L91-L105 | [
"def",
"type",
"(",
"self",
")",
":",
"color",
"=",
"self",
".",
"_color",
"if",
"color",
"is",
"None",
":",
"return",
"None",
"if",
"color",
".",
"themeColor",
"is",
"not",
"None",
":",
"return",
"MSO_COLOR_TYPE",
".",
"THEME",
"if",
"color",
".",
"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | InlineShape.type | The type of this inline shape as a member of
``docx.enum.shape.WD_INLINE_SHAPE``, e.g. ``LINKED_PICTURE``.
Read-only. | docx/shape.py | def type(self):
"""
The type of this inline shape as a member of
``docx.enum.shape.WD_INLINE_SHAPE``, e.g. ``LINKED_PICTURE``.
Read-only.
"""
graphicData = self._inline.graphic.graphicData
uri = graphicData.uri
if uri == nsmap['pic']:
blip = gr... | def type(self):
"""
The type of this inline shape as a member of
``docx.enum.shape.WD_INLINE_SHAPE``, e.g. ``LINKED_PICTURE``.
Read-only.
"""
graphicData = self._inline.graphic.graphicData
uri = graphicData.uri
if uri == nsmap['pic']:
blip = gr... | [
"The",
"type",
"of",
"this",
"inline",
"shape",
"as",
"a",
"member",
"of",
"docx",
".",
"enum",
".",
"shape",
".",
"WD_INLINE_SHAPE",
"e",
".",
"g",
".",
"LINKED_PICTURE",
".",
"Read",
"-",
"only",
"."
] | python-openxml/python-docx | python | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/shape.py#L73-L90 | [
"def",
"type",
"(",
"self",
")",
":",
"graphicData",
"=",
"self",
".",
"_inline",
".",
"graphic",
".",
"graphicData",
"uri",
"=",
"graphicData",
".",
"uri",
"if",
"uri",
"==",
"nsmap",
"[",
"'pic'",
"]",
":",
"blip",
"=",
"graphicData",
".",
"pic",
"... | 6756f6cd145511d3eb6d1d188beea391b1ddfd53 |
train | to_df | Extracts the data from a Plotly Figure
Parameters
----------
figure : plotly_figure
Figure from which data will be
extracted
Returns a DataFrame or list of DataFrame | cufflinks/extract.py | def to_df(figure):
"""
Extracts the data from a Plotly Figure
Parameters
----------
figure : plotly_figure
Figure from which data will be
extracted
Returns a DataFrame or list of DataFrame
"""
dfs=[]
for trace in figure['data']:
if '... | def to_df(figure):
"""
Extracts the data from a Plotly Figure
Parameters
----------
figure : plotly_figure
Figure from which data will be
extracted
Returns a DataFrame or list of DataFrame
"""
dfs=[]
for trace in figure['data']:
if '... | [
"Extracts",
"the",
"data",
"from",
"a",
"Plotly",
"Figure"
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/extract.py#L4-L69 | [
"def",
"to_df",
"(",
"figure",
")",
":",
"dfs",
"=",
"[",
"]",
"for",
"trace",
"in",
"figure",
"[",
"'data'",
"]",
":",
"if",
"'scatter'",
"in",
"trace",
"[",
"'type'",
"]",
":",
"try",
":",
"if",
"type",
"(",
"trace",
"[",
"'x'",
"]",
"[",
"0"... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | to_rgba | Converts from hex|rgb to rgba
Parameters:
-----------
color : string
Color representation on hex or rgb
alpha : float
Value from 0 to 1.0 that represents the
alpha value.
Example:
to_rgba('#E1E5ED',0.6)
... | cufflinks/colors.py | def to_rgba(color, alpha):
"""
Converts from hex|rgb to rgba
Parameters:
-----------
color : string
Color representation on hex or rgb
alpha : float
Value from 0 to 1.0 that represents the
alpha value.
Example:
... | def to_rgba(color, alpha):
"""
Converts from hex|rgb to rgba
Parameters:
-----------
color : string
Color representation on hex or rgb
alpha : float
Value from 0 to 1.0 that represents the
alpha value.
Example:
... | [
"Converts",
"from",
"hex|rgb",
"to",
"rgba"
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/colors.py#L23-L52 | [
"def",
"to_rgba",
"(",
"color",
",",
"alpha",
")",
":",
"if",
"type",
"(",
"color",
")",
"==",
"tuple",
":",
"color",
",",
"alpha",
"=",
"color",
"color",
"=",
"color",
".",
"lower",
"(",
")",
"if",
"'rgba'",
"in",
"color",
":",
"cl",
"=",
"list"... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | hex_to_rgb | Converts from hex to rgb
Parameters:
-----------
color : string
Color representation on hex or rgb
Example:
hex_to_rgb('#E1E5ED')
hex_to_rgb('#f03') | cufflinks/colors.py | def hex_to_rgb(color):
"""
Converts from hex to rgb
Parameters:
-----------
color : string
Color representation on hex or rgb
Example:
hex_to_rgb('#E1E5ED')
hex_to_rgb('#f03')
"""
color = normalize(color)
color = color[1:]
# r... | def hex_to_rgb(color):
"""
Converts from hex to rgb
Parameters:
-----------
color : string
Color representation on hex or rgb
Example:
hex_to_rgb('#E1E5ED')
hex_to_rgb('#f03')
"""
color = normalize(color)
color = color[1:]
# r... | [
"Converts",
"from",
"hex",
"to",
"rgb"
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/colors.py#L55-L71 | [
"def",
"hex_to_rgb",
"(",
"color",
")",
":",
"color",
"=",
"normalize",
"(",
"color",
")",
"color",
"=",
"color",
"[",
"1",
":",
"]",
"# return 'rgb'+str(tuple(ord(c) for c in color.decode('hex')))",
"return",
"'rgb'",
"+",
"str",
"(",
"(",
"int",
"(",
"color"... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | normalize | Returns an hex color
Parameters:
-----------
color : string
Color representation in rgba|rgb|hex
Example:
normalize('#f03') | cufflinks/colors.py | def normalize(color):
"""
Returns an hex color
Parameters:
-----------
color : string
Color representation in rgba|rgb|hex
Example:
normalize('#f03')
"""
if type(color) == tuple:
color = to_rgba(*color)
if 'rgba' in color:
ret... | def normalize(color):
"""
Returns an hex color
Parameters:
-----------
color : string
Color representation in rgba|rgb|hex
Example:
normalize('#f03')
"""
if type(color) == tuple:
color = to_rgba(*color)
if 'rgba' in color:
ret... | [
"Returns",
"an",
"hex",
"color"
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/colors.py#L74-L102 | [
"def",
"normalize",
"(",
"color",
")",
":",
"if",
"type",
"(",
"color",
")",
"==",
"tuple",
":",
"color",
"=",
"to_rgba",
"(",
"*",
"color",
")",
"if",
"'rgba'",
"in",
"color",
":",
"return",
"rgb_to_hex",
"(",
"rgba_to_rgb",
"(",
"color",
")",
")",
... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | rgb_to_hex | Converts from rgb to hex
Parameters:
-----------
color : string
Color representation on hex or rgb
Example:
rgb_to_hex('rgb(23,25,24)') | cufflinks/colors.py | def rgb_to_hex(color):
"""
Converts from rgb to hex
Parameters:
-----------
color : string
Color representation on hex or rgb
Example:
rgb_to_hex('rgb(23,25,24)')
"""
rgb = eval(color.replace('rgb', ''))
# return '#'+''.join(map(chr, rgb)).en... | def rgb_to_hex(color):
"""
Converts from rgb to hex
Parameters:
-----------
color : string
Color representation on hex or rgb
Example:
rgb_to_hex('rgb(23,25,24)')
"""
rgb = eval(color.replace('rgb', ''))
# return '#'+''.join(map(chr, rgb)).en... | [
"Converts",
"from",
"rgb",
"to",
"hex"
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/colors.py#L105-L119 | [
"def",
"rgb_to_hex",
"(",
"color",
")",
":",
"rgb",
"=",
"eval",
"(",
"color",
".",
"replace",
"(",
"'rgb'",
",",
"''",
")",
")",
"# return '#'+''.join(map(chr, rgb)).encode('hex')",
"return",
"'#'",
"+",
"''",
".",
"join",
"(",
"[",
"'{0:02x}'",
".",
"for... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | rgba_to_rgb | Converts from rgba to rgb
Parameters:
-----------
color : string
Color representation in rgba
bg : string
Color representation in rgb
Example:
rgba_to_rgb('rgb(23,25,24,.4)'' | cufflinks/colors.py | def rgba_to_rgb(color, bg='rgb(255,255,255)'):
"""
Converts from rgba to rgb
Parameters:
-----------
color : string
Color representation in rgba
bg : string
Color representation in rgb
Example:
rgba_to_rgb('rgb(23,25,24,.4... | def rgba_to_rgb(color, bg='rgb(255,255,255)'):
"""
Converts from rgba to rgb
Parameters:
-----------
color : string
Color representation in rgba
bg : string
Color representation in rgb
Example:
rgba_to_rgb('rgb(23,25,24,.4... | [
"Converts",
"from",
"rgba",
"to",
"rgb"
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/colors.py#L122-L143 | [
"def",
"rgba_to_rgb",
"(",
"color",
",",
"bg",
"=",
"'rgb(255,255,255)'",
")",
":",
"def",
"c_tup",
"(",
"c",
")",
":",
"return",
"eval",
"(",
"c",
"[",
"c",
".",
"find",
"(",
"'('",
")",
":",
"]",
")",
"color",
"=",
"c_tup",
"(",
"color",
")",
... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | hex_to_hsv | Converts from hex to hsv
Parameters:
-----------
color : string
Color representation on color
Example:
hex_to_hsv('#ff9933') | cufflinks/colors.py | def hex_to_hsv(color):
"""
Converts from hex to hsv
Parameters:
-----------
color : string
Color representation on color
Example:
hex_to_hsv('#ff9933')
"""
color = normalize(color)
color = color[1:]
# color=tuple(ord(c)/255.0 for c in col... | def hex_to_hsv(color):
"""
Converts from hex to hsv
Parameters:
-----------
color : string
Color representation on color
Example:
hex_to_hsv('#ff9933')
"""
color = normalize(color)
color = color[1:]
# color=tuple(ord(c)/255.0 for c in col... | [
"Converts",
"from",
"hex",
"to",
"hsv"
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/colors.py#L146-L163 | [
"def",
"hex_to_hsv",
"(",
"color",
")",
":",
"color",
"=",
"normalize",
"(",
"color",
")",
"color",
"=",
"color",
"[",
"1",
":",
"]",
"# color=tuple(ord(c)/255.0 for c in color.decode('hex'))",
"color",
"=",
"(",
"int",
"(",
"color",
"[",
"0",
":",
"2",
"]... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | color_range | Generates a scale of colours from a base colour
Parameters:
-----------
color : string
Color representation in hex
N : int
number of colours to generate
Example:
color_range('#ff9933',20) | cufflinks/colors.py | def color_range(color, N=20):
"""
Generates a scale of colours from a base colour
Parameters:
-----------
color : string
Color representation in hex
N : int
number of colours to generate
Example:
color_range('#ff9933',20... | def color_range(color, N=20):
"""
Generates a scale of colours from a base colour
Parameters:
-----------
color : string
Color representation in hex
N : int
number of colours to generate
Example:
color_range('#ff9933',20... | [
"Generates",
"a",
"scale",
"of",
"colours",
"from",
"a",
"base",
"colour"
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/colors.py#L166-L195 | [
"def",
"color_range",
"(",
"color",
",",
"N",
"=",
"20",
")",
":",
"color",
"=",
"normalize",
"(",
"color",
")",
"org",
"=",
"color",
"color",
"=",
"hex_to_hsv",
"(",
"color",
")",
"HSV_tuples",
"=",
"[",
"(",
"color",
"[",
"0",
"]",
",",
"x",
",... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | color_table | Generates a colour table
Parameters:
-----------
color : string | list | dict
Color representation in rgba|rgb|hex
If a list of colors is passed then these
are displayed in a table
N : int
number of colou... | cufflinks/colors.py | def color_table(color, N=1, sort=False, sort_values=False, inline=False, as_html=False):
"""
Generates a colour table
Parameters:
-----------
color : string | list | dict
Color representation in rgba|rgb|hex
If a list of colors is passed then these
... | def color_table(color, N=1, sort=False, sort_values=False, inline=False, as_html=False):
"""
Generates a colour table
Parameters:
-----------
color : string | list | dict
Color representation in rgba|rgb|hex
If a list of colors is passed then these
... | [
"Generates",
"a",
"colour",
"table"
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/colors.py#L198-L281 | [
"def",
"color_table",
"(",
"color",
",",
"N",
"=",
"1",
",",
"sort",
"=",
"False",
",",
"sort_values",
"=",
"False",
",",
"inline",
"=",
"False",
",",
"as_html",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"color",
",",
"list",
")",
":",
"c_",... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | colorgen | Returns a generator with a list of colors
and gradients of those colors
Parameters:
-----------
colors : list(colors)
List of colors to use
Example:
colorgen()
colorgen(['blue','red','pink'])
colorgen(['#f03','rgb(23,25,25)']) | cufflinks/colors.py | def colorgen(colors=None, n=None, scale=None, theme=None):
"""
Returns a generator with a list of colors
and gradients of those colors
Parameters:
-----------
colors : list(colors)
List of colors to use
Example:
colorgen()
colorgen(['blue... | def colorgen(colors=None, n=None, scale=None, theme=None):
"""
Returns a generator with a list of colors
and gradients of those colors
Parameters:
-----------
colors : list(colors)
List of colors to use
Example:
colorgen()
colorgen(['blue... | [
"Returns",
"a",
"generator",
"with",
"a",
"list",
"of",
"colors",
"and",
"gradients",
"of",
"those",
"colors"
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/colors.py#L284-L316 | [
"def",
"colorgen",
"(",
"colors",
"=",
"None",
",",
"n",
"=",
"None",
",",
"scale",
"=",
"None",
",",
"theme",
"=",
"None",
")",
":",
"from",
".",
"themes",
"import",
"THEMES",
"step",
"=",
".1",
"if",
"not",
"colors",
":",
"if",
"not",
"scale",
... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | scales | Displays a color scale (HTML)
Parameters:
-----------
scale : str
Color scale name
If no scale name is provided then all scales are returned
(max number for each scale)
If scale='all' then all scale combinations... | cufflinks/colors.py | def scales(scale=None):
"""
Displays a color scale (HTML)
Parameters:
-----------
scale : str
Color scale name
If no scale name is provided then all scales are returned
(max number for each scale)
If sca... | def scales(scale=None):
"""
Displays a color scale (HTML)
Parameters:
-----------
scale : str
Color scale name
If no scale name is provided then all scales are returned
(max number for each scale)
If sca... | [
"Displays",
"a",
"color",
"scale",
"(",
"HTML",
")"
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/colors.py#L594-L625 | [
"def",
"scales",
"(",
"scale",
"=",
"None",
")",
":",
"if",
"scale",
":",
"if",
"scale",
"==",
"'all'",
":",
"display",
"(",
"HTML",
"(",
"cl",
".",
"to_html",
"(",
"_scales",
")",
")",
")",
"else",
":",
"display",
"(",
"HTML",
"(",
"cl",
".",
... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | get_scales | Returns a color scale
Parameters:
-----------
scale : str
Color scale name
If the color name is preceded by a minus (-)
then the scale is inversed
n : int
Number of colors
If n < numbe... | cufflinks/colors.py | def get_scales(scale=None, n=None):
"""
Returns a color scale
Parameters:
-----------
scale : str
Color scale name
If the color name is preceded by a minus (-)
then the scale is inversed
n : int
Nu... | def get_scales(scale=None, n=None):
"""
Returns a color scale
Parameters:
-----------
scale : str
Color scale name
If the color name is preceded by a minus (-)
then the scale is inversed
n : int
Nu... | [
"Returns",
"a",
"color",
"scale"
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/colors.py#L667-L714 | [
"def",
"get_scales",
"(",
"scale",
"=",
"None",
",",
"n",
"=",
"None",
")",
":",
"if",
"scale",
":",
"is_reverse",
"=",
"False",
"if",
"scale",
"[",
"0",
"]",
"==",
"'-'",
":",
"scale",
"=",
"scale",
"[",
"1",
":",
"]",
"is_reverse",
"=",
"True",... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | get_colorscale | Returns a color scale to be used for a plotly figure
Parameters:
-----------
scale : str or list
Color scale name
If the color name is preceded by a minus (-)
then the scale is inversed.
Also accepts a list of colors (... | cufflinks/colors.py | def get_colorscale(scale):
"""
Returns a color scale to be used for a plotly figure
Parameters:
-----------
scale : str or list
Color scale name
If the color name is preceded by a minus (-)
then the scale is inversed.
... | def get_colorscale(scale):
"""
Returns a color scale to be used for a plotly figure
Parameters:
-----------
scale : str or list
Color scale name
If the color name is preceded by a minus (-)
then the scale is inversed.
... | [
"Returns",
"a",
"color",
"scale",
"to",
"be",
"used",
"for",
"a",
"plotly",
"figure"
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/colors.py#L717-L743 | [
"def",
"get_colorscale",
"(",
"scale",
")",
":",
"if",
"type",
"(",
"scale",
")",
"in",
"string_types",
":",
"scale",
"=",
"get_scales",
"(",
"scale",
")",
"else",
":",
"if",
"type",
"(",
"scale",
")",
"!=",
"list",
":",
"raise",
"Exception",
"(",
"\... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | _to_iplot | Generates a plotly Data object
Parameters
----------
colors : list or dict
{key:color} to specify the color for each column
[colors] to use the colors in the defined order
colorscale : str
Color scale name
Only valid if 'colors' is null
See cufflinks.colors.scales() for available scales
kind :... | cufflinks/plotlytools.py | def _to_iplot(self,colors=None,colorscale=None,kind='scatter',mode='lines',interpolation='linear',symbol='dot',size='12',fill=False,
width=3,dash='solid',sortbars=False,keys=False,bestfit=False,bestfit_colors=None,opacity=0.6,
mean=False,mean_colors=None,asDates=False,asTimestamp=False,text=None,**kwargs):
"""
Ge... | def _to_iplot(self,colors=None,colorscale=None,kind='scatter',mode='lines',interpolation='linear',symbol='dot',size='12',fill=False,
width=3,dash='solid',sortbars=False,keys=False,bestfit=False,bestfit_colors=None,opacity=0.6,
mean=False,mean_colors=None,asDates=False,asTimestamp=False,text=None,**kwargs):
"""
Ge... | [
"Generates",
"a",
"plotly",
"Data",
"object"
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/plotlytools.py#L37-L198 | [
"def",
"_to_iplot",
"(",
"self",
",",
"colors",
"=",
"None",
",",
"colorscale",
"=",
"None",
",",
"kind",
"=",
"'scatter'",
",",
"mode",
"=",
"'lines'",
",",
"interpolation",
"=",
"'linear'",
",",
"symbol",
"=",
"'dot'",
",",
"size",
"=",
"'12'",
",",
... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | _iplot | Returns a plotly chart either as inline chart, image of Figure object
Parameters:
-----------
kind : string
Kind of chart
scatter
bar
box
spread
ratio
heatmap
surface
histogram
bubble
bubble3d
scatter3d
scattergeo
ohlc
candle
pie
choroplet
data... | cufflinks/plotlytools.py | def _iplot(self,kind='scatter',data=None,layout=None,filename='',sharing=None,title='',xTitle='',yTitle='',zTitle='',theme=None,colors=None,colorscale=None,fill=False,width=None,
dash='solid',mode='',interpolation='linear',symbol='circle',size=12,barmode='',sortbars=False,bargap=None,bargroupgap=None,bins=None,histn... | def _iplot(self,kind='scatter',data=None,layout=None,filename='',sharing=None,title='',xTitle='',yTitle='',zTitle='',theme=None,colors=None,colorscale=None,fill=False,width=None,
dash='solid',mode='',interpolation='linear',symbol='circle',size=12,barmode='',sortbars=False,bargap=None,bargroupgap=None,bins=None,histn... | [
"Returns",
"a",
"plotly",
"chart",
"either",
"as",
"inline",
"chart",
"image",
"of",
"Figure",
"object"
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/plotlytools.py#L200-L1217 | [
"def",
"_iplot",
"(",
"self",
",",
"kind",
"=",
"'scatter'",
",",
"data",
"=",
"None",
",",
"layout",
"=",
"None",
",",
"filename",
"=",
"''",
",",
"sharing",
"=",
"None",
",",
"title",
"=",
"''",
",",
"xTitle",
"=",
"''",
",",
"yTitle",
"=",
"''... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | get_items_as_list | Returns a dict with an item per key
Parameters:
-----------
items : string, list or dict
Items (ie line styles)
keys: list
List of keys
items_names : string
Name of items | cufflinks/plotlytools.py | def get_items_as_list(items,keys,items_names='styles'):
"""
Returns a dict with an item per key
Parameters:
-----------
items : string, list or dict
Items (ie line styles)
keys: list
List of keys
items_names : string
Name of items
"""
if type(items)!=dict:
if type(items)==list:
if len(items... | def get_items_as_list(items,keys,items_names='styles'):
"""
Returns a dict with an item per key
Parameters:
-----------
items : string, list or dict
Items (ie line styles)
keys: list
List of keys
items_names : string
Name of items
"""
if type(items)!=dict:
if type(items)==list:
if len(items... | [
"Returns",
"a",
"dict",
"with",
"an",
"item",
"per",
"key"
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/plotlytools.py#L1234-L1255 | [
"def",
"get_items_as_list",
"(",
"items",
",",
"keys",
",",
"items_names",
"=",
"'styles'",
")",
":",
"if",
"type",
"(",
"items",
")",
"!=",
"dict",
":",
"if",
"type",
"(",
"items",
")",
"==",
"list",
":",
"if",
"len",
"(",
"items",
")",
"!=",
"len... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | _scatter_matrix | Displays a matrix with scatter plot for each pair of
Series in the DataFrame.
The diagonal shows a histogram for each of the Series
Parameters:
-----------
df : DataFrame
Pandas DataFrame
theme : string
Theme to be used (if not the default)
bins : int
Number of bins to use for histogram
color : s... | cufflinks/plotlytools.py | def _scatter_matrix(self,theme=None,bins=10,color='grey',size=2, asFigure=False, **iplot_kwargs):
"""
Displays a matrix with scatter plot for each pair of
Series in the DataFrame.
The diagonal shows a histogram for each of the Series
Parameters:
-----------
df : DataFrame
Pandas DataFrame
theme : string
... | def _scatter_matrix(self,theme=None,bins=10,color='grey',size=2, asFigure=False, **iplot_kwargs):
"""
Displays a matrix with scatter plot for each pair of
Series in the DataFrame.
The diagonal shows a histogram for each of the Series
Parameters:
-----------
df : DataFrame
Pandas DataFrame
theme : string
... | [
"Displays",
"a",
"matrix",
"with",
"scatter",
"plot",
"for",
"each",
"pair",
"of",
"Series",
"in",
"the",
"DataFrame",
".",
"The",
"diagonal",
"shows",
"a",
"histogram",
"for",
"each",
"of",
"the",
"Series"
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/plotlytools.py#L1258-L1283 | [
"def",
"_scatter_matrix",
"(",
"self",
",",
"theme",
"=",
"None",
",",
"bins",
"=",
"10",
",",
"color",
"=",
"'grey'",
",",
"size",
"=",
"2",
",",
"asFigure",
"=",
"False",
",",
"*",
"*",
"iplot_kwargs",
")",
":",
"sm",
"=",
"tools",
".",
"scatter_... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | iplot | Plots a figure in IPython, creates an HTML or generates an Image
figure : figure
Plotly figure to be charted
validate : bool
If True then all values are validated before
it is charted
sharing : string
Sets the sharing level permission
public - anyone can see this chart
private - only you can see this... | cufflinks/plotlytools.py | def iplot(figure,validate=True,sharing=None,filename='',
online=None,asImage=False,asUrl=False,asPlot=False,
dimensions=None,display_image=True,**kwargs):
"""
Plots a figure in IPython, creates an HTML or generates an Image
figure : figure
Plotly figure to be charted
validate : bool
If True then all va... | def iplot(figure,validate=True,sharing=None,filename='',
online=None,asImage=False,asUrl=False,asPlot=False,
dimensions=None,display_image=True,**kwargs):
"""
Plots a figure in IPython, creates an HTML or generates an Image
figure : figure
Plotly figure to be charted
validate : bool
If True then all va... | [
"Plots",
"a",
"figure",
"in",
"IPython",
"creates",
"an",
"HTML",
"or",
"generates",
"an",
"Image"
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/plotlytools.py#L1321-L1463 | [
"def",
"iplot",
"(",
"figure",
",",
"validate",
"=",
"True",
",",
"sharing",
"=",
"None",
",",
"filename",
"=",
"''",
",",
"online",
"=",
"None",
",",
"asImage",
"=",
"False",
",",
"asUrl",
"=",
"False",
",",
"asPlot",
"=",
"False",
",",
"dimensions"... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | _ta_plot | Generates a Technical Study Chart
Parameters:
-----------
study : string
Technical Study to be charted
sma - 'Simple Moving Average'
rsi - 'R Strength Indicator'
periods : int
Number of periods
column : string
Name of the column on which the
study will be done
include : bool
... | cufflinks/plotlytools.py | def _ta_plot(self,study,periods=14,column=None,include=True,str='{name}({period})',detail=False,
theme=None,sharing=None,filename='',asFigure=False,**iplot_kwargs):
"""
Generates a Technical Study Chart
Parameters:
-----------
study : string
Technical Study to be charted
sma - 'Simple Moving Averag... | def _ta_plot(self,study,periods=14,column=None,include=True,str='{name}({period})',detail=False,
theme=None,sharing=None,filename='',asFigure=False,**iplot_kwargs):
"""
Generates a Technical Study Chart
Parameters:
-----------
study : string
Technical Study to be charted
sma - 'Simple Moving Averag... | [
"Generates",
"a",
"Technical",
"Study",
"Chart"
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/plotlytools.py#L1480-L1655 | [
"def",
"_ta_plot",
"(",
"self",
",",
"study",
",",
"periods",
"=",
"14",
",",
"column",
"=",
"None",
",",
"include",
"=",
"True",
",",
"str",
"=",
"'{name}({period})'",
",",
"detail",
"=",
"False",
",",
"theme",
"=",
"None",
",",
"sharing",
"=",
"Non... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | _fig_iplot | Plots a figure in IPython
figure : figure
Plotly figure to be charted
validate : bool
If True then all values are validated before
it is charted
sharing : string
Sets the sharing level permission
public - anyone can see this chart
private - only you can see this chart
secret - only people with the... | cufflinks/plotlytools.py | def _fig_iplot(self,validate=True,sharing=None,filename='',
online=None,asImage=False,asUrl=False,asPlot=False,
dimensions=None,display_image=True,**kwargs):
"""
Plots a figure in IPython
figure : figure
Plotly figure to be charted
validate : bool
If True then all values are validated before
it is c... | def _fig_iplot(self,validate=True,sharing=None,filename='',
online=None,asImage=False,asUrl=False,asPlot=False,
dimensions=None,display_image=True,**kwargs):
"""
Plots a figure in IPython
figure : figure
Plotly figure to be charted
validate : bool
If True then all values are validated before
it is c... | [
"Plots",
"a",
"figure",
"in",
"IPython"
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/plotlytools.py#L1657-L1715 | [
"def",
"_fig_iplot",
"(",
"self",
",",
"validate",
"=",
"True",
",",
"sharing",
"=",
"None",
",",
"filename",
"=",
"''",
",",
"online",
"=",
"None",
",",
"asImage",
"=",
"False",
",",
"asUrl",
"=",
"False",
",",
"asPlot",
"=",
"False",
",",
"dimensio... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | ensure_local_files | Ensure that filesystem is setup/filled out in a valid way | cufflinks/auth.py | def ensure_local_files():
"""
Ensure that filesystem is setup/filled out in a valid way
"""
if _file_permissions:
if not os.path.isdir(AUTH_DIR):
os.mkdir(AUTH_DIR)
for fn in [CONFIG_FILE]:
contents = load_json_dict(fn)
for key, val in list(_FILE_CONTENT[fn].items()):
if key not in contents:
c... | def ensure_local_files():
"""
Ensure that filesystem is setup/filled out in a valid way
"""
if _file_permissions:
if not os.path.isdir(AUTH_DIR):
os.mkdir(AUTH_DIR)
for fn in [CONFIG_FILE]:
contents = load_json_dict(fn)
for key, val in list(_FILE_CONTENT[fn].items()):
if key not in contents:
c... | [
"Ensure",
"that",
"filesystem",
"is",
"setup",
"/",
"filled",
"out",
"in",
"a",
"valid",
"way"
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/auth.py#L64-L83 | [
"def",
"ensure_local_files",
"(",
")",
":",
"if",
"_file_permissions",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"AUTH_DIR",
")",
":",
"os",
".",
"mkdir",
"(",
"AUTH_DIR",
")",
"for",
"fn",
"in",
"[",
"CONFIG_FILE",
"]",
":",
"contents",
... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | set_config_file | Set the keyword-value pairs in `~/.config`.
sharing : string
Sets the sharing level permission
public - anyone can see this chart
private - only you can see this chart
secret - only people with the link can see the chart
theme : string
Sets the default theme
See cufflinks.getThemes() for availab... | cufflinks/auth.py | def set_config_file(sharing=None,theme=None,colorscale=None,offline=None,offline_connected=None,
offline_url=None,offline_show_link=None,offline_link_text=None,
offline_config=None,
datagen_mode=None,**kwargs):
"""
Set the keyword-value pairs in `~/.config`.
sharing : string
Sets the sharing level... | def set_config_file(sharing=None,theme=None,colorscale=None,offline=None,offline_connected=None,
offline_url=None,offline_show_link=None,offline_link_text=None,
offline_config=None,
datagen_mode=None,**kwargs):
"""
Set the keyword-value pairs in `~/.config`.
sharing : string
Sets the sharing level... | [
"Set",
"the",
"keyword",
"-",
"value",
"pairs",
"in",
"~",
"/",
".",
"config",
"."
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/auth.py#L86-L174 | [
"def",
"set_config_file",
"(",
"sharing",
"=",
"None",
",",
"theme",
"=",
"None",
",",
"colorscale",
"=",
"None",
",",
"offline",
"=",
"None",
",",
"offline_connected",
"=",
"None",
",",
"offline_url",
"=",
"None",
",",
"offline_show_link",
"=",
"None",
",... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
train | load_json_dict | Checks if file exists. Returns {} if something fails. | cufflinks/auth.py | def load_json_dict(filename, *args):
"""Checks if file exists. Returns {} if something fails."""
data = {}
if os.path.exists(filename):
with open(filename, "r") as f:
try:
data = json.load(f)
if not isinstance(data, dict):
data = {}
except:
pass
if args:
return {key: data[key] for key ... | def load_json_dict(filename, *args):
"""Checks if file exists. Returns {} if something fails."""
data = {}
if os.path.exists(filename):
with open(filename, "r") as f:
try:
data = json.load(f)
if not isinstance(data, dict):
data = {}
except:
pass
if args:
return {key: data[key] for key ... | [
"Checks",
"if",
"file",
"exists",
".",
"Returns",
"{}",
"if",
"something",
"fails",
"."
] | santosjorge/cufflinks | python | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/auth.py#L193-L206 | [
"def",
"load_json_dict",
"(",
"filename",
",",
"*",
"args",
")",
":",
"data",
"=",
"{",
"}",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"\"r\"",
")",
"as",
"f",
":",
"try",
":",
"data"... | ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.