Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
ProjectUpdate.branch_override | (self) | Whether a branch other than the project default is used. | Whether a branch other than the project default is used. | def branch_override(self):
"""Whether a branch other than the project default is used."""
if not self.project:
return True
return bool(self.scm_branch and self.scm_branch != self.project.scm_branch) | [
"def",
"branch_override",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"project",
":",
"return",
"True",
"return",
"bool",
"(",
"self",
".",
"scm_branch",
"and",
"self",
".",
"scm_branch",
"!=",
"self",
".",
"project",
".",
"scm_branch",
")"
] | [
574,
4
] | [
578,
83
] | python | en | ['en', 'en', 'en'] | True |
ProjectUpdate.preferred_instance_groups | (self) |
Project updates should pretty much always run on the control plane
however, we are not yet saying no to custom groupings within the control plane
Thus, we return custom groups and then unconditionally add the control plane
|
Project updates should pretty much always run on the control plane
however, we are not yet saying no to custom groupings within the control plane
Thus, we return custom groups and then unconditionally add the control plane
| def preferred_instance_groups(self):
'''
Project updates should pretty much always run on the control plane
however, we are not yet saying no to custom groupings within the control plane
Thus, we return custom groups and then unconditionally add the control plane
'''
if s... | [
"def",
"preferred_instance_groups",
"(",
"self",
")",
":",
"if",
"self",
".",
"organization",
"is",
"not",
"None",
":",
"organization_groups",
"=",
"[",
"x",
"for",
"x",
"in",
"self",
".",
"organization",
".",
"instance_groups",
".",
"all",
"(",
")",
"]",
... | [
616,
4
] | [
633,
30
] | python | en | ['en', 'error', 'th'] | False |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Sunpower sensors. | Set up the Sunpower sensors. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Sunpower sensors."""
sunpower_state = hass.data[DOMAIN][config_entry.entry_id]
_LOGGER.error("Sunpower_state: %s", sunpower_state)
coordinator = sunpower_state[SUNPOWER_COORDINATOR]
sunpower_data = coordinator.data
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"sunpower_state",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"_LOGGER",
".",
"error",
"(",
"\"Sunpower_sta... | [
22,
0
] | [
91,
38
] | python | en | ['en', 'lb', 'en'] | True |
SunPowerPVSBasic.__init__ | (self, coordinator, pvs_info, field, title, unit, icon) | Initialize the sensor. | Initialize the sensor. | def __init__(self, coordinator, pvs_info, field, title, unit, icon):
"""Initialize the sensor."""
super().__init__(coordinator, pvs_info)
self._title = title
self._field = field
self._unit = unit
self._icon = icon | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"pvs_info",
",",
"field",
",",
"title",
",",
"unit",
",",
"icon",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
",",
"pvs_info",
")",
"self",
".",
"_title",
"=",
"title",
"s... | [
97,
4
] | [
103,
25
] | python | en | ['en', 'en', 'en'] | True |
SunPowerPVSBasic.unit_of_measurement | (self) | Return the unit of measurement. | Return the unit of measurement. | def unit_of_measurement(self):
"""Return the unit of measurement."""
return self._unit | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit"
] | [
106,
4
] | [
108,
25
] | python | en | ['en', 'la', 'en'] | True |
SunPowerPVSBasic.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self):
"""Icon to use in the frontend, if any."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_icon"
] | [
111,
4
] | [
113,
25
] | python | en | ['en', 'en', 'en'] | True |
SunPowerPVSBasic.name | (self) | Device Name. | Device Name. | def name(self):
"""Device Name."""
return self._title | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_title"
] | [
116,
4
] | [
118,
26
] | python | en | ['en', 'en', 'en'] | False |
SunPowerPVSBasic.unique_id | (self) | Device Uniqueid. | Device Uniqueid. | def unique_id(self):
"""Device Uniqueid."""
return f"{self.base_unique_id}_pvs_{self._field}" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f\"{self.base_unique_id}_pvs_{self._field}\""
] | [
121,
4
] | [
123,
57
] | python | fr | ['fr', 'fr', 'en'] | False |
SunPowerPVSBasic.state | (self) | Get the current value | Get the current value | def state(self):
"""Get the current value"""
return self.coordinator.data[PVS_DEVICE_TYPE][self.base_unique_id][self._field] | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"coordinator",
".",
"data",
"[",
"PVS_DEVICE_TYPE",
"]",
"[",
"self",
".",
"base_unique_id",
"]",
"[",
"self",
".",
"_field",
"]"
] | [
126,
4
] | [
128,
87
] | python | en | ['en', 'en', 'en'] | True |
SunPowerMeterBasic.__init__ | (self, coordinator, meter_info, pvs_info, field, title, unit, icon) | Initialize the sensor. | Initialize the sensor. | def __init__(self, coordinator, meter_info, pvs_info, field, title, unit, icon):
"""Initialize the sensor."""
super().__init__(coordinator, meter_info, pvs_info)
self._title = title
self._field = field
self._unit = unit
self._icon = icon | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"meter_info",
",",
"pvs_info",
",",
"field",
",",
"title",
",",
"unit",
",",
"icon",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
",",
"meter_info",
",",
"pvs_info",
")",
"se... | [
134,
4
] | [
140,
25
] | python | en | ['en', 'en', 'en'] | True |
SunPowerMeterBasic.unit_of_measurement | (self) | Return the unit of measurement. | Return the unit of measurement. | def unit_of_measurement(self):
"""Return the unit of measurement."""
return self._unit | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit"
] | [
143,
4
] | [
145,
25
] | python | en | ['en', 'la', 'en'] | True |
SunPowerMeterBasic.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self):
"""Icon to use in the frontend, if any."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_icon"
] | [
148,
4
] | [
150,
25
] | python | en | ['en', 'en', 'en'] | True |
SunPowerMeterBasic.name | (self) | Device Name. | Device Name. | def name(self):
"""Device Name."""
return self._title | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_title"
] | [
153,
4
] | [
155,
26
] | python | en | ['en', 'en', 'en'] | False |
SunPowerMeterBasic.unique_id | (self) | Device Uniqueid. | Device Uniqueid. | def unique_id(self):
"""Device Uniqueid."""
return f"{self.base_unique_id}_pvs_{self._field}" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f\"{self.base_unique_id}_pvs_{self._field}\""
] | [
158,
4
] | [
160,
57
] | python | fr | ['fr', 'fr', 'en'] | False |
SunPowerMeterBasic.state | (self) | Get the current value | Get the current value | def state(self):
"""Get the current value"""
return self.coordinator.data[METER_DEVICE_TYPE][self.base_unique_id][self._field] | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"coordinator",
".",
"data",
"[",
"METER_DEVICE_TYPE",
"]",
"[",
"self",
".",
"base_unique_id",
"]",
"[",
"self",
".",
"_field",
"]"
] | [
163,
4
] | [
165,
89
] | python | en | ['en', 'en', 'en'] | True |
SunPowerInverterBasic.__init__ | (self, coordinator, inverter_info, pvs_info, field, title, unit, icon) | Initialize the sensor. | Initialize the sensor. | def __init__(self, coordinator, inverter_info, pvs_info, field, title, unit, icon):
"""Initialize the sensor."""
super().__init__(coordinator, inverter_info, pvs_info)
self._title = title
self._field = field
self._unit = unit
self._icon = icon | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"inverter_info",
",",
"pvs_info",
",",
"field",
",",
"title",
",",
"unit",
",",
"icon",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
",",
"inverter_info",
",",
"pvs_info",
")",... | [
171,
4
] | [
177,
25
] | python | en | ['en', 'en', 'en'] | True |
SunPowerInverterBasic.unit_of_measurement | (self) | Return the unit of measurement. | Return the unit of measurement. | def unit_of_measurement(self):
"""Return the unit of measurement."""
return self._unit | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit"
] | [
180,
4
] | [
182,
25
] | python | en | ['en', 'la', 'en'] | True |
SunPowerInverterBasic.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self):
"""Icon to use in the frontend, if any."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_icon"
] | [
185,
4
] | [
187,
25
] | python | en | ['en', 'en', 'en'] | True |
SunPowerInverterBasic.name | (self) | Device Name. | Device Name. | def name(self):
"""Device Name."""
return self._title | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_title"
] | [
190,
4
] | [
192,
26
] | python | en | ['en', 'en', 'en'] | False |
SunPowerInverterBasic.unique_id | (self) | Device Uniqueid. | Device Uniqueid. | def unique_id(self):
"""Device Uniqueid."""
return f"{self.base_unique_id}_pvs_{self._field}" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f\"{self.base_unique_id}_pvs_{self._field}\""
] | [
195,
4
] | [
197,
57
] | python | fr | ['fr', 'fr', 'en'] | False |
SunPowerInverterBasic.state | (self) | Get the current value | Get the current value | def state(self):
"""Get the current value"""
return self.coordinator.data[INVERTER_DEVICE_TYPE][self.base_unique_id][self._field] | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"coordinator",
".",
"data",
"[",
"INVERTER_DEVICE_TYPE",
"]",
"[",
"self",
".",
"base_unique_id",
"]",
"[",
"self",
".",
"_field",
"]"
] | [
200,
4
] | [
202,
92
] | python | en | ['en', 'en', 'en'] | True |
TLSRPGM.Activate | (self, tms) |
data = self.command(struct.pack('<BBH', self.CMD_FUNCS, self.CMDF_SWIRE_ACTIVATE, count), 10)
self._port.timeout = t
if data == None:
print('Activate Error[%d]!' % self.err)
return False
print('ok')
self.ext_pc = struct.unpack('<I', data[4:8])
print('CPU PC=0x%08x' % self.ext_pc)
return True
|
data = self.command(struct.pack('<BBH', self.CMD_FUNCS, self.CMDF_SWIRE_ACTIVATE, count), 10)
self._port.timeout = t
if data == None:
print('Activate Error[%d]!' % self.err)
return False
print('ok')
self.ext_pc = struct.unpack('<I', data[4:8])
print('CPU PC=0x%08x' % self.ext_pc)
return True
| def Activate(self, tms):
count = 0
if tms > 0:
count = int(tms/((self.pgm_swaddrlen + 5.7)*5*self.pgm_swdiv/2400))
if count > 0xffff:
count = 0xffff
t = self._port.timeout
self._port.timeout = tms/1000 + 0.5
#print('Count = %d, timeout = %.6f' % (count, self._port.timeout))
print('Activate %d ms..... | [
"def",
"Activate",
"(",
"self",
",",
"tms",
")",
":",
"count",
"=",
"0",
"if",
"tms",
">",
"0",
":",
"count",
"=",
"int",
"(",
"tms",
"/",
"(",
"(",
"self",
".",
"pgm_swaddrlen",
"+",
"5.7",
")",
"*",
"5",
"*",
"self",
".",
"pgm_swdiv",
"/",
... | [
345,
1
] | [
404,
13
] | python | en | ['en', 'ja', 'th'] | False |
_find_all_simple | (path) |
Find all files under 'path'
|
Find all files under 'path'
| def _find_all_simple(path):
"""
Find all files under 'path'
"""
results = (
os.path.join(base, file)
for base, dirs, files in os.walk(path, followlinks=True)
for file in files
)
return filter(os.path.isfile, results) | [
"def",
"_find_all_simple",
"(",
"path",
")",
":",
"results",
"=",
"(",
"os",
".",
"path",
".",
"join",
"(",
"base",
",",
"file",
")",
"for",
"base",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"path",
",",
"followlinks",
"=",
"True",
... | [
245,
0
] | [
254,
42
] | python | en | ['en', 'error', 'th'] | False |
findall | (dir=os.curdir) |
Find all files under 'dir' and return the list of full filenames.
Unless dir is '.', return full filenames with dir prepended.
|
Find all files under 'dir' and return the list of full filenames.
Unless dir is '.', return full filenames with dir prepended.
| def findall(dir=os.curdir):
"""
Find all files under 'dir' and return the list of full filenames.
Unless dir is '.', return full filenames with dir prepended.
"""
files = _find_all_simple(dir)
if dir == os.curdir:
make_rel = functools.partial(os.path.relpath, start=dir)
files = m... | [
"def",
"findall",
"(",
"dir",
"=",
"os",
".",
"curdir",
")",
":",
"files",
"=",
"_find_all_simple",
"(",
"dir",
")",
"if",
"dir",
"==",
"os",
".",
"curdir",
":",
"make_rel",
"=",
"functools",
".",
"partial",
"(",
"os",
".",
"path",
".",
"relpath",
... | [
257,
0
] | [
266,
22
] | python | en | ['en', 'error', 'th'] | False |
glob_to_re | (pattern) | Translate a shell-like glob pattern to a regular expression; return
a string containing the regex. Differs from 'fnmatch.translate()' in
that '*' does not match "special characters" (which are
platform-specific).
| Translate a shell-like glob pattern to a regular expression; return
a string containing the regex. Differs from 'fnmatch.translate()' in
that '*' does not match "special characters" (which are
platform-specific).
| def glob_to_re(pattern):
"""Translate a shell-like glob pattern to a regular expression; return
a string containing the regex. Differs from 'fnmatch.translate()' in
that '*' does not match "special characters" (which are
platform-specific).
"""
pattern_re = fnmatch.translate(pattern)
# '?'... | [
"def",
"glob_to_re",
"(",
"pattern",
")",
":",
"pattern_re",
"=",
"fnmatch",
".",
"translate",
"(",
"pattern",
")",
"# '?' and '*' in the glob pattern become '.' and '.*' in the RE, which",
"# IMHO is wrong -- '?' and '*' aren't supposed to match slash in Unix,",
"# and by extension ... | [
269,
0
] | [
289,
21
] | python | en | ['en', 'haw', 'en'] | True |
translate_pattern | (pattern, anchor=1, prefix=None, is_regex=0) | Translate a shell-like wildcard pattern to a compiled regular
expression. Return the compiled regex. If 'is_regex' true,
then 'pattern' is directly compiled to a regex (if it's a string)
or just returned as-is (assumes it's a regex object).
| Translate a shell-like wildcard pattern to a compiled regular
expression. Return the compiled regex. If 'is_regex' true,
then 'pattern' is directly compiled to a regex (if it's a string)
or just returned as-is (assumes it's a regex object).
| def translate_pattern(pattern, anchor=1, prefix=None, is_regex=0):
"""Translate a shell-like wildcard pattern to a compiled regular
expression. Return the compiled regex. If 'is_regex' true,
then 'pattern' is directly compiled to a regex (if it's a string)
or just returned as-is (assumes it's a regex ... | [
"def",
"translate_pattern",
"(",
"pattern",
",",
"anchor",
"=",
"1",
",",
"prefix",
"=",
"None",
",",
"is_regex",
"=",
"0",
")",
":",
"if",
"is_regex",
":",
"if",
"isinstance",
"(",
"pattern",
",",
"str",
")",
":",
"return",
"re",
".",
"compile",
"("... | [
292,
0
] | [
326,
33
] | python | en | ['en', 'en', 'en'] | True |
FileList.debug_print | (self, msg) | Print 'msg' to stdout if the global DEBUG (taken from the
DISTUTILS_DEBUG environment variable) flag is true.
| Print 'msg' to stdout if the global DEBUG (taken from the
DISTUTILS_DEBUG environment variable) flag is true.
| def debug_print(self, msg):
"""Print 'msg' to stdout if the global DEBUG (taken from the
DISTUTILS_DEBUG environment variable) flag is true.
"""
from distutils.debug import DEBUG
if DEBUG:
print(msg) | [
"def",
"debug_print",
"(",
"self",
",",
"msg",
")",
":",
"from",
"distutils",
".",
"debug",
"import",
"DEBUG",
"if",
"DEBUG",
":",
"print",
"(",
"msg",
")"
] | [
40,
4
] | [
46,
22
] | python | en | ['en', 'en', 'en'] | True |
FileList.include_pattern | (self, pattern, anchor=1, prefix=None, is_regex=0) | Select strings (presumably filenames) from 'self.files' that
match 'pattern', a Unix-style wildcard (glob) pattern. Patterns
are not quite the same as implemented by the 'fnmatch' module: '*'
and '?' match non-special characters, where "special" is platform-
dependent: slash on Unix; c... | Select strings (presumably filenames) from 'self.files' that
match 'pattern', a Unix-style wildcard (glob) pattern. Patterns
are not quite the same as implemented by the 'fnmatch' module: '*'
and '?' match non-special characters, where "special" is platform-
dependent: slash on Unix; c... | def include_pattern(self, pattern, anchor=1, prefix=None, is_regex=0):
"""Select strings (presumably filenames) from 'self.files' that
match 'pattern', a Unix-style wildcard (glob) pattern. Patterns
are not quite the same as implemented by the 'fnmatch' module: '*'
and '?' match non-sp... | [
"def",
"include_pattern",
"(",
"self",
",",
"pattern",
",",
"anchor",
"=",
"1",
",",
"prefix",
"=",
"None",
",",
"is_regex",
"=",
"0",
")",
":",
"# XXX docstring lying about what the special chars are?",
"files_found",
"=",
"False",
"pattern_re",
"=",
"translate_p... | [
179,
4
] | [
219,
26
] | python | en | ['en', 'en', 'en'] | True |
FileList.exclude_pattern | (self, pattern,
anchor=1, prefix=None, is_regex=0) | Remove strings (presumably filenames) from 'files' that match
'pattern'. Other parameters are the same as for
'include_pattern()', above.
The list 'self.files' is modified in place.
Return True if files are found, False otherwise.
| Remove strings (presumably filenames) from 'files' that match
'pattern'. Other parameters are the same as for
'include_pattern()', above.
The list 'self.files' is modified in place.
Return True if files are found, False otherwise.
| def exclude_pattern (self, pattern,
anchor=1, prefix=None, is_regex=0):
"""Remove strings (presumably filenames) from 'files' that match
'pattern'. Other parameters are the same as for
'include_pattern()', above.
The list 'self.files' is modified in place.
... | [
"def",
"exclude_pattern",
"(",
"self",
",",
"pattern",
",",
"anchor",
"=",
"1",
",",
"prefix",
"=",
"None",
",",
"is_regex",
"=",
"0",
")",
":",
"files_found",
"=",
"False",
"pattern_re",
"=",
"translate_pattern",
"(",
"pattern",
",",
"anchor",
",",
"pre... | [
222,
4
] | [
239,
26
] | python | en | ['en', 'en', 'en'] | True |
_WKBReader.read | (self, wkb) | Returns a _pointer_ to C GEOS Geometry object from the given WKB. | Returns a _pointer_ to C GEOS Geometry object from the given WKB. | def read(self, wkb):
"Returns a _pointer_ to C GEOS Geometry object from the given WKB."
if isinstance(wkb, six.memoryview):
wkb_s = bytes(wkb)
return wkb_reader_read(self.ptr, wkb_s, len(wkb_s))
elif isinstance(wkb, (bytes, six.string_types)):
return wkb_read... | [
"def",
"read",
"(",
"self",
",",
"wkb",
")",
":",
"if",
"isinstance",
"(",
"wkb",
",",
"six",
".",
"memoryview",
")",
":",
"wkb_s",
"=",
"bytes",
"(",
"wkb",
")",
"return",
"wkb_reader_read",
"(",
"self",
".",
"ptr",
",",
"wkb_s",
",",
"len",
"(",
... | [
147,
4
] | [
155,
27
] | python | en | ['en', 'en', 'en'] | True |
WKTWriter.write | (self, geom) | Returns the WKT representation of the given geometry. | Returns the WKT representation of the given geometry. | def write(self, geom):
"Returns the WKT representation of the given geometry."
return wkt_writer_write(self.ptr, geom.ptr) | [
"def",
"write",
"(",
"self",
",",
"geom",
")",
":",
"return",
"wkt_writer_write",
"(",
"self",
".",
"ptr",
",",
"geom",
".",
"ptr",
")"
] | [
175,
4
] | [
177,
51
] | python | en | ['en', 'en', 'en'] | True |
WKBWriter.write | (self, geom) | Returns the WKB representation of the given geometry. | Returns the WKB representation of the given geometry. | def write(self, geom):
"Returns the WKB representation of the given geometry."
from django.contrib.gis.geos import Polygon
geom = self._handle_empty_point(geom)
wkb = wkb_writer_write(self.ptr, geom.ptr, byref(c_size_t()))
if isinstance(geom, Polygon) and geom.empty:
... | [
"def",
"write",
"(",
"self",
",",
"geom",
")",
":",
"from",
"django",
".",
"contrib",
".",
"gis",
".",
"geos",
"import",
"Polygon",
"geom",
"=",
"self",
".",
"_handle_empty_point",
"(",
"geom",
")",
"wkb",
"=",
"wkb_writer_write",
"(",
"self",
".",
"pt... | [
233,
4
] | [
242,
34
] | python | en | ['en', 'en', 'en'] | True |
WKBWriter.write_hex | (self, geom) | Returns the HEXEWKB representation of the given geometry. | Returns the HEXEWKB representation of the given geometry. | def write_hex(self, geom):
"Returns the HEXEWKB representation of the given geometry."
from django.contrib.gis.geos.polygon import Polygon
geom = self._handle_empty_point(geom)
wkb = wkb_writer_write_hex(self.ptr, geom.ptr, byref(c_size_t()))
if isinstance(geom, Polygon) and geom... | [
"def",
"write_hex",
"(",
"self",
",",
"geom",
")",
":",
"from",
"django",
".",
"contrib",
".",
"gis",
".",
"geos",
".",
"polygon",
"import",
"Polygon",
"geom",
"=",
"self",
".",
"_handle_empty_point",
"(",
"geom",
")",
"wkb",
"=",
"wkb_writer_write_hex",
... | [
244,
4
] | [
251,
18
] | python | en | ['en', 'en', 'en'] | True |
JobTemplate.launch | (self, payload={}) | Launch the job_template using related->launch endpoint. | Launch the job_template using related->launch endpoint. | def launch(self, payload={}):
"""Launch the job_template using related->launch endpoint."""
# get related->launch
launch_pg = self.get_related('launch')
# launch the job_template
result = launch_pg.post(payload)
# return job
if result.json['type'] == 'job':
... | [
"def",
"launch",
"(",
"self",
",",
"payload",
"=",
"{",
"}",
")",
":",
"# get related->launch",
"launch_pg",
"=",
"self",
".",
"get_related",
"(",
"'launch'",
")",
"# launch the job_template",
"result",
"=",
"launch_pg",
".",
"post",
"(",
"payload",
")",
"# ... | [
17,
4
] | [
38,
78
] | python | en | ['en', 'en', 'en'] | True |
ByteaParserTest._import_cast | (self) | Use ctypes to access the C function.
Raise any sort of error: we just support this where ctypes works as
expected.
| Use ctypes to access the C function. | def _import_cast(self):
"""Use ctypes to access the C function.
Raise any sort of error: we just support this where ctypes works as
expected.
"""
import ctypes
lib = ctypes.pydll.LoadLibrary(psycopg2._psycopg.__file__)
cast = lib.typecast_BINARY_cast
cast... | [
"def",
"_import_cast",
"(",
"self",
")",
":",
"import",
"ctypes",
"lib",
"=",
"ctypes",
".",
"pydll",
".",
"LoadLibrary",
"(",
"psycopg2",
".",
"_psycopg",
".",
"__file__",
")",
"cast",
"=",
"lib",
".",
"typecast_BINARY_cast",
"cast",
".",
"argtypes",
"=",... | [
464,
4
] | [
475,
19
] | python | en | ['en', 'en', 'en'] | True |
ByteaParserTest.cast | (self, buffer) | Cast a buffer from the output format | Cast a buffer from the output format | def cast(self, buffer):
"""Cast a buffer from the output format"""
l = buffer and len(buffer) or 0
rv = self._cast(buffer, l, None)
if rv is None:
return None
if sys.version_info[0] < 3:
return str(rv)
else:
return rv.tobytes() | [
"def",
"cast",
"(",
"self",
",",
"buffer",
")",
":",
"l",
"=",
"buffer",
"and",
"len",
"(",
"buffer",
")",
"or",
"0",
"rv",
"=",
"self",
".",
"_cast",
"(",
"buffer",
",",
"l",
",",
"None",
")",
"if",
"rv",
"is",
"None",
":",
"return",
"None",
... | [
477,
4
] | [
488,
31
] | python | en | ['en', 'en', 'en'] | True |
add_paragraph_block | (state, contentstate) |
Utility function for adding an unstyled (paragraph) block to contentstate;
useful for element handlers that aren't paragraph elements themselves, but need
to insert paragraphs to ensure correctness
|
Utility function for adding an unstyled (paragraph) block to contentstate;
useful for element handlers that aren't paragraph elements themselves, but need
to insert paragraphs to ensure correctness
| def add_paragraph_block(state, contentstate):
"""
Utility function for adding an unstyled (paragraph) block to contentstate;
useful for element handlers that aren't paragraph elements themselves, but need
to insert paragraphs to ensure correctness
"""
block = Block('unstyled', depth=state.list_d... | [
"def",
"add_paragraph_block",
"(",
"state",
",",
"contentstate",
")",
":",
"block",
"=",
"Block",
"(",
"'unstyled'",
",",
"depth",
"=",
"state",
".",
"list_depth",
")",
"contentstate",
".",
"blocks",
".",
"append",
"(",
"block",
")",
"state",
".",
"current... | [
63,
0
] | [
73,
46
] | python | en | ['en', 'error', 'th'] | False |
InlineEntityElementHandler.get_attribute_data | (self, attrs) |
Given a dict of attributes found on the source element, return the data dict
to be associated with the resulting entity
|
Given a dict of attributes found on the source element, return the data dict
to be associated with the resulting entity
| def get_attribute_data(self, attrs):
"""
Given a dict of attributes found on the source element, return the data dict
to be associated with the resulting entity
"""
return {} | [
"def",
"get_attribute_data",
"(",
"self",
",",
"attrs",
")",
":",
"return",
"{",
"}"
] | [
188,
4
] | [
193,
17
] | python | en | ['en', 'error', 'th'] | False |
common_context | (user: UserProfile) | Common context used for things like outgoing emails that don't
have a request.
| Common context used for things like outgoing emails that don't
have a request.
| def common_context(user: UserProfile) -> Dict[str, Any]:
"""Common context used for things like outgoing emails that don't
have a request.
"""
return {
"realm_uri": user.realm.uri,
"realm_name": user.realm.name,
"root_domain_uri": settings.ROOT_DOMAIN_URI,
"external_uri_s... | [
"def",
"common_context",
"(",
"user",
":",
"UserProfile",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"{",
"\"realm_uri\"",
":",
"user",
".",
"realm",
".",
"uri",
",",
"\"realm_name\"",
":",
"user",
".",
"realm",
".",
"name",
",",
... | [
37,
0
] | [
48,
5
] | python | en | ['en', 'en', 'en'] | True |
zulip_default_context | (request: HttpRequest) | Context available to all Zulip Jinja2 templates that have a request
passed in. Designed to provide the long list of variables at the
bottom of this function in a wide range of situations: logged-in
or logged-out, subdomains or not, etc.
The main variable in the below is whether we know what realm the
... | Context available to all Zulip Jinja2 templates that have a request
passed in. Designed to provide the long list of variables at the
bottom of this function in a wide range of situations: logged-in
or logged-out, subdomains or not, etc. | def zulip_default_context(request: HttpRequest) -> Dict[str, Any]:
"""Context available to all Zulip Jinja2 templates that have a request
passed in. Designed to provide the long list of variables at the
bottom of this function in a wide range of situations: logged-in
or logged-out, subdomains or not, e... | [
"def",
"zulip_default_context",
"(",
"request",
":",
"HttpRequest",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"realm",
"=",
"get_realm_from_request",
"(",
"request",
")",
"if",
"realm",
"is",
"None",
":",
"realm_uri",
"=",
"settings",
".",
"ROOT... | [
80,
0
] | [
178,
18
] | python | en | ['en', 'en', 'en'] | True |
get_tag_uri | (url, date) |
Creates a TagURI.
See http://web.archive.org/web/20110514113830/http://diveintomark.org/archives/2004/05/28/howto-atom-id
|
Creates a TagURI. | def get_tag_uri(url, date):
"""
Creates a TagURI.
See http://web.archive.org/web/20110514113830/http://diveintomark.org/archives/2004/05/28/howto-atom-id
"""
bits = urlparse(url)
d = ''
if date is not None:
d = ',%s' % datetime_safe.new_datetime(date).strftime('%Y-%m-%d')
return... | [
"def",
"get_tag_uri",
"(",
"url",
",",
"date",
")",
":",
"bits",
"=",
"urlparse",
"(",
"url",
")",
"d",
"=",
"''",
"if",
"date",
"is",
"not",
"None",
":",
"d",
"=",
"',%s'",
"%",
"datetime_safe",
".",
"new_datetime",
"(",
"date",
")",
".",
"strftim... | [
76,
0
] | [
86,
74
] | python | en | ['en', 'error', 'th'] | False |
SyndicationFeed.add_item | (self, title, link, description, author_email=None,
author_name=None, author_link=None, pubdate=None, comments=None,
unique_id=None, unique_id_is_permalink=None, enclosure=None,
categories=(), item_copyright=None, ttl=None, updateddate=None,
enclosures... |
Adds an item to the feed. All args are expected to be Python Unicode
objects except pubdate and updateddate, which are datetime.datetime
objects, and enclosures, which is an iterable of instances of the
Enclosure class.
|
Adds an item to the feed. All args are expected to be Python Unicode
objects except pubdate and updateddate, which are datetime.datetime
objects, and enclosures, which is an iterable of instances of the
Enclosure class.
| def add_item(self, title, link, description, author_email=None,
author_name=None, author_link=None, pubdate=None, comments=None,
unique_id=None, unique_id_is_permalink=None, enclosure=None,
categories=(), item_copyright=None, ttl=None, updateddate=None,
... | [
"def",
"add_item",
"(",
"self",
",",
"title",
",",
"link",
",",
"description",
",",
"author_email",
"=",
"None",
",",
"author_name",
"=",
"None",
",",
"author_link",
"=",
"None",
",",
"pubdate",
"=",
"None",
",",
"comments",
"=",
"None",
",",
"unique_id"... | [
119,
4
] | [
165,
31
] | python | en | ['en', 'error', 'th'] | False |
SyndicationFeed.root_attributes | (self) |
Return extra attributes to place on the root (i.e. feed/channel) element.
Called from write().
|
Return extra attributes to place on the root (i.e. feed/channel) element.
Called from write().
| def root_attributes(self):
"""
Return extra attributes to place on the root (i.e. feed/channel) element.
Called from write().
"""
return {} | [
"def",
"root_attributes",
"(",
"self",
")",
":",
"return",
"{",
"}"
] | [
170,
4
] | [
175,
17
] | python | en | ['en', 'error', 'th'] | False |
SyndicationFeed.add_root_elements | (self, handler) |
Add elements in the root (i.e. feed/channel) element. Called
from write().
|
Add elements in the root (i.e. feed/channel) element. Called
from write().
| def add_root_elements(self, handler):
"""
Add elements in the root (i.e. feed/channel) element. Called
from write().
"""
pass | [
"def",
"add_root_elements",
"(",
"self",
",",
"handler",
")",
":",
"pass"
] | [
177,
4
] | [
182,
12
] | python | en | ['en', 'error', 'th'] | False |
SyndicationFeed.item_attributes | (self, item) |
Return extra attributes to place on each item (i.e. item/entry) element.
|
Return extra attributes to place on each item (i.e. item/entry) element.
| def item_attributes(self, item):
"""
Return extra attributes to place on each item (i.e. item/entry) element.
"""
return {} | [
"def",
"item_attributes",
"(",
"self",
",",
"item",
")",
":",
"return",
"{",
"}"
] | [
184,
4
] | [
188,
17
] | python | en | ['en', 'error', 'th'] | False |
SyndicationFeed.add_item_elements | (self, handler, item) |
Add elements on each item (i.e. item/entry) element.
|
Add elements on each item (i.e. item/entry) element.
| def add_item_elements(self, handler, item):
"""
Add elements on each item (i.e. item/entry) element.
"""
pass | [
"def",
"add_item_elements",
"(",
"self",
",",
"handler",
",",
"item",
")",
":",
"pass"
] | [
190,
4
] | [
194,
12
] | python | en | ['en', 'error', 'th'] | False |
SyndicationFeed.write | (self, outfile, encoding) |
Outputs the feed in the given encoding to outfile, which is a file-like
object. Subclasses should override this.
|
Outputs the feed in the given encoding to outfile, which is a file-like
object. Subclasses should override this.
| def write(self, outfile, encoding):
"""
Outputs the feed in the given encoding to outfile, which is a file-like
object. Subclasses should override this.
"""
raise NotImplementedError('subclasses of SyndicationFeed must provide a write() method') | [
"def",
"write",
"(",
"self",
",",
"outfile",
",",
"encoding",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of SyndicationFeed must provide a write() method'",
")"
] | [
196,
4
] | [
201,
96
] | python | en | ['en', 'error', 'th'] | False |
SyndicationFeed.writeString | (self, encoding) |
Returns the feed in the given encoding as a string.
|
Returns the feed in the given encoding as a string.
| def writeString(self, encoding):
"""
Returns the feed in the given encoding as a string.
"""
s = StringIO()
self.write(s, encoding)
return s.getvalue() | [
"def",
"writeString",
"(",
"self",
",",
"encoding",
")",
":",
"s",
"=",
"StringIO",
"(",
")",
"self",
".",
"write",
"(",
"s",
",",
"encoding",
")",
"return",
"s",
".",
"getvalue",
"(",
")"
] | [
203,
4
] | [
209,
27
] | python | en | ['en', 'error', 'th'] | False |
SyndicationFeed.latest_post_date | (self) |
Returns the latest item's pubdate or updateddate. If no items
have either of these attributes this returns the current UTC date/time.
|
Returns the latest item's pubdate or updateddate. If no items
have either of these attributes this returns the current UTC date/time.
| def latest_post_date(self):
"""
Returns the latest item's pubdate or updateddate. If no items
have either of these attributes this returns the current UTC date/time.
"""
latest_date = None
date_keys = ('updateddate', 'pubdate')
for item in self.items:
... | [
"def",
"latest_post_date",
"(",
"self",
")",
":",
"latest_date",
"=",
"None",
"date_keys",
"=",
"(",
"'updateddate'",
",",
"'pubdate'",
")",
"for",
"item",
"in",
"self",
".",
"items",
":",
"for",
"date_key",
"in",
"date_keys",
":",
"item_date",
"=",
"item"... | [
211,
4
] | [
227,
76
] | python | en | ['en', 'error', 'th'] | False |
Enclosure.__init__ | (self, url, length, mime_type) | All args are expected to be Python Unicode objects | All args are expected to be Python Unicode objects | def __init__(self, url, length, mime_type):
"All args are expected to be Python Unicode objects"
self.length, self.mime_type = length, mime_type
self.url = iri_to_uri(url) | [
"def",
"__init__",
"(",
"self",
",",
"url",
",",
"length",
",",
"mime_type",
")",
":",
"self",
".",
"length",
",",
"self",
".",
"mime_type",
"=",
"length",
",",
"mime_type",
"self",
".",
"url",
"=",
"iri_to_uri",
"(",
"url",
")"
] | [
232,
4
] | [
235,
34
] | python | en | ['en', 'en', 'en'] | True |
partition_name_dt | (part_name) |
part_name examples:
main_jobevent_20210318_09
main_projectupdateevent_20210318_11
main_inventoryupdateevent_20210318_03
|
part_name examples:
main_jobevent_20210318_09
main_projectupdateevent_20210318_11
main_inventoryupdateevent_20210318_03
| def partition_name_dt(part_name):
"""
part_name examples:
main_jobevent_20210318_09
main_projectupdateevent_20210318_11
main_inventoryupdateevent_20210318_03
"""
if '_unpartitioned' in part_name:
return None
p = re.compile('([a-z]+)_([a-z]+)_([0-9]+)_([0-9][0-9])')
... | [
"def",
"partition_name_dt",
"(",
"part_name",
")",
":",
"if",
"'_unpartitioned'",
"in",
"part_name",
":",
"return",
"None",
"p",
"=",
"re",
".",
"compile",
"(",
"'([a-z]+)_([a-z]+)_([0-9]+)_([0-9][0-9])'",
")",
"m",
"=",
"p",
".",
"match",
"(",
"part_name",
")... | [
34,
0
] | [
49,
13
] | python | en | ['en', 'error', 'th'] | False |
RequirementSet.__init__ | (self, check_supported_wheels=True) | Create a RequirementSet.
| Create a RequirementSet.
| def __init__(self, check_supported_wheels=True):
# type: (bool) -> None
"""Create a RequirementSet.
"""
self.requirements = OrderedDict() # type: Dict[str, InstallRequirement] # noqa: E501
self.check_supported_wheels = check_supported_wheels
self.unnamed_requirements ... | [
"def",
"__init__",
"(",
"self",
",",
"check_supported_wheels",
"=",
"True",
")",
":",
"# type: (bool) -> None",
"self",
".",
"requirements",
"=",
"OrderedDict",
"(",
")",
"# type: Dict[str, InstallRequirement] # noqa: E501",
"self",
".",
"check_supported_wheels",
"=",
... | [
23,
4
] | [
31,
38
] | python | en | ['en', 'en', 'en'] | True |
RequirementSet.add_requirement | (
self,
install_req, # type: InstallRequirement
parent_req_name=None, # type: Optional[str]
extras_requested=None # type: Optional[Iterable[str]]
) | Add install_req as a requirement to install.
:param parent_req_name: The name of the requirement that needed this
added. The name is used because when multiple unnamed requirements
resolve to the same name, we could otherwise end up with dependency
links that point outside t... | Add install_req as a requirement to install. | def add_requirement(
self,
install_req, # type: InstallRequirement
parent_req_name=None, # type: Optional[str]
extras_requested=None # type: Optional[Iterable[str]]
):
# type: (...) -> Tuple[List[InstallRequirement], Optional[InstallRequirement]] # noqa: E501
"""A... | [
"def",
"add_requirement",
"(",
"self",
",",
"install_req",
",",
"# type: InstallRequirement",
"parent_req_name",
"=",
"None",
",",
"# type: Optional[str]",
"extras_requested",
"=",
"None",
"# type: Optional[Iterable[str]]",
")",
":",
"# type: (...) -> Tuple[List[InstallRequirem... | [
67,
4
] | [
180,
43
] | python | en | ['en', 'en', 'en'] | True |
SSLTransport._validate_ssl_context_for_tls_in_tls | (ssl_context) |
Raises a ProxySchemeUnsupported if the provided ssl_context can't be used
for TLS in TLS.
The only requirement is that the ssl_context provides the 'wrap_bio'
methods.
|
Raises a ProxySchemeUnsupported if the provided ssl_context can't be used
for TLS in TLS. | def _validate_ssl_context_for_tls_in_tls(ssl_context):
"""
Raises a ProxySchemeUnsupported if the provided ssl_context can't be used
for TLS in TLS.
The only requirement is that the ssl_context provides the 'wrap_bio'
methods.
"""
if not hasattr(ssl_context, "wr... | [
"def",
"_validate_ssl_context_for_tls_in_tls",
"(",
"ssl_context",
")",
":",
"if",
"not",
"hasattr",
"(",
"ssl_context",
",",
"\"wrap_bio\"",
")",
":",
"if",
"six",
".",
"PY2",
":",
"raise",
"ProxySchemeUnsupported",
"(",
"\"TLS in TLS requires SSLContext.wrap_bio() whi... | [
22,
4
] | [
41,
17
] | python | en | ['en', 'error', 'th'] | False |
SSLTransport.__init__ | (
self, socket, ssl_context, server_hostname=None, suppress_ragged_eofs=True
) |
Create an SSLTransport around socket using the provided ssl_context.
|
Create an SSLTransport around socket using the provided ssl_context.
| def __init__(
self, socket, ssl_context, server_hostname=None, suppress_ragged_eofs=True
):
"""
Create an SSLTransport around socket using the provided ssl_context.
"""
self.incoming = ssl.MemoryBIO()
self.outgoing = ssl.MemoryBIO()
self.suppress_ragged_eofs ... | [
"def",
"__init__",
"(",
"self",
",",
"socket",
",",
"ssl_context",
",",
"server_hostname",
"=",
"None",
",",
"suppress_ragged_eofs",
"=",
"True",
")",
":",
"self",
".",
"incoming",
"=",
"ssl",
".",
"MemoryBIO",
"(",
")",
"self",
".",
"outgoing",
"=",
"ss... | [
43,
4
] | [
60,
51
] | python | en | ['en', 'error', 'th'] | False |
SSLTransport.makefile | (
self, mode="r", buffering=None, encoding=None, errors=None, newline=None
) |
Python's httpclient uses makefile and buffered io when reading HTTP
messages and we need to support it.
This is unfortunately a copy and paste of socket.py makefile with small
changes to point to the socket directly.
|
Python's httpclient uses makefile and buffered io when reading HTTP
messages and we need to support it. | def makefile(
self, mode="r", buffering=None, encoding=None, errors=None, newline=None
):
"""
Python's httpclient uses makefile and buffered io when reading HTTP
messages and we need to support it.
This is unfortunately a copy and paste of socket.py makefile with small
... | [
"def",
"makefile",
"(",
"self",
",",
"mode",
"=",
"\"r\"",
",",
"buffering",
"=",
"None",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"None",
",",
"newline",
"=",
"None",
")",
":",
"if",
"not",
"set",
"(",
"mode",
")",
"<=",
"{",
"\"r\"",
"... | [
104,
4
] | [
147,
19
] | python | en | ['en', 'error', 'th'] | False |
SSLTransport._ssl_io_loop | (self, func, *args) | Performs an I/O loop between incoming/outgoing and the socket. | Performs an I/O loop between incoming/outgoing and the socket. | def _ssl_io_loop(self, func, *args):
""" Performs an I/O loop between incoming/outgoing and the socket."""
should_loop = True
ret = None
while should_loop:
errno = None
try:
ret = func(*args)
except ssl.SSLError as e:
i... | [
"def",
"_ssl_io_loop",
"(",
"self",
",",
"func",
",",
"*",
"args",
")",
":",
"should_loop",
"=",
"True",
"ret",
"=",
"None",
"while",
"should_loop",
":",
"errno",
"=",
"None",
"try",
":",
"ret",
"=",
"func",
"(",
"*",
"args",
")",
"except",
"ssl",
... | [
194,
4
] | [
220,
18
] | python | en | ['en', 'en', 'en'] | True |
was_modified_since | (header=None, mtime=0, size=0) |
Was something modified since the user last downloaded it?
header
This is the value of the If-Modified-Since header. If this is None,
I'll just return True.
mtime
This is the modification time of the item we're talking about.
size
This is the size of the item we're talking ab... |
Was something modified since the user last downloaded it? | def was_modified_since(header=None, mtime=0, size=0):
"""
Was something modified since the user last downloaded it?
header
This is the value of the If-Modified-Since header. If this is None,
I'll just return True.
mtime
This is the modification time of the item we're talking about.
... | [
"def",
"was_modified_since",
"(",
"header",
"=",
"None",
",",
"mtime",
"=",
"0",
",",
"size",
"=",
"0",
")",
":",
"try",
":",
"if",
"header",
"is",
"None",
":",
"raise",
"ValueError",
"matches",
"=",
"re",
".",
"match",
"(",
"r\"^([^;]+)(; length=([0-9]+... | [
28,
0
] | [
58,
16
] | python | en | ['en', 'error', 'th'] | False |
Manifest.__init__ | (self, base=None) |
Initialise an instance.
:param base: The base directory to explore under.
|
Initialise an instance. | def __init__(self, base=None):
"""
Initialise an instance.
:param base: The base directory to explore under.
"""
self.base = os.path.abspath(os.path.normpath(base or os.getcwd()))
self.prefix = self.base + os.sep
self.allfiles = None
self.files = set() | [
"def",
"__init__",
"(",
"self",
",",
"base",
"=",
"None",
")",
":",
"self",
".",
"base",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"normpath",
"(",
"base",
"or",
"os",
".",
"getcwd",
"(",
")",
")",
")",
"self",
".",
... | [
41,
4
] | [
50,
26
] | python | en | ['en', 'error', 'th'] | False |
Manifest.findall | (self) | Find all files under the base and set ``allfiles`` to the absolute
pathnames of files found.
| Find all files under the base and set ``allfiles`` to the absolute
pathnames of files found.
| def findall(self):
"""Find all files under the base and set ``allfiles`` to the absolute
pathnames of files found.
"""
from stat import S_ISREG, S_ISDIR, S_ISLNK
self.allfiles = allfiles = []
root = self.base
stack = [root]
pop = stack.pop
push = ... | [
"def",
"findall",
"(",
"self",
")",
":",
"from",
"stat",
"import",
"S_ISREG",
",",
"S_ISDIR",
",",
"S_ISLNK",
"self",
".",
"allfiles",
"=",
"allfiles",
"=",
"[",
"]",
"root",
"=",
"self",
".",
"base",
"stack",
"=",
"[",
"root",
"]",
"pop",
"=",
"st... | [
56,
4
] | [
81,
34
] | python | en | ['en', 'en', 'en'] | True |
Manifest.add | (self, item) |
Add a file to the manifest.
:param item: The pathname to add. This can be relative to the base.
|
Add a file to the manifest. | def add(self, item):
"""
Add a file to the manifest.
:param item: The pathname to add. This can be relative to the base.
"""
if not item.startswith(self.prefix):
item = os.path.join(self.base, item)
self.files.add(os.path.normpath(item)) | [
"def",
"add",
"(",
"self",
",",
"item",
")",
":",
"if",
"not",
"item",
".",
"startswith",
"(",
"self",
".",
"prefix",
")",
":",
"item",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"base",
",",
"item",
")",
"self",
".",
"files",
".",
... | [
83,
4
] | [
91,
46
] | python | en | ['en', 'error', 'th'] | False |
Manifest.add_many | (self, items) |
Add a list of files to the manifest.
:param items: The pathnames to add. These can be relative to the base.
|
Add a list of files to the manifest. | def add_many(self, items):
"""
Add a list of files to the manifest.
:param items: The pathnames to add. These can be relative to the base.
"""
for item in items:
self.add(item) | [
"def",
"add_many",
"(",
"self",
",",
"items",
")",
":",
"for",
"item",
"in",
"items",
":",
"self",
".",
"add",
"(",
"item",
")"
] | [
93,
4
] | [
100,
26
] | python | en | ['en', 'error', 'th'] | False |
Manifest.sorted | (self, wantdirs=False) |
Return sorted files in directory order
|
Return sorted files in directory order
| def sorted(self, wantdirs=False):
"""
Return sorted files in directory order
"""
def add_dir(dirs, d):
dirs.add(d)
logger.debug('add_dir added %s', d)
if d != self.base:
parent, _ = os.path.split(d)
assert parent not in... | [
"def",
"sorted",
"(",
"self",
",",
"wantdirs",
"=",
"False",
")",
":",
"def",
"add_dir",
"(",
"dirs",
",",
"d",
")",
":",
"dirs",
".",
"add",
"(",
"d",
")",
"logger",
".",
"debug",
"(",
"'add_dir added %s'",
",",
"d",
")",
"if",
"d",
"!=",
"self"... | [
102,
4
] | [
122,
63
] | python | en | ['en', 'error', 'th'] | False |
Manifest.clear | (self) | Clear all collected files. | Clear all collected files. | def clear(self):
"""Clear all collected files."""
self.files = set()
self.allfiles = [] | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"files",
"=",
"set",
"(",
")",
"self",
".",
"allfiles",
"=",
"[",
"]"
] | [
124,
4
] | [
127,
26
] | python | en | ['en', 'en', 'en'] | True |
Manifest.process_directive | (self, directive) |
Process a directive which either adds some files from ``allfiles`` to
``files``, or removes some files from ``files``.
:param directive: The directive to process. This should be in a format
compatible with distutils ``MANIFEST.in`` files:
http://docs.... |
Process a directive which either adds some files from ``allfiles`` to
``files``, or removes some files from ``files``. | def process_directive(self, directive):
"""
Process a directive which either adds some files from ``allfiles`` to
``files``, or removes some files from ``files``.
:param directive: The directive to process. This should be in a format
compatible with distutils ``MANI... | [
"def",
"process_directive",
"(",
"self",
",",
"directive",
")",
":",
"# Parse the line: split it up, make sure the right number of words",
"# is there, and return the relevant words. 'action' is always",
"# defined: it's the first word of the line. Which of the other",
"# three are defined d... | [
129,
4
] | [
202,
45
] | python | en | ['en', 'error', 'th'] | False |
Manifest._parse_directive | (self, directive) |
Validate a directive.
:param directive: The directive to validate.
:return: A tuple of action, patterns, thedir, dir_patterns
|
Validate a directive.
:param directive: The directive to validate.
:return: A tuple of action, patterns, thedir, dir_patterns
| def _parse_directive(self, directive):
"""
Validate a directive.
:param directive: The directive to validate.
:return: A tuple of action, patterns, thedir, dir_patterns
"""
words = directive.split()
if len(words) == 1 and words[0] not in ('include', 'exclude',
... | [
"def",
"_parse_directive",
"(",
"self",
",",
"directive",
")",
":",
"words",
"=",
"directive",
".",
"split",
"(",
")",
"if",
"len",
"(",
"words",
")",
"==",
"1",
"and",
"words",
"[",
"0",
"]",
"not",
"in",
"(",
"'include'",
",",
"'exclude'",
",",
"... | [
208,
4
] | [
253,
52
] | python | en | ['en', 'error', 'th'] | False |
Manifest._include_pattern | (self, pattern, anchor=True, prefix=None,
is_regex=False) | Select strings (presumably filenames) from 'self.files' that
match 'pattern', a Unix-style wildcard (glob) pattern.
Patterns are not quite the same as implemented by the 'fnmatch'
module: '*' and '?' match non-special characters, where "special"
is platform-dependent: slash on Unix; co... | Select strings (presumably filenames) from 'self.files' that
match 'pattern', a Unix-style wildcard (glob) pattern. | def _include_pattern(self, pattern, anchor=True, prefix=None,
is_regex=False):
"""Select strings (presumably filenames) from 'self.files' that
match 'pattern', a Unix-style wildcard (glob) pattern.
Patterns are not quite the same as implemented by the 'fnmatch'
... | [
"def",
"_include_pattern",
"(",
"self",
",",
"pattern",
",",
"anchor",
"=",
"True",
",",
"prefix",
"=",
"None",
",",
"is_regex",
"=",
"False",
")",
":",
"# XXX docstring lying about what the special chars are?",
"found",
"=",
"False",
"pattern_re",
"=",
"self",
... | [
255,
4
] | [
294,
20
] | python | en | ['en', 'en', 'en'] | True |
Manifest._exclude_pattern | (self, pattern, anchor=True, prefix=None,
is_regex=False) | Remove strings (presumably filenames) from 'files' that match
'pattern'.
Other parameters are the same as for 'include_pattern()', above.
The list 'self.files' is modified in place. Return True if files are
found.
This API is public to allow e.g. exclusion of SCM subdirs, e.g. ... | Remove strings (presumably filenames) from 'files' that match
'pattern'. | def _exclude_pattern(self, pattern, anchor=True, prefix=None,
is_regex=False):
"""Remove strings (presumably filenames) from 'files' that match
'pattern'.
Other parameters are the same as for 'include_pattern()', above.
The list 'self.files' is modified in place... | [
"def",
"_exclude_pattern",
"(",
"self",
",",
"pattern",
",",
"anchor",
"=",
"True",
",",
"prefix",
"=",
"None",
",",
"is_regex",
"=",
"False",
")",
":",
"found",
"=",
"False",
"pattern_re",
"=",
"self",
".",
"_translate_pattern",
"(",
"pattern",
",",
"an... | [
296,
4
] | [
314,
20
] | python | en | ['en', 'en', 'en'] | True |
Manifest._translate_pattern | (self, pattern, anchor=True, prefix=None,
is_regex=False) | Translate a shell-like wildcard pattern to a compiled regular
expression.
Return the compiled regex. If 'is_regex' true,
then 'pattern' is directly compiled to a regex (if it's a string)
or just returned as-is (assumes it's a regex object).
| Translate a shell-like wildcard pattern to a compiled regular
expression. | def _translate_pattern(self, pattern, anchor=True, prefix=None,
is_regex=False):
"""Translate a shell-like wildcard pattern to a compiled regular
expression.
Return the compiled regex. If 'is_regex' true,
then 'pattern' is directly compiled to a regex (if it'... | [
"def",
"_translate_pattern",
"(",
"self",
",",
"pattern",
",",
"anchor",
"=",
"True",
",",
"prefix",
"=",
"None",
",",
"is_regex",
"=",
"False",
")",
":",
"if",
"is_regex",
":",
"if",
"isinstance",
"(",
"pattern",
",",
"str",
")",
":",
"return",
"re",
... | [
316,
4
] | [
369,
37
] | python | en | ['en', 'en', 'en'] | True |
Manifest._glob_to_re | (self, pattern) | Translate a shell-like glob pattern to a regular expression.
Return a string containing the regex. Differs from
'fnmatch.translate()' in that '*' does not match "special characters"
(which are platform-specific).
| Translate a shell-like glob pattern to a regular expression. | def _glob_to_re(self, pattern):
"""Translate a shell-like glob pattern to a regular expression.
Return a string containing the regex. Differs from
'fnmatch.translate()' in that '*' does not match "special characters"
(which are platform-specific).
"""
pattern_re = fnmat... | [
"def",
"_glob_to_re",
"(",
"self",
",",
"pattern",
")",
":",
"pattern_re",
"=",
"fnmatch",
".",
"translate",
"(",
"pattern",
")",
"# '?' and '*' in the glob pattern become '.' and '.*' in the RE, which",
"# IMHO is wrong -- '?' and '*' aren't supposed to match slash in Unix,",
"#... | [
371,
4
] | [
392,
25
] | python | en | ['en', 'ny', 'en'] | True |
rand | (obj, batch_size, seed=None) | Random selection of points.
Parameters
----------
obj : edbo.objective
Objective data container.
batch_size : int
Number of points to be selected.
seed : None, int
Random seed.
Returns
----------
pandas.DataFrame
Selected domain poin... | Random selection of points.
Parameters
----------
obj : edbo.objective
Objective data container.
batch_size : int
Number of points to be selected.
seed : None, int
Random seed.
Returns
----------
pandas.DataFrame
Selected domain poin... | def rand(obj, batch_size, seed=None):
"""Random selection of points.
Parameters
----------
obj : edbo.objective
Objective data container.
batch_size : int
Number of points to be selected.
seed : None, int
Random seed.
Returns
----------
p... | [
"def",
"rand",
"(",
"obj",
",",
"batch_size",
",",
"seed",
"=",
"None",
")",
":",
"batch",
"=",
"obj",
".",
"domain",
".",
"sample",
"(",
"n",
"=",
"batch_size",
",",
"random_state",
"=",
"seed",
")",
"return",
"batch"
] | [
140,
0
] | [
162,
16
] | python | en | ['en', 'en', 'en'] | True |
external_data | (obj) | External data reader.
Parameters
----------
obj : edbo.objective
Objective data container.
Returns
----------
pandas.DataFrame
Selected domain points.
| External data reader.
Parameters
----------
obj : edbo.objective
Objective data container.
Returns
----------
pandas.DataFrame
Selected domain points.
| def external_data(obj):
"""External data reader.
Parameters
----------
obj : edbo.objective
Objective data container.
Returns
----------
pandas.DataFrame
Selected domain points.
"""
print('\nUsing external results for initializaiton..... | [
"def",
"external_data",
"(",
"obj",
")",
":",
"print",
"(",
"'\\nUsing external results for initializaiton...\\n'",
")",
"return",
"obj",
".",
"results",
".",
"drop",
"(",
"obj",
".",
"target",
",",
"axis",
"=",
"1",
")"
] | [
166,
0
] | [
182,
47
] | python | en | ['en', 'lb', 'en'] | True |
PAM | (obj, batch_size, distance='gower', visualize=True,
seed=None, export_path=None) | Partitioning around medoids algorithm.
PAM function returns medoids of learned clusters.
PAM implimentated using pyclustering: https://pypi.org/project/pyclustering/
Parameters
----------
obj : edbo.objective
Objective data container.
batch_size : int
... | Partitioning around medoids algorithm.
PAM function returns medoids of learned clusters.
PAM implimentated using pyclustering: https://pypi.org/project/pyclustering/
Parameters
----------
obj : edbo.objective
Objective data container.
batch_size : int
... | def PAM(obj, batch_size, distance='gower', visualize=True,
seed=None, export_path=None):
"""Partitioning around medoids algorithm.
PAM function returns medoids of learned clusters.
PAM implimentated using pyclustering: https://pypi.org/project/pyclustering/
Parameters... | [
"def",
"PAM",
"(",
"obj",
",",
"batch_size",
",",
"distance",
"=",
"'gower'",
",",
"visualize",
"=",
"True",
",",
"seed",
"=",
"None",
",",
"export_path",
"=",
"None",
")",
":",
"# print('\\nInitializing using PAM...\\n')",
"# Set random initial medoids",
"if",
... | [
185,
0
] | [
267,
18
] | python | en | ['en', 'de', 'en'] | True |
k_means | (obj, batch_size, visualize=True, seed=None, export_path=None,
n_init=1, return_clusters=False, return_centroids=False) | K-Means algorithm.
k_means function returns domain points closest to the means of learned clusters.
k-means clustering implemented using scikit-learn: https://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html
Parameters
----------
obj : edbo.objective
... | K-Means algorithm.
k_means function returns domain points closest to the means of learned clusters.
k-means clustering implemented using scikit-learn: https://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html
Parameters
----------
obj : edbo.objective
... | def k_means(obj, batch_size, visualize=True, seed=None, export_path=None,
n_init=1, return_clusters=False, return_centroids=False):
"""K-Means algorithm.
k_means function returns domain points closest to the means of learned clusters.
k-means clustering implemented using scikit-learn:... | [
"def",
"k_means",
"(",
"obj",
",",
"batch_size",
",",
"visualize",
"=",
"True",
",",
"seed",
"=",
"None",
",",
"export_path",
"=",
"None",
",",
"n_init",
"=",
"1",
",",
"return_clusters",
"=",
"False",
",",
"return_centroids",
"=",
"False",
")",
":",
"... | [
269,
0
] | [
345,
18
] | python | en | ['en', 'fr', 'en'] | False |
Init.__init__ | (self, method, batch_size, distance='gower') |
Parameters
----------
method : str
Sampling method. Opions include: 'random', 'PAM', 'k-means', and
'external'.
batch_size : int
Number of points to select.
distance_metric : str
Distance metric to be used with PAM. Opti... |
Parameters
----------
method : str
Sampling method. Opions include: 'random', 'PAM', 'k-means', and
'external'.
batch_size : int
Number of points to select.
distance_metric : str
Distance metric to be used with PAM. Opti... | def __init__(self, method, batch_size, distance='gower'):
"""
Parameters
----------
method : str
Sampling method. Opions include: 'random', 'PAM', 'k-means', and
'external'.
batch_size : int
Number of points to select.
distanc... | [
"def",
"__init__",
"(",
"self",
",",
"method",
",",
"batch_size",
",",
"distance",
"=",
"'gower'",
")",
":",
"self",
".",
"method",
"=",
"method",
"self",
".",
"batch_size",
"=",
"batch_size",
"self",
".",
"distance_metric",
"=",
"distance"
] | [
23,
4
] | [
40,
39
] | python | en | ['en', 'ja', 'th'] | False |
Init.run | (self, obj, seed=None, export_path=None, visualize=False) | Run initialization algorithm on user defined domain.
Parameters
----------
obj : edbo.objective
Objective data container.
seed : None, int
Random seed for random selection and initial choice of medoids
or centroids.
export_path : None... | Run initialization algorithm on user defined domain.
Parameters
----------
obj : edbo.objective
Objective data container.
seed : None, int
Random seed for random selection and initial choice of medoids
or centroids.
export_path : None... | def run(self, obj, seed=None, export_path=None, visualize=False):
"""Run initialization algorithm on user defined domain.
Parameters
----------
obj : edbo.objective
Objective data container.
seed : None, int
Random seed for random selection and in... | [
"def",
"run",
"(",
"self",
",",
"obj",
",",
"seed",
"=",
"None",
",",
"export_path",
"=",
"None",
",",
"visualize",
"=",
"False",
")",
":",
"if",
"'rand'",
"in",
"self",
".",
"method",
".",
"lower",
"(",
")",
":",
"self",
".",
"experiments",
"=",
... | [
42,
4
] | [
88,
31
] | python | en | ['es', 'en', 'en'] | True |
Init.plot_choices | (self, obj, export_path=None) | Plot low dimensional embeddingd of initialization points in domain.
Parameters
----------
obj : edbo.objective
Objective data container.
export_path : None, str
Path to export visualization if applicable.
Returns
----------
... | Plot low dimensional embeddingd of initialization points in domain.
Parameters
----------
obj : edbo.objective
Objective data container.
export_path : None, str
Path to export visualization if applicable.
Returns
----------
... | def plot_choices(self, obj, export_path=None):
"""Plot low dimensional embeddingd of initialization points in domain.
Parameters
----------
obj : edbo.objective
Objective data container.
export_path : None, str
Path to export visualization if appl... | [
"def",
"plot_choices",
"(",
"self",
",",
"obj",
",",
"export_path",
"=",
"None",
")",
":",
"X",
"=",
"pd",
".",
"concat",
"(",
"[",
"obj",
".",
"domain",
".",
"drop",
"(",
"self",
".",
"experiments",
".",
"index",
".",
"values",
",",
"axis",
"=",
... | [
90,
4
] | [
136,
52
] | python | en | ['en', 'en', 'en'] | True |
load_dumped_estimators | (gof_result, task_id=None) |
Loads the estimators that have been dumped during the configuration runs into a GoodnessOfFitResults object at the corresponding single
result entry. Assumes an ml-logger instance has been set-up and configured correctly.
Args:
gof_result: a GoodnessOfFitResults object containing single result entries.... |
Loads the estimators that have been dumped during the configuration runs into a GoodnessOfFitResults object at the corresponding single
result entry. Assumes an ml-logger instance has been set-up and configured correctly.
Args:
gof_result: a GoodnessOfFitResults object containing single result entries.... | def load_dumped_estimators(gof_result, task_id=None):
"""
Loads the estimators that have been dumped during the configuration runs into a GoodnessOfFitResults object at the corresponding single
result entry. Assumes an ml-logger instance has been set-up and configured correctly.
Args:
gof_result: a Go... | [
"def",
"load_dumped_estimators",
"(",
"gof_result",
",",
"task_id",
"=",
"None",
")",
":",
"assert",
"logger",
"assert",
"task_id",
"is",
"None",
"or",
"isinstance",
"(",
"task_id",
",",
"list",
")",
"or",
"np",
".",
"isscalar",
"(",
"task_id",
")",
"if",
... | [
404,
0
] | [
436,
19
] | python | en | ['en', 'error', 'th'] | False |
ConfigRunner.__init__ | (self, exp_prefix, est_params, sim_params, observations, keys_of_interest, n_mc_samples=10 ** 7,
n_x_cond=5, n_seeds=5, use_gpu=True, tail_measures=True) | ---------- Either load or generate the configs ---------- | ---------- Either load or generate the configs ---------- | def __init__(self, exp_prefix, est_params, sim_params, observations, keys_of_interest, n_mc_samples=10 ** 7,
n_x_cond=5, n_seeds=5, use_gpu=True, tail_measures=True):
assert est_params and exp_prefix and sim_params and keys_of_interest
assert observations.all()
# every simulator configurati... | [
"def",
"__init__",
"(",
"self",
",",
"exp_prefix",
",",
"est_params",
",",
"sim_params",
",",
"observations",
",",
"keys_of_interest",
",",
"n_mc_samples",
"=",
"10",
"**",
"7",
",",
"n_x_cond",
"=",
"5",
",",
"n_seeds",
"=",
"5",
",",
"use_gpu",
"=",
"T... | [
65,
2
] | [
104,
75
] | python | en | ['en', 'en', 'en'] | True |
ConfigRunner._generate_configuration_variants | (self, est_params, sim_params) |
Creates all possible combinations from the (configured) estimators and simulators.
Requires configured estimators and simulators in the constructor:
Args:
est_params: estimator parameters as dict with 2 levels
sim_params: density simulator parameters as dict with 2 levels
Returns:
... |
Creates all possible combinations from the (configured) estimators and simulators.
Requires configured estimators and simulators in the constructor: | def _generate_configuration_variants(self, est_params, sim_params):
"""
Creates all possible combinations from the (configured) estimators and simulators.
Requires configured estimators and simulators in the constructor:
Args:
est_params: estimator parameters as dict with 2 levels
sim_p... | [
"def",
"_generate_configuration_variants",
"(",
"self",
",",
"est_params",
",",
"sim_params",
")",
":",
"self",
".",
"est_configs",
"=",
"_create_configurations",
"(",
"est_params",
")",
"self",
".",
"sim_configs",
"=",
"_create_configurations",
"(",
"sim_params",
"... | [
107,
2
] | [
161,
18
] | python | en | ['en', 'error', 'th'] | False |
ConfigRunner.run_configurations | (self, estimator_filter=None,
limit=None, dump_models=False, multiprocessing=True, n_workers=None) |
Runs the given configurations, i.e.
1) fits the estimator to the simulation and
2) executes goodness-of-fit (currently: e.g. kl-divergence, wasserstein-distance etc.) tests
Every successful run yields a result object of type GoodnessOfFitResult which contains
information on both estimator, simulato... |
Runs the given configurations, i.e.
1) fits the estimator to the simulation and
2) executes goodness-of-fit (currently: e.g. kl-divergence, wasserstein-distance etc.) tests
Every successful run yields a result object of type GoodnessOfFitResult which contains
information on both estimator, simulato... | def run_configurations(self, estimator_filter=None,
limit=None, dump_models=False, multiprocessing=True, n_workers=None):
"""
Runs the given configurations, i.e.
1) fits the estimator to the simulation and
2) executes goodness-of-fit (currently: e.g. kl-divergence, wasserstein-d... | [
"def",
"run_configurations",
"(",
"self",
",",
"estimator_filter",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"dump_models",
"=",
"False",
",",
"multiprocessing",
"=",
"True",
",",
"n_workers",
"=",
"None",
")",
":",
"self",
".",
"dump_models",
"=",
"dum... | [
163,
2
] | [
215,
38
] | python | en | ['en', 'error', 'th'] | False |
ConfigRunner._get_results_dataframe | (self, results) | retrieves the dataframe for one or more GoodnessOfFitResults result objects.
Args:
results: a list or single object of type GoodnessOfFitResults
Returns:
a pandas dataframe
| retrieves the dataframe for one or more GoodnessOfFitResults result objects. | def _get_results_dataframe(self, results):
""" retrieves the dataframe for one or more GoodnessOfFitResults result objects.
Args:
results: a list or single object of type GoodnessOfFitResults
Returns:
a pandas dataframe
"""
n_results = len(results)
assert n_results > 0, "... | [
"def",
"_get_results_dataframe",
"(",
"self",
",",
"results",
")",
":",
"n_results",
"=",
"len",
"(",
"results",
")",
"assert",
"n_results",
">",
"0",
",",
"\"no results given\"",
"results_dict",
"=",
"results",
".",
"report_dict",
"(",
"keys_of_interest",
"=",
... | [
299,
2
] | [
312,
52
] | python | en | ['en', 'en', 'en'] | True |
ConfigRunner._export_results | (self, task, gof_result, file_handle_results) | write result to file | write result to file | def _export_results(self, task, gof_result, file_handle_results):
assert len(gof_result) > 0, "no results given"
""" write result to file"""
try:
gof_result_df = self._get_results_dataframe(results=gof_result)
gof_result.result_df = gof_result_df
io.append_result_to_csv(file_handle_result... | [
"def",
"_export_results",
"(",
"self",
",",
"task",
",",
"gof_result",
",",
"file_handle_results",
")",
":",
"assert",
"len",
"(",
"gof_result",
")",
">",
"0",
",",
"\"no results given\"",
"try",
":",
"gof_result_df",
"=",
"self",
".",
"_get_results_dataframe",
... | [
314,
2
] | [
325,
27
] | python | en | ['en', 'en', 'en'] | True |
Dib.expose | (self, handle) |
Copy the bitmap contents to a device context.
:param handle: Device context (HDC), cast to a Python integer, or an
HDC or HWND instance. In PythonWin, you can use
``CDC.GetHandleAttrib()`` to get a suitable handle.
|
Copy the bitmap contents to a device context. | def expose(self, handle):
"""
Copy the bitmap contents to a device context.
:param handle: Device context (HDC), cast to a Python integer, or an
HDC or HWND instance. In PythonWin, you can use
``CDC.GetHandleAttrib()`` to get a suitable handle.
... | [
"def",
"expose",
"(",
"self",
",",
"handle",
")",
":",
"if",
"isinstance",
"(",
"handle",
",",
"HWND",
")",
":",
"dc",
"=",
"self",
".",
"image",
".",
"getdc",
"(",
"handle",
")",
"try",
":",
"result",
"=",
"self",
".",
"image",
".",
"expose",
"(... | [
85,
4
] | [
101,
21
] | python | en | ['en', 'error', 'th'] | False |
Dib.draw | (self, handle, dst, src=None) |
Same as expose, but allows you to specify where to draw the image, and
what part of it to draw.
The destination and source areas are given as 4-tuple rectangles. If
the source is omitted, the entire image is copied. If the source and
the destination have different sizes, the im... |
Same as expose, but allows you to specify where to draw the image, and
what part of it to draw. | def draw(self, handle, dst, src=None):
"""
Same as expose, but allows you to specify where to draw the image, and
what part of it to draw.
The destination and source areas are given as 4-tuple rectangles. If
the source is omitted, the entire image is copied. If the source and
... | [
"def",
"draw",
"(",
"self",
",",
"handle",
",",
"dst",
",",
"src",
"=",
"None",
")",
":",
"if",
"not",
"src",
":",
"src",
"=",
"(",
"0",
",",
"0",
")",
"+",
"self",
".",
"size",
"if",
"isinstance",
"(",
"handle",
",",
"HWND",
")",
":",
"dc",
... | [
103,
4
] | [
123,
21
] | python | en | ['en', 'error', 'th'] | False |
Dib.query_palette | (self, handle) |
Installs the palette associated with the image in the given device
context.
This method should be called upon **QUERYNEWPALETTE** and
**PALETTECHANGED** events from Windows. If this method returns a
non-zero value, one or more display palette entries were changed, and
t... |
Installs the palette associated with the image in the given device
context. | def query_palette(self, handle):
"""
Installs the palette associated with the image in the given device
context.
This method should be called upon **QUERYNEWPALETTE** and
**PALETTECHANGED** events from Windows. If this method returns a
non-zero value, one or more display... | [
"def",
"query_palette",
"(",
"self",
",",
"handle",
")",
":",
"if",
"isinstance",
"(",
"handle",
",",
"HWND",
")",
":",
"handle",
"=",
"self",
".",
"image",
".",
"getdc",
"(",
"handle",
")",
"try",
":",
"result",
"=",
"self",
".",
"image",
".",
"qu... | [
125,
4
] | [
148,
21
] | python | en | ['en', 'error', 'th'] | False |
Dib.paste | (self, im, box=None) |
Paste a PIL image into the bitmap image.
:param im: A PIL image. The size must match the target region.
If the mode does not match, the image is converted to the
mode of the bitmap image.
:param box: A 4-tuple defining the left, upper, right, and
... |
Paste a PIL image into the bitmap image. | def paste(self, im, box=None):
"""
Paste a PIL image into the bitmap image.
:param im: A PIL image. The size must match the target region.
If the mode does not match, the image is converted to the
mode of the bitmap image.
:param box: A 4-tuple def... | [
"def",
"paste",
"(",
"self",
",",
"im",
",",
"box",
"=",
"None",
")",
":",
"im",
".",
"load",
"(",
")",
"if",
"self",
".",
"mode",
"!=",
"im",
".",
"mode",
":",
"im",
"=",
"im",
".",
"convert",
"(",
"self",
".",
"mode",
")",
"if",
"box",
":... | [
150,
4
] | [
168,
35
] | python | en | ['en', 'error', 'th'] | False |
Dib.frombytes | (self, buffer) |
Load display memory contents from byte data.
:param buffer: A buffer containing display data (usually
data returned from :py:func:`~PIL.ImageWin.Dib.tobytes`)
|
Load display memory contents from byte data. | def frombytes(self, buffer):
"""
Load display memory contents from byte data.
:param buffer: A buffer containing display data (usually
data returned from :py:func:`~PIL.ImageWin.Dib.tobytes`)
"""
return self.image.frombytes(buffer) | [
"def",
"frombytes",
"(",
"self",
",",
"buffer",
")",
":",
"return",
"self",
".",
"image",
".",
"frombytes",
"(",
"buffer",
")"
] | [
170,
4
] | [
177,
43
] | python | en | ['en', 'error', 'th'] | False |
Dib.tobytes | (self) |
Copy display memory contents to bytes object.
:return: A bytes object containing display data.
|
Copy display memory contents to bytes object. | def tobytes(self):
"""
Copy display memory contents to bytes object.
:return: A bytes object containing display data.
"""
return self.image.tobytes() | [
"def",
"tobytes",
"(",
"self",
")",
":",
"return",
"self",
".",
"image",
".",
"tobytes",
"(",
")"
] | [
179,
4
] | [
185,
35
] | python | en | ['en', 'error', 'th'] | False |
check_err | (code, cpl=False) |
Checks the given CPL/OGRERR, and raises an exception where appropriate.
|
Checks the given CPL/OGRERR, and raises an exception where appropriate.
| def check_err(code, cpl=False):
"""
Checks the given CPL/OGRERR, and raises an exception where appropriate.
"""
err_dict = CPLERR_DICT if cpl else OGRERR_DICT
if code == ERR_NONE:
return
elif code in err_dict:
e, msg = err_dict[code]
raise e(msg)
else:
raise ... | [
"def",
"check_err",
"(",
"code",
",",
"cpl",
"=",
"False",
")",
":",
"err_dict",
"=",
"CPLERR_DICT",
"if",
"cpl",
"else",
"OGRERR_DICT",
"if",
"code",
"==",
"ERR_NONE",
":",
"return",
"elif",
"code",
"in",
"err_dict",
":",
"e",
",",
"msg",
"=",
"err_di... | [
62,
0
] | [
74,
62
] | python | en | ['en', 'error', 'th'] | False |
FileEntry.stat_regular_file | (path, stat_function) |
Wrap `stat_function` to raise appropriate errors if `path` is not a
regular file
|
Wrap `stat_function` to raise appropriate errors if `path` is not a
regular file
| def stat_regular_file(path, stat_function):
"""
Wrap `stat_function` to raise appropriate errors if `path` is not a
regular file
"""
try:
stat_result = stat_function(path)
except KeyError:
raise MissingFileError(path)
except OSError as e:
... | [
"def",
"stat_regular_file",
"(",
"path",
",",
"stat_function",
")",
":",
"try",
":",
"stat_result",
"=",
"stat_function",
"(",
"path",
")",
"except",
"KeyError",
":",
"raise",
"MissingFileError",
"(",
"path",
")",
"except",
"OSError",
"as",
"e",
":",
"if",
... | [
223,
4
] | [
242,
26
] | python | en | ['en', 'error', 'th'] | False |
check_other_queues | (queue_counts_dict: Dict[str, int]) | Do a simple queue size check for queues whose workers don't publish stats files. | Do a simple queue size check for queues whose workers don't publish stats files. | def check_other_queues(queue_counts_dict: Dict[str, int]) -> List[Dict[str, Any]]:
"""Do a simple queue size check for queues whose workers don't publish stats files."""
results = []
for queue, count in queue_counts_dict.items():
if queue in normal_queues:
continue
if count > C... | [
"def",
"check_other_queues",
"(",
"queue_counts_dict",
":",
"Dict",
"[",
"str",
",",
"int",
"]",
")",
"->",
"List",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"results",
"=",
"[",
"]",
"for",
"queue",
",",
"count",
"in",
"queue_counts_dict",
... | [
111,
0
] | [
126,
18
] | python | en | ['en', 'en', 'en'] | True |
hide_file | (path) |
Set the hidden attribute on a file or directory.
From http://stackoverflow.com/questions/19622133/
`path` must be text.
|
Set the hidden attribute on a file or directory. | def hide_file(path):
"""
Set the hidden attribute on a file or directory.
From http://stackoverflow.com/questions/19622133/
`path` must be text.
"""
__import__('ctypes.wintypes')
SetFileAttributes = ctypes.windll.kernel32.SetFileAttributesW
SetFileAttributes.argtypes = ctypes.wintypes.... | [
"def",
"hide_file",
"(",
"path",
")",
":",
"__import__",
"(",
"'ctypes.wintypes'",
")",
"SetFileAttributes",
"=",
"ctypes",
".",
"windll",
".",
"kernel32",
".",
"SetFileAttributesW",
"SetFileAttributes",
".",
"argtypes",
"=",
"ctypes",
".",
"wintypes",
".",
"LPW... | [
11,
0
] | [
28,
31
] | python | en | ['en', 'error', 'th'] | False |
test_job_template_delete_access_with_survey | (job_template_with_survey, admin_user) | The survey_spec view relies on JT `can_delete` to determine permission
to delete the survey. This checks that system admins can delete the survey on a JT. | The survey_spec view relies on JT `can_delete` to determine permission
to delete the survey. This checks that system admins can delete the survey on a JT. | def test_job_template_delete_access_with_survey(job_template_with_survey, admin_user):
"""The survey_spec view relies on JT `can_delete` to determine permission
to delete the survey. This checks that system admins can delete the survey on a JT."""
access = JobTemplateAccess(admin_user)
assert access.can... | [
"def",
"test_job_template_delete_access_with_survey",
"(",
"job_template_with_survey",
",",
"admin_user",
")",
":",
"access",
"=",
"JobTemplateAccess",
"(",
"admin_user",
")",
"assert",
"access",
".",
"can_delete",
"(",
"job_template_with_survey",
")"
] | [
243,
0
] | [
247,
54
] | python | en | ['en', 'en', 'en'] | True |
test_delete_survey_spec | (job_template_with_survey, delete, admin_user) | Functional delete test through the survey_spec view. | Functional delete test through the survey_spec view. | def test_delete_survey_spec(job_template_with_survey, delete, admin_user):
"""Functional delete test through the survey_spec view."""
delete(reverse('api:job_template_survey_spec', kwargs={'pk': job_template_with_survey.pk}), admin_user, expect=200)
new_jt = JobTemplate.objects.get(pk=job_template_with_surv... | [
"def",
"test_delete_survey_spec",
"(",
"job_template_with_survey",
",",
"delete",
",",
"admin_user",
")",
":",
"delete",
"(",
"reverse",
"(",
"'api:job_template_survey_spec'",
",",
"kwargs",
"=",
"{",
"'pk'",
":",
"job_template_with_survey",
".",
"pk",
"}",
")",
"... | [
252,
0
] | [
256,
35
] | python | en | ['en', 'fr', 'en'] | True |
test_launch_survey_enabled_but_no_survey_spec | (job_template_factory, post, admin_user) | False-ish values for survey_spec are interpreted as a survey with 0 questions. | False-ish values for survey_spec are interpreted as a survey with 0 questions. | def test_launch_survey_enabled_but_no_survey_spec(job_template_factory, post, admin_user):
"""False-ish values for survey_spec are interpreted as a survey with 0 questions."""
objects = job_template_factory('jt', organization='org1', project='prj', inventory='inv', credential='cred')
obj = objects.job_templ... | [
"def",
"test_launch_survey_enabled_but_no_survey_spec",
"(",
"job_template_factory",
",",
"post",
",",
"admin_user",
")",
":",
"objects",
"=",
"job_template_factory",
"(",
"'jt'",
",",
"organization",
"=",
"'org1'",
",",
"project",
"=",
"'prj'",
",",
"inventory",
"=... | [
263,
0
] | [
270,
72
] | python | en | ['en', 'en', 'en'] | True |
IntegrationTests.test_package_spec_installed | (self) |
Illustrate the recommended procedure to determine if
a specified version of a package is installed.
|
Illustrate the recommended procedure to determine if
a specified version of a package is installed.
| def test_package_spec_installed(self):
"""
Illustrate the recommended procedure to determine if
a specified version of a package is installed.
"""
def is_installed(package_spec):
req = packaging.requirements.Requirement(package_spec)
return version(req.nam... | [
"def",
"test_package_spec_installed",
"(",
"self",
")",
":",
"def",
"is_installed",
"(",
"package_spec",
")",
":",
"req",
"=",
"packaging",
".",
"requirements",
".",
"Requirement",
"(",
"package_spec",
")",
"return",
"version",
"(",
"req",
".",
"name",
")",
... | [
18,
4
] | [
29,
51
] | python | en | ['en', 'error', 'th'] | False |
SystemJobTemplate.launch | (self, payload={}) | Launch the system_job_template using related->launch endpoint. | Launch the system_job_template using related->launch endpoint. | def launch(self, payload={}):
"""Launch the system_job_template using related->launch endpoint."""
result = self.related.launch.post(payload)
# return job
jobs_pg = self.get_related('jobs', id=result.json['system_job'])
assert jobs_pg.count == 1, "system_job_template launched (i... | [
"def",
"launch",
"(",
"self",
",",
"payload",
"=",
"{",
"}",
")",
":",
"result",
"=",
"self",
".",
"related",
".",
"launch",
".",
"post",
"(",
"payload",
")",
"# return job",
"jobs_pg",
"=",
"self",
".",
"get_related",
"(",
"'jobs'",
",",
"id",
"=",
... | [
7,
4
] | [
14,
33
] | python | en | ['en', 'en', 'en'] | True |
BackupExport._construct_schedule | (mac: str, schedule_type: str) |
Construct the schedule as the scheduler does
:param mac:
:param schedule_type:
:return: dict
|
Construct the schedule as the scheduler does
:param mac:
:param schedule_type:
:return: dict
| def _construct_schedule(mac: str, schedule_type: str):
"""
Construct the schedule as the scheduler does
:param mac:
:param schedule_type:
:return: dict
"""
# TODO maybe decide to drop etcd-member because it's tricky to deal with two roles
# etcd-member + k... | [
"def",
"_construct_schedule",
"(",
"mac",
":",
"str",
",",
"schedule_type",
":",
"str",
")",
":",
"# TODO maybe decide to drop etcd-member because it's tricky to deal with two roles",
"# etcd-member + kubernetes-control-plane: in fact it's only one",
"if",
"schedule_type",
"==",
"S... | [
241,
4
] | [
259,
9
] | python | en | ['en', 'error', 'th'] | False |
BackupExport.get_playbook | (self) |
Get and reproduce the data sent inside the db from an API level
:return:
|
Get and reproduce the data sent inside the db from an API level
:return:
| def get_playbook(self):
"""
Get and reproduce the data sent inside the db from an API level
:return:
"""
playbook = []
with session_commit(sess_maker=self.sess_maker) as session:
for schedule_type in [ScheduleRoles.kubernetes_control_plane, ScheduleRoles.kuber... | [
"def",
"get_playbook",
"(",
"self",
")",
":",
"playbook",
"=",
"[",
"]",
"with",
"session_commit",
"(",
"sess_maker",
"=",
"self",
".",
"sess_maker",
")",
"as",
"session",
":",
"for",
"schedule_type",
"in",
"[",
"ScheduleRoles",
".",
"kubernetes_control_plane"... | [
261,
4
] | [
275,
23
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.