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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
JMeterExprCompiler.translate_jmeter_expr | (self, expr) |
Translates JMeter expression into Apiritif-based Python expression.
:type expr: str
:return:
|
Translates JMeter expression into Apiritif-based Python expression.
:type expr: str
:return:
| def translate_jmeter_expr(self, expr):
"""
Translates JMeter expression into Apiritif-based Python expression.
:type expr: str
:return:
"""
self.log.debug("Attempting to translate JMeter expression %r", expr)
functions = {
'__time': TimeFunction,
... | [
"def",
"translate_jmeter_expr",
"(",
"self",
",",
"expr",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Attempting to translate JMeter expression %r\"",
",",
"expr",
")",
"functions",
"=",
"{",
"'__time'",
":",
"TimeFunction",
",",
"'__Random'",
":",
"Rand... | [
253,
4
] | [
295,
21
] | python | en | ['en', 'error', 'th'] | False |
f | (x) | Noise free objective. | Noise free objective. | def f(x):
"""Noise free objective."""
return np.sin(10 * x) * x * 100 | [
"def",
"f",
"(",
"x",
")",
":",
"return",
"np",
".",
"sin",
"(",
"10",
"*",
"x",
")",
"*",
"x",
"*",
"100"
] | [
24,
0
] | [
27,
35
] | python | en | ['en', 'en', 'en'] | True |
gen_filenames | (only_new=False) |
Returns a list of filenames referenced in sys.modules and translation
files.
|
Returns a list of filenames referenced in sys.modules and translation
files.
| def gen_filenames(only_new=False):
"""
Returns a list of filenames referenced in sys.modules and translation
files.
"""
# N.B. ``list(...)`` is needed, because this runs in parallel with
# application code which might be mutating ``sys.modules``, and this will
# fail with RuntimeError: canno... | [
"def",
"gen_filenames",
"(",
"only_new",
"=",
"False",
")",
":",
"# N.B. ``list(...)`` is needed, because this runs in parallel with",
"# application code which might be mutating ``sys.modules``, and this will",
"# fail with RuntimeError: cannot mutate dictionary while iterating",
"global",
... | [
82,
0
] | [
127,
60
] | python | en | ['en', 'error', 'th'] | False |
inotify_code_changed | () |
Checks for changed code using inotify. After being called
it blocks until a change event has been fired.
|
Checks for changed code using inotify. After being called
it blocks until a change event has been fired.
| def inotify_code_changed():
"""
Checks for changed code using inotify. After being called
it blocks until a change event has been fired.
"""
class EventHandler(pyinotify.ProcessEvent):
modified_code = None
def process_default(self, event):
if event.path.endswith('.mo'):
... | [
"def",
"inotify_code_changed",
"(",
")",
":",
"class",
"EventHandler",
"(",
"pyinotify",
".",
"ProcessEvent",
")",
":",
"modified_code",
"=",
"None",
"def",
"process_default",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"path",
".",
"endswith",
... | [
153,
0
] | [
199,
37
] | python | en | ['en', 'error', 'th'] | False |
find_element_by_shadow | (shadow_loc) |
Enables finding element using the Shadow Locator
:param shadow_loc: shadow locator in the string form - css locators divided by commas, e.g. 'c-comp1, c-basic, .std_btn'
:return: the found element otherwise NoSuchElementException is raised
|
Enables finding element using the Shadow Locator
:param shadow_loc: shadow locator in the string form - css locators divided by commas, e.g. 'c-comp1, c-basic, .std_btn'
:return: the found element otherwise NoSuchElementException is raised
| def find_element_by_shadow(shadow_loc):
"""
Enables finding element using the Shadow Locator
:param shadow_loc: shadow locator in the string form - css locators divided by commas, e.g. 'c-comp1, c-basic, .std_btn'
:return: the found element otherwise NoSuchElementException is raised
"""
el = Non... | [
"def",
"find_element_by_shadow",
"(",
"shadow_loc",
")",
":",
"el",
"=",
"None",
"css_path",
"=",
"[",
"x",
".",
"strip",
"(",
")",
"for",
"x",
"in",
"shadow_loc",
".",
"split",
"(",
"','",
")",
"]",
"for",
"p",
"in",
"css_path",
":",
"if",
"not",
... | [
25,
0
] | [
43,
43
] | python | en | ['en', 'error', 'th'] | False |
get_locator | (locators, parent_el=None, ignore_implicit_wait=False, raise_exception=False) |
:param locators: List of Dictionaries holding the locators, e.g. [{'id': 'elem_id'},
{css: 'my_cls'}]
:param parent_el: reference to the parent element (WebElement instance), optional - if provided the find_elements
method is called on it instead of global context
:param ignore_implicit_wait: set i... |
:param locators: List of Dictionaries holding the locators, e.g. [{'id': 'elem_id'},
{css: 'my_cls'}]
:param parent_el: reference to the parent element (WebElement instance), optional - if provided the find_elements
method is called on it instead of global context
:param ignore_implicit_wait: set i... | def get_locator(locators, parent_el=None, ignore_implicit_wait=False, raise_exception=False):
"""
:param locators: List of Dictionaries holding the locators, e.g. [{'id': 'elem_id'},
{css: 'my_cls'}]
:param parent_el: reference to the parent element (WebElement instance), optional - if provided the find... | [
"def",
"get_locator",
"(",
"locators",
",",
"parent_el",
"=",
"None",
",",
"ignore_implicit_wait",
"=",
"False",
",",
"raise_exception",
"=",
"False",
")",
":",
"driver",
"=",
"_get_driver",
"(",
")",
"timeout",
"=",
"_get_timeout",
"(",
")",
"first_locator",
... | [
70,
0
] | [
114,
18
] | python | en | ['en', 'error', 'th'] | False |
get_elements | (locators) |
:param locators: List of Dictionaries holding the locators, e.g. [{'id': 'elem_id'},
{css: 'my_cls'}]
:return: all elements that match the first valid locator out of the passed locators
|
:param locators: List of Dictionaries holding the locators, e.g. [{'id': 'elem_id'},
{css: 'my_cls'}]
:return: all elements that match the first valid locator out of the passed locators
| def get_elements(locators):
"""
:param locators: List of Dictionaries holding the locators, e.g. [{'id': 'elem_id'},
{css: 'my_cls'}]
:return: all elements that match the first valid locator out of the passed locators
"""
elements = []
first_locator = True
driver = _get_driver()
for ... | [
"def",
"get_elements",
"(",
"locators",
")",
":",
"elements",
"=",
"[",
"]",
"first_locator",
"=",
"True",
"driver",
"=",
"_get_driver",
"(",
")",
"for",
"locator",
"in",
"locators",
":",
"locator_type",
"=",
"list",
"(",
"locator",
".",
"keys",
"(",
")"... | [
117,
0
] | [
138,
19
] | python | en | ['en', 'error', 'th'] | False |
dialogs_replace | () |
Replaces the standard JavaScript methods, i.e. 'window.confirm', 'window.alert' and 'window.prompt' with
own implementation that stores the messages from the dialogs and also is capable of returning user defined
values
|
Replaces the standard JavaScript methods, i.e. 'window.confirm', 'window.alert' and 'window.prompt' with
own implementation that stores the messages from the dialogs and also is capable of returning user defined
values
| def dialogs_replace():
"""
Replaces the standard JavaScript methods, i.e. 'window.confirm', 'window.alert' and 'window.prompt' with
own implementation that stores the messages from the dialogs and also is capable of returning user defined
values
"""
_get_driver().execute_script("""
if... | [
"def",
"dialogs_replace",
"(",
")",
":",
"_get_driver",
"(",
")",
".",
"execute_script",
"(",
"\"\"\"\n if (window.__webdriverAlerts) { return; }\n window.__webdriverAlerts = [];\n window.__webdriverOriginalAlert = window.alert;\n window.__webdriverNextAlert... | [
195,
0
] | [
234,
12
] | python | en | ['en', 'error', 'th'] | False |
dialogs_get_next_confirm | () |
:return: the message from the last invocation of 'window.confirm'
|
:return: the message from the last invocation of 'window.confirm'
| def dialogs_get_next_confirm():
"""
:return: the message from the last invocation of 'window.confirm'
"""
return _get_driver().execute_script("""
if (!window.__webdriverConfirms) { return null; }
return window.__webdriverConfirms.shift();
""") | [
"def",
"dialogs_get_next_confirm",
"(",
")",
":",
"return",
"_get_driver",
"(",
")",
".",
"execute_script",
"(",
"\"\"\"\n if (!window.__webdriverConfirms) { return null; }\n return window.__webdriverConfirms.shift();\n \"\"\"",
")"
] | [
237,
0
] | [
244,
19
] | python | en | ['en', 'error', 'th'] | False |
dialogs_get_next_alert | () |
:return: the alert message from the last invocation of 'window.alert'
|
:return: the alert message from the last invocation of 'window.alert'
| def dialogs_get_next_alert():
"""
:return: the alert message from the last invocation of 'window.alert'
"""
return _get_driver().execute_script("""
if (!window.__webdriverAlerts) { return null }
var t = window.__webdriverAlerts.shift();
if (t) { t = t.to... | [
"def",
"dialogs_get_next_alert",
"(",
")",
":",
"return",
"_get_driver",
"(",
")",
".",
"execute_script",
"(",
"\"\"\"\n if (!window.__webdriverAlerts) { return null } \n var t = window.__webdriverAlerts.shift(); \n if (t) { t = t.toString().repla... | [
247,
0
] | [
256,
18
] | python | en | ['en', 'error', 'th'] | False |
dialogs_get_next_prompt | () |
:return: the message from the last invocation of 'window.prompt'
|
:return: the message from the last invocation of 'window.prompt'
| def dialogs_get_next_prompt():
"""
:return: the message from the last invocation of 'window.prompt'
"""
return _get_driver().execute_script("""
if (!window.__webdriverPrompts) { return null; }
return window.__webdriverPrompts.shift();
""") | [
"def",
"dialogs_get_next_prompt",
"(",
")",
":",
"return",
"_get_driver",
"(",
")",
".",
"execute_script",
"(",
"\"\"\"\n if (!window.__webdriverPrompts) { return null; }\n return window.__webdriverPrompts.shift();\n \"\"\"",
")"
] | [
259,
0
] | [
266,
18
] | python | en | ['en', 'error', 'th'] | False |
dialogs_answer_on_next_alert | (value) |
Simulates click on OK button in the next alert
|
Simulates click on OK button in the next alert
| def dialogs_answer_on_next_alert(value):
"""
Simulates click on OK button in the next alert
"""
dialogs_replace()
if str(value).lower() == '#ok':
_get_driver().execute_script("window.__webdriverNextAlert = true") | [
"def",
"dialogs_answer_on_next_alert",
"(",
"value",
")",
":",
"dialogs_replace",
"(",
")",
"if",
"str",
"(",
"value",
")",
".",
"lower",
"(",
")",
"==",
"'#ok'",
":",
"_get_driver",
"(",
")",
".",
"execute_script",
"(",
"\"window.__webdriverNextAlert = true\"",... | [
269,
0
] | [
275,
74
] | python | en | ['en', 'error', 'th'] | False |
dialogs_answer_on_next_prompt | (value) |
:param value: The value to be used to answer the next 'window.prompt', if '#cancel' is provided then
click on cancel button is simulated by returning null
|
:param value: The value to be used to answer the next 'window.prompt', if '#cancel' is provided then
click on cancel button is simulated by returning null
| def dialogs_answer_on_next_prompt(value):
"""
:param value: The value to be used to answer the next 'window.prompt', if '#cancel' is provided then
click on cancel button is simulated by returning null
"""
dialogs_replace()
if str(value).lower() == '#cancel':
_get_driver().execute_script(... | [
"def",
"dialogs_answer_on_next_prompt",
"(",
"value",
")",
":",
"dialogs_replace",
"(",
")",
"if",
"str",
"(",
"value",
")",
".",
"lower",
"(",
")",
"==",
"'#cancel'",
":",
"_get_driver",
"(",
")",
".",
"execute_script",
"(",
"\"window.__webdriverNextPrompt = nu... | [
278,
0
] | [
287,
84
] | python | en | ['en', 'error', 'th'] | False |
dialogs_answer_on_next_confirm | (value) |
:param value: either '#ok' to click on OK button or '#cancel' to simulate click on Cancel button in the
next 'window.confirm' method
|
:param value: either '#ok' to click on OK button or '#cancel' to simulate click on Cancel button in the
next 'window.confirm' method
| def dialogs_answer_on_next_confirm(value):
"""
:param value: either '#ok' to click on OK button or '#cancel' to simulate click on Cancel button in the
next 'window.confirm' method
"""
dialogs_replace()
if str(value).lower() == '#ok':
confirm = 'true'
else:
confirm = 'false'
... | [
"def",
"dialogs_answer_on_next_confirm",
"(",
"value",
")",
":",
"dialogs_replace",
"(",
")",
"if",
"str",
"(",
"value",
")",
".",
"lower",
"(",
")",
"==",
"'#ok'",
":",
"confirm",
"=",
"'true'",
"else",
":",
"confirm",
"=",
"'false'",
"_get_driver",
"(",
... | [
290,
0
] | [
300,
81
] | python | en | ['en', 'error', 'th'] | False |
get_loop_range | (start, end, step) |
:return: the range over which the loop will operate
|
:return: the range over which the loop will operate
| def get_loop_range(start, end, step):
"""
:return: the range over which the loop will operate
"""
start = int(start)
end = int(end)
step = int(step)
end = end + 1 if step > 0 else end - 1
return range(start, end, step) | [
"def",
"get_loop_range",
"(",
"start",
",",
"end",
",",
"step",
")",
":",
"start",
"=",
"int",
"(",
"start",
")",
"end",
"=",
"int",
"(",
"end",
")",
"step",
"=",
"int",
"(",
"step",
")",
"end",
"=",
"end",
"+",
"1",
"if",
"step",
">",
"0",
"... | [
361,
0
] | [
369,
34
] | python | en | ['en', 'error', 'th'] | False |
open_window | (url) |
Opens the given url in a new window and also switches to it automatically
|
Opens the given url in a new window and also switches to it automatically
| def open_window(url):
"""
Opens the given url in a new window and also switches to it automatically
"""
driver = _get_driver()
driver.execute_script("window.open('%s');" % url)
driver.switch_to.window(driver.window_handles[-1]) | [
"def",
"open_window",
"(",
"url",
")",
":",
"driver",
"=",
"_get_driver",
"(",
")",
"driver",
".",
"execute_script",
"(",
"\"window.open('%s');\"",
"%",
"url",
")",
"driver",
".",
"switch_to",
".",
"window",
"(",
"driver",
".",
"window_handles",
"[",
"-",
... | [
405,
0
] | [
411,
54
] | python | en | ['en', 'error', 'th'] | False |
waiter | () |
Allows waiting for page to finish loading before performing other actions on non completely loaded page
|
Allows waiting for page to finish loading before performing other actions on non completely loaded page
| def waiter():
"""
Allows waiting for page to finish loading before performing other actions on non completely loaded page
"""
try:
WebDriverWait(_get_driver(), _get_timeout()) \
.until(lambda driver: driver.execute_script('return document.readyState') == 'complete',
... | [
"def",
"waiter",
"(",
")",
":",
"try",
":",
"WebDriverWait",
"(",
"_get_driver",
"(",
")",
",",
"_get_timeout",
"(",
")",
")",
".",
"until",
"(",
"lambda",
"driver",
":",
"driver",
".",
"execute_script",
"(",
"'return document.readyState'",
")",
"==",
"'co... | [
446,
0
] | [
455,
12
] | python | en | ['en', 'error', 'th'] | False |
Layer.__init__ | (self, layer_ptr, ds) |
Initializes on an OGR C pointer to the Layer and the `DataSource` object
that owns this layer. The `DataSource` object is required so that a
reference to it is kept with this Layer. This prevents garbage
collection of the `DataSource` while this Layer is still active.
|
Initializes on an OGR C pointer to the Layer and the `DataSource` object
that owns this layer. The `DataSource` object is required so that a
reference to it is kept with this Layer. This prevents garbage
collection of the `DataSource` while this Layer is still active.
| def __init__(self, layer_ptr, ds):
"""
Initializes on an OGR C pointer to the Layer and the `DataSource` object
that owns this layer. The `DataSource` object is required so that a
reference to it is kept with this Layer. This prevents garbage
collection of the `DataSource` whil... | [
"def",
"__init__",
"(",
"self",
",",
"layer_ptr",
",",
"ds",
")",
":",
"if",
"not",
"layer_ptr",
":",
"raise",
"GDALException",
"(",
"'Cannot create Layer, invalid pointer given'",
")",
"self",
".",
"ptr",
"=",
"layer_ptr",
"self",
".",
"_ds",
"=",
"ds",
"se... | [
27,
4
] | [
40,
63
] | python | en | ['en', 'error', 'th'] | False |
Layer.__getitem__ | (self, index) | Gets the Feature at the specified index. | Gets the Feature at the specified index. | def __getitem__(self, index):
"Gets the Feature at the specified index."
if isinstance(index, six.integer_types):
# An integer index was given -- we cannot do a check based on the
# number of features because the beginning and ending feature IDs
# are not guaranteed t... | [
"def",
"__getitem__",
"(",
"self",
",",
"index",
")",
":",
"if",
"isinstance",
"(",
"index",
",",
"six",
".",
"integer_types",
")",
":",
"# An integer index was given -- we cannot do a check based on the",
"# number of features because the beginning and ending feature IDs",
"... | [
42,
4
] | [
56,
93
] | python | en | ['en', 'en', 'en'] | True |
Layer.__iter__ | (self) | Iterates over each Feature in the Layer. | Iterates over each Feature in the Layer. | def __iter__(self):
"Iterates over each Feature in the Layer."
# ResetReading() must be called before iteration is to begin.
capi.reset_reading(self._ptr)
for i in range(self.num_feat):
yield Feature(capi.get_next_feature(self._ptr), self) | [
"def",
"__iter__",
"(",
"self",
")",
":",
"# ResetReading() must be called before iteration is to begin.",
"capi",
".",
"reset_reading",
"(",
"self",
".",
"_ptr",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"num_feat",
")",
":",
"yield",
"Feature",
"(",
... | [
58,
4
] | [
63,
65
] | python | en | ['en', 'en', 'en'] | True |
Layer.__len__ | (self) | The length is the number of features. | The length is the number of features. | def __len__(self):
"The length is the number of features."
return self.num_feat | [
"def",
"__len__",
"(",
"self",
")",
":",
"return",
"self",
".",
"num_feat"
] | [
65,
4
] | [
67,
28
] | python | en | ['en', 'en', 'en'] | True |
Layer.__str__ | (self) | The string name of the layer. | The string name of the layer. | def __str__(self):
"The string name of the layer."
return self.name | [
"def",
"__str__",
"(",
"self",
")",
":",
"return",
"self",
".",
"name"
] | [
69,
4
] | [
71,
24
] | python | en | ['en', 'en', 'en'] | True |
Layer._make_feature | (self, feat_id) |
Helper routine for __getitem__ that constructs a Feature from the given
Feature ID. If the OGR Layer does not support random-access reading,
then each feature of the layer will be incremented through until the
a Feature is found matching the given feature ID.
|
Helper routine for __getitem__ that constructs a Feature from the given
Feature ID. If the OGR Layer does not support random-access reading,
then each feature of the layer will be incremented through until the
a Feature is found matching the given feature ID.
| def _make_feature(self, feat_id):
"""
Helper routine for __getitem__ that constructs a Feature from the given
Feature ID. If the OGR Layer does not support random-access reading,
then each feature of the layer will be incremented through until the
a Feature is found matching the... | [
"def",
"_make_feature",
"(",
"self",
",",
"feat_id",
")",
":",
"if",
"self",
".",
"_random_read",
":",
"# If the Layer supports random reading, return.",
"try",
":",
"return",
"Feature",
"(",
"capi",
".",
"get_feature",
"(",
"self",
".",
"ptr",
",",
"feat_id",
... | [
73,
4
] | [
93,
64
] | python | en | ['en', 'error', 'th'] | False |
Layer.extent | (self) | Returns the extent (an Envelope) of this layer. | Returns the extent (an Envelope) of this layer. | def extent(self):
"Returns the extent (an Envelope) of this layer."
env = OGREnvelope()
capi.get_extent(self.ptr, byref(env), 1)
return Envelope(env) | [
"def",
"extent",
"(",
"self",
")",
":",
"env",
"=",
"OGREnvelope",
"(",
")",
"capi",
".",
"get_extent",
"(",
"self",
".",
"ptr",
",",
"byref",
"(",
"env",
")",
",",
"1",
")",
"return",
"Envelope",
"(",
"env",
")"
] | [
97,
4
] | [
101,
28
] | python | en | ['en', 'en', 'en'] | True |
Layer.name | (self) | Returns the name of this layer in the Data Source. | Returns the name of this layer in the Data Source. | def name(self):
"Returns the name of this layer in the Data Source."
name = capi.get_fd_name(self._ldefn)
return force_text(name, self._ds.encoding, strings_only=True) | [
"def",
"name",
"(",
"self",
")",
":",
"name",
"=",
"capi",
".",
"get_fd_name",
"(",
"self",
".",
"_ldefn",
")",
"return",
"force_text",
"(",
"name",
",",
"self",
".",
"_ds",
".",
"encoding",
",",
"strings_only",
"=",
"True",
")"
] | [
104,
4
] | [
107,
69
] | python | en | ['en', 'en', 'en'] | True |
Layer.num_feat | (self, force=1) | Returns the number of features in the Layer. | Returns the number of features in the Layer. | def num_feat(self, force=1):
"Returns the number of features in the Layer."
return capi.get_feature_count(self.ptr, force) | [
"def",
"num_feat",
"(",
"self",
",",
"force",
"=",
"1",
")",
":",
"return",
"capi",
".",
"get_feature_count",
"(",
"self",
".",
"ptr",
",",
"force",
")"
] | [
110,
4
] | [
112,
54
] | python | en | ['en', 'en', 'en'] | True |
Layer.num_fields | (self) | Returns the number of fields in the Layer. | Returns the number of fields in the Layer. | def num_fields(self):
"Returns the number of fields in the Layer."
return capi.get_field_count(self._ldefn) | [
"def",
"num_fields",
"(",
"self",
")",
":",
"return",
"capi",
".",
"get_field_count",
"(",
"self",
".",
"_ldefn",
")"
] | [
115,
4
] | [
117,
48
] | python | en | ['en', 'en', 'en'] | True |
Layer.geom_type | (self) | Returns the geometry type (OGRGeomType) of the Layer. | Returns the geometry type (OGRGeomType) of the Layer. | def geom_type(self):
"Returns the geometry type (OGRGeomType) of the Layer."
return OGRGeomType(capi.get_fd_geom_type(self._ldefn)) | [
"def",
"geom_type",
"(",
"self",
")",
":",
"return",
"OGRGeomType",
"(",
"capi",
".",
"get_fd_geom_type",
"(",
"self",
".",
"_ldefn",
")",
")"
] | [
120,
4
] | [
122,
62
] | python | en | ['en', 'en', 'en'] | True |
Layer.srs | (self) | Returns the Spatial Reference used in this Layer. | Returns the Spatial Reference used in this Layer. | def srs(self):
"Returns the Spatial Reference used in this Layer."
try:
ptr = capi.get_layer_srs(self.ptr)
return SpatialReference(srs_api.clone_srs(ptr))
except SRSException:
return None | [
"def",
"srs",
"(",
"self",
")",
":",
"try",
":",
"ptr",
"=",
"capi",
".",
"get_layer_srs",
"(",
"self",
".",
"ptr",
")",
"return",
"SpatialReference",
"(",
"srs_api",
".",
"clone_srs",
"(",
"ptr",
")",
")",
"except",
"SRSException",
":",
"return",
"Non... | [
125,
4
] | [
131,
23
] | python | en | ['en', 'en', 'en'] | True |
Layer.fields | (self) |
Returns a list of string names corresponding to each of the Fields
available in this Layer.
|
Returns a list of string names corresponding to each of the Fields
available in this Layer.
| def fields(self):
"""
Returns a list of string names corresponding to each of the Fields
available in this Layer.
"""
return [force_text(capi.get_field_name(capi.get_field_defn(self._ldefn, i)),
self._ds.encoding, strings_only=True)
for ... | [
"def",
"fields",
"(",
"self",
")",
":",
"return",
"[",
"force_text",
"(",
"capi",
".",
"get_field_name",
"(",
"capi",
".",
"get_field_defn",
"(",
"self",
".",
"_ldefn",
",",
"i",
")",
")",
",",
"self",
".",
"_ds",
".",
"encoding",
",",
"strings_only",
... | [
134,
4
] | [
141,
48
] | python | en | ['en', 'error', 'th'] | False |
Layer.field_types | (self) |
Returns a list of the types of fields in this Layer. For example,
the list [OFTInteger, OFTReal, OFTString] would be returned for
an OGR layer that had an integer, a floating-point, and string
fields.
|
Returns a list of the types of fields in this Layer. For example,
the list [OFTInteger, OFTReal, OFTString] would be returned for
an OGR layer that had an integer, a floating-point, and string
fields.
| def field_types(self):
"""
Returns a list of the types of fields in this Layer. For example,
the list [OFTInteger, OFTReal, OFTString] would be returned for
an OGR layer that had an integer, a floating-point, and string
fields.
"""
return [OGRFieldTypes[capi.get_... | [
"def",
"field_types",
"(",
"self",
")",
":",
"return",
"[",
"OGRFieldTypes",
"[",
"capi",
".",
"get_field_type",
"(",
"capi",
".",
"get_field_defn",
"(",
"self",
".",
"_ldefn",
",",
"i",
")",
")",
"]",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"nu... | [
144,
4
] | [
152,
48
] | python | en | ['en', 'error', 'th'] | False |
Layer.field_widths | (self) | Returns a list of the maximum field widths for the features. | Returns a list of the maximum field widths for the features. | def field_widths(self):
"Returns a list of the maximum field widths for the features."
return [capi.get_field_width(capi.get_field_defn(self._ldefn, i))
for i in range(self.num_fields)] | [
"def",
"field_widths",
"(",
"self",
")",
":",
"return",
"[",
"capi",
".",
"get_field_width",
"(",
"capi",
".",
"get_field_defn",
"(",
"self",
".",
"_ldefn",
",",
"i",
")",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"num_fields",
")",
"]"
] | [
155,
4
] | [
158,
48
] | python | en | ['en', 'en', 'en'] | True |
Layer.field_precisions | (self) | Returns the field precisions for the features. | Returns the field precisions for the features. | def field_precisions(self):
"Returns the field precisions for the features."
return [capi.get_field_precision(capi.get_field_defn(self._ldefn, i))
for i in range(self.num_fields)] | [
"def",
"field_precisions",
"(",
"self",
")",
":",
"return",
"[",
"capi",
".",
"get_field_precision",
"(",
"capi",
".",
"get_field_defn",
"(",
"self",
".",
"_ldefn",
",",
"i",
")",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"num_fields",
")",
"]"... | [
161,
4
] | [
164,
48
] | python | en | ['en', 'en', 'en'] | True |
Layer.get_fields | (self, field_name) |
Returns a list containing the given field name for every Feature
in the Layer.
|
Returns a list containing the given field name for every Feature
in the Layer.
| def get_fields(self, field_name):
"""
Returns a list containing the given field name for every Feature
in the Layer.
"""
if field_name not in self.fields:
raise GDALException('invalid field name: %s' % field_name)
return [feat.get(field_name) for feat in self] | [
"def",
"get_fields",
"(",
"self",
",",
"field_name",
")",
":",
"if",
"field_name",
"not",
"in",
"self",
".",
"fields",
":",
"raise",
"GDALException",
"(",
"'invalid field name: %s'",
"%",
"field_name",
")",
"return",
"[",
"feat",
".",
"get",
"(",
"field_name... | [
190,
4
] | [
197,
54
] | python | en | ['en', 'error', 'th'] | False |
Layer.get_geoms | (self, geos=False) |
Returns a list containing the OGRGeometry for every Feature in
the Layer.
|
Returns a list containing the OGRGeometry for every Feature in
the Layer.
| def get_geoms(self, geos=False):
"""
Returns a list containing the OGRGeometry for every Feature in
the Layer.
"""
if geos:
from django.contrib.gis.geos import GEOSGeometry
return [GEOSGeometry(feat.geom.wkb) for feat in self]
else:
ret... | [
"def",
"get_geoms",
"(",
"self",
",",
"geos",
"=",
"False",
")",
":",
"if",
"geos",
":",
"from",
"django",
".",
"contrib",
".",
"gis",
".",
"geos",
"import",
"GEOSGeometry",
"return",
"[",
"GEOSGeometry",
"(",
"feat",
".",
"geom",
".",
"wkb",
")",
"f... | [
199,
4
] | [
208,
47
] | python | en | ['en', 'error', 'th'] | False |
Layer.test_capability | (self, capability) |
Returns a bool indicating whether the this Layer supports the given
capability (a string). Valid capability strings include:
'RandomRead', 'SequentialWrite', 'RandomWrite', 'FastSpatialFilter',
'FastFeatureCount', 'FastGetExtent', 'CreateField', 'Transactions',
'DeleteFea... |
Returns a bool indicating whether the this Layer supports the given
capability (a string). Valid capability strings include:
'RandomRead', 'SequentialWrite', 'RandomWrite', 'FastSpatialFilter',
'FastFeatureCount', 'FastGetExtent', 'CreateField', 'Transactions',
'DeleteFea... | def test_capability(self, capability):
"""
Returns a bool indicating whether the this Layer supports the given
capability (a string). Valid capability strings include:
'RandomRead', 'SequentialWrite', 'RandomWrite', 'FastSpatialFilter',
'FastFeatureCount', 'FastGetExtent', '... | [
"def",
"test_capability",
"(",
"self",
",",
"capability",
")",
":",
"return",
"bool",
"(",
"capi",
".",
"test_capability",
"(",
"self",
".",
"ptr",
",",
"force_bytes",
"(",
"capability",
")",
")",
")"
] | [
210,
4
] | [
218,
76
] | python | en | ['en', 'error', 'th'] | False |
TestParsingCode.setUpClass | (cls) | Create manually parsed dict to check against | Create manually parsed dict to check against | def setUpClass(cls):
"""Create manually parsed dict to check against"""
example_config_str = """\
[test1]
float = 0.5 ; some comment
int = 1
string1 = bob ; default to string when no other parsers work
time1 = 2007-07-20T14:18:09.909001 ; times are parsed if matching this format
#But m... | [
"def",
"setUpClass",
"(",
"cls",
")",
":",
"example_config_str",
"=",
"\"\"\"\\\n[test1]\nfloat = 0.5 ; some comment\nint = 1\nstring1 = bob ; default to string when no other parsers work\ntime1 = 2007-07-20T14:18:09.909001 ; times are parsed if matching this format\n#But must have ... | [
20,
4
] | [
50,
48
] | python | en | ['en', 'en', 'en'] | True |
filesys_decode | (path) |
Ensure that the given path is decoded,
NONE when no expected encoding works
|
Ensure that the given path is decoded,
NONE when no expected encoding works
| def filesys_decode(path):
"""
Ensure that the given path is decoded,
NONE when no expected encoding works
"""
if isinstance(path, str):
return path
fs_enc = sys.getfilesystemencoding() or 'utf-8'
candidates = fs_enc, 'utf-8'
for enc in candidates:
try:
retu... | [
"def",
"filesys_decode",
"(",
"path",
")",
":",
"if",
"isinstance",
"(",
"path",
",",
"str",
")",
":",
"return",
"path",
"fs_enc",
"=",
"sys",
".",
"getfilesystemencoding",
"(",
")",
"or",
"'utf-8'",
"candidates",
"=",
"fs_enc",
",",
"'utf-8'",
"for",
"e... | [
17,
0
] | [
33,
20
] | python | en | ['en', 'error', 'th'] | False |
try_encode | (string, enc) | turn unicode encoding into a functional routine | turn unicode encoding into a functional routine | def try_encode(string, enc):
"turn unicode encoding into a functional routine"
try:
return string.encode(enc)
except UnicodeEncodeError:
return None | [
"def",
"try_encode",
"(",
"string",
",",
"enc",
")",
":",
"try",
":",
"return",
"string",
".",
"encode",
"(",
"enc",
")",
"except",
"UnicodeEncodeError",
":",
"return",
"None"
] | [
36,
0
] | [
41,
19
] | python | en | ['en', 'en', 'en'] | True |
FileField.get_prep_value | (self, value) | Returns field's value prepared for saving into a database. | Returns field's value prepared for saving into a database. | def get_prep_value(self, value):
"Returns field's value prepared for saving into a database."
value = super(FileField, self).get_prep_value(value)
# Need to convert File objects provided via a form to unicode for database insertion
if value is None:
return None
return... | [
"def",
"get_prep_value",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"super",
"(",
"FileField",
",",
"self",
")",
".",
"get_prep_value",
"(",
"value",
")",
"# Need to convert File objects provided via a form to unicode for database insertion",
"if",
"value",
"i... | [
283,
4
] | [
289,
35
] | python | en | ['en', 'en', 'en'] | True |
FileField.pre_save | (self, model_instance, add) | Returns field's value just before saving. | Returns field's value just before saving. | def pre_save(self, model_instance, add):
"Returns field's value just before saving."
file = super(FileField, self).pre_save(model_instance, add)
if file and not file._committed:
# Commit the file to storage prior to saving the model
file.save(file.name, file.file, save=Fa... | [
"def",
"pre_save",
"(",
"self",
",",
"model_instance",
",",
"add",
")",
":",
"file",
"=",
"super",
"(",
"FileField",
",",
"self",
")",
".",
"pre_save",
"(",
"model_instance",
",",
"add",
")",
"if",
"file",
"and",
"not",
"file",
".",
"_committed",
":",
... | [
291,
4
] | [
297,
19
] | python | en | ['en', 'en', 'en'] | True |
FileField.generate_filename | (self, instance, filename) |
Apply (if callable) or prepend (if a string) upload_to to the filename,
then delegate further processing of the name to the storage backend.
Until the storage layer, all file paths are expected to be Unix style
(with forward slashes).
|
Apply (if callable) or prepend (if a string) upload_to to the filename,
then delegate further processing of the name to the storage backend.
Until the storage layer, all file paths are expected to be Unix style
(with forward slashes).
| def generate_filename(self, instance, filename):
"""
Apply (if callable) or prepend (if a string) upload_to to the filename,
then delegate further processing of the name to the storage backend.
Until the storage layer, all file paths are expected to be Unix style
(with forward sl... | [
"def",
"generate_filename",
"(",
"self",
",",
"instance",
",",
"filename",
")",
":",
"if",
"callable",
"(",
"self",
".",
"upload_to",
")",
":",
"filename",
"=",
"self",
".",
"upload_to",
"(",
"instance",
",",
"filename",
")",
"else",
":",
"dirname",
"=",... | [
319,
4
] | [
331,
55
] | python | en | ['en', 'error', 'th'] | False |
ImageField.update_dimension_fields | (self, instance, force=False, *args, **kwargs) |
Updates field's width and height fields, if defined.
This method is hooked up to model's post_init signal to update
dimensions after instantiating a model instance. However, dimensions
won't be updated if the dimensions fields are already populated. This
avoids unnecessary re... |
Updates field's width and height fields, if defined. | def update_dimension_fields(self, instance, force=False, *args, **kwargs):
"""
Updates field's width and height fields, if defined.
This method is hooked up to model's post_init signal to update
dimensions after instantiating a model instance. However, dimensions
won't be updat... | [
"def",
"update_dimension_fields",
"(",
"self",
",",
"instance",
",",
"force",
"=",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Nothing to update if the field doesn't have dimension fields or if",
"# the field is deferred.",
"has_dimension_fields",
"="... | [
436,
4
] | [
491,
56
] | python | en | ['en', 'error', 'th'] | False |
property_name | (property: str, index: int) | The Freshdesk API is currently pretty broken: statuses are customizable
but the API will only tell you the number associated with the status, not
the name. While we engage the Freshdesk developers about exposing this
information through the API, since only FlightCar uses this integration,
hardcode their... | The Freshdesk API is currently pretty broken: statuses are customizable
but the API will only tell you the number associated with the status, not
the name. While we engage the Freshdesk developers about exposing this
information through the API, since only FlightCar uses this integration,
hardcode their... | def property_name(property: str, index: int) -> str:
"""The Freshdesk API is currently pretty broken: statuses are customizable
but the API will only tell you the number associated with the status, not
the name. While we engage the Freshdesk developers about exposing this
information through the API, si... | [
"def",
"property_name",
"(",
"property",
":",
"str",
",",
"index",
":",
"int",
")",
"->",
"str",
":",
"statuses",
"=",
"[",
"\"\"",
",",
"\"\"",
",",
"\"Open\"",
",",
"\"Pending\"",
",",
"\"Resolved\"",
",",
"\"Closed\"",
",",
"\"Waiting on Customer\"",
",... | [
44,
0
] | [
70,
15
] | python | en | ['en', 'en', 'en'] | True |
parse_freshdesk_event | (event_string: str) | These are always of the form "{ticket_action:created}" or
"{status:{from:4,to:6}}". Note the lack of string quoting: this isn't
valid JSON so we have to parse it ourselves.
| These are always of the form "{ticket_action:created}" or
"{status:{from:4,to:6}}". Note the lack of string quoting: this isn't
valid JSON so we have to parse it ourselves.
| def parse_freshdesk_event(event_string: str) -> List[str]:
"""These are always of the form "{ticket_action:created}" or
"{status:{from:4,to:6}}". Note the lack of string quoting: this isn't
valid JSON so we have to parse it ourselves.
"""
data = event_string.replace("{", "").replace("}", "").replace... | [
"def",
"parse_freshdesk_event",
"(",
"event_string",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"data",
"=",
"event_string",
".",
"replace",
"(",
"\"{\"",
",",
"\"\"",
")",
".",
"replace",
"(",
"\"}\"",
",",
"\"\"",
")",
".",
"replace",
"(",
... | [
73,
0
] | [
92,
9
] | python | en | ['en', 'en', 'en'] | True |
format_freshdesk_note_message | (ticket: TicketDict, event_info: List[str]) | There are public (visible to customers) and private note types. | There are public (visible to customers) and private note types. | def format_freshdesk_note_message(ticket: TicketDict, event_info: List[str]) -> str:
"""There are public (visible to customers) and private note types."""
note_type = event_info[1]
content = NOTE_TEMPLATE.format(
name=ticket.requester_name,
email=ticket.requester_email,
note_type=not... | [
"def",
"format_freshdesk_note_message",
"(",
"ticket",
":",
"TicketDict",
",",
"event_info",
":",
"List",
"[",
"str",
"]",
")",
"->",
"str",
":",
"note_type",
"=",
"event_info",
"[",
"1",
"]",
"content",
"=",
"NOTE_TEMPLATE",
".",
"format",
"(",
"name",
"=... | [
95,
0
] | [
106,
18
] | python | en | ['en', 'en', 'en'] | True |
format_freshdesk_property_change_message | (ticket: TicketDict, event_info: List[str]) | Freshdesk will only tell us the first event to match our webhook
configuration, so if we change multiple properties, we only get the before
and after data for the first one.
| Freshdesk will only tell us the first event to match our webhook
configuration, so if we change multiple properties, we only get the before
and after data for the first one.
| def format_freshdesk_property_change_message(ticket: TicketDict, event_info: List[str]) -> str:
"""Freshdesk will only tell us the first event to match our webhook
configuration, so if we change multiple properties, we only get the before
and after data for the first one.
"""
content = PROPERTY_CHAN... | [
"def",
"format_freshdesk_property_change_message",
"(",
"ticket",
":",
"TicketDict",
",",
"event_info",
":",
"List",
"[",
"str",
"]",
")",
"->",
"str",
":",
"content",
"=",
"PROPERTY_CHANGE_TEMPLATE",
".",
"format",
"(",
"name",
"=",
"ticket",
".",
"requester_na... | [
109,
0
] | [
124,
18
] | python | en | ['en', 'en', 'en'] | True |
format_freshdesk_ticket_creation_message | (ticket: TicketDict) | They send us the description as HTML. | They send us the description as HTML. | def format_freshdesk_ticket_creation_message(ticket: TicketDict) -> str:
"""They send us the description as HTML."""
cleaned_description = convert_html_to_markdown(ticket.description)
content = TICKET_CREATION_TEMPLATE.format(
name=ticket.requester_name,
email=ticket.requester_email,
... | [
"def",
"format_freshdesk_ticket_creation_message",
"(",
"ticket",
":",
"TicketDict",
")",
"->",
"str",
":",
"cleaned_description",
"=",
"convert_html_to_markdown",
"(",
"ticket",
".",
"description",
")",
"content",
"=",
"TICKET_CREATION_TEMPLATE",
".",
"format",
"(",
... | [
127,
0
] | [
141,
18
] | python | en | ['en', 'en', 'en'] | True |
test_multi_vault_preserved_on_put | (get, put, admin_user, job_template, vault_credential) |
A PUT request will necessarily specify deprecated fields, but if the deprecated
field is a singleton while the `credentials` relation has many, that makes
it very easy to drop those credentials not specified in the PUT data
|
A PUT request will necessarily specify deprecated fields, but if the deprecated
field is a singleton while the `credentials` relation has many, that makes
it very easy to drop those credentials not specified in the PUT data
| def test_multi_vault_preserved_on_put(get, put, admin_user, job_template, vault_credential):
"""
A PUT request will necessarily specify deprecated fields, but if the deprecated
field is a singleton while the `credentials` relation has many, that makes
it very easy to drop those credentials not specified... | [
"def",
"test_multi_vault_preserved_on_put",
"(",
"get",
",",
"put",
",",
"admin_user",
",",
"job_template",
",",
"vault_credential",
")",
":",
"vault2",
"=",
"Credential",
".",
"objects",
".",
"create",
"(",
"name",
"=",
"'second-vault'",
",",
"credential_type",
... | [
150,
0
] | [
164,
48
] | python | en | ['en', 'error', 'th'] | False |
MenuItem.is_shown | (self, request) |
Whether this menu item should be shown for the given request; permission
checks etc should go here. By default, menu items are shown all the time
|
Whether this menu item should be shown for the given request; permission
checks etc should go here. By default, menu items are shown all the time
| def is_shown(self, request):
"""
Whether this menu item should be shown for the given request; permission
checks etc should go here. By default, menu items are shown all the time
"""
return True | [
"def",
"is_shown",
"(",
"self",
",",
"request",
")",
":",
"return",
"True"
] | [
27,
4
] | [
32,
19
] | python | en | ['en', 'error', 'th'] | False |
MenuItem.get_context | (self, request) | Defines context for the template, overridable to use more data | Defines context for the template, overridable to use more data | def get_context(self, request):
"""Defines context for the template, overridable to use more data"""
return {
'name': self.name,
'url': self.url,
'classnames': self.classnames,
'icon_name': self.icon_name,
'attr_string': self.attr_string,
... | [
"def",
"get_context",
"(",
"self",
",",
"request",
")",
":",
"return",
"{",
"'name'",
":",
"self",
".",
"name",
",",
"'url'",
":",
"self",
".",
"url",
",",
"'classnames'",
":",
"self",
".",
"classnames",
",",
"'icon_name'",
":",
"self",
".",
"icon_name... | [
37,
4
] | [
47,
9
] | python | en | ['en', 'en', 'en'] | True |
DIDWallet.create_new_did_wallet | (
wallet_state_manager: Any,
wallet: Wallet,
amount: int,
backups_ids: List = [],
num_of_backup_ids_needed: uint64 = None,
name: str = None,
) |
This must be called under the wallet state manager lock
|
This must be called under the wallet state manager lock
| async def create_new_did_wallet(
wallet_state_manager: Any,
wallet: Wallet,
amount: int,
backups_ids: List = [],
num_of_backup_ids_needed: uint64 = None,
name: str = None,
):
"""
This must be called under the wallet state manager lock
"""
... | [
"async",
"def",
"create_new_did_wallet",
"(",
"wallet_state_manager",
":",
"Any",
",",
"wallet",
":",
"Wallet",
",",
"amount",
":",
"int",
",",
"backups_ids",
":",
"List",
"=",
"[",
"]",
",",
"num_of_backup_ids_needed",
":",
"uint64",
"=",
"None",
",",
"name... | [
43,
4
] | [
126,
19
] | python | en | ['en', 'error', 'th'] | False |
DIDWallet.select_coins | (self, amount, exclude: List[Coin] = None) | Returns a set of coins that can be used for generating a new transaction. | Returns a set of coins that can be used for generating a new transaction. | async def select_coins(self, amount, exclude: List[Coin] = None) -> Optional[Set[Coin]]:
"""Returns a set of coins that can be used for generating a new transaction."""
if exclude is None:
exclude = []
spendable_amount = await self.get_spendable_balance()
if amount > spendab... | [
"async",
"def",
"select_coins",
"(",
"self",
",",
"amount",
",",
"exclude",
":",
"List",
"[",
"Coin",
"]",
"=",
"None",
")",
"->",
"Optional",
"[",
"Set",
"[",
"Coin",
"]",
"]",
":",
"if",
"exclude",
"is",
"None",
":",
"exclude",
"=",
"[",
"]",
"... | [
242,
4
] | [
285,
25
] | python | en | ['en', 'en', 'en'] | True |
DIDWallet.coin_added | (self, coin: Coin, header_hash: bytes32, removals: List[Coin], height: int) | Notification from wallet state manager that wallet has been received. | Notification from wallet state manager that wallet has been received. | async def coin_added(self, coin: Coin, header_hash: bytes32, removals: List[Coin], height: int):
"""Notification from wallet state manager that wallet has been received."""
self.log.info("DID wallet has been notified that coin was added")
inner_puzzle = await self.inner_puzzle_for_did_puzzle(coi... | [
"async",
"def",
"coin_added",
"(",
"self",
",",
"coin",
":",
"Coin",
",",
"header_hash",
":",
"bytes32",
",",
"removals",
":",
"List",
"[",
"Coin",
"]",
",",
"height",
":",
"int",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"DID wallet has been n... | [
288,
4
] | [
310,
63
] | python | en | ['en', 'en', 'en'] | True |
DIDWallet.generate_new_decentralised_id | (self, amount: uint64) |
This must be called under the wallet state manager lock
|
This must be called under the wallet state manager lock
| async def generate_new_decentralised_id(self, amount: uint64) -> Optional[SpendBundle]:
"""
This must be called under the wallet state manager lock
"""
coins = await self.standard_wallet.select_coins(amount)
if coins is None:
return None
origin = coins.copy(... | [
"async",
"def",
"generate_new_decentralised_id",
"(",
"self",
",",
"amount",
":",
"uint64",
")",
"->",
"Optional",
"[",
"SpendBundle",
"]",
":",
"coins",
"=",
"await",
"self",
".",
"standard_wallet",
".",
"select_coins",
"(",
"amount",
")",
"if",
"coins",
"i... | [
755,
4
] | [
805,
25
] | python | en | ['en', 'error', 'th'] | False |
Create | (env=None) | Returns a new `Runfiles` instance.
The returned object is either:
- manifest-based, meaning it looks up runfile paths from a manifest file, or
- directory-based, meaning it looks up runfile paths under a given directory
path
If `env` contains "RUNFILES_MANIFEST_FILE" with non-empty value, this method
re... | Returns a new `Runfiles` instance. | def Create(env=None):
"""Returns a new `Runfiles` instance.
The returned object is either:
- manifest-based, meaning it looks up runfile paths from a manifest file, or
- directory-based, meaning it looks up runfile paths under a given directory
path
If `env` contains "RUNFILES_MANIFEST_FILE" with non-em... | [
"def",
"Create",
"(",
"env",
"=",
"None",
")",
":",
"env_map",
"=",
"os",
".",
"environ",
"if",
"env",
"is",
"None",
"else",
"env",
"manifest",
"=",
"env_map",
".",
"get",
"(",
"\"RUNFILES_MANIFEST_FILE\"",
")",
"if",
"manifest",
":",
"return",
"CreateMa... | [
79,
0
] | [
112,
13
] | python | en | ['en', 'lb', 'en'] | True |
_PathsFrom | (argv0, runfiles_mf, runfiles_dir, is_runfiles_manifest,
is_runfiles_directory) | Discover runfiles manifest and runfiles directory paths.
Args:
argv0: string; the value of sys.argv[0]
runfiles_mf: string; the value of the RUNFILES_MANIFEST_FILE environment
variable
runfiles_dir: string; the value of the RUNFILES_DIR environment variable
is_runfiles_manifest: lambda(string):... | Discover runfiles manifest and runfiles directory paths. | def _PathsFrom(argv0, runfiles_mf, runfiles_dir, is_runfiles_manifest,
is_runfiles_directory):
"""Discover runfiles manifest and runfiles directory paths.
Args:
argv0: string; the value of sys.argv[0]
runfiles_mf: string; the value of the RUNFILES_MANIFEST_FILE environment
variable
... | [
"def",
"_PathsFrom",
"(",
"argv0",
",",
"runfiles_mf",
",",
"runfiles_dir",
",",
"is_runfiles_manifest",
",",
"is_runfiles_directory",
")",
":",
"mf_alid",
"=",
"is_runfiles_manifest",
"(",
"runfiles_mf",
")",
"dir_valid",
"=",
"is_runfiles_directory",
"(",
"runfiles_... | [
244,
0
] | [
292,
76
] | python | en | ['en', 'en', 'en'] | True |
_Runfiles.Rlocation | (self, path) | Returns the runtime path of a runfile.
Runfiles are data-dependencies of Bazel-built binaries and tests.
The returned path may not be valid. The caller should check the path's
validity and that the path exists.
The function may return None. In that case the caller can be sure that the
rule does n... | Returns the runtime path of a runfile. | def Rlocation(self, path):
"""Returns the runtime path of a runfile.
Runfiles are data-dependencies of Bazel-built binaries and tests.
The returned path may not be valid. The caller should check the path's
validity and that the path exists.
The function may return None. In that case the caller ca... | [
"def",
"Rlocation",
"(",
"self",
",",
"path",
")",
":",
"if",
"not",
"path",
":",
"raise",
"ValueError",
"(",
")",
"if",
"not",
"isinstance",
"(",
"path",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
")",
"if",
"(",
"path",
".",
"startswith",
"... | [
124,
2
] | [
155,
48
] | python | en | ['en', 'en', 'en'] | True |
_Runfiles.EnvVars | (self) | Returns environment variables for subprocesses.
The caller should set the returned key-value pairs in the environment of
subprocesses in case those subprocesses are also Bazel-built binaries that
need to use runfiles.
Returns:
{string: string}; a dict; keys are environment variable names, values... | Returns environment variables for subprocesses. | def EnvVars(self):
"""Returns environment variables for subprocesses.
The caller should set the returned key-value pairs in the environment of
subprocesses in case those subprocesses are also Bazel-built binaries that
need to use runfiles.
Returns:
{string: string}; a dict; keys are environm... | [
"def",
"EnvVars",
"(",
"self",
")",
":",
"return",
"self",
".",
"_strategy",
".",
"EnvVars",
"(",
")"
] | [
157,
2
] | [
168,
35
] | python | en | ['en', 'en', 'en'] | True |
_ManifestBased._LoadRunfiles | (path) | Loads the runfiles manifest. | Loads the runfiles manifest. | def _LoadRunfiles(path):
"""Loads the runfiles manifest."""
result = {}
with open(path, "r") as f:
for line in f:
line = line.strip()
if line:
tokens = line.split(" ", 1)
if len(tokens) == 1:
result[line] = line
else:
result[tokens[... | [
"def",
"_LoadRunfiles",
"(",
"path",
")",
":",
"result",
"=",
"{",
"}",
"with",
"open",
"(",
"path",
",",
"\"r\"",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"if",
"line",
":",
"tokens",
"="... | [
186,
2
] | [
198,
17
] | python | en | ['en', 'co', 'en'] | True |
static | (prefix, view=serve, **kwargs) |
Helper function to return a URL pattern for serving files in debug mode.
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
# ... the rest of your URLconf goes here ...
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
Helper function to return a URL pattern for serving files in debug mode. | def static(prefix, view=serve, **kwargs):
"""
Helper function to return a URL pattern for serving files in debug mode.
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
# ... the rest of your URLconf goes here ...
] + static(settings.MEDIA_URL,... | [
"def",
"static",
"(",
"prefix",
",",
"view",
"=",
"serve",
",",
"*",
"*",
"kwargs",
")",
":",
"# No-op if not in debug mode or an non-local prefix",
"if",
"not",
"settings",
".",
"DEBUG",
"or",
"(",
"prefix",
"and",
"'://'",
"in",
"prefix",
")",
":",
"return... | [
8,
0
] | [
26,
5
] | python | en | ['en', 'error', 'th'] | False |
api_exception_handler | (exc, context) |
Override default API exception handler to catch IntegrityError exceptions.
|
Override default API exception handler to catch IntegrityError exceptions.
| def api_exception_handler(exc, context):
"""
Override default API exception handler to catch IntegrityError exceptions.
"""
if isinstance(exc, IntegrityError):
exc = ParseError(exc.args[0])
if isinstance(exc, FieldError):
exc = ParseError(exc.args[0])
if isinstance(context['view'... | [
"def",
"api_exception_handler",
"(",
"exc",
",",
"context",
")",
":",
"if",
"isinstance",
"(",
"exc",
",",
"IntegrityError",
")",
":",
"exc",
"=",
"ParseError",
"(",
"exc",
".",
"args",
"[",
"0",
"]",
")",
"if",
"isinstance",
"(",
"exc",
",",
"FieldErr... | [
187,
0
] | [
206,
42
] | python | en | ['en', 'error', 'th'] | False |
DashboardView.get | (self, request, format=None) | Show Dashboard Details | Show Dashboard Details | def get(self, request, format=None):
'''Show Dashboard Details'''
data = OrderedDict()
data['related'] = {'jobs_graph': reverse('api:dashboard_jobs_graph_view', request=request)}
user_inventory = get_user_queryset(request.user, models.Inventory)
inventory_with_failed_hosts = user... | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"format",
"=",
"None",
")",
":",
"data",
"=",
"OrderedDict",
"(",
")",
"data",
"[",
"'related'",
"]",
"=",
"{",
"'jobs_graph'",
":",
"reverse",
"(",
"'api:dashboard_jobs_graph_view'",
",",
"request",
"=",
"... | [
216,
4
] | [
305,
29
] | python | en | ['en', 'de', 'en'] | True |
UserDetail.update_filter | (self, request, *args, **kwargs) | make sure non-read-only fields that can only be edited by admins, are only edited by admins | make sure non-read-only fields that can only be edited by admins, are only edited by admins | def update_filter(self, request, *args, **kwargs):
'''make sure non-read-only fields that can only be edited by admins, are only edited by admins'''
obj = self.get_object()
can_change = request.user.can_access(models.User, 'change', obj, request.data)
can_admin = request.user.can_access(... | [
"def",
"update_filter",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"obj",
"=",
"self",
".",
"get_object",
"(",
")",
"can_change",
"=",
"request",
".",
"user",
".",
"can_access",
"(",
"models",
".",
"User",
",",
... | [
1321,
4
] | [
1344,
90
] | python | en | ['en', 'en', 'en'] | True |
JobTemplateLaunch.modernize_launch_payload | (self, data, obj) |
Steps to do simple translations of request data to support
old field structure to launch endpoint
TODO: delete this method with future API version changes
|
Steps to do simple translations of request data to support
old field structure to launch endpoint
TODO: delete this method with future API version changes
| def modernize_launch_payload(self, data, obj):
"""
Steps to do simple translations of request data to support
old field structure to launch endpoint
TODO: delete this method with future API version changes
"""
modern_data = data.copy()
id_fd = '{}_id'.format('inv... | [
"def",
"modernize_launch_payload",
"(",
"self",
",",
"data",
",",
"obj",
")",
":",
"modern_data",
"=",
"data",
".",
"copy",
"(",
")",
"id_fd",
"=",
"'{}_id'",
".",
"format",
"(",
"'inventory'",
")",
"if",
"'inventory'",
"not",
"in",
"modern_data",
"and",
... | [
2365,
4
] | [
2381,
26
] | python | en | ['en', 'error', 'th'] | False |
JobTemplateLaunch.sanitize_for_response | (self, data) |
Model objects cannot be serialized by DRF,
this replaces objects with their ids for inclusion in response
|
Model objects cannot be serialized by DRF,
this replaces objects with their ids for inclusion in response
| def sanitize_for_response(self, data):
"""
Model objects cannot be serialized by DRF,
this replaces objects with their ids for inclusion in response
"""
def display_value(val):
if hasattr(val, 'id'):
return val.id
else:
ret... | [
"def",
"sanitize_for_response",
"(",
"self",
",",
"data",
")",
":",
"def",
"display_value",
"(",
"val",
")",
":",
"if",
"hasattr",
"(",
"val",
",",
"'id'",
")",
":",
"return",
"val",
".",
"id",
"else",
":",
"return",
"val",
"sanitized_data",
"=",
"{",
... | [
2419,
4
] | [
2440,
29
] | python | en | ['en', 'error', 'th'] | False |
gaussian | (height, center_x, center_y, semimajor, semiminor, theta) | Return a 2D Gaussian function with the given parameters.
Args:
height (float): (z-)value of the 2D Gaussian
center_x (float): x center of the Gaussian
center_y (float): y center of the Gaussian
semimajor (float): major axis of the Gaussian
semiminor (float): minor axis ... | Return a 2D Gaussian function with the given parameters. | def gaussian(height, center_x, center_y, semimajor, semiminor, theta):
"""Return a 2D Gaussian function with the given parameters.
Args:
height (float): (z-)value of the 2D Gaussian
center_x (float): x center of the Gaussian
center_y (float): y center of the Gaussian
semimaj... | [
"def",
"gaussian",
"(",
"height",
",",
"center_x",
",",
"center_y",
",",
"semimajor",
",",
"semiminor",
",",
"theta",
")",
":",
"return",
"lambda",
"x",
",",
"y",
":",
"height",
"*",
"exp",
"(",
"-",
"log",
"(",
"2.0",
")",
"*",
"(",
"(",
"(",
"c... | [
6,
0
] | [
35,
43
] | python | en | ['en', 'en', 'en'] | True |
JumpDiffusionModel.__init__ | (self, random_seed=None) | Starting values for the model variables (unconditional expectation except for log-return) | Starting values for the model variables (unconditional expectation except for log-return) | def __init__(self, random_seed=None):
self.random_state = np.random.RandomState(seed=random_seed)
self.random_seed = random_seed
# Parameters based on the paper with slight modifications
self.r = 0.0
self.kappa_V = 3.011
self.theta_V = 0.0365
self.xi_V = 0.346
self.kappa_L = 2.353
s... | [
"def",
"__init__",
"(",
"self",
",",
"random_seed",
"=",
"None",
")",
":",
"self",
".",
"random_state",
"=",
"np",
".",
"random",
".",
"RandomState",
"(",
"seed",
"=",
"random_seed",
")",
"self",
".",
"random_seed",
"=",
"random_seed",
"# Parameters based on... | [
13,
2
] | [
54,
26
] | python | en | ['en', 'en', 'en'] | True |
JumpDiffusionModel.simulate_conditional | (self, X) | Draws random samples from the conditional distribution
Args:
X: x to be conditioned on when drawing a sample from y ~ p(y|x) - numpy array of shape (n_samples, 3)
thereby x is a horizontal stack of V, L and Psi
-> x = (V, L, Psi)
Returns: (X,Y)
- X: the x to of the conditi... | Draws random samples from the conditional distribution | def simulate_conditional(self, X):
""" Draws random samples from the conditional distribution
Args:
X: x to be conditioned on when drawing a sample from y ~ p(y|x) - numpy array of shape (n_samples, 3)
thereby x is a horizontal stack of V, L and Psi
-> x = (V, L, Psi)
Returns:... | [
"def",
"simulate_conditional",
"(",
"self",
",",
"X",
")",
":",
"X",
"=",
"self",
".",
"_handle_input_dimensionality",
"(",
"X",
")",
"V_sim",
",",
"L_sim",
",",
"Psi_sim",
"=",
"X",
"[",
":",
",",
"0",
"]",
",",
"X",
"[",
":",
",",
"1",
"]",
","... | [
65,
2
] | [
84,
15
] | python | en | ['en', 'en', 'en'] | True |
JumpDiffusionModel.simulate | (self, n_samples=10000) | Simulates a time-series of n_samples time steps
Args:
samples: (int) number of samples to be drawn from the joint distribution P(X,Y)
Returns: (X,Y)
- X: horizontal stack of simulated V (spot vol), L (illigudity) and Psi (latent state) - numpy array of shape (n_samples, 3)
- Y: log ret... | Simulates a time-series of n_samples time steps | def simulate(self, n_samples=10000):
""" Simulates a time-series of n_samples time steps
Args:
samples: (int) number of samples to be drawn from the joint distribution P(X,Y)
Returns: (X,Y)
- X: horizontal stack of simulated V (spot vol), L (illigudity) and Psi (latent state) - numpy array... | [
"def",
"simulate",
"(",
"self",
",",
"n_samples",
"=",
"10000",
")",
":",
"assert",
"n_samples",
">",
"0",
"N",
"=",
"1",
"y_sim",
"=",
"np",
".",
"zeros",
"(",
"(",
"n_samples",
"+",
"1",
",",
"N",
")",
")",
"V_sim",
"=",
"np",
".",
"zeros",
"... | [
86,
2
] | [
116,
15
] | python | en | ['en', 'en', 'en'] | True |
TestCompareRevisionsWithNonModelField.test_base_form_class_used | (self) | First ensure that the non-model field is appearing in edit. | First ensure that the non-model field is appearing in edit. | def test_base_form_class_used(self):
"""First ensure that the non-model field is appearing in edit."""
edit_url = reverse('wagtailadmin_pages:add', args=('tests', 'formclassadditionalfieldpage', self.test_page.id))
response = self.client.get(edit_url)
self.assertContains(response, '<inpu... | [
"def",
"test_base_form_class_used",
"(",
"self",
")",
":",
"edit_url",
"=",
"reverse",
"(",
"'wagtailadmin_pages:add'",
",",
"args",
"=",
"(",
"'tests'",
",",
"'formclassadditionalfieldpage'",
",",
"self",
".",
"test_page",
".",
"id",
")",
")",
"response",
"=",
... | [
353,
4
] | [
357,
121
] | python | en | ['en', 'en', 'en'] | True |
TestCompareRevisionsWithNonModelField.test_compare_revisions | (self) | Confirm that the non-model field is not shown in revision. | Confirm that the non-model field is not shown in revision. | def test_compare_revisions(self):
"""Confirm that the non-model field is not shown in revision."""
compare_url = reverse(
'wagtailadmin_pages:revisions_compare',
args=(self.test_page.id, self.test_page_revision.id, self.test_page_revision_new.id)
)
response = self... | [
"def",
"test_compare_revisions",
"(",
"self",
")",
":",
"compare_url",
"=",
"reverse",
"(",
"'wagtailadmin_pages:revisions_compare'",
",",
"args",
"=",
"(",
"self",
".",
"test_page",
".",
"id",
",",
"self",
".",
"test_page_revision",
".",
"id",
",",
"self",
".... | [
359,
4
] | [
368,
58
] | python | en | ['en', 'en', 'en'] | True |
TestRevisionsUnschedule.test_unschedule_view | (self) |
This tests that the unschedule view responds with a confirm page
|
This tests that the unschedule view responds with a confirm page
| def test_unschedule_view(self):
"""
This tests that the unschedule view responds with a confirm page
"""
response = self.client.get(reverse('wagtailadmin_pages:revisions_unschedule', args=(self.christmas_event.id, self.this_christmas_revision.id)))
self.assertEqual(response.statu... | [
"def",
"test_unschedule_view",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_pages:revisions_unschedule'",
",",
"args",
"=",
"(",
"self",
".",
"christmas_event",
".",
"id",
",",
"self",
".",
"t... | [
402,
4
] | [
408,
97
] | python | en | ['en', 'error', 'th'] | False |
TestRevisionsUnschedule.test_unschedule_view_invalid_page_id | (self) |
This tests that the unschedule view returns an error if the page id is invalid
|
This tests that the unschedule view returns an error if the page id is invalid
| def test_unschedule_view_invalid_page_id(self):
"""
This tests that the unschedule view returns an error if the page id is invalid
"""
# Get unschedule page
response = self.client.get(reverse('wagtailadmin_pages:revisions_unschedule', args=(12345, 67894)))
# Check that t... | [
"def",
"test_unschedule_view_invalid_page_id",
"(",
"self",
")",
":",
"# Get unschedule page",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_pages:revisions_unschedule'",
",",
"args",
"=",
"(",
"12345",
",",
"67894",
")",
... | [
410,
4
] | [
418,
51
] | python | en | ['en', 'error', 'th'] | False |
TestRevisionsUnschedule.test_unschedule_view_invalid_revision_id | (self) |
This tests that the unschedule view returns an error if the page id is invalid
|
This tests that the unschedule view returns an error if the page id is invalid
| def test_unschedule_view_invalid_revision_id(self):
"""
This tests that the unschedule view returns an error if the page id is invalid
"""
# Get unschedule page
response = self.client.get(reverse('wagtailadmin_pages:revisions_unschedule', args=(self.christmas_event.id, 67894)))
... | [
"def",
"test_unschedule_view_invalid_revision_id",
"(",
"self",
")",
":",
"# Get unschedule page",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_pages:revisions_unschedule'",
",",
"args",
"=",
"(",
"self",
".",
"christmas_even... | [
420,
4
] | [
428,
51
] | python | en | ['en', 'error', 'th'] | False |
TestRevisionsUnschedule.test_unschedule_view_bad_permissions | (self) |
This tests that the unschedule view doesn't allow users without publish permissions
|
This tests that the unschedule view doesn't allow users without publish permissions
| def test_unschedule_view_bad_permissions(self):
"""
This tests that the unschedule view doesn't allow users without publish permissions
"""
# Remove privileges from user
self.user.is_superuser = False
self.user.user_permissions.add(
Permission.objects.get(cont... | [
"def",
"test_unschedule_view_bad_permissions",
"(",
"self",
")",
":",
"# Remove privileges from user",
"self",
".",
"user",
".",
"is_superuser",
"=",
"False",
"self",
".",
"user",
".",
"user_permissions",
".",
"add",
"(",
"Permission",
".",
"objects",
".",
"get",
... | [
430,
4
] | [
445,
51
] | python | en | ['en', 'error', 'th'] | False |
TestRevisionsUnschedule.test_unschedule_view_post | (self) |
This posts to the unschedule view and checks that the revision was unscheduled
|
This posts to the unschedule view and checks that the revision was unscheduled
| def test_unschedule_view_post(self):
"""
This posts to the unschedule view and checks that the revision was unscheduled
"""
# Post to the unschedule page
response = self.client.post(reverse('wagtailadmin_pages:revisions_unschedule', args=(self.christmas_event.id, self.this_chris... | [
"def",
"test_unschedule_view_post",
"(",
"self",
")",
":",
"# Post to the unschedule page",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtailadmin_pages:revisions_unschedule'",
",",
"args",
"=",
"(",
"self",
".",
"christmas_event",
... | [
447,
4
] | [
462,
117
] | python | en | ['en', 'error', 'th'] | False |
TestRevisionsUnscheduleForUnpublishedPages.test_unschedule_view | (self) |
This tests that the unschedule view responds with a confirm page
|
This tests that the unschedule view responds with a confirm page
| def test_unschedule_view(self):
"""
This tests that the unschedule view responds with a confirm page
"""
response = self.client.get(reverse('wagtailadmin_pages:revisions_unschedule', args=(self.unpublished_event.id, self.unpublished_revision.id)))
self.assertEqual(response.status... | [
"def",
"test_unschedule_view",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_pages:revisions_unschedule'",
",",
"args",
"=",
"(",
"self",
".",
"unpublished_event",
".",
"id",
",",
"self",
".",
... | [
481,
4
] | [
487,
97
] | python | en | ['en', 'error', 'th'] | False |
TestRevisionsUnscheduleForUnpublishedPages.test_unschedule_view_post | (self) |
This posts to the unschedule view and checks that the revision was unscheduled
|
This posts to the unschedule view and checks that the revision was unscheduled
| def test_unschedule_view_post(self):
"""
This posts to the unschedule view and checks that the revision was unscheduled
"""
# Post to the unschedule page
response = self.client.post(reverse('wagtailadmin_pages:revisions_unschedule', args=(self.unpublished_event.id, self.unpublis... | [
"def",
"test_unschedule_view_post",
"(",
"self",
")",
":",
"# Post to the unschedule page",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtailadmin_pages:revisions_unschedule'",
",",
"args",
"=",
"(",
"self",
".",
"unpublished_event",
... | [
489,
4
] | [
504,
116
] | python | en | ['en', 'error', 'th'] | False |
cluster | (data, k, temp, num_iter, init, cluster_temp) |
pytorch (differentiable) implementation of soft k-means clustering.
Modified from https://github.com/bwilder0/clusternet
|
pytorch (differentiable) implementation of soft k-means clustering.
Modified from https://github.com/bwilder0/clusternet
| def cluster(data, k, temp, num_iter, init, cluster_temp):
'''
pytorch (differentiable) implementation of soft k-means clustering.
Modified from https://github.com/bwilder0/clusternet
'''
cuda0 = torch.cuda.is_available()#False
if cuda0:
mu = init.cuda()
data = dat... | [
"def",
"cluster",
"(",
"data",
",",
"k",
",",
"temp",
",",
"num_iter",
",",
"init",
",",
"cluster_temp",
")",
":",
"cuda0",
"=",
"torch",
".",
"cuda",
".",
"is_available",
"(",
")",
"#False",
"if",
"cuda0",
":",
"mu",
"=",
"init",
".",
"cuda",
"(",... | [
104,
0
] | [
146,
16
] | python | en | ['en', 'error', 'th'] | False |
request | (method, url, **kwargs) | Constructs and sends a :class:`Request <Request>`.
:param method: method for the new :class:`Request` object: ``GET``, ``OPTIONS``, ``HEAD``, ``POST``, ``PUT``, ``PATCH``, or ``DELETE``.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary, list of tuples or bytes to se... | Constructs and sends a :class:`Request <Request>`. | def request(method, url, **kwargs):
"""Constructs and sends a :class:`Request <Request>`.
:param method: method for the new :class:`Request` object: ``GET``, ``OPTIONS``, ``HEAD``, ``POST``, ``PUT``, ``PATCH``, or ``DELETE``.
:param url: URL for the new :class:`Request` object.
:param params: (optional... | [
"def",
"request",
"(",
"method",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"# By using the 'with' statement we are sure the session is closed, thus we",
"# avoid leaving sockets open which can trigger a ResourceWarning in some",
"# cases, and look like a memory leak in others.",
"... | [
15,
0
] | [
60,
64
] | python | en | ['en', 'en', 'en'] | True |
get | (url, params=None, **kwargs) | r"""Sends a GET request.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary, list of tuples or bytes to send
in the query string for the :class:`Request`.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:return: :class:`Response <Response>` o... | r"""Sends a GET request. | def get(url, params=None, **kwargs):
r"""Sends a GET request.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary, list of tuples or bytes to send
in the query string for the :class:`Request`.
:param \*\*kwargs: Optional arguments that ``request`` takes.
... | [
"def",
"get",
"(",
"url",
",",
"params",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'allow_redirects'",
",",
"True",
")",
"return",
"request",
"(",
"'get'",
",",
"url",
",",
"params",
"=",
"params",
",",
"*",
... | [
63,
0
] | [
75,
55
] | python | en | ['en', 'co', 'en'] | True |
options | (url, **kwargs) | r"""Sends an OPTIONS request.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:return: :class:`Response <Response>` object
:rtype: requests.Response
| r"""Sends an OPTIONS request. | def options(url, **kwargs):
r"""Sends an OPTIONS request.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:return: :class:`Response <Response>` object
:rtype: requests.Response
"""
kwargs.setdefault('allow_redirects', True)... | [
"def",
"options",
"(",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'allow_redirects'",
",",
"True",
")",
"return",
"request",
"(",
"'options'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
78,
0
] | [
88,
44
] | python | en | ['en', 'en', 'en'] | True |
head | (url, **kwargs) | r"""Sends a HEAD request.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes. If
`allow_redirects` is not provided, it will be set to `False` (as
opposed to the default :meth:`request` behavior).
:return: :class:`Response <Respo... | r"""Sends a HEAD request. | def head(url, **kwargs):
r"""Sends a HEAD request.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes. If
`allow_redirects` is not provided, it will be set to `False` (as
opposed to the default :meth:`request` behavior).
:re... | [
"def",
"head",
"(",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'allow_redirects'",
",",
"False",
")",
"return",
"request",
"(",
"'head'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
91,
0
] | [
103,
41
] | python | en | ['en', 'co', 'en'] | True |
post | (url, data=None, json=None, **kwargs) | r"""Sends a POST request.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) json data to send in the body of the :class:`Request`.
:param \*\*kw... | r"""Sends a POST request. | def post(url, data=None, json=None, **kwargs):
r"""Sends a POST request.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) json data to send in ... | [
"def",
"post",
"(",
"url",
",",
"data",
"=",
"None",
",",
"json",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"request",
"(",
"'post'",
",",
"url",
",",
"data",
"=",
"data",
",",
"json",
"=",
"json",
",",
"*",
"*",
"kwargs",
")"
] | [
106,
0
] | [
118,
63
] | python | en | ['en', 'en', 'en'] | True |
put | (url, data=None, **kwargs) | r"""Sends a PUT request.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) json data to send in the body of the :class:`Request`.
:param \*\*kwa... | r"""Sends a PUT request. | def put(url, data=None, **kwargs):
r"""Sends a PUT request.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) json data to send in the body of t... | [
"def",
"put",
"(",
"url",
",",
"data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"request",
"(",
"'put'",
",",
"url",
",",
"data",
"=",
"data",
",",
"*",
"*",
"kwargs",
")"
] | [
121,
0
] | [
133,
51
] | python | en | ['en', 'co', 'en'] | True |
patch | (url, data=None, **kwargs) | r"""Sends a PATCH request.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) json data to send in the body of the :class:`Request`.
:param \*\*k... | r"""Sends a PATCH request. | def patch(url, data=None, **kwargs):
r"""Sends a PATCH request.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) json data to send in the body ... | [
"def",
"patch",
"(",
"url",
",",
"data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"request",
"(",
"'patch'",
",",
"url",
",",
"data",
"=",
"data",
",",
"*",
"*",
"kwargs",
")"
] | [
136,
0
] | [
148,
53
] | python | en | ['en', 'co', 'en'] | True |
delete | (url, **kwargs) | r"""Sends a DELETE request.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:return: :class:`Response <Response>` object
:rtype: requests.Response
| r"""Sends a DELETE request. | def delete(url, **kwargs):
r"""Sends a DELETE request.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:return: :class:`Response <Response>` object
:rtype: requests.Response
"""
return request('delete', url, **kwargs) | [
"def",
"delete",
"(",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"request",
"(",
"'delete'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
151,
0
] | [
160,
43
] | python | en | ['en', 'it', 'en'] | True |
image_entity | (props) |
Helper to construct elements of the form
<embed alt="Right-aligned image" embedtype="image" format="right" id="1"/>
when converting from contentstate data
|
Helper to construct elements of the form
<embed alt="Right-aligned image" embedtype="image" format="right" id="1"/>
when converting from contentstate data
| def image_entity(props):
"""
Helper to construct elements of the form
<embed alt="Right-aligned image" embedtype="image" format="right" id="1"/>
when converting from contentstate data
"""
return DOM.create_element('embed', {
'embedtype': 'image',
'format': props.get('format'),
... | [
"def",
"image_entity",
"(",
"props",
")",
":",
"return",
"DOM",
".",
"create_element",
"(",
"'embed'",
",",
"{",
"'embedtype'",
":",
"'image'",
",",
"'format'",
":",
"props",
".",
"get",
"(",
"'format'",
")",
",",
"'id'",
":",
"props",
".",
"get",
"(",... | [
11,
0
] | [
22,
6
] | python | en | ['en', 'error', 'th'] | False |
_find_vc2017 | () | Returns "15, path" based on the result of invoking vswhere.exe
If no install is found, returns "None, None"
The version is returned to avoid unnecessarily changing the function
result. It may be ignored when the path is not None.
If vswhere.exe is not available, by definition, VS 2017 is not
insta... | Returns "15, path" based on the result of invoking vswhere.exe
If no install is found, returns "None, None" | def _find_vc2017():
"""Returns "15, path" based on the result of invoking vswhere.exe
If no install is found, returns "None, None"
The version is returned to avoid unnecessarily changing the function
result. It may be ignored when the path is not None.
If vswhere.exe is not available, by definitio... | [
"def",
"_find_vc2017",
"(",
")",
":",
"root",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\"ProgramFiles(x86)\"",
")",
"or",
"os",
".",
"environ",
".",
"get",
"(",
"\"ProgramFiles\"",
")",
"if",
"not",
"root",
":",
"return",
"None",
",",
"None",
"try"... | [
59,
0
] | [
89,
21
] | python | en | ['en', 'en', 'en'] | True |
_find_exe | (exe, paths=None) | Return path to an MSVC executable program.
Tries to find the program in several places: first, one of the
MSVC program search paths from the registry; next, the directories
in the PATH environment variable. If any of those work, return an
absolute path that is known to exist. If none of them work, ju... | Return path to an MSVC executable program. | def _find_exe(exe, paths=None):
"""Return path to an MSVC executable program.
Tries to find the program in several places: first, one of the
MSVC program search paths from the registry; next, the directories
in the PATH environment variable. If any of those work, return an
absolute path that is kn... | [
"def",
"_find_exe",
"(",
"exe",
",",
"paths",
"=",
"None",
")",
":",
"if",
"not",
"paths",
":",
"paths",
"=",
"os",
".",
"getenv",
"(",
"'path'",
")",
".",
"split",
"(",
"os",
".",
"pathsep",
")",
"for",
"p",
"in",
"paths",
":",
"fn",
"=",
"os"... | [
146,
0
] | [
161,
14
] | python | en | ['en', 'en', 'en'] | True |
MSVCCompiler._fallback_spawn | (self, cmd, env) |
Discovered in pypa/distutils#15, some tools monkeypatch the compiler,
so the 'env' kwarg causes a TypeError. Detect this condition and
restore the legacy, unsafe behavior.
|
Discovered in pypa/distutils#15, some tools monkeypatch the compiler,
so the 'env' kwarg causes a TypeError. Detect this condition and
restore the legacy, unsafe behavior.
| def _fallback_spawn(self, cmd, env):
"""
Discovered in pypa/distutils#15, some tools monkeypatch the compiler,
so the 'env' kwarg causes a TypeError. Detect this condition and
restore the legacy, unsafe behavior.
"""
bag = type('Bag', (), {})()
try:
yi... | [
"def",
"_fallback_spawn",
"(",
"self",
",",
"cmd",
",",
"env",
")",
":",
"bag",
"=",
"type",
"(",
"'Bag'",
",",
"(",
")",
",",
"{",
"}",
")",
"(",
")",
"try",
":",
"yield",
"bag",
"except",
"TypeError",
"as",
"exc",
":",
"if",
"\"unexpected keyword... | [
513,
4
] | [
530,
42
] | python | en | ['en', 'error', 'th'] | False |
julian_date | (time=None, modified=False) |
Calculate the Julian date at a given timestamp.
Args:
time (datetime.datetime): Timestamp to calculate JD for.
modified (bool): If True, return the Modified Julian Date:
the number of days (including fractions) which have elapsed between
the start of 17 November 1858 ... |
Calculate the Julian date at a given timestamp. | def julian_date(time=None, modified=False):
"""
Calculate the Julian date at a given timestamp.
Args:
time (datetime.datetime): Timestamp to calculate JD for.
modified (bool): If True, return the Modified Julian Date:
the number of days (including fractions) which have elapsed... | [
"def",
"julian_date",
"(",
"time",
"=",
"None",
",",
"modified",
"=",
"False",
")",
":",
"if",
"not",
"time",
":",
"time",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
"pytz",
".",
"utc",
")",
"mjdstart",
"=",
"datetime",
".",
"datetime",
"(",
... | [
32,
0
] | [
54,
36
] | python | en | ['en', 'error', 'th'] | False |
mjd2datetime | (mjd) |
Convert a Modified Julian Date to datetime via 'unix time' representation.
NB 'unix time' is defined by the casacore/casacore package.
|
Convert a Modified Julian Date to datetime via 'unix time' representation. | def mjd2datetime(mjd):
"""
Convert a Modified Julian Date to datetime via 'unix time' representation.
NB 'unix time' is defined by the casacore/casacore package.
"""
q = quantity("%sd" % mjd)
return datetime.datetime.fromtimestamp(q.to_unix_time()) | [
"def",
"mjd2datetime",
"(",
"mjd",
")",
":",
"q",
"=",
"quantity",
"(",
"\"%sd\"",
"%",
"mjd",
")",
"return",
"datetime",
".",
"datetime",
".",
"fromtimestamp",
"(",
"q",
".",
"to_unix_time",
"(",
")",
")"
] | [
57,
0
] | [
64,
60
] | python | en | ['en', 'error', 'th'] | False |
mjd2lst | (mjd, position=None) |
Converts a Modified Julian Date into Local Apparent Sidereal Time in
seconds at a given position. If position is None, we default to the
reference position of CS002.
mjd -- Modified Julian Date (float, in days)
position -- Position (casacore measure)
|
Converts a Modified Julian Date into Local Apparent Sidereal Time in
seconds at a given position. If position is None, we default to the
reference position of CS002. | def mjd2lst(mjd, position=None):
"""
Converts a Modified Julian Date into Local Apparent Sidereal Time in
seconds at a given position. If position is None, we default to the
reference position of CS002.
mjd -- Modified Julian Date (float, in days)
position -- Position (casacore measure)
"""... | [
"def",
"mjd2lst",
"(",
"mjd",
",",
"position",
"=",
"None",
")",
":",
"dm",
"=",
"measures",
"(",
")",
"position",
"=",
"position",
"or",
"dm",
".",
"position",
"(",
"\"ITRF\"",
",",
"\"%fm\"",
"%",
"ITRF_X",
",",
"\"%fm\"",
"%",
"ITRF_Y",
",",
"\"%f... | [
67,
0
] | [
83,
48
] | python | en | ['en', 'error', 'th'] | False |
mjds2lst | (mjds, position=None) |
As mjd2lst(), but takes an argument in seconds rather than days.
Args:
mjds (float):Modified Julian Date (in seconds)
position (casacore measure): Position for LST calcs
|
As mjd2lst(), but takes an argument in seconds rather than days. | def mjds2lst(mjds, position=None):
"""
As mjd2lst(), but takes an argument in seconds rather than days.
Args:
mjds (float):Modified Julian Date (in seconds)
position (casacore measure): Position for LST calcs
"""
return mjd2lst(mjds/SECONDS_IN_DAY, position) | [
"def",
"mjds2lst",
"(",
"mjds",
",",
"position",
"=",
"None",
")",
":",
"return",
"mjd2lst",
"(",
"mjds",
"/",
"SECONDS_IN_DAY",
",",
"position",
")"
] | [
86,
0
] | [
94,
49
] | python | en | ['en', 'error', 'th'] | False |
jd2lst | (jd, position=None) |
Converts a Julian Date into Local Apparent Sidereal Time in seconds at a
given position. If position is None, we default to the reference position
of CS002.
Args:
jd (float): Julian Date
position (casacore measure): Position for LST calcs.
|
Converts a Julian Date into Local Apparent Sidereal Time in seconds at a
given position. If position is None, we default to the reference position
of CS002. | def jd2lst(jd, position=None):
"""
Converts a Julian Date into Local Apparent Sidereal Time in seconds at a
given position. If position is None, we default to the reference position
of CS002.
Args:
jd (float): Julian Date
position (casacore measure): Position for LST calcs.
"""
... | [
"def",
"jd2lst",
"(",
"jd",
",",
"position",
"=",
"None",
")",
":",
"return",
"mjd2lst",
"(",
"jd",
"-",
"2400000.5",
",",
"position",
")"
] | [
97,
0
] | [
107,
44
] | python | en | ['en', 'error', 'th'] | False |
julian2unix | (timestamp) |
Convert a modifed julian timestamp (number of seconds since 17 November
1858) to Unix timestamp (number of seconds since 1 January 1970).
Args:
timestamp (numbers.Number): Number of seconds since the Unix epoch.
Returns:
numbers.Number: Number of seconds since the modified Julian epoc... |
Convert a modifed julian timestamp (number of seconds since 17 November
1858) to Unix timestamp (number of seconds since 1 January 1970). | def julian2unix(timestamp):
"""
Convert a modifed julian timestamp (number of seconds since 17 November
1858) to Unix timestamp (number of seconds since 1 January 1970).
Args:
timestamp (numbers.Number): Number of seconds since the Unix epoch.
Returns:
numbers.Number: Number of sec... | [
"def",
"julian2unix",
"(",
"timestamp",
")",
":",
"return",
"timestamp",
"-",
"unix_epoch"
] | [
125,
0
] | [
136,
33
] | python | en | ['en', 'error', 'th'] | False |
unix2julian | (timestamp) |
Convert a Unix timestamp (number of seconds since 1 January 1970) to a
modified Julian timestamp (number of seconds since 17 November 1858).
Args:
timestamp (numbers.Number): Number of seconds since the modified
Julian epoch.
Returns:
numbers.Number: Number of seconds sinc... |
Convert a Unix timestamp (number of seconds since 1 January 1970) to a
modified Julian timestamp (number of seconds since 17 November 1858). | def unix2julian(timestamp):
"""
Convert a Unix timestamp (number of seconds since 1 January 1970) to a
modified Julian timestamp (number of seconds since 17 November 1858).
Args:
timestamp (numbers.Number): Number of seconds since the modified
Julian epoch.
Returns:
num... | [
"def",
"unix2julian",
"(",
"timestamp",
")",
":",
"return",
"timestamp",
"+",
"unix_epoch"
] | [
139,
0
] | [
151,
33
] | python | en | ['en', 'error', 'th'] | False |
sec2deg | (seconds) | Seconds of time to degrees of arc | Seconds of time to degrees of arc | def sec2deg(seconds):
"""Seconds of time to degrees of arc"""
return 15.0 * seconds / 3600.0 | [
"def",
"sec2deg",
"(",
"seconds",
")",
":",
"return",
"15.0",
"*",
"seconds",
"/",
"3600.0"
] | [
154,
0
] | [
156,
34
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.