id_within_dataset
int64 1
55.5k
| snippet
stringlengths 19
14.2k
| tokens
listlengths 6
1.63k
| nl
stringlengths 6
352
| split_within_dataset
stringclasses 1
value | is_duplicated
bool 2
classes |
|---|---|---|---|---|---|
50,343
|
def register_callback(operation, resource_type=EXP_RESOURCE_TYPE):
callback = mock.Mock(__name__='callback', im_class=mock.Mock(__name__='class'))
notifications.register_event_callback(operation, resource_type, callback)
return callback
|
[
"def",
"register_callback",
"(",
"operation",
",",
"resource_type",
"=",
"EXP_RESOURCE_TYPE",
")",
":",
"callback",
"=",
"mock",
".",
"Mock",
"(",
"__name__",
"=",
"'callback'",
",",
"im_class",
"=",
"mock",
".",
"Mock",
"(",
"__name__",
"=",
"'class'",
")",
")",
"notifications",
".",
"register_event_callback",
"(",
"operation",
",",
"resource_type",
",",
"callback",
")",
"return",
"callback"
] |
helper for creating and registering a mock callback .
|
train
| false
|
50,344
|
def get_app_errors():
global _app_errors
get_apps()
return _app_errors
|
[
"def",
"get_app_errors",
"(",
")",
":",
"global",
"_app_errors",
"get_apps",
"(",
")",
"return",
"_app_errors"
] |
returns the map of known problems with the installed_apps .
|
train
| false
|
50,345
|
def image_in_image(im1, im2, tp):
(m, n) = im1.shape[:2]
fp = array([[0, m, m, 0], [0, 0, n, n], [1, 1, 1, 1]])
H = homography.Haffine_from_points(tp, fp)
im1_t = ndimage.affine_transform(im1, H[:2, :2], (H[(0, 2)], H[(1, 2)]), im2.shape[:2])
alpha = (im1_t > 0)
return (((1 - alpha) * im2) + (alpha * im1_t))
|
[
"def",
"image_in_image",
"(",
"im1",
",",
"im2",
",",
"tp",
")",
":",
"(",
"m",
",",
"n",
")",
"=",
"im1",
".",
"shape",
"[",
":",
"2",
"]",
"fp",
"=",
"array",
"(",
"[",
"[",
"0",
",",
"m",
",",
"m",
",",
"0",
"]",
",",
"[",
"0",
",",
"0",
",",
"n",
",",
"n",
"]",
",",
"[",
"1",
",",
"1",
",",
"1",
",",
"1",
"]",
"]",
")",
"H",
"=",
"homography",
".",
"Haffine_from_points",
"(",
"tp",
",",
"fp",
")",
"im1_t",
"=",
"ndimage",
".",
"affine_transform",
"(",
"im1",
",",
"H",
"[",
":",
"2",
",",
":",
"2",
"]",
",",
"(",
"H",
"[",
"(",
"0",
",",
"2",
")",
"]",
",",
"H",
"[",
"(",
"1",
",",
"2",
")",
"]",
")",
",",
"im2",
".",
"shape",
"[",
":",
"2",
"]",
")",
"alpha",
"=",
"(",
"im1_t",
">",
"0",
")",
"return",
"(",
"(",
"(",
"1",
"-",
"alpha",
")",
"*",
"im2",
")",
"+",
"(",
"alpha",
"*",
"im1_t",
")",
")"
] |
put im1 in im2 with an affine transformation such that corners are as close to tp as possible .
|
train
| false
|
50,347
|
def n_deep(obj, names):
for name in names:
try:
obj = getattr(obj, name)
except KeyError:
raise APIError(('This object is missing the %s attribute.' % name), obj)
return obj
|
[
"def",
"n_deep",
"(",
"obj",
",",
"names",
")",
":",
"for",
"name",
"in",
"names",
":",
"try",
":",
"obj",
"=",
"getattr",
"(",
"obj",
",",
"name",
")",
"except",
"KeyError",
":",
"raise",
"APIError",
"(",
"(",
"'This object is missing the %s attribute.'",
"%",
"name",
")",
",",
"obj",
")",
"return",
"obj"
] |
a function to descend len levels in an object and retrieve the attribute there .
|
train
| false
|
50,350
|
def set_chassis_location(location, host=None, admin_username=None, admin_password=None):
return __execute_cmd('setsysinfo -c chassislocation {0}'.format(location), host=host, admin_username=admin_username, admin_password=admin_password)
|
[
"def",
"set_chassis_location",
"(",
"location",
",",
"host",
"=",
"None",
",",
"admin_username",
"=",
"None",
",",
"admin_password",
"=",
"None",
")",
":",
"return",
"__execute_cmd",
"(",
"'setsysinfo -c chassislocation {0}'",
".",
"format",
"(",
"location",
")",
",",
"host",
"=",
"host",
",",
"admin_username",
"=",
"admin_username",
",",
"admin_password",
"=",
"admin_password",
")"
] |
set the location of the chassis .
|
train
| true
|
50,352
|
def _GetDefines(config):
defines = []
for d in config.get('defines', []):
if (type(d) == list):
fd = '='.join([str(dpart) for dpart in d])
else:
fd = str(d)
defines.append(fd)
return defines
|
[
"def",
"_GetDefines",
"(",
"config",
")",
":",
"defines",
"=",
"[",
"]",
"for",
"d",
"in",
"config",
".",
"get",
"(",
"'defines'",
",",
"[",
"]",
")",
":",
"if",
"(",
"type",
"(",
"d",
")",
"==",
"list",
")",
":",
"fd",
"=",
"'='",
".",
"join",
"(",
"[",
"str",
"(",
"dpart",
")",
"for",
"dpart",
"in",
"d",
"]",
")",
"else",
":",
"fd",
"=",
"str",
"(",
"d",
")",
"defines",
".",
"append",
"(",
"fd",
")",
"return",
"defines"
] |
returns the list of preprocessor definitions for this configuation .
|
train
| false
|
50,353
|
def clean_description(desc):
return textwrap.dedent(desc)
|
[
"def",
"clean_description",
"(",
"desc",
")",
":",
"return",
"textwrap",
".",
"dedent",
"(",
"desc",
")"
] |
cleans a description .
|
train
| false
|
50,355
|
@library.global_function
def thisyear():
return jinja2.Markup(datetime.date.today().year)
|
[
"@",
"library",
".",
"global_function",
"def",
"thisyear",
"(",
")",
":",
"return",
"jinja2",
".",
"Markup",
"(",
"datetime",
".",
"date",
".",
"today",
"(",
")",
".",
"year",
")"
] |
the current year .
|
train
| false
|
50,356
|
@checker('.html', severity=2, falsepositives=True)
def check_leaked_markup(fn, lines):
for (lno, line) in enumerate(lines):
if leaked_markup_re.search(line):
(yield ((lno + 1), ('possibly leaked markup: %r' % line)))
|
[
"@",
"checker",
"(",
"'.html'",
",",
"severity",
"=",
"2",
",",
"falsepositives",
"=",
"True",
")",
"def",
"check_leaked_markup",
"(",
"fn",
",",
"lines",
")",
":",
"for",
"(",
"lno",
",",
"line",
")",
"in",
"enumerate",
"(",
"lines",
")",
":",
"if",
"leaked_markup_re",
".",
"search",
"(",
"line",
")",
":",
"(",
"yield",
"(",
"(",
"lno",
"+",
"1",
")",
",",
"(",
"'possibly leaked markup: %r'",
"%",
"line",
")",
")",
")"
] |
check html files for leaked rest markup; this only works if the html files have been built .
|
train
| false
|
50,357
|
def create_source_index():
create_index()
return STORAGE.create_index(SourceSchema(), 'source')
|
[
"def",
"create_source_index",
"(",
")",
":",
"create_index",
"(",
")",
"return",
"STORAGE",
".",
"create_index",
"(",
"SourceSchema",
"(",
")",
",",
"'source'",
")"
] |
creates source string index .
|
train
| false
|
50,358
|
def send_suggestion_email(exploration_title, exploration_id, author_id, recipient_list):
email_subject = ('New suggestion for "%s"' % exploration_title)
email_body_template = 'Hi %s,<br>%s has submitted a new suggestion for your Oppia exploration, <a href="https://www.oppia.org/create/%s">"%s"</a>.<br>You can accept or reject this suggestion by visiting the <a href="https://www.oppia.org/create/%s#/feedback">feedback page</a> for your exploration.<br><br>Thanks!<br>- The Oppia Team<br><br>%s'
if (not feconf.CAN_SEND_EMAILS):
log_new_error('This app cannot send emails to users.')
return
if (not feconf.CAN_SEND_FEEDBACK_MESSAGE_EMAILS):
log_new_error('This app cannot send feedback message emails to users.')
return
author_settings = user_services.get_user_settings(author_id)
can_users_receive_email = can_users_receive_thread_email(recipient_list, exploration_id, True)
for (index, recipient_id) in enumerate(recipient_list):
recipient_user_settings = user_services.get_user_settings(recipient_id)
if can_users_receive_email[index]:
email_body = (email_body_template % (recipient_user_settings.username, author_settings.username, exploration_id, exploration_title, exploration_id, EMAIL_FOOTER.value))
_send_email(recipient_id, feconf.SYSTEM_COMMITTER_ID, feconf.EMAIL_INTENT_SUGGESTION_NOTIFICATION, email_subject, email_body, feconf.NOREPLY_EMAIL_ADDRESS)
|
[
"def",
"send_suggestion_email",
"(",
"exploration_title",
",",
"exploration_id",
",",
"author_id",
",",
"recipient_list",
")",
":",
"email_subject",
"=",
"(",
"'New suggestion for \"%s\"'",
"%",
"exploration_title",
")",
"email_body_template",
"=",
"'Hi %s,<br>%s has submitted a new suggestion for your Oppia exploration, <a href=\"https://www.oppia.org/create/%s\">\"%s\"</a>.<br>You can accept or reject this suggestion by visiting the <a href=\"https://www.oppia.org/create/%s#/feedback\">feedback page</a> for your exploration.<br><br>Thanks!<br>- The Oppia Team<br><br>%s'",
"if",
"(",
"not",
"feconf",
".",
"CAN_SEND_EMAILS",
")",
":",
"log_new_error",
"(",
"'This app cannot send emails to users.'",
")",
"return",
"if",
"(",
"not",
"feconf",
".",
"CAN_SEND_FEEDBACK_MESSAGE_EMAILS",
")",
":",
"log_new_error",
"(",
"'This app cannot send feedback message emails to users.'",
")",
"return",
"author_settings",
"=",
"user_services",
".",
"get_user_settings",
"(",
"author_id",
")",
"can_users_receive_email",
"=",
"can_users_receive_thread_email",
"(",
"recipient_list",
",",
"exploration_id",
",",
"True",
")",
"for",
"(",
"index",
",",
"recipient_id",
")",
"in",
"enumerate",
"(",
"recipient_list",
")",
":",
"recipient_user_settings",
"=",
"user_services",
".",
"get_user_settings",
"(",
"recipient_id",
")",
"if",
"can_users_receive_email",
"[",
"index",
"]",
":",
"email_body",
"=",
"(",
"email_body_template",
"%",
"(",
"recipient_user_settings",
".",
"username",
",",
"author_settings",
".",
"username",
",",
"exploration_id",
",",
"exploration_title",
",",
"exploration_id",
",",
"EMAIL_FOOTER",
".",
"value",
")",
")",
"_send_email",
"(",
"recipient_id",
",",
"feconf",
".",
"SYSTEM_COMMITTER_ID",
",",
"feconf",
".",
"EMAIL_INTENT_SUGGESTION_NOTIFICATION",
",",
"email_subject",
",",
"email_body",
",",
"feconf",
".",
"NOREPLY_EMAIL_ADDRESS",
")"
] |
send emails to notify the given recipients about new suggestion .
|
train
| false
|
50,361
|
def output_protruding_glyphs(font, ymin, ymax):
protruding_glyphs = []
glyf_table = font['glyf']
for glyph_name in glyf_table.keys():
glyph = glyf_table[glyph_name]
if (glyph.numberOfContours == 0):
continue
if ((glyph.yMin < ymin) or (glyph.yMax > ymax)):
protruding_glyphs.append(glyph_name)
if protruding_glyphs:
print ('Protruding glyphs in %s:' % font_data.font_name(font)),
print ', '.join(sorted(protruding_glyphs))
|
[
"def",
"output_protruding_glyphs",
"(",
"font",
",",
"ymin",
",",
"ymax",
")",
":",
"protruding_glyphs",
"=",
"[",
"]",
"glyf_table",
"=",
"font",
"[",
"'glyf'",
"]",
"for",
"glyph_name",
"in",
"glyf_table",
".",
"keys",
"(",
")",
":",
"glyph",
"=",
"glyf_table",
"[",
"glyph_name",
"]",
"if",
"(",
"glyph",
".",
"numberOfContours",
"==",
"0",
")",
":",
"continue",
"if",
"(",
"(",
"glyph",
".",
"yMin",
"<",
"ymin",
")",
"or",
"(",
"glyph",
".",
"yMax",
">",
"ymax",
")",
")",
":",
"protruding_glyphs",
".",
"append",
"(",
"glyph_name",
")",
"if",
"protruding_glyphs",
":",
"print",
"(",
"'Protruding glyphs in %s:'",
"%",
"font_data",
".",
"font_name",
"(",
"font",
")",
")",
",",
"print",
"', '",
".",
"join",
"(",
"sorted",
"(",
"protruding_glyphs",
")",
")"
] |
outputs all glyphs going outside the specified vertical range .
|
train
| false
|
50,362
|
@pytest.fixture
def progress_widget(qtbot, monkeypatch, config_stub):
config_stub.data = {'colors': {'statusbar.progress.bg': 'black'}, 'fonts': {}}
monkeypatch.setattr('qutebrowser.mainwindow.statusbar.progress.style.config', config_stub)
widget = Progress()
qtbot.add_widget(widget)
assert (not widget.isVisible())
assert (not widget.isTextVisible())
return widget
|
[
"@",
"pytest",
".",
"fixture",
"def",
"progress_widget",
"(",
"qtbot",
",",
"monkeypatch",
",",
"config_stub",
")",
":",
"config_stub",
".",
"data",
"=",
"{",
"'colors'",
":",
"{",
"'statusbar.progress.bg'",
":",
"'black'",
"}",
",",
"'fonts'",
":",
"{",
"}",
"}",
"monkeypatch",
".",
"setattr",
"(",
"'qutebrowser.mainwindow.statusbar.progress.style.config'",
",",
"config_stub",
")",
"widget",
"=",
"Progress",
"(",
")",
"qtbot",
".",
"add_widget",
"(",
"widget",
")",
"assert",
"(",
"not",
"widget",
".",
"isVisible",
"(",
")",
")",
"assert",
"(",
"not",
"widget",
".",
"isTextVisible",
"(",
")",
")",
"return",
"widget"
] |
create a progress widget and checks its initial state .
|
train
| false
|
50,363
|
def test_predict():
tpot_obj = TPOTClassifier()
try:
tpot_obj.predict(testing_features)
assert False
except ValueError:
pass
|
[
"def",
"test_predict",
"(",
")",
":",
"tpot_obj",
"=",
"TPOTClassifier",
"(",
")",
"try",
":",
"tpot_obj",
".",
"predict",
"(",
"testing_features",
")",
"assert",
"False",
"except",
"ValueError",
":",
"pass"
] |
assert that the tpot predict function raises a valueerror when no optimized pipeline exists .
|
train
| false
|
50,365
|
def unicode_urlencode(obj, charset='utf-8', for_qs=False):
if (not isinstance(obj, string_types)):
obj = text_type(obj)
if isinstance(obj, text_type):
obj = obj.encode(charset)
safe = (((not for_qs) and '/') or '')
rv = text_type(url_quote(obj, safe))
if for_qs:
rv = rv.replace('%20', '+')
return rv
|
[
"def",
"unicode_urlencode",
"(",
"obj",
",",
"charset",
"=",
"'utf-8'",
",",
"for_qs",
"=",
"False",
")",
":",
"if",
"(",
"not",
"isinstance",
"(",
"obj",
",",
"string_types",
")",
")",
":",
"obj",
"=",
"text_type",
"(",
"obj",
")",
"if",
"isinstance",
"(",
"obj",
",",
"text_type",
")",
":",
"obj",
"=",
"obj",
".",
"encode",
"(",
"charset",
")",
"safe",
"=",
"(",
"(",
"(",
"not",
"for_qs",
")",
"and",
"'/'",
")",
"or",
"''",
")",
"rv",
"=",
"text_type",
"(",
"url_quote",
"(",
"obj",
",",
"safe",
")",
")",
"if",
"for_qs",
":",
"rv",
"=",
"rv",
".",
"replace",
"(",
"'%20'",
",",
"'+'",
")",
"return",
"rv"
] |
url escapes a single bytestring or unicode string with the given charset if applicable to url safe quoting under all rules that need to be considered under all supported python versions .
|
train
| true
|
50,366
|
def _parse_cc(text):
if (not text):
return None
else:
m = re.match('(\\d+)\\.(\\d+)', text)
if (not m):
raise ValueError('NUMBA_FORCE_CUDA_CC must be specified as a string of "major.minor" where major and minor are decimals')
grp = m.groups()
return (int(grp[0]), int(grp[1]))
|
[
"def",
"_parse_cc",
"(",
"text",
")",
":",
"if",
"(",
"not",
"text",
")",
":",
"return",
"None",
"else",
":",
"m",
"=",
"re",
".",
"match",
"(",
"'(\\\\d+)\\\\.(\\\\d+)'",
",",
"text",
")",
"if",
"(",
"not",
"m",
")",
":",
"raise",
"ValueError",
"(",
"'NUMBA_FORCE_CUDA_CC must be specified as a string of \"major.minor\" where major and minor are decimals'",
")",
"grp",
"=",
"m",
".",
"groups",
"(",
")",
"return",
"(",
"int",
"(",
"grp",
"[",
"0",
"]",
")",
",",
"int",
"(",
"grp",
"[",
"1",
"]",
")",
")"
] |
parse cuda compute capability version string .
|
train
| false
|
50,367
|
def guid64():
return base91(random.randint(0, ((2 ** 64) - 1)))
|
[
"def",
"guid64",
"(",
")",
":",
"return",
"base91",
"(",
"random",
".",
"randint",
"(",
"0",
",",
"(",
"(",
"2",
"**",
"64",
")",
"-",
"1",
")",
")",
")"
] |
return a base91-encoded 64bit random number .
|
train
| false
|
50,368
|
@register.filter('json')
def json_filter(value):
return mark_safe(json.dumps(value, cls=SafeJSONEncoder))
|
[
"@",
"register",
".",
"filter",
"(",
"'json'",
")",
"def",
"json_filter",
"(",
"value",
")",
":",
"return",
"mark_safe",
"(",
"json",
".",
"dumps",
"(",
"value",
",",
"cls",
"=",
"SafeJSONEncoder",
")",
")"
] |
returns the json representation of value in a safe manner .
|
train
| false
|
50,370
|
@contextmanager
def assert_deallocated(func, *args, **kwargs):
with gc_state(False):
obj = func(*args, **kwargs)
ref = weakref.ref(obj)
(yield obj)
del obj
if (ref() is not None):
raise ReferenceError('Remaining reference(s) to object')
|
[
"@",
"contextmanager",
"def",
"assert_deallocated",
"(",
"func",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"with",
"gc_state",
"(",
"False",
")",
":",
"obj",
"=",
"func",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"ref",
"=",
"weakref",
".",
"ref",
"(",
"obj",
")",
"(",
"yield",
"obj",
")",
"del",
"obj",
"if",
"(",
"ref",
"(",
")",
"is",
"not",
"None",
")",
":",
"raise",
"ReferenceError",
"(",
"'Remaining reference(s) to object'",
")"
] |
context manager to check that object is deallocated this is useful for checking that an object can be freed directly by reference counting .
|
train
| false
|
50,371
|
def get_admin_context(show_deleted=False):
return RequestContext(auth_token=None, tenant=None, is_admin=True, show_deleted=show_deleted, overwrite=False)
|
[
"def",
"get_admin_context",
"(",
"show_deleted",
"=",
"False",
")",
":",
"return",
"RequestContext",
"(",
"auth_token",
"=",
"None",
",",
"tenant",
"=",
"None",
",",
"is_admin",
"=",
"True",
",",
"show_deleted",
"=",
"show_deleted",
",",
"overwrite",
"=",
"False",
")"
] |
create an administrator context .
|
train
| false
|
50,372
|
def _ConvertArgsDictToList(statement, args):
access_logger = _AccessLogger()
(statement % access_logger)
return [args[key] for key in access_logger.accessed_keys]
|
[
"def",
"_ConvertArgsDictToList",
"(",
"statement",
",",
"args",
")",
":",
"access_logger",
"=",
"_AccessLogger",
"(",
")",
"(",
"statement",
"%",
"access_logger",
")",
"return",
"[",
"args",
"[",
"key",
"]",
"for",
"key",
"in",
"access_logger",
".",
"accessed_keys",
"]"
] |
convert a given args mapping to a list of positional arguments .
|
train
| false
|
50,373
|
def test_resize():
assert_raises(ValueError, resize, np.zeros(3), (3, 3))
assert_raises(ValueError, resize, np.zeros((3, 3)), (3,))
assert_raises(ValueError, resize, np.zeros((3, 3)), (4, 4), kind='foo')
for (kind, tol) in (('nearest', 1e-05), ('linear', 0.2)):
shape = np.array((10, 11, 3))
data = np.random.RandomState(0).rand(*shape)
assert_allclose(data, resize(data, shape[:2], kind=kind), rtol=1e-05, atol=1e-05)
assert_allclose(data, resize(resize(data, (2 * shape[:2]), kind=kind), shape[:2], kind=kind), atol=tol, rtol=tol)
|
[
"def",
"test_resize",
"(",
")",
":",
"assert_raises",
"(",
"ValueError",
",",
"resize",
",",
"np",
".",
"zeros",
"(",
"3",
")",
",",
"(",
"3",
",",
"3",
")",
")",
"assert_raises",
"(",
"ValueError",
",",
"resize",
",",
"np",
".",
"zeros",
"(",
"(",
"3",
",",
"3",
")",
")",
",",
"(",
"3",
",",
")",
")",
"assert_raises",
"(",
"ValueError",
",",
"resize",
",",
"np",
".",
"zeros",
"(",
"(",
"3",
",",
"3",
")",
")",
",",
"(",
"4",
",",
"4",
")",
",",
"kind",
"=",
"'foo'",
")",
"for",
"(",
"kind",
",",
"tol",
")",
"in",
"(",
"(",
"'nearest'",
",",
"1e-05",
")",
",",
"(",
"'linear'",
",",
"0.2",
")",
")",
":",
"shape",
"=",
"np",
".",
"array",
"(",
"(",
"10",
",",
"11",
",",
"3",
")",
")",
"data",
"=",
"np",
".",
"random",
".",
"RandomState",
"(",
"0",
")",
".",
"rand",
"(",
"*",
"shape",
")",
"assert_allclose",
"(",
"data",
",",
"resize",
"(",
"data",
",",
"shape",
"[",
":",
"2",
"]",
",",
"kind",
"=",
"kind",
")",
",",
"rtol",
"=",
"1e-05",
",",
"atol",
"=",
"1e-05",
")",
"assert_allclose",
"(",
"data",
",",
"resize",
"(",
"resize",
"(",
"data",
",",
"(",
"2",
"*",
"shape",
"[",
":",
"2",
"]",
")",
",",
"kind",
"=",
"kind",
")",
",",
"shape",
"[",
":",
"2",
"]",
",",
"kind",
"=",
"kind",
")",
",",
"atol",
"=",
"tol",
",",
"rtol",
"=",
"tol",
")"
] |
test image resizing algorithms .
|
train
| false
|
50,375
|
def additions_remove(**kwargs):
kernel = __grains__.get('kernel', '')
if (kernel == 'Linux'):
ret = _additions_remove_linux()
if (not ret):
ret = _additions_remove_use_cd(**kwargs)
return ret
|
[
"def",
"additions_remove",
"(",
"**",
"kwargs",
")",
":",
"kernel",
"=",
"__grains__",
".",
"get",
"(",
"'kernel'",
",",
"''",
")",
"if",
"(",
"kernel",
"==",
"'Linux'",
")",
":",
"ret",
"=",
"_additions_remove_linux",
"(",
")",
"if",
"(",
"not",
"ret",
")",
":",
"ret",
"=",
"_additions_remove_use_cd",
"(",
"**",
"kwargs",
")",
"return",
"ret"
] |
remove virtualbox guest additions .
|
train
| true
|
50,376
|
def _get_configured_repos():
repos_cfg = configparser.ConfigParser()
repos_cfg.read([((REPOS + '/') + fname) for fname in os.listdir(REPOS)])
return repos_cfg
|
[
"def",
"_get_configured_repos",
"(",
")",
":",
"repos_cfg",
"=",
"configparser",
".",
"ConfigParser",
"(",
")",
"repos_cfg",
".",
"read",
"(",
"[",
"(",
"(",
"REPOS",
"+",
"'/'",
")",
"+",
"fname",
")",
"for",
"fname",
"in",
"os",
".",
"listdir",
"(",
"REPOS",
")",
"]",
")",
"return",
"repos_cfg"
] |
get all the info about repositories from the configurations .
|
train
| false
|
50,378
|
def get_open_fds_count():
pid = os.getpid()
procs = check_output([u'lsof', u'-w', u'-Ff', u'-p', str(pid)])
nprocs = len([s for s in procs.decode(u'utf-8').split(u'\n') if (s and (s[0] == u'f') and s[1:].isdigit())])
return nprocs
|
[
"def",
"get_open_fds_count",
"(",
")",
":",
"pid",
"=",
"os",
".",
"getpid",
"(",
")",
"procs",
"=",
"check_output",
"(",
"[",
"u'lsof'",
",",
"u'-w'",
",",
"u'-Ff'",
",",
"u'-p'",
",",
"str",
"(",
"pid",
")",
"]",
")",
"nprocs",
"=",
"len",
"(",
"[",
"s",
"for",
"s",
"in",
"procs",
".",
"decode",
"(",
"u'utf-8'",
")",
".",
"split",
"(",
"u'\\n'",
")",
"if",
"(",
"s",
"and",
"(",
"s",
"[",
"0",
"]",
"==",
"u'f'",
")",
"and",
"s",
"[",
"1",
":",
"]",
".",
"isdigit",
"(",
")",
")",
"]",
")",
"return",
"nprocs"
] |
return the number of open file descriptors for current process .
|
train
| false
|
50,380
|
def test_resize_icon_shrink():
resize_size = 32
final_size = (32, 12)
_uploader(resize_size, final_size)
|
[
"def",
"test_resize_icon_shrink",
"(",
")",
":",
"resize_size",
"=",
"32",
"final_size",
"=",
"(",
"32",
",",
"12",
")",
"_uploader",
"(",
"resize_size",
",",
"final_size",
")"
] |
image should be shrunk so that the longest side is 32px .
|
train
| false
|
50,381
|
def in6_getnsma(a):
r = in6_and(a, inet_pton(socket.AF_INET6, '::ff:ffff'))
r = in6_or(inet_pton(socket.AF_INET6, 'ff02::1:ff00:0'), r)
return r
|
[
"def",
"in6_getnsma",
"(",
"a",
")",
":",
"r",
"=",
"in6_and",
"(",
"a",
",",
"inet_pton",
"(",
"socket",
".",
"AF_INET6",
",",
"'::ff:ffff'",
")",
")",
"r",
"=",
"in6_or",
"(",
"inet_pton",
"(",
"socket",
".",
"AF_INET6",
",",
"'ff02::1:ff00:0'",
")",
",",
"r",
")",
"return",
"r"
] |
return link-local solicited-node multicast address for given address .
|
train
| true
|
50,382
|
def generate_views(action):
view_id = (action.get('view_id') or False)
if isinstance(view_id, (list, tuple)):
view_id = view_id[0]
view_modes = action['view_mode'].split(',')
if (len(view_modes) > 1):
if view_id:
raise ValueError(('Non-db action dictionaries should provide either multiple view modes or a single view mode and an optional view id.\n\n Got view modes %r and view id %r for action %r' % (view_modes, view_id, action)))
action['views'] = [(False, mode) for mode in view_modes]
return
action['views'] = [(view_id, view_modes[0])]
|
[
"def",
"generate_views",
"(",
"action",
")",
":",
"view_id",
"=",
"(",
"action",
".",
"get",
"(",
"'view_id'",
")",
"or",
"False",
")",
"if",
"isinstance",
"(",
"view_id",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"view_id",
"=",
"view_id",
"[",
"0",
"]",
"view_modes",
"=",
"action",
"[",
"'view_mode'",
"]",
".",
"split",
"(",
"','",
")",
"if",
"(",
"len",
"(",
"view_modes",
")",
">",
"1",
")",
":",
"if",
"view_id",
":",
"raise",
"ValueError",
"(",
"(",
"'Non-db action dictionaries should provide either multiple view modes or a single view mode and an optional view id.\\n\\n Got view modes %r and view id %r for action %r'",
"%",
"(",
"view_modes",
",",
"view_id",
",",
"action",
")",
")",
")",
"action",
"[",
"'views'",
"]",
"=",
"[",
"(",
"False",
",",
"mode",
")",
"for",
"mode",
"in",
"view_modes",
"]",
"return",
"action",
"[",
"'views'",
"]",
"=",
"[",
"(",
"view_id",
",",
"view_modes",
"[",
"0",
"]",
")",
"]"
] |
while the server generates a sequence called "views" computing dependencies between a bunch of stuff for views coming directly from the database .
|
train
| false
|
50,383
|
def quota_usage_get_all_by_project_and_user(context, project_id, user_id):
return IMPL.quota_usage_get_all_by_project_and_user(context, project_id, user_id)
|
[
"def",
"quota_usage_get_all_by_project_and_user",
"(",
"context",
",",
"project_id",
",",
"user_id",
")",
":",
"return",
"IMPL",
".",
"quota_usage_get_all_by_project_and_user",
"(",
"context",
",",
"project_id",
",",
"user_id",
")"
] |
retrieve all usage associated with a given resource .
|
train
| false
|
50,384
|
def _html_escape_url(attr, safe_mode=False):
escaped = attr.replace('"', '"').replace('<', '<').replace('>', '>')
if safe_mode:
escaped = escaped.replace('+', ' ')
escaped = escaped.replace("'", ''')
return escaped
|
[
"def",
"_html_escape_url",
"(",
"attr",
",",
"safe_mode",
"=",
"False",
")",
":",
"escaped",
"=",
"attr",
".",
"replace",
"(",
"'\"'",
",",
"'"'",
")",
".",
"replace",
"(",
"'<'",
",",
"'<'",
")",
".",
"replace",
"(",
"'>'",
",",
"'>'",
")",
"if",
"safe_mode",
":",
"escaped",
"=",
"escaped",
".",
"replace",
"(",
"'+'",
",",
"' '",
")",
"escaped",
"=",
"escaped",
".",
"replace",
"(",
"\"'\"",
",",
"'''",
")",
"return",
"escaped"
] |
replace special characters that are potentially malicious in url string .
|
train
| false
|
50,386
|
def process_survey_link(survey_link, user):
return survey_link.format(UNIQUE_ID=unique_id_for_user(user))
|
[
"def",
"process_survey_link",
"(",
"survey_link",
",",
"user",
")",
":",
"return",
"survey_link",
".",
"format",
"(",
"UNIQUE_ID",
"=",
"unique_id_for_user",
"(",
"user",
")",
")"
] |
if {unique_id} appears in the link .
|
train
| false
|
50,388
|
def dup_qq_heu_gcd(f, g, K0):
result = _dup_ff_trivial_gcd(f, g, K0)
if (result is not None):
return result
K1 = K0.get_ring()
(cf, f) = dup_clear_denoms(f, K0, K1)
(cg, g) = dup_clear_denoms(g, K0, K1)
f = dup_convert(f, K0, K1)
g = dup_convert(g, K0, K1)
(h, cff, cfg) = dup_zz_heu_gcd(f, g, K1)
h = dup_convert(h, K1, K0)
c = dup_LC(h, K0)
h = dup_monic(h, K0)
cff = dup_convert(cff, K1, K0)
cfg = dup_convert(cfg, K1, K0)
cff = dup_mul_ground(cff, K0.quo(c, cf), K0)
cfg = dup_mul_ground(cfg, K0.quo(c, cg), K0)
return (h, cff, cfg)
|
[
"def",
"dup_qq_heu_gcd",
"(",
"f",
",",
"g",
",",
"K0",
")",
":",
"result",
"=",
"_dup_ff_trivial_gcd",
"(",
"f",
",",
"g",
",",
"K0",
")",
"if",
"(",
"result",
"is",
"not",
"None",
")",
":",
"return",
"result",
"K1",
"=",
"K0",
".",
"get_ring",
"(",
")",
"(",
"cf",
",",
"f",
")",
"=",
"dup_clear_denoms",
"(",
"f",
",",
"K0",
",",
"K1",
")",
"(",
"cg",
",",
"g",
")",
"=",
"dup_clear_denoms",
"(",
"g",
",",
"K0",
",",
"K1",
")",
"f",
"=",
"dup_convert",
"(",
"f",
",",
"K0",
",",
"K1",
")",
"g",
"=",
"dup_convert",
"(",
"g",
",",
"K0",
",",
"K1",
")",
"(",
"h",
",",
"cff",
",",
"cfg",
")",
"=",
"dup_zz_heu_gcd",
"(",
"f",
",",
"g",
",",
"K1",
")",
"h",
"=",
"dup_convert",
"(",
"h",
",",
"K1",
",",
"K0",
")",
"c",
"=",
"dup_LC",
"(",
"h",
",",
"K0",
")",
"h",
"=",
"dup_monic",
"(",
"h",
",",
"K0",
")",
"cff",
"=",
"dup_convert",
"(",
"cff",
",",
"K1",
",",
"K0",
")",
"cfg",
"=",
"dup_convert",
"(",
"cfg",
",",
"K1",
",",
"K0",
")",
"cff",
"=",
"dup_mul_ground",
"(",
"cff",
",",
"K0",
".",
"quo",
"(",
"c",
",",
"cf",
")",
",",
"K0",
")",
"cfg",
"=",
"dup_mul_ground",
"(",
"cfg",
",",
"K0",
".",
"quo",
"(",
"c",
",",
"cg",
")",
",",
"K0",
")",
"return",
"(",
"h",
",",
"cff",
",",
"cfg",
")"
] |
heuristic polynomial gcd in q[x] .
|
train
| false
|
50,389
|
def send_update_with_states(context, instance, old_vm_state, new_vm_state, old_task_state, new_task_state, service='compute', host=None, verify_states=False):
if (not CONF.notifications.notify_on_state_change):
return
fire_update = True
if verify_states:
fire_update = False
if (old_vm_state != new_vm_state):
fire_update = True
elif ((CONF.notifications.notify_on_state_change == 'vm_and_task_state') and (old_task_state != new_task_state)):
fire_update = True
if fire_update:
try:
_send_instance_update_notification(context, instance, old_vm_state=old_vm_state, old_task_state=old_task_state, new_vm_state=new_vm_state, new_task_state=new_task_state, service=service, host=host)
except exception.InstanceNotFound:
LOG.debug('Failed to send instance update notification. The instance could not be found and was most likely deleted.', instance=instance)
except Exception:
LOG.exception(_LE('Failed to send state update notification'), instance=instance)
|
[
"def",
"send_update_with_states",
"(",
"context",
",",
"instance",
",",
"old_vm_state",
",",
"new_vm_state",
",",
"old_task_state",
",",
"new_task_state",
",",
"service",
"=",
"'compute'",
",",
"host",
"=",
"None",
",",
"verify_states",
"=",
"False",
")",
":",
"if",
"(",
"not",
"CONF",
".",
"notifications",
".",
"notify_on_state_change",
")",
":",
"return",
"fire_update",
"=",
"True",
"if",
"verify_states",
":",
"fire_update",
"=",
"False",
"if",
"(",
"old_vm_state",
"!=",
"new_vm_state",
")",
":",
"fire_update",
"=",
"True",
"elif",
"(",
"(",
"CONF",
".",
"notifications",
".",
"notify_on_state_change",
"==",
"'vm_and_task_state'",
")",
"and",
"(",
"old_task_state",
"!=",
"new_task_state",
")",
")",
":",
"fire_update",
"=",
"True",
"if",
"fire_update",
":",
"try",
":",
"_send_instance_update_notification",
"(",
"context",
",",
"instance",
",",
"old_vm_state",
"=",
"old_vm_state",
",",
"old_task_state",
"=",
"old_task_state",
",",
"new_vm_state",
"=",
"new_vm_state",
",",
"new_task_state",
"=",
"new_task_state",
",",
"service",
"=",
"service",
",",
"host",
"=",
"host",
")",
"except",
"exception",
".",
"InstanceNotFound",
":",
"LOG",
".",
"debug",
"(",
"'Failed to send instance update notification. The instance could not be found and was most likely deleted.'",
",",
"instance",
"=",
"instance",
")",
"except",
"Exception",
":",
"LOG",
".",
"exception",
"(",
"_LE",
"(",
"'Failed to send state update notification'",
")",
",",
"instance",
"=",
"instance",
")"
] |
send compute .
|
train
| false
|
50,390
|
def smart_urlquote(url):
(scheme, netloc, path, query, fragment) = urlparse.urlsplit(url)
try:
netloc = netloc.encode('idna')
except UnicodeError:
pass
else:
url = urlparse.urlunsplit((scheme, netloc, path, query, fragment))
if (('%' not in url) or unquoted_percents_re.search(url)):
url = urllib.quote(smart_str(url), safe="!*'();:@&=+$,/?#[]~")
return force_unicode(url)
|
[
"def",
"smart_urlquote",
"(",
"url",
")",
":",
"(",
"scheme",
",",
"netloc",
",",
"path",
",",
"query",
",",
"fragment",
")",
"=",
"urlparse",
".",
"urlsplit",
"(",
"url",
")",
"try",
":",
"netloc",
"=",
"netloc",
".",
"encode",
"(",
"'idna'",
")",
"except",
"UnicodeError",
":",
"pass",
"else",
":",
"url",
"=",
"urlparse",
".",
"urlunsplit",
"(",
"(",
"scheme",
",",
"netloc",
",",
"path",
",",
"query",
",",
"fragment",
")",
")",
"if",
"(",
"(",
"'%'",
"not",
"in",
"url",
")",
"or",
"unquoted_percents_re",
".",
"search",
"(",
"url",
")",
")",
":",
"url",
"=",
"urllib",
".",
"quote",
"(",
"smart_str",
"(",
"url",
")",
",",
"safe",
"=",
"\"!*'();:@&=+$,/?#[]~\"",
")",
"return",
"force_unicode",
"(",
"url",
")"
] |
quotes a url if it isnt already quoted .
|
train
| false
|
50,391
|
def test_oldclass_newclass_construction():
class nc(object, ):
pass
class oc:
pass
newType = type(oc).__new__(type(oc), 'foo', (nc, oc), {})
AreEqual(type(newType), type)
|
[
"def",
"test_oldclass_newclass_construction",
"(",
")",
":",
"class",
"nc",
"(",
"object",
",",
")",
":",
"pass",
"class",
"oc",
":",
"pass",
"newType",
"=",
"type",
"(",
"oc",
")",
".",
"__new__",
"(",
"type",
"(",
"oc",
")",
",",
"'foo'",
",",
"(",
"nc",
",",
"oc",
")",
",",
"{",
"}",
")",
"AreEqual",
"(",
"type",
"(",
"newType",
")",
",",
"type",
")"
] |
calling __new__ on and old-class passing in new-classes should result in a new-style type .
|
train
| false
|
50,392
|
def fulfill_course_milestone(course_key, user):
if (not settings.FEATURES.get('MILESTONES_APP')):
return None
try:
course_milestones = milestones_api.get_course_milestones(course_key=course_key, relationship='fulfills')
except InvalidMilestoneRelationshipTypeException:
seed_milestone_relationship_types()
course_milestones = milestones_api.get_course_milestones(course_key=course_key, relationship='fulfills')
for milestone in course_milestones:
milestones_api.add_user_milestone({'id': user.id}, milestone)
|
[
"def",
"fulfill_course_milestone",
"(",
"course_key",
",",
"user",
")",
":",
"if",
"(",
"not",
"settings",
".",
"FEATURES",
".",
"get",
"(",
"'MILESTONES_APP'",
")",
")",
":",
"return",
"None",
"try",
":",
"course_milestones",
"=",
"milestones_api",
".",
"get_course_milestones",
"(",
"course_key",
"=",
"course_key",
",",
"relationship",
"=",
"'fulfills'",
")",
"except",
"InvalidMilestoneRelationshipTypeException",
":",
"seed_milestone_relationship_types",
"(",
")",
"course_milestones",
"=",
"milestones_api",
".",
"get_course_milestones",
"(",
"course_key",
"=",
"course_key",
",",
"relationship",
"=",
"'fulfills'",
")",
"for",
"milestone",
"in",
"course_milestones",
":",
"milestones_api",
".",
"add_user_milestone",
"(",
"{",
"'id'",
":",
"user",
".",
"id",
"}",
",",
"milestone",
")"
] |
marks the course specified by the given course_key as complete for the given user .
|
train
| false
|
50,394
|
def _get_aliases(context, data_dict):
res_id = data_dict['resource_id']
alias_sql = sqlalchemy.text(u'SELECT name FROM "_table_metadata" WHERE alias_of = :id')
results = context['connection'].execute(alias_sql, id=res_id).fetchall()
return [x[0] for x in results]
|
[
"def",
"_get_aliases",
"(",
"context",
",",
"data_dict",
")",
":",
"res_id",
"=",
"data_dict",
"[",
"'resource_id'",
"]",
"alias_sql",
"=",
"sqlalchemy",
".",
"text",
"(",
"u'SELECT name FROM \"_table_metadata\" WHERE alias_of = :id'",
")",
"results",
"=",
"context",
"[",
"'connection'",
"]",
".",
"execute",
"(",
"alias_sql",
",",
"id",
"=",
"res_id",
")",
".",
"fetchall",
"(",
")",
"return",
"[",
"x",
"[",
"0",
"]",
"for",
"x",
"in",
"results",
"]"
] |
get a list of aliases for a resource .
|
train
| false
|
50,395
|
def reset_notifier():
global _notifier
_notifier = None
|
[
"def",
"reset_notifier",
"(",
")",
":",
"global",
"_notifier",
"_notifier",
"=",
"None"
] |
reset the notifications internal state .
|
train
| false
|
50,396
|
def pause_check():
global __PAUSE_END
if ((__PAUSE_END is not None) and ((__PAUSE_END - time.time()) < 0)):
__PAUSE_END = None
logging.debug('Force resume, negative timer')
sabnzbd.unpause_all()
|
[
"def",
"pause_check",
"(",
")",
":",
"global",
"__PAUSE_END",
"if",
"(",
"(",
"__PAUSE_END",
"is",
"not",
"None",
")",
"and",
"(",
"(",
"__PAUSE_END",
"-",
"time",
".",
"time",
"(",
")",
")",
"<",
"0",
")",
")",
":",
"__PAUSE_END",
"=",
"None",
"logging",
".",
"debug",
"(",
"'Force resume, negative timer'",
")",
"sabnzbd",
".",
"unpause_all",
"(",
")"
] |
unpause when time left is negative .
|
train
| false
|
50,397
|
def rolling_apply(arg, window, func, min_periods=None, freq=None, center=False, args=(), kwargs={}):
return ensure_compat('rolling', 'apply', arg, window=window, freq=freq, center=center, min_periods=min_periods, func_kw=['func', 'args', 'kwargs'], func=func, args=args, kwargs=kwargs)
|
[
"def",
"rolling_apply",
"(",
"arg",
",",
"window",
",",
"func",
",",
"min_periods",
"=",
"None",
",",
"freq",
"=",
"None",
",",
"center",
"=",
"False",
",",
"args",
"=",
"(",
")",
",",
"kwargs",
"=",
"{",
"}",
")",
":",
"return",
"ensure_compat",
"(",
"'rolling'",
",",
"'apply'",
",",
"arg",
",",
"window",
"=",
"window",
",",
"freq",
"=",
"freq",
",",
"center",
"=",
"center",
",",
"min_periods",
"=",
"min_periods",
",",
"func_kw",
"=",
"[",
"'func'",
",",
"'args'",
",",
"'kwargs'",
"]",
",",
"func",
"=",
"func",
",",
"args",
"=",
"args",
",",
"kwargs",
"=",
"kwargs",
")"
] |
generic moving function application .
|
train
| false
|
50,398
|
def css_gradient(gradient):
(stop, finalStop) = (gradient.start(), gradient.finalStop())
(x1, y1, x2, y2) = (stop.x(), stop.y(), finalStop.x(), finalStop.y())
stops = gradient.stops()
stops = '\n'.join((' stop: {0:f} {1}'.format(stop, color.name()) for (stop, color) in stops))
return 'qlineargradient(\n x1: {x1}, y1: {y1}, x2: {x1}, y2: {y2},\n{stops})'.format(x1=x1, y1=y1, x2=x2, y2=y2, stops=stops)
|
[
"def",
"css_gradient",
"(",
"gradient",
")",
":",
"(",
"stop",
",",
"finalStop",
")",
"=",
"(",
"gradient",
".",
"start",
"(",
")",
",",
"gradient",
".",
"finalStop",
"(",
")",
")",
"(",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
")",
"=",
"(",
"stop",
".",
"x",
"(",
")",
",",
"stop",
".",
"y",
"(",
")",
",",
"finalStop",
".",
"x",
"(",
")",
",",
"finalStop",
".",
"y",
"(",
")",
")",
"stops",
"=",
"gradient",
".",
"stops",
"(",
")",
"stops",
"=",
"'\\n'",
".",
"join",
"(",
"(",
"' stop: {0:f} {1}'",
".",
"format",
"(",
"stop",
",",
"color",
".",
"name",
"(",
")",
")",
"for",
"(",
"stop",
",",
"color",
")",
"in",
"stops",
")",
")",
"return",
"'qlineargradient(\\n x1: {x1}, y1: {y1}, x2: {x1}, y2: {y2},\\n{stops})'",
".",
"format",
"(",
"x1",
"=",
"x1",
",",
"y1",
"=",
"y1",
",",
"x2",
"=",
"x2",
",",
"y2",
"=",
"y2",
",",
"stops",
"=",
"stops",
")"
] |
given an instance of a qlineargradient return an equivalent qt css gradient fragment .
|
train
| false
|
50,399
|
def noSentence():
pass
|
[
"def",
"noSentence",
"(",
")",
":",
"pass"
] |
this doesnt start with a capital .
|
train
| false
|
50,400
|
def task_id():
global _task_id
return _task_id
|
[
"def",
"task_id",
"(",
")",
":",
"global",
"_task_id",
"return",
"_task_id"
] |
returns the current task id .
|
train
| false
|
50,401
|
def _get_handler(settings):
filename = settings.get('LOG_FILE')
if filename:
encoding = settings.get('LOG_ENCODING')
handler = logging.FileHandler(filename, encoding=encoding)
elif settings.getbool('LOG_ENABLED'):
handler = logging.StreamHandler()
else:
handler = logging.NullHandler()
formatter = logging.Formatter(fmt=settings.get('LOG_FORMAT'), datefmt=settings.get('LOG_DATEFORMAT'))
handler.setFormatter(formatter)
handler.setLevel(settings.get('LOG_LEVEL'))
if settings.getbool('LOG_SHORT_NAMES'):
handler.addFilter(TopLevelFormatter(['scrapy']))
return handler
|
[
"def",
"_get_handler",
"(",
"settings",
")",
":",
"filename",
"=",
"settings",
".",
"get",
"(",
"'LOG_FILE'",
")",
"if",
"filename",
":",
"encoding",
"=",
"settings",
".",
"get",
"(",
"'LOG_ENCODING'",
")",
"handler",
"=",
"logging",
".",
"FileHandler",
"(",
"filename",
",",
"encoding",
"=",
"encoding",
")",
"elif",
"settings",
".",
"getbool",
"(",
"'LOG_ENABLED'",
")",
":",
"handler",
"=",
"logging",
".",
"StreamHandler",
"(",
")",
"else",
":",
"handler",
"=",
"logging",
".",
"NullHandler",
"(",
")",
"formatter",
"=",
"logging",
".",
"Formatter",
"(",
"fmt",
"=",
"settings",
".",
"get",
"(",
"'LOG_FORMAT'",
")",
",",
"datefmt",
"=",
"settings",
".",
"get",
"(",
"'LOG_DATEFORMAT'",
")",
")",
"handler",
".",
"setFormatter",
"(",
"formatter",
")",
"handler",
".",
"setLevel",
"(",
"settings",
".",
"get",
"(",
"'LOG_LEVEL'",
")",
")",
"if",
"settings",
".",
"getbool",
"(",
"'LOG_SHORT_NAMES'",
")",
":",
"handler",
".",
"addFilter",
"(",
"TopLevelFormatter",
"(",
"[",
"'scrapy'",
"]",
")",
")",
"return",
"handler"
] |
return a log handler object according to settings .
|
train
| false
|
50,403
|
def get_polar_motion(time):
(xp, yp, status) = iers.IERS_Auto.open().pm_xy(time, return_status=True)
wmsg = None
if np.any((status == iers.TIME_BEFORE_IERS_RANGE)):
wmsg = u'Tried to get polar motions for times before IERS data is valid. Defaulting to polar motion from the 50-yr mean for those. This may affect precision at the 10s of arcsec level'
xp.ravel()[(status.ravel() == iers.TIME_BEFORE_IERS_RANGE)] = _DEFAULT_PM[0]
yp.ravel()[(status.ravel() == iers.TIME_BEFORE_IERS_RANGE)] = _DEFAULT_PM[1]
warnings.warn(wmsg, AstropyWarning)
if np.any((status == iers.TIME_BEYOND_IERS_RANGE)):
wmsg = u'Tried to get polar motions for times after IERS data is valid. Defaulting to polar motion from the 50-yr mean for those. This may affect precision at the 10s of arcsec level'
xp.ravel()[(status.ravel() == iers.TIME_BEYOND_IERS_RANGE)] = _DEFAULT_PM[0]
yp.ravel()[(status.ravel() == iers.TIME_BEYOND_IERS_RANGE)] = _DEFAULT_PM[1]
warnings.warn(wmsg, AstropyWarning)
return (xp.to(u.radian).value, yp.to(u.radian).value)
|
[
"def",
"get_polar_motion",
"(",
"time",
")",
":",
"(",
"xp",
",",
"yp",
",",
"status",
")",
"=",
"iers",
".",
"IERS_Auto",
".",
"open",
"(",
")",
".",
"pm_xy",
"(",
"time",
",",
"return_status",
"=",
"True",
")",
"wmsg",
"=",
"None",
"if",
"np",
".",
"any",
"(",
"(",
"status",
"==",
"iers",
".",
"TIME_BEFORE_IERS_RANGE",
")",
")",
":",
"wmsg",
"=",
"u'Tried to get polar motions for times before IERS data is valid. Defaulting to polar motion from the 50-yr mean for those. This may affect precision at the 10s of arcsec level'",
"xp",
".",
"ravel",
"(",
")",
"[",
"(",
"status",
".",
"ravel",
"(",
")",
"==",
"iers",
".",
"TIME_BEFORE_IERS_RANGE",
")",
"]",
"=",
"_DEFAULT_PM",
"[",
"0",
"]",
"yp",
".",
"ravel",
"(",
")",
"[",
"(",
"status",
".",
"ravel",
"(",
")",
"==",
"iers",
".",
"TIME_BEFORE_IERS_RANGE",
")",
"]",
"=",
"_DEFAULT_PM",
"[",
"1",
"]",
"warnings",
".",
"warn",
"(",
"wmsg",
",",
"AstropyWarning",
")",
"if",
"np",
".",
"any",
"(",
"(",
"status",
"==",
"iers",
".",
"TIME_BEYOND_IERS_RANGE",
")",
")",
":",
"wmsg",
"=",
"u'Tried to get polar motions for times after IERS data is valid. Defaulting to polar motion from the 50-yr mean for those. This may affect precision at the 10s of arcsec level'",
"xp",
".",
"ravel",
"(",
")",
"[",
"(",
"status",
".",
"ravel",
"(",
")",
"==",
"iers",
".",
"TIME_BEYOND_IERS_RANGE",
")",
"]",
"=",
"_DEFAULT_PM",
"[",
"0",
"]",
"yp",
".",
"ravel",
"(",
")",
"[",
"(",
"status",
".",
"ravel",
"(",
")",
"==",
"iers",
".",
"TIME_BEYOND_IERS_RANGE",
")",
"]",
"=",
"_DEFAULT_PM",
"[",
"1",
"]",
"warnings",
".",
"warn",
"(",
"wmsg",
",",
"AstropyWarning",
")",
"return",
"(",
"xp",
".",
"to",
"(",
"u",
".",
"radian",
")",
".",
"value",
",",
"yp",
".",
"to",
"(",
"u",
".",
"radian",
")",
".",
"value",
")"
] |
gets the two polar motion components in radians for use with apio13 .
|
train
| false
|
50,404
|
def hyponyms(source):
return closure(source, HYPONYM)
|
[
"def",
"hyponyms",
"(",
"source",
")",
":",
"return",
"closure",
"(",
"source",
",",
"HYPONYM",
")"
] |
return source and its hyponyms .
|
train
| false
|
50,405
|
def get_root_helper_child_pid(pid, expected_cmd, run_as_root=False):
pid = str(pid)
if run_as_root:
while True:
try:
pid = find_child_pids(pid)[0]
except IndexError:
return
if pid_invoked_with_cmdline(pid, expected_cmd):
break
return pid
|
[
"def",
"get_root_helper_child_pid",
"(",
"pid",
",",
"expected_cmd",
",",
"run_as_root",
"=",
"False",
")",
":",
"pid",
"=",
"str",
"(",
"pid",
")",
"if",
"run_as_root",
":",
"while",
"True",
":",
"try",
":",
"pid",
"=",
"find_child_pids",
"(",
"pid",
")",
"[",
"0",
"]",
"except",
"IndexError",
":",
"return",
"if",
"pid_invoked_with_cmdline",
"(",
"pid",
",",
"expected_cmd",
")",
":",
"break",
"return",
"pid"
] |
get the first non root_helper child pid in the process hierarchy .
|
train
| false
|
50,406
|
def cat_to_opts(cat, pp=None, script=None, priority=None):
def_cat = config.get_categories('*')
cat = safe_lower(cat)
if (cat in ('', 'none', 'default')):
cat = '*'
try:
my_cat = config.get_categories()[cat]
except KeyError:
my_cat = def_cat
if (pp is None):
pp = my_cat.pp()
if (pp == ''):
pp = def_cat.pp()
if (not script):
script = my_cat.script()
if (safe_lower(script) in ('', 'default')):
script = def_cat.script()
if ((priority is None) or (priority == DEFAULT_PRIORITY)):
priority = my_cat.priority()
if (priority == DEFAULT_PRIORITY):
priority = def_cat.priority()
return (cat, pp, script, priority)
|
[
"def",
"cat_to_opts",
"(",
"cat",
",",
"pp",
"=",
"None",
",",
"script",
"=",
"None",
",",
"priority",
"=",
"None",
")",
":",
"def_cat",
"=",
"config",
".",
"get_categories",
"(",
"'*'",
")",
"cat",
"=",
"safe_lower",
"(",
"cat",
")",
"if",
"(",
"cat",
"in",
"(",
"''",
",",
"'none'",
",",
"'default'",
")",
")",
":",
"cat",
"=",
"'*'",
"try",
":",
"my_cat",
"=",
"config",
".",
"get_categories",
"(",
")",
"[",
"cat",
"]",
"except",
"KeyError",
":",
"my_cat",
"=",
"def_cat",
"if",
"(",
"pp",
"is",
"None",
")",
":",
"pp",
"=",
"my_cat",
".",
"pp",
"(",
")",
"if",
"(",
"pp",
"==",
"''",
")",
":",
"pp",
"=",
"def_cat",
".",
"pp",
"(",
")",
"if",
"(",
"not",
"script",
")",
":",
"script",
"=",
"my_cat",
".",
"script",
"(",
")",
"if",
"(",
"safe_lower",
"(",
"script",
")",
"in",
"(",
"''",
",",
"'default'",
")",
")",
":",
"script",
"=",
"def_cat",
".",
"script",
"(",
")",
"if",
"(",
"(",
"priority",
"is",
"None",
")",
"or",
"(",
"priority",
"==",
"DEFAULT_PRIORITY",
")",
")",
":",
"priority",
"=",
"my_cat",
".",
"priority",
"(",
")",
"if",
"(",
"priority",
"==",
"DEFAULT_PRIORITY",
")",
":",
"priority",
"=",
"def_cat",
".",
"priority",
"(",
")",
"return",
"(",
"cat",
",",
"pp",
",",
"script",
",",
"priority",
")"
] |
derive options from category .
|
train
| false
|
50,407
|
def compogen(g_s, symbol):
if (len(g_s) == 1):
return g_s[0]
foo = g_s[0].subs(symbol, g_s[1])
if (len(g_s) == 2):
return foo
return compogen(([foo] + g_s[2:]), symbol)
|
[
"def",
"compogen",
"(",
"g_s",
",",
"symbol",
")",
":",
"if",
"(",
"len",
"(",
"g_s",
")",
"==",
"1",
")",
":",
"return",
"g_s",
"[",
"0",
"]",
"foo",
"=",
"g_s",
"[",
"0",
"]",
".",
"subs",
"(",
"symbol",
",",
"g_s",
"[",
"1",
"]",
")",
"if",
"(",
"len",
"(",
"g_s",
")",
"==",
"2",
")",
":",
"return",
"foo",
"return",
"compogen",
"(",
"(",
"[",
"foo",
"]",
"+",
"g_s",
"[",
"2",
":",
"]",
")",
",",
"symbol",
")"
] |
returns the composition of functions .
|
train
| false
|
50,408
|
def not_loaded():
prov = providers()
ret = set()
for mod_dir in salt.loader._module_dirs(__opts__, 'modules', 'module'):
if (not os.path.isabs(mod_dir)):
continue
if (not os.path.isdir(mod_dir)):
continue
for fn_ in os.listdir(mod_dir):
if fn_.startswith('_'):
continue
name = fn_.split('.')[0]
if (name not in prov):
ret.add(name)
return sorted(ret)
|
[
"def",
"not_loaded",
"(",
")",
":",
"prov",
"=",
"providers",
"(",
")",
"ret",
"=",
"set",
"(",
")",
"for",
"mod_dir",
"in",
"salt",
".",
"loader",
".",
"_module_dirs",
"(",
"__opts__",
",",
"'modules'",
",",
"'module'",
")",
":",
"if",
"(",
"not",
"os",
".",
"path",
".",
"isabs",
"(",
"mod_dir",
")",
")",
":",
"continue",
"if",
"(",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"mod_dir",
")",
")",
":",
"continue",
"for",
"fn_",
"in",
"os",
".",
"listdir",
"(",
"mod_dir",
")",
":",
"if",
"fn_",
".",
"startswith",
"(",
"'_'",
")",
":",
"continue",
"name",
"=",
"fn_",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
"if",
"(",
"name",
"not",
"in",
"prov",
")",
":",
"ret",
".",
"add",
"(",
"name",
")",
"return",
"sorted",
"(",
"ret",
")"
] |
list the modules that were not loaded by the salt loader system cli example: .
|
train
| false
|
50,415
|
def LeastSquares(xs, ys):
(meanx, varx) = MeanVar(xs)
meany = Mean(ys)
slope = (Cov(xs, ys, meanx, meany) / varx)
inter = (meany - (slope * meanx))
return (inter, slope)
|
[
"def",
"LeastSquares",
"(",
"xs",
",",
"ys",
")",
":",
"(",
"meanx",
",",
"varx",
")",
"=",
"MeanVar",
"(",
"xs",
")",
"meany",
"=",
"Mean",
"(",
"ys",
")",
"slope",
"=",
"(",
"Cov",
"(",
"xs",
",",
"ys",
",",
"meanx",
",",
"meany",
")",
"/",
"varx",
")",
"inter",
"=",
"(",
"meany",
"-",
"(",
"slope",
"*",
"meanx",
")",
")",
"return",
"(",
"inter",
",",
"slope",
")"
] |
computes a linear least squares fit for ys as a function of xs .
|
train
| false
|
50,416
|
def make_intrinsic_template(handle, defn, name):
base = _IntrinsicTemplate
name = ('_IntrinsicTemplate_%s' % name)
dct = dict(key=handle, _definition_func=staticmethod(defn), _impl_cache={}, _overload_cache={})
return type(base)(name, (base,), dct)
|
[
"def",
"make_intrinsic_template",
"(",
"handle",
",",
"defn",
",",
"name",
")",
":",
"base",
"=",
"_IntrinsicTemplate",
"name",
"=",
"(",
"'_IntrinsicTemplate_%s'",
"%",
"name",
")",
"dct",
"=",
"dict",
"(",
"key",
"=",
"handle",
",",
"_definition_func",
"=",
"staticmethod",
"(",
"defn",
")",
",",
"_impl_cache",
"=",
"{",
"}",
",",
"_overload_cache",
"=",
"{",
"}",
")",
"return",
"type",
"(",
"base",
")",
"(",
"name",
",",
"(",
"base",
",",
")",
",",
"dct",
")"
] |
make a template class for a intrinsic handle *handle* defined by the function *defn* .
|
train
| false
|
50,417
|
def get_sys_info():
p = os.path
path = p.realpath(p.dirname(p.abspath(p.join(__file__, '..'))))
return pkg_info(path)
|
[
"def",
"get_sys_info",
"(",
")",
":",
"p",
"=",
"os",
".",
"path",
"path",
"=",
"p",
".",
"realpath",
"(",
"p",
".",
"dirname",
"(",
"p",
".",
"abspath",
"(",
"p",
".",
"join",
"(",
"__file__",
",",
"'..'",
")",
")",
")",
")",
"return",
"pkg_info",
"(",
"path",
")"
] |
return useful information about ipython and the system .
|
train
| false
|
50,419
|
def use_tx():
from txaio import tx
txaio._use_framework(tx)
|
[
"def",
"use_tx",
"(",
")",
":",
"from",
"txaio",
"import",
"tx",
"txaio",
".",
"_use_framework",
"(",
"tx",
")"
] |
monkey-patched for doc-building .
|
train
| false
|
50,420
|
def str2html(sourcestring, colors=None, title='', markup='html', header=None, footer=None, linenumbers=0, form=None):
stringIO = StringIO.StringIO()
Parser(sourcestring, colors=colors, title=title, out=stringIO, markup=markup, header=header, footer=footer, linenumbers=linenumbers).format(form)
stringIO.seek(0)
return stringIO.read()
|
[
"def",
"str2html",
"(",
"sourcestring",
",",
"colors",
"=",
"None",
",",
"title",
"=",
"''",
",",
"markup",
"=",
"'html'",
",",
"header",
"=",
"None",
",",
"footer",
"=",
"None",
",",
"linenumbers",
"=",
"0",
",",
"form",
"=",
"None",
")",
":",
"stringIO",
"=",
"StringIO",
".",
"StringIO",
"(",
")",
"Parser",
"(",
"sourcestring",
",",
"colors",
"=",
"colors",
",",
"title",
"=",
"title",
",",
"out",
"=",
"stringIO",
",",
"markup",
"=",
"markup",
",",
"header",
"=",
"header",
",",
"footer",
"=",
"footer",
",",
"linenumbers",
"=",
"linenumbers",
")",
".",
"format",
"(",
"form",
")",
"stringIO",
".",
"seek",
"(",
"0",
")",
"return",
"stringIO",
".",
"read",
"(",
")"
] |
converts a code to colorized html .
|
train
| false
|
50,421
|
def open_tunnel(addr, server, keyfile=None, password=None, paramiko=None, timeout=60):
lport = select_random_ports(1)[0]
(transport, addr) = addr.split('://')
(ip, rport) = addr.split(':')
rport = int(rport)
if (paramiko is None):
paramiko = (sys.platform == 'win32')
if paramiko:
tunnelf = paramiko_tunnel
else:
tunnelf = openssh_tunnel
tunnel = tunnelf(lport, rport, server, remoteip=ip, keyfile=keyfile, password=password, timeout=timeout)
return (('tcp://127.0.0.1:%i' % lport), tunnel)
|
[
"def",
"open_tunnel",
"(",
"addr",
",",
"server",
",",
"keyfile",
"=",
"None",
",",
"password",
"=",
"None",
",",
"paramiko",
"=",
"None",
",",
"timeout",
"=",
"60",
")",
":",
"lport",
"=",
"select_random_ports",
"(",
"1",
")",
"[",
"0",
"]",
"(",
"transport",
",",
"addr",
")",
"=",
"addr",
".",
"split",
"(",
"'://'",
")",
"(",
"ip",
",",
"rport",
")",
"=",
"addr",
".",
"split",
"(",
"':'",
")",
"rport",
"=",
"int",
"(",
"rport",
")",
"if",
"(",
"paramiko",
"is",
"None",
")",
":",
"paramiko",
"=",
"(",
"sys",
".",
"platform",
"==",
"'win32'",
")",
"if",
"paramiko",
":",
"tunnelf",
"=",
"paramiko_tunnel",
"else",
":",
"tunnelf",
"=",
"openssh_tunnel",
"tunnel",
"=",
"tunnelf",
"(",
"lport",
",",
"rport",
",",
"server",
",",
"remoteip",
"=",
"ip",
",",
"keyfile",
"=",
"keyfile",
",",
"password",
"=",
"password",
",",
"timeout",
"=",
"timeout",
")",
"return",
"(",
"(",
"'tcp://127.0.0.1:%i'",
"%",
"lport",
")",
",",
"tunnel",
")"
] |
open a tunneled connection from a 0mq url .
|
train
| true
|
50,424
|
def create_arguments(primary, pyfunction, call_node, scope):
args = list(call_node.args)
args.extend(call_node.keywords)
called = call_node.func
if (_is_method_call(primary, pyfunction) and isinstance(called, ast.Attribute)):
args.insert(0, called.value)
return Arguments(args, scope)
|
[
"def",
"create_arguments",
"(",
"primary",
",",
"pyfunction",
",",
"call_node",
",",
"scope",
")",
":",
"args",
"=",
"list",
"(",
"call_node",
".",
"args",
")",
"args",
".",
"extend",
"(",
"call_node",
".",
"keywords",
")",
"called",
"=",
"call_node",
".",
"func",
"if",
"(",
"_is_method_call",
"(",
"primary",
",",
"pyfunction",
")",
"and",
"isinstance",
"(",
"called",
",",
"ast",
".",
"Attribute",
")",
")",
":",
"args",
".",
"insert",
"(",
"0",
",",
"called",
".",
"value",
")",
"return",
"Arguments",
"(",
"args",
",",
"scope",
")"
] |
a factory for creating arguments .
|
train
| true
|
50,426
|
def get_wmt_enfr_dev_set(directory):
dev_name = 'newstest2013'
dev_path = os.path.join(directory, dev_name)
if (not (gfile.Exists((dev_path + '.fr')) and gfile.Exists((dev_path + '.en')))):
dev_file = maybe_download(directory, 'dev-v2.tgz', _WMT_ENFR_DEV_URL)
print(('Extracting tgz file %s' % dev_file))
with tarfile.open(dev_file, 'r:gz') as dev_tar:
fr_dev_file = dev_tar.getmember((('dev/' + dev_name) + '.fr'))
en_dev_file = dev_tar.getmember((('dev/' + dev_name) + '.en'))
fr_dev_file.name = (dev_name + '.fr')
en_dev_file.name = (dev_name + '.en')
dev_tar.extract(fr_dev_file, directory)
dev_tar.extract(en_dev_file, directory)
return dev_path
|
[
"def",
"get_wmt_enfr_dev_set",
"(",
"directory",
")",
":",
"dev_name",
"=",
"'newstest2013'",
"dev_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"dev_name",
")",
"if",
"(",
"not",
"(",
"gfile",
".",
"Exists",
"(",
"(",
"dev_path",
"+",
"'.fr'",
")",
")",
"and",
"gfile",
".",
"Exists",
"(",
"(",
"dev_path",
"+",
"'.en'",
")",
")",
")",
")",
":",
"dev_file",
"=",
"maybe_download",
"(",
"directory",
",",
"'dev-v2.tgz'",
",",
"_WMT_ENFR_DEV_URL",
")",
"print",
"(",
"(",
"'Extracting tgz file %s'",
"%",
"dev_file",
")",
")",
"with",
"tarfile",
".",
"open",
"(",
"dev_file",
",",
"'r:gz'",
")",
"as",
"dev_tar",
":",
"fr_dev_file",
"=",
"dev_tar",
".",
"getmember",
"(",
"(",
"(",
"'dev/'",
"+",
"dev_name",
")",
"+",
"'.fr'",
")",
")",
"en_dev_file",
"=",
"dev_tar",
".",
"getmember",
"(",
"(",
"(",
"'dev/'",
"+",
"dev_name",
")",
"+",
"'.en'",
")",
")",
"fr_dev_file",
".",
"name",
"=",
"(",
"dev_name",
"+",
"'.fr'",
")",
"en_dev_file",
".",
"name",
"=",
"(",
"dev_name",
"+",
"'.en'",
")",
"dev_tar",
".",
"extract",
"(",
"fr_dev_file",
",",
"directory",
")",
"dev_tar",
".",
"extract",
"(",
"en_dev_file",
",",
"directory",
")",
"return",
"dev_path"
] |
download the wmt en-fr training corpus to directory unless its there .
|
train
| false
|
50,428
|
def generate_glance_url():
return ('%s://%s:%d' % (CONF.glance_protocol, CONF.glance_host, CONF.glance_port))
|
[
"def",
"generate_glance_url",
"(",
")",
":",
"return",
"(",
"'%s://%s:%d'",
"%",
"(",
"CONF",
".",
"glance_protocol",
",",
"CONF",
".",
"glance_host",
",",
"CONF",
".",
"glance_port",
")",
")"
] |
generate the url to glance .
|
train
| false
|
50,430
|
def _expand_user(filepath_or_buffer):
if isinstance(filepath_or_buffer, string_types):
return os.path.expanduser(filepath_or_buffer)
return filepath_or_buffer
|
[
"def",
"_expand_user",
"(",
"filepath_or_buffer",
")",
":",
"if",
"isinstance",
"(",
"filepath_or_buffer",
",",
"string_types",
")",
":",
"return",
"os",
".",
"path",
".",
"expanduser",
"(",
"filepath_or_buffer",
")",
"return",
"filepath_or_buffer"
] |
return the argument with an initial component of ~ or ~user replaced by that users home directory .
|
train
| false
|
50,431
|
def init_tasks():
db = Database()
cfg = Config()
log.debug('Checking for locked tasks..')
for task in db.list_tasks(status=TASK_RUNNING):
if cfg.cuckoo.reschedule:
task_id = db.reschedule(task.id)
log.info('Rescheduled task with ID %s and target %s: task #%s', task.id, task.target, task_id)
else:
db.set_status(task.id, TASK_FAILED_ANALYSIS)
log.info('Updated running task ID {0} status to failed_analysis'.format(task.id))
log.debug('Checking for pending service tasks..')
for task in db.list_tasks(status=TASK_PENDING, category='service'):
db.set_status(task.id, TASK_FAILED_ANALYSIS)
|
[
"def",
"init_tasks",
"(",
")",
":",
"db",
"=",
"Database",
"(",
")",
"cfg",
"=",
"Config",
"(",
")",
"log",
".",
"debug",
"(",
"'Checking for locked tasks..'",
")",
"for",
"task",
"in",
"db",
".",
"list_tasks",
"(",
"status",
"=",
"TASK_RUNNING",
")",
":",
"if",
"cfg",
".",
"cuckoo",
".",
"reschedule",
":",
"task_id",
"=",
"db",
".",
"reschedule",
"(",
"task",
".",
"id",
")",
"log",
".",
"info",
"(",
"'Rescheduled task with ID %s and target %s: task #%s'",
",",
"task",
".",
"id",
",",
"task",
".",
"target",
",",
"task_id",
")",
"else",
":",
"db",
".",
"set_status",
"(",
"task",
".",
"id",
",",
"TASK_FAILED_ANALYSIS",
")",
"log",
".",
"info",
"(",
"'Updated running task ID {0} status to failed_analysis'",
".",
"format",
"(",
"task",
".",
"id",
")",
")",
"log",
".",
"debug",
"(",
"'Checking for pending service tasks..'",
")",
"for",
"task",
"in",
"db",
".",
"list_tasks",
"(",
"status",
"=",
"TASK_PENDING",
",",
"category",
"=",
"'service'",
")",
":",
"db",
".",
"set_status",
"(",
"task",
".",
"id",
",",
"TASK_FAILED_ANALYSIS",
")"
] |
check tasks and reschedule uncompleted ones .
|
train
| false
|
50,432
|
def sign_remote_certificate(argdic, **kwargs):
if ('signing_policy' not in argdic):
return 'signing_policy must be specified'
if (not isinstance(argdic, dict)):
argdic = ast.literal_eval(argdic)
signing_policy = {}
if ('signing_policy' in argdic):
signing_policy = _get_signing_policy(argdic['signing_policy'])
if (not signing_policy):
return 'Signing policy {0} does not exist.'.format(argdic['signing_policy'])
if isinstance(signing_policy, list):
dict_ = {}
for item in signing_policy:
dict_.update(item)
signing_policy = dict_
if ('minions' in signing_policy):
if ('__pub_id' not in kwargs):
return 'minion sending this request could not be identified'
if (not __salt__['match.glob'](signing_policy['minions'], kwargs['__pub_id'])):
return '{0} not permitted to use signing policy {1}'.format(kwargs['__pub_id'], argdic['signing_policy'])
try:
return create_certificate(path=None, text=True, **argdic)
except Exception as except_:
return str(except_)
|
[
"def",
"sign_remote_certificate",
"(",
"argdic",
",",
"**",
"kwargs",
")",
":",
"if",
"(",
"'signing_policy'",
"not",
"in",
"argdic",
")",
":",
"return",
"'signing_policy must be specified'",
"if",
"(",
"not",
"isinstance",
"(",
"argdic",
",",
"dict",
")",
")",
":",
"argdic",
"=",
"ast",
".",
"literal_eval",
"(",
"argdic",
")",
"signing_policy",
"=",
"{",
"}",
"if",
"(",
"'signing_policy'",
"in",
"argdic",
")",
":",
"signing_policy",
"=",
"_get_signing_policy",
"(",
"argdic",
"[",
"'signing_policy'",
"]",
")",
"if",
"(",
"not",
"signing_policy",
")",
":",
"return",
"'Signing policy {0} does not exist.'",
".",
"format",
"(",
"argdic",
"[",
"'signing_policy'",
"]",
")",
"if",
"isinstance",
"(",
"signing_policy",
",",
"list",
")",
":",
"dict_",
"=",
"{",
"}",
"for",
"item",
"in",
"signing_policy",
":",
"dict_",
".",
"update",
"(",
"item",
")",
"signing_policy",
"=",
"dict_",
"if",
"(",
"'minions'",
"in",
"signing_policy",
")",
":",
"if",
"(",
"'__pub_id'",
"not",
"in",
"kwargs",
")",
":",
"return",
"'minion sending this request could not be identified'",
"if",
"(",
"not",
"__salt__",
"[",
"'match.glob'",
"]",
"(",
"signing_policy",
"[",
"'minions'",
"]",
",",
"kwargs",
"[",
"'__pub_id'",
"]",
")",
")",
":",
"return",
"'{0} not permitted to use signing policy {1}'",
".",
"format",
"(",
"kwargs",
"[",
"'__pub_id'",
"]",
",",
"argdic",
"[",
"'signing_policy'",
"]",
")",
"try",
":",
"return",
"create_certificate",
"(",
"path",
"=",
"None",
",",
"text",
"=",
"True",
",",
"**",
"argdic",
")",
"except",
"Exception",
"as",
"except_",
":",
"return",
"str",
"(",
"except_",
")"
] |
request a certificate to be remotely signed according to a signing policy .
|
train
| true
|
50,433
|
def _init_os2():
g = {}
g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1)
g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1)
g['INCLUDEPY'] = get_python_inc(plat_specific=0)
g['SO'] = '.pyd'
g['EXE'] = '.exe'
global _config_vars
_config_vars = g
|
[
"def",
"_init_os2",
"(",
")",
":",
"g",
"=",
"{",
"}",
"g",
"[",
"'LIBDEST'",
"]",
"=",
"get_python_lib",
"(",
"plat_specific",
"=",
"0",
",",
"standard_lib",
"=",
"1",
")",
"g",
"[",
"'BINLIBDEST'",
"]",
"=",
"get_python_lib",
"(",
"plat_specific",
"=",
"1",
",",
"standard_lib",
"=",
"1",
")",
"g",
"[",
"'INCLUDEPY'",
"]",
"=",
"get_python_inc",
"(",
"plat_specific",
"=",
"0",
")",
"g",
"[",
"'SO'",
"]",
"=",
"'.pyd'",
"g",
"[",
"'EXE'",
"]",
"=",
"'.exe'",
"global",
"_config_vars",
"_config_vars",
"=",
"g"
] |
initialize the module as appropriate for os/2 .
|
train
| false
|
50,434
|
def log_to_atan(f, g):
if (f.degree() < g.degree()):
(f, g) = ((- g), f)
f = f.to_field()
g = g.to_field()
(p, q) = f.div(g)
if q.is_zero:
return (2 * atan(p.as_expr()))
else:
(s, t, h) = g.gcdex((- f))
u = ((f * s) + (g * t)).quo(h)
A = (2 * atan(u.as_expr()))
return (A + log_to_atan(s, t))
|
[
"def",
"log_to_atan",
"(",
"f",
",",
"g",
")",
":",
"if",
"(",
"f",
".",
"degree",
"(",
")",
"<",
"g",
".",
"degree",
"(",
")",
")",
":",
"(",
"f",
",",
"g",
")",
"=",
"(",
"(",
"-",
"g",
")",
",",
"f",
")",
"f",
"=",
"f",
".",
"to_field",
"(",
")",
"g",
"=",
"g",
".",
"to_field",
"(",
")",
"(",
"p",
",",
"q",
")",
"=",
"f",
".",
"div",
"(",
"g",
")",
"if",
"q",
".",
"is_zero",
":",
"return",
"(",
"2",
"*",
"atan",
"(",
"p",
".",
"as_expr",
"(",
")",
")",
")",
"else",
":",
"(",
"s",
",",
"t",
",",
"h",
")",
"=",
"g",
".",
"gcdex",
"(",
"(",
"-",
"f",
")",
")",
"u",
"=",
"(",
"(",
"f",
"*",
"s",
")",
"+",
"(",
"g",
"*",
"t",
")",
")",
".",
"quo",
"(",
"h",
")",
"A",
"=",
"(",
"2",
"*",
"atan",
"(",
"u",
".",
"as_expr",
"(",
")",
")",
")",
"return",
"(",
"A",
"+",
"log_to_atan",
"(",
"s",
",",
"t",
")",
")"
] |
convert complex logarithms to real arctangents .
|
train
| false
|
50,435
|
def add_skip_patch(result):
return make_instancemethod(TextTestResult.addSkip, result)
|
[
"def",
"add_skip_patch",
"(",
"result",
")",
":",
"return",
"make_instancemethod",
"(",
"TextTestResult",
".",
"addSkip",
",",
"result",
")"
] |
create a new addskip method to patch into a result instance that delegates to adderror .
|
train
| false
|
50,436
|
def gqn(val):
if isinstance(val, basestring):
if isinstance(val, unicode):
val = val.encode('ascii')
return ("'%s'" % val)
else:
return str(val)
|
[
"def",
"gqn",
"(",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"basestring",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"unicode",
")",
":",
"val",
"=",
"val",
".",
"encode",
"(",
"'ascii'",
")",
"return",
"(",
"\"'%s'\"",
"%",
"val",
")",
"else",
":",
"return",
"str",
"(",
"val",
")"
] |
the geographic quote name function; used for quoting tables and geometries .
|
train
| false
|
50,437
|
def erase_specular(image, lower_threshold=0.0, upper_threshold=150.0):
thresh = cv2.inRange(image, np.asarray(float(lower_threshold)), np.asarray(256.0))
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (7, 7))
hi_mask = cv2.dilate(thresh, kernel, iterations=2)
specular = cv2.inpaint(image, hi_mask, 2, flags=cv2.INPAINT_TELEA)
return specular
|
[
"def",
"erase_specular",
"(",
"image",
",",
"lower_threshold",
"=",
"0.0",
",",
"upper_threshold",
"=",
"150.0",
")",
":",
"thresh",
"=",
"cv2",
".",
"inRange",
"(",
"image",
",",
"np",
".",
"asarray",
"(",
"float",
"(",
"lower_threshold",
")",
")",
",",
"np",
".",
"asarray",
"(",
"256.0",
")",
")",
"kernel",
"=",
"cv2",
".",
"getStructuringElement",
"(",
"cv2",
".",
"MORPH_ELLIPSE",
",",
"(",
"7",
",",
"7",
")",
")",
"hi_mask",
"=",
"cv2",
".",
"dilate",
"(",
"thresh",
",",
"kernel",
",",
"iterations",
"=",
"2",
")",
"specular",
"=",
"cv2",
".",
"inpaint",
"(",
"image",
",",
"hi_mask",
",",
"2",
",",
"flags",
"=",
"cv2",
".",
"INPAINT_TELEA",
")",
"return",
"specular"
] |
erase_specular: removes specular reflections within given threshold using a binary mask .
|
train
| false
|
50,440
|
def p_statement_expr():
print t[1]
|
[
"def",
"p_statement_expr",
"(",
")",
":",
"print",
"t",
"[",
"1",
"]"
] |
statement : expression .
|
train
| false
|
50,441
|
def _handle_identical_cert_request(config, lineage):
if (not lineage.ensure_deployed()):
return ('reinstall', lineage)
if renewal.should_renew(config, lineage):
return ('renew', lineage)
if config.reinstall:
return ('reinstall', lineage)
question = "You have an existing certificate that has exactly the same domains or certificate name you requested and isn't close to expiry.{br}(ref: {0}){br}{br}What would you like to do?".format(lineage.configfile.filename, br=os.linesep)
if (config.verb == 'run'):
keep_opt = 'Attempt to reinstall this existing certificate'
elif (config.verb == 'certonly'):
keep_opt = 'Keep the existing certificate for now'
choices = [keep_opt, 'Renew & replace the cert (limit ~5 per 7 days)']
display = zope.component.getUtility(interfaces.IDisplay)
response = display.menu(question, choices, 'OK', 'Cancel', default=0, force_interactive=True)
if (response[0] == display_util.CANCEL):
raise errors.Error('User chose to cancel the operation and may reinvoke the client.')
elif (response[1] == 0):
return ('reinstall', lineage)
elif (response[1] == 1):
return ('renew', lineage)
else:
assert False, 'This is impossible'
|
[
"def",
"_handle_identical_cert_request",
"(",
"config",
",",
"lineage",
")",
":",
"if",
"(",
"not",
"lineage",
".",
"ensure_deployed",
"(",
")",
")",
":",
"return",
"(",
"'reinstall'",
",",
"lineage",
")",
"if",
"renewal",
".",
"should_renew",
"(",
"config",
",",
"lineage",
")",
":",
"return",
"(",
"'renew'",
",",
"lineage",
")",
"if",
"config",
".",
"reinstall",
":",
"return",
"(",
"'reinstall'",
",",
"lineage",
")",
"question",
"=",
"\"You have an existing certificate that has exactly the same domains or certificate name you requested and isn't close to expiry.{br}(ref: {0}){br}{br}What would you like to do?\"",
".",
"format",
"(",
"lineage",
".",
"configfile",
".",
"filename",
",",
"br",
"=",
"os",
".",
"linesep",
")",
"if",
"(",
"config",
".",
"verb",
"==",
"'run'",
")",
":",
"keep_opt",
"=",
"'Attempt to reinstall this existing certificate'",
"elif",
"(",
"config",
".",
"verb",
"==",
"'certonly'",
")",
":",
"keep_opt",
"=",
"'Keep the existing certificate for now'",
"choices",
"=",
"[",
"keep_opt",
",",
"'Renew & replace the cert (limit ~5 per 7 days)'",
"]",
"display",
"=",
"zope",
".",
"component",
".",
"getUtility",
"(",
"interfaces",
".",
"IDisplay",
")",
"response",
"=",
"display",
".",
"menu",
"(",
"question",
",",
"choices",
",",
"'OK'",
",",
"'Cancel'",
",",
"default",
"=",
"0",
",",
"force_interactive",
"=",
"True",
")",
"if",
"(",
"response",
"[",
"0",
"]",
"==",
"display_util",
".",
"CANCEL",
")",
":",
"raise",
"errors",
".",
"Error",
"(",
"'User chose to cancel the operation and may reinvoke the client.'",
")",
"elif",
"(",
"response",
"[",
"1",
"]",
"==",
"0",
")",
":",
"return",
"(",
"'reinstall'",
",",
"lineage",
")",
"elif",
"(",
"response",
"[",
"1",
"]",
"==",
"1",
")",
":",
"return",
"(",
"'renew'",
",",
"lineage",
")",
"else",
":",
"assert",
"False",
",",
"'This is impossible'"
] |
figure out what to do if a lineage has the same names as a previously obtained one .
|
train
| false
|
50,442
|
def GetImplementationClass(kind_or_class_key):
if isinstance(kind_or_class_key, tuple):
try:
implementation_class = polymodel._class_map[kind_or_class_key]
except KeyError:
raise db.KindError(("No implementation for class '%s'" % kind_or_class_key))
else:
implementation_class = db.class_for_kind(kind_or_class_key)
return implementation_class
|
[
"def",
"GetImplementationClass",
"(",
"kind_or_class_key",
")",
":",
"if",
"isinstance",
"(",
"kind_or_class_key",
",",
"tuple",
")",
":",
"try",
":",
"implementation_class",
"=",
"polymodel",
".",
"_class_map",
"[",
"kind_or_class_key",
"]",
"except",
"KeyError",
":",
"raise",
"db",
".",
"KindError",
"(",
"(",
"\"No implementation for class '%s'\"",
"%",
"kind_or_class_key",
")",
")",
"else",
":",
"implementation_class",
"=",
"db",
".",
"class_for_kind",
"(",
"kind_or_class_key",
")",
"return",
"implementation_class"
] |
returns the implementation class for a given kind or class key .
|
train
| false
|
50,443
|
def resig(app, what, name, obj, options, signature, return_annotation):
docobj = getattr(obj, '__docobj__', None)
if (docobj is not None):
argspec = inspect.getargspec(docobj)
if (argspec[0] and (argspec[0][0] in ('cls', 'self'))):
del argspec[0][0]
signature = inspect.formatargspec(*argspec)
return (signature, return_annotation)
|
[
"def",
"resig",
"(",
"app",
",",
"what",
",",
"name",
",",
"obj",
",",
"options",
",",
"signature",
",",
"return_annotation",
")",
":",
"docobj",
"=",
"getattr",
"(",
"obj",
",",
"'__docobj__'",
",",
"None",
")",
"if",
"(",
"docobj",
"is",
"not",
"None",
")",
":",
"argspec",
"=",
"inspect",
".",
"getargspec",
"(",
"docobj",
")",
"if",
"(",
"argspec",
"[",
"0",
"]",
"and",
"(",
"argspec",
"[",
"0",
"]",
"[",
"0",
"]",
"in",
"(",
"'cls'",
",",
"'self'",
")",
")",
")",
":",
"del",
"argspec",
"[",
"0",
"]",
"[",
"0",
"]",
"signature",
"=",
"inspect",
".",
"formatargspec",
"(",
"*",
"argspec",
")",
"return",
"(",
"signature",
",",
"return_annotation",
")"
] |
allow for preservation of @action_method decorated methods in configurator .
|
train
| false
|
50,444
|
def TYPPRICE(barDs, count):
return call_talib_with_hlc(barDs, count, talib.TYPPRICE)
|
[
"def",
"TYPPRICE",
"(",
"barDs",
",",
"count",
")",
":",
"return",
"call_talib_with_hlc",
"(",
"barDs",
",",
"count",
",",
"talib",
".",
"TYPPRICE",
")"
] |
typical price .
|
train
| false
|
50,446
|
def with_comprehensive_theme(theme_dir_name):
def _decorator(func):
@wraps(func)
def _decorated(*args, **kwargs):
domain = '{theme_dir_name}.org'.format(theme_dir_name=re.sub('\\.org$', '', theme_dir_name))
(site, __) = Site.objects.get_or_create(domain=domain, name=domain)
(site_theme, __) = SiteTheme.objects.get_or_create(site=site, theme_dir_name=theme_dir_name)
with patch('openedx.core.djangoapps.theming.helpers.get_current_site_theme', return_value=site_theme):
with patch('openedx.core.djangoapps.theming.helpers.get_current_site', return_value=site):
return func(*args, **kwargs)
return _decorated
return _decorator
|
[
"def",
"with_comprehensive_theme",
"(",
"theme_dir_name",
")",
":",
"def",
"_decorator",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"_decorated",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"domain",
"=",
"'{theme_dir_name}.org'",
".",
"format",
"(",
"theme_dir_name",
"=",
"re",
".",
"sub",
"(",
"'\\\\.org$'",
",",
"''",
",",
"theme_dir_name",
")",
")",
"(",
"site",
",",
"__",
")",
"=",
"Site",
".",
"objects",
".",
"get_or_create",
"(",
"domain",
"=",
"domain",
",",
"name",
"=",
"domain",
")",
"(",
"site_theme",
",",
"__",
")",
"=",
"SiteTheme",
".",
"objects",
".",
"get_or_create",
"(",
"site",
"=",
"site",
",",
"theme_dir_name",
"=",
"theme_dir_name",
")",
"with",
"patch",
"(",
"'openedx.core.djangoapps.theming.helpers.get_current_site_theme'",
",",
"return_value",
"=",
"site_theme",
")",
":",
"with",
"patch",
"(",
"'openedx.core.djangoapps.theming.helpers.get_current_site'",
",",
"return_value",
"=",
"site",
")",
":",
"return",
"func",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"return",
"_decorated",
"return",
"_decorator"
] |
a decorator to run a test with a comprehensive theming enabled .
|
train
| false
|
50,447
|
def get_typelibs(module, version):
logger.warn('get_typelibs is deprecated, use get_gi_typelibs instead')
return get_gi_typelibs(module, version)[1]
|
[
"def",
"get_typelibs",
"(",
"module",
",",
"version",
")",
":",
"logger",
".",
"warn",
"(",
"'get_typelibs is deprecated, use get_gi_typelibs instead'",
")",
"return",
"get_gi_typelibs",
"(",
"module",
",",
"version",
")",
"[",
"1",
"]"
] |
deprecated; only here for backwards compat .
|
train
| false
|
50,448
|
def cur_usec():
dt = datetime.now()
t = (((dt.minute * 60) + dt.second) + (dt.microsecond / 1000000.0))
return t
|
[
"def",
"cur_usec",
"(",
")",
":",
"dt",
"=",
"datetime",
".",
"now",
"(",
")",
"t",
"=",
"(",
"(",
"(",
"dt",
".",
"minute",
"*",
"60",
")",
"+",
"dt",
".",
"second",
")",
"+",
"(",
"dt",
".",
"microsecond",
"/",
"1000000.0",
")",
")",
"return",
"t"
] |
return current time in usecs .
|
train
| false
|
50,449
|
def polygon_clip(rp, cp, r0, c0, r1, c1):
poly = path.Path(np.vstack((rp, cp)).T, closed=True)
clip_rect = transforms.Bbox([[r0, c0], [r1, c1]])
poly_clipped = poly.clip_to_bbox(clip_rect).to_polygons()[0]
if np.all((poly_clipped[(-1)] == poly_clipped[(-2)])):
poly_clipped = poly_clipped[:(-1)]
return (poly_clipped[:, 0], poly_clipped[:, 1])
|
[
"def",
"polygon_clip",
"(",
"rp",
",",
"cp",
",",
"r0",
",",
"c0",
",",
"r1",
",",
"c1",
")",
":",
"poly",
"=",
"path",
".",
"Path",
"(",
"np",
".",
"vstack",
"(",
"(",
"rp",
",",
"cp",
")",
")",
".",
"T",
",",
"closed",
"=",
"True",
")",
"clip_rect",
"=",
"transforms",
".",
"Bbox",
"(",
"[",
"[",
"r0",
",",
"c0",
"]",
",",
"[",
"r1",
",",
"c1",
"]",
"]",
")",
"poly_clipped",
"=",
"poly",
".",
"clip_to_bbox",
"(",
"clip_rect",
")",
".",
"to_polygons",
"(",
")",
"[",
"0",
"]",
"if",
"np",
".",
"all",
"(",
"(",
"poly_clipped",
"[",
"(",
"-",
"1",
")",
"]",
"==",
"poly_clipped",
"[",
"(",
"-",
"2",
")",
"]",
")",
")",
":",
"poly_clipped",
"=",
"poly_clipped",
"[",
":",
"(",
"-",
"1",
")",
"]",
"return",
"(",
"poly_clipped",
"[",
":",
",",
"0",
"]",
",",
"poly_clipped",
"[",
":",
",",
"1",
"]",
")"
] |
clip a polygon to the given bounding box .
|
train
| false
|
50,451
|
def add_filename_suffix(filepath, suffix):
(root, extension) = splitext(basename(filepath))
return ((root + suffix) + extension)
|
[
"def",
"add_filename_suffix",
"(",
"filepath",
",",
"suffix",
")",
":",
"(",
"root",
",",
"extension",
")",
"=",
"splitext",
"(",
"basename",
"(",
"filepath",
")",
")",
"return",
"(",
"(",
"root",
"+",
"suffix",
")",
"+",
"extension",
")"
] |
adds a suffix to the filepath .
|
train
| false
|
50,452
|
def json2py(jsonstr):
if (not isinstance(jsonstr, str)):
return jsonstr
from xml.sax.saxutils import unescape
try:
jsonstr = unescape(jsonstr, {"u'": '"'})
jsonstr = unescape(jsonstr, {"'": '"'})
python_structure = json.loads(jsonstr)
except ValueError:
_debug(('ERROR: attempting to convert %s using modules/s3db/survey/json2py.py' % jsonstr))
return jsonstr
else:
return python_structure
|
[
"def",
"json2py",
"(",
"jsonstr",
")",
":",
"if",
"(",
"not",
"isinstance",
"(",
"jsonstr",
",",
"str",
")",
")",
":",
"return",
"jsonstr",
"from",
"xml",
".",
"sax",
".",
"saxutils",
"import",
"unescape",
"try",
":",
"jsonstr",
"=",
"unescape",
"(",
"jsonstr",
",",
"{",
"\"u'\"",
":",
"'\"'",
"}",
")",
"jsonstr",
"=",
"unescape",
"(",
"jsonstr",
",",
"{",
"\"'\"",
":",
"'\"'",
"}",
")",
"python_structure",
"=",
"json",
".",
"loads",
"(",
"jsonstr",
")",
"except",
"ValueError",
":",
"_debug",
"(",
"(",
"'ERROR: attempting to convert %s using modules/s3db/survey/json2py.py'",
"%",
"jsonstr",
")",
")",
"return",
"jsonstr",
"else",
":",
"return",
"python_structure"
] |
utility function to convert a string in json to a python structure .
|
train
| false
|
50,453
|
def to_tp_relative_path(pootle_path):
return u'/'.join(pootle_path.split(u'/')[3:])
|
[
"def",
"to_tp_relative_path",
"(",
"pootle_path",
")",
":",
"return",
"u'/'",
".",
"join",
"(",
"pootle_path",
".",
"split",
"(",
"u'/'",
")",
"[",
"3",
":",
"]",
")"
] |
returns a path relative to translation projects .
|
train
| false
|
50,454
|
def test_image_load():
assert_raises(AssertionError, load, 1)
path = os.path.join(pylearn2.__path__[0], 'utils', 'tests', 'example_image', 'mnist0.jpg')
img = load(path)
eq_(img.shape, (28, 28, 1))
|
[
"def",
"test_image_load",
"(",
")",
":",
"assert_raises",
"(",
"AssertionError",
",",
"load",
",",
"1",
")",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"pylearn2",
".",
"__path__",
"[",
"0",
"]",
",",
"'utils'",
",",
"'tests'",
",",
"'example_image'",
",",
"'mnist0.jpg'",
")",
"img",
"=",
"load",
"(",
"path",
")",
"eq_",
"(",
"img",
".",
"shape",
",",
"(",
"28",
",",
"28",
",",
"1",
")",
")"
] |
test utils .
|
train
| false
|
50,455
|
def convert_dashes(dash):
mpl_dash_map = {'-': 'solid', '--': 'dashed', ':': 'dotted', '-.': 'dashdot'}
return mpl_dash_map.get(dash, dash)
|
[
"def",
"convert_dashes",
"(",
"dash",
")",
":",
"mpl_dash_map",
"=",
"{",
"'-'",
":",
"'solid'",
",",
"'--'",
":",
"'dashed'",
",",
"':'",
":",
"'dotted'",
",",
"'-.'",
":",
"'dashdot'",
"}",
"return",
"mpl_dash_map",
".",
"get",
"(",
"dash",
",",
"dash",
")"
] |
converts a matplotlib dash specification bokeh .
|
train
| false
|
50,456
|
def _msg_filter(f):
return (os.path.isfile(f) and f.endswith(EXT))
|
[
"def",
"_msg_filter",
"(",
"f",
")",
":",
"return",
"(",
"os",
".",
"path",
".",
"isfile",
"(",
"f",
")",
"and",
"f",
".",
"endswith",
"(",
"EXT",
")",
")"
] |
predicate for filtering directory list .
|
train
| false
|
50,457
|
def is_autoincrement(conn, table, field):
rows = query(conn, "\n SELECT TRIGGER_NAME\n FROM USER_TRIGGERS,\n (SELECT NAME, LISTAGG(TEXT, ' ') WITHIN GROUP (ORDER BY LINE) TEXT\n FROM USER_SOURCE\n WHERE TYPE = 'TRIGGER'\n GROUP BY NAME\n ) TRIGGER_DEFINITION\n WHERE TRIGGER_NAME = NAME\n AND TRIGGERING_EVENT = 'INSERT'\n AND TRIGGER_TYPE = 'BEFORE EACH ROW'\n AND TABLE_NAME = :t\n AND UPPER(TEXT) LIKE UPPER('%.NEXTVAL%')\n AND UPPER(TEXT) LIKE UPPER('%:NEW.' || :c || '%')\n ", table, field['COLUMN_NAME'])
return ((rows and True) or False)
|
[
"def",
"is_autoincrement",
"(",
"conn",
",",
"table",
",",
"field",
")",
":",
"rows",
"=",
"query",
"(",
"conn",
",",
"\"\\n SELECT TRIGGER_NAME\\n FROM USER_TRIGGERS,\\n (SELECT NAME, LISTAGG(TEXT, ' ') WITHIN GROUP (ORDER BY LINE) TEXT\\n FROM USER_SOURCE\\n WHERE TYPE = 'TRIGGER'\\n GROUP BY NAME\\n ) TRIGGER_DEFINITION\\n WHERE TRIGGER_NAME = NAME\\n AND TRIGGERING_EVENT = 'INSERT'\\n AND TRIGGER_TYPE = 'BEFORE EACH ROW'\\n AND TABLE_NAME = :t\\n AND UPPER(TEXT) LIKE UPPER('%.NEXTVAL%')\\n AND UPPER(TEXT) LIKE UPPER('%:NEW.' || :c || '%')\\n \"",
",",
"table",
",",
"field",
"[",
"'COLUMN_NAME'",
"]",
")",
"return",
"(",
"(",
"rows",
"and",
"True",
")",
"or",
"False",
")"
] |
find auto increment fields .
|
train
| false
|
50,460
|
def ValidateStringLength(name, value, max_len):
if isinstance(value, unicode):
value = value.encode('utf-8')
if (len(value) > max_len):
raise datastore_errors.BadValueError(('Property %s is %d bytes long; it must be %d or less. Consider Text instead, which can store strings of any length.' % (name, len(value), max_len)))
|
[
"def",
"ValidateStringLength",
"(",
"name",
",",
"value",
",",
"max_len",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"unicode",
")",
":",
"value",
"=",
"value",
".",
"encode",
"(",
"'utf-8'",
")",
"if",
"(",
"len",
"(",
"value",
")",
">",
"max_len",
")",
":",
"raise",
"datastore_errors",
".",
"BadValueError",
"(",
"(",
"'Property %s is %d bytes long; it must be %d or less. Consider Text instead, which can store strings of any length.'",
"%",
"(",
"name",
",",
"len",
"(",
"value",
")",
",",
"max_len",
")",
")",
")"
] |
raises an exception if the supplied string is too long .
|
train
| false
|
50,461
|
def csm_indices(csm):
return csm_properties(csm)[1]
|
[
"def",
"csm_indices",
"(",
"csm",
")",
":",
"return",
"csm_properties",
"(",
"csm",
")",
"[",
"1",
"]"
] |
return the indices field of the sparse variable .
|
train
| false
|
50,462
|
def is_eventvar(expr):
assert isinstance(expr, string_types), (u'%s is not a string' % expr)
return (re.match(u'^e\\d*$', expr) is not None)
|
[
"def",
"is_eventvar",
"(",
"expr",
")",
":",
"assert",
"isinstance",
"(",
"expr",
",",
"string_types",
")",
",",
"(",
"u'%s is not a string'",
"%",
"expr",
")",
"return",
"(",
"re",
".",
"match",
"(",
"u'^e\\\\d*$'",
",",
"expr",
")",
"is",
"not",
"None",
")"
] |
an event variable must be a single lowercase e character followed by zero or more digits .
|
train
| false
|
50,465
|
def check_field(collection, field):
print ('Getting %s from %r' % (field.name, collection))
assert_equals(field.default, getattr(collection, field.name))
new_value = ('new ' + field.name)
print ('Setting %s to %s on %r' % (field.name, new_value, collection))
setattr(collection, field.name, new_value)
print ('Checking %s on %r' % (field.name, collection))
assert_equals(new_value, getattr(collection, field.name))
print ('Deleting %s from %r' % (field.name, collection))
delattr(collection, field.name)
print ('Back to defaults for %s in %r' % (field.name, collection))
assert_equals(field.default, getattr(collection, field.name))
|
[
"def",
"check_field",
"(",
"collection",
",",
"field",
")",
":",
"print",
"(",
"'Getting %s from %r'",
"%",
"(",
"field",
".",
"name",
",",
"collection",
")",
")",
"assert_equals",
"(",
"field",
".",
"default",
",",
"getattr",
"(",
"collection",
",",
"field",
".",
"name",
")",
")",
"new_value",
"=",
"(",
"'new '",
"+",
"field",
".",
"name",
")",
"print",
"(",
"'Setting %s to %s on %r'",
"%",
"(",
"field",
".",
"name",
",",
"new_value",
",",
"collection",
")",
")",
"setattr",
"(",
"collection",
",",
"field",
".",
"name",
",",
"new_value",
")",
"print",
"(",
"'Checking %s on %r'",
"%",
"(",
"field",
".",
"name",
",",
"collection",
")",
")",
"assert_equals",
"(",
"new_value",
",",
"getattr",
"(",
"collection",
",",
"field",
".",
"name",
")",
")",
"print",
"(",
"'Deleting %s from %r'",
"%",
"(",
"field",
".",
"name",
",",
"collection",
")",
")",
"delattr",
"(",
"collection",
",",
"field",
".",
"name",
")",
"print",
"(",
"'Back to defaults for %s in %r'",
"%",
"(",
"field",
".",
"name",
",",
"collection",
")",
")",
"assert_equals",
"(",
"field",
".",
"default",
",",
"getattr",
"(",
"collection",
",",
"field",
".",
"name",
")",
")"
] |
test method .
|
train
| false
|
50,466
|
def diag_vec(operator):
size = (operator.size[0], operator.size[0])
return lo.LinOp(lo.DIAG_VEC, size, [operator], None)
|
[
"def",
"diag_vec",
"(",
"operator",
")",
":",
"size",
"=",
"(",
"operator",
".",
"size",
"[",
"0",
"]",
",",
"operator",
".",
"size",
"[",
"0",
"]",
")",
"return",
"lo",
".",
"LinOp",
"(",
"lo",
".",
"DIAG_VEC",
",",
"size",
",",
"[",
"operator",
"]",
",",
"None",
")"
] |
converts a vector to a diagonal matrix .
|
train
| false
|
50,468
|
def without_confirmation(proc, TIMEOUT):
_set_confirmation(proc, False)
proc.sendline(u'ehco test')
proc.sendline(u'fuck')
assert proc.expect([TIMEOUT, u'echo test'])
assert proc.expect([TIMEOUT, u'test'])
|
[
"def",
"without_confirmation",
"(",
"proc",
",",
"TIMEOUT",
")",
":",
"_set_confirmation",
"(",
"proc",
",",
"False",
")",
"proc",
".",
"sendline",
"(",
"u'ehco test'",
")",
"proc",
".",
"sendline",
"(",
"u'fuck'",
")",
"assert",
"proc",
".",
"expect",
"(",
"[",
"TIMEOUT",
",",
"u'echo test'",
"]",
")",
"assert",
"proc",
".",
"expect",
"(",
"[",
"TIMEOUT",
",",
"u'test'",
"]",
")"
] |
ensures that command can be fixed when confirmation disabled .
|
train
| false
|
50,469
|
def sh_margins(start=None, end=None, retry_count=3, pause=0.001):
start = (du.today_last_year() if (start is None) else start)
end = (du.today() if (end is None) else end)
if (du.diff_day(start, end) < 0):
return None
(start, end) = (start.replace('-', ''), end.replace('-', ''))
data = pd.DataFrame()
ct._write_head()
df = _sh_hz(data, start=start, end=end, retry_count=retry_count, pause=pause)
return df
|
[
"def",
"sh_margins",
"(",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"retry_count",
"=",
"3",
",",
"pause",
"=",
"0.001",
")",
":",
"start",
"=",
"(",
"du",
".",
"today_last_year",
"(",
")",
"if",
"(",
"start",
"is",
"None",
")",
"else",
"start",
")",
"end",
"=",
"(",
"du",
".",
"today",
"(",
")",
"if",
"(",
"end",
"is",
"None",
")",
"else",
"end",
")",
"if",
"(",
"du",
".",
"diff_day",
"(",
"start",
",",
"end",
")",
"<",
"0",
")",
":",
"return",
"None",
"(",
"start",
",",
"end",
")",
"=",
"(",
"start",
".",
"replace",
"(",
"'-'",
",",
"''",
")",
",",
"end",
".",
"replace",
"(",
"'-'",
",",
"''",
")",
")",
"data",
"=",
"pd",
".",
"DataFrame",
"(",
")",
"ct",
".",
"_write_head",
"(",
")",
"df",
"=",
"_sh_hz",
"(",
"data",
",",
"start",
"=",
"start",
",",
"end",
"=",
"end",
",",
"retry_count",
"=",
"retry_count",
",",
"pause",
"=",
"pause",
")",
"return",
"df"
] |
parameters start:string 开始日期 format:yyyy-mm-dd 为空时取去年今日 end:string 结束日期 format:yyyy-mm-dd 为空时取当前日期 retry_count : int .
|
train
| false
|
50,470
|
def p_expr_binary(p):
p[0] = ('BINOP', p[2], p[1], p[3])
|
[
"def",
"p_expr_binary",
"(",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"(",
"'BINOP'",
",",
"p",
"[",
"2",
"]",
",",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"3",
"]",
")"
] |
expr : expr plus expr | expr minus expr | expr times expr | expr divide expr | expr power expr .
|
train
| false
|
50,471
|
def es_query_with_analyzer(query, locale):
analyzer = es_analyzer_for_locale(locale, synonyms=True)
new_query = {}
from kitsune.search.models import get_mapping_types
localized_fields = []
for mt in get_mapping_types():
localized_fields.extend(mt.get_localized_fields())
for (k, v) in query.items():
(field, action) = k.split('__')
if (field in localized_fields):
new_query[(k + '_analyzer')] = (v, analyzer)
else:
new_query[k] = v
return new_query
|
[
"def",
"es_query_with_analyzer",
"(",
"query",
",",
"locale",
")",
":",
"analyzer",
"=",
"es_analyzer_for_locale",
"(",
"locale",
",",
"synonyms",
"=",
"True",
")",
"new_query",
"=",
"{",
"}",
"from",
"kitsune",
".",
"search",
".",
"models",
"import",
"get_mapping_types",
"localized_fields",
"=",
"[",
"]",
"for",
"mt",
"in",
"get_mapping_types",
"(",
")",
":",
"localized_fields",
".",
"extend",
"(",
"mt",
".",
"get_localized_fields",
"(",
")",
")",
"for",
"(",
"k",
",",
"v",
")",
"in",
"query",
".",
"items",
"(",
")",
":",
"(",
"field",
",",
"action",
")",
"=",
"k",
".",
"split",
"(",
"'__'",
")",
"if",
"(",
"field",
"in",
"localized_fields",
")",
":",
"new_query",
"[",
"(",
"k",
"+",
"'_analyzer'",
")",
"]",
"=",
"(",
"v",
",",
"analyzer",
")",
"else",
":",
"new_query",
"[",
"k",
"]",
"=",
"v",
"return",
"new_query"
] |
transform a query dict to use _analyzer actions for the right fields .
|
train
| false
|
50,473
|
def _get_version_info(blade_root_dir, svn_roots):
svn_info_map = {}
if os.path.exists(('%s/.git' % blade_root_dir)):
cmd = 'git log -n 1'
dirname = os.path.dirname(blade_root_dir)
version_info = _exec_get_version_info(cmd, None)
if version_info:
svn_info_map[dirname] = version_info
return svn_info_map
for root_dir in svn_roots:
root_dir_realpath = os.path.realpath(root_dir)
svn_working_dir = os.path.dirname(root_dir_realpath)
svn_dir = os.path.basename(root_dir_realpath)
cmd = ('svn info %s' % svn_dir)
version_info = _exec_get_version_info(cmd, svn_working_dir)
if (not version_info):
cmd = 'git ls-remote --get-url && git branch | grep "*" && git log -n 1'
version_info = _exec_get_version_info(cmd, root_dir_realpath)
if (not version_info):
console.warning(('Failed to get version control info in %s' % root_dir))
if version_info:
svn_info_map[root_dir] = version_info
return svn_info_map
|
[
"def",
"_get_version_info",
"(",
"blade_root_dir",
",",
"svn_roots",
")",
":",
"svn_info_map",
"=",
"{",
"}",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"(",
"'%s/.git'",
"%",
"blade_root_dir",
")",
")",
":",
"cmd",
"=",
"'git log -n 1'",
"dirname",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"blade_root_dir",
")",
"version_info",
"=",
"_exec_get_version_info",
"(",
"cmd",
",",
"None",
")",
"if",
"version_info",
":",
"svn_info_map",
"[",
"dirname",
"]",
"=",
"version_info",
"return",
"svn_info_map",
"for",
"root_dir",
"in",
"svn_roots",
":",
"root_dir_realpath",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"root_dir",
")",
"svn_working_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"root_dir_realpath",
")",
"svn_dir",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"root_dir_realpath",
")",
"cmd",
"=",
"(",
"'svn info %s'",
"%",
"svn_dir",
")",
"version_info",
"=",
"_exec_get_version_info",
"(",
"cmd",
",",
"svn_working_dir",
")",
"if",
"(",
"not",
"version_info",
")",
":",
"cmd",
"=",
"'git ls-remote --get-url && git branch | grep \"*\" && git log -n 1'",
"version_info",
"=",
"_exec_get_version_info",
"(",
"cmd",
",",
"root_dir_realpath",
")",
"if",
"(",
"not",
"version_info",
")",
":",
"console",
".",
"warning",
"(",
"(",
"'Failed to get version control info in %s'",
"%",
"root_dir",
")",
")",
"if",
"version_info",
":",
"svn_info_map",
"[",
"root_dir",
"]",
"=",
"version_info",
"return",
"svn_info_map"
] |
gets svn root dir info .
|
train
| false
|
50,474
|
@docstring.dedent_interpd
def zoomed_inset_axes(parent_axes, zoom, loc=1, bbox_to_anchor=None, bbox_transform=None, axes_class=None, axes_kwargs=None, borderpad=0.5):
if (axes_class is None):
axes_class = HostAxes
if (axes_kwargs is None):
inset_axes = axes_class(parent_axes.figure, parent_axes.get_position())
else:
inset_axes = axes_class(parent_axes.figure, parent_axes.get_position(), **axes_kwargs)
axes_locator = AnchoredZoomLocator(parent_axes, zoom=zoom, loc=loc, bbox_to_anchor=bbox_to_anchor, bbox_transform=bbox_transform, borderpad=borderpad)
inset_axes.set_axes_locator(axes_locator)
_add_inset_axes(parent_axes, inset_axes)
return inset_axes
|
[
"@",
"docstring",
".",
"dedent_interpd",
"def",
"zoomed_inset_axes",
"(",
"parent_axes",
",",
"zoom",
",",
"loc",
"=",
"1",
",",
"bbox_to_anchor",
"=",
"None",
",",
"bbox_transform",
"=",
"None",
",",
"axes_class",
"=",
"None",
",",
"axes_kwargs",
"=",
"None",
",",
"borderpad",
"=",
"0.5",
")",
":",
"if",
"(",
"axes_class",
"is",
"None",
")",
":",
"axes_class",
"=",
"HostAxes",
"if",
"(",
"axes_kwargs",
"is",
"None",
")",
":",
"inset_axes",
"=",
"axes_class",
"(",
"parent_axes",
".",
"figure",
",",
"parent_axes",
".",
"get_position",
"(",
")",
")",
"else",
":",
"inset_axes",
"=",
"axes_class",
"(",
"parent_axes",
".",
"figure",
",",
"parent_axes",
".",
"get_position",
"(",
")",
",",
"**",
"axes_kwargs",
")",
"axes_locator",
"=",
"AnchoredZoomLocator",
"(",
"parent_axes",
",",
"zoom",
"=",
"zoom",
",",
"loc",
"=",
"loc",
",",
"bbox_to_anchor",
"=",
"bbox_to_anchor",
",",
"bbox_transform",
"=",
"bbox_transform",
",",
"borderpad",
"=",
"borderpad",
")",
"inset_axes",
".",
"set_axes_locator",
"(",
"axes_locator",
")",
"_add_inset_axes",
"(",
"parent_axes",
",",
"inset_axes",
")",
"return",
"inset_axes"
] |
create an anchored inset axes by scaling a parent axes .
|
train
| false
|
50,475
|
def image_upload_to_dispatcher(entry, filename):
return entry.image_upload_to(filename)
|
[
"def",
"image_upload_to_dispatcher",
"(",
"entry",
",",
"filename",
")",
":",
"return",
"entry",
".",
"image_upload_to",
"(",
"filename",
")"
] |
dispatch function to allow overriding of image_upload_to method .
|
train
| false
|
50,477
|
def print_bucket_acl(bucket_name):
storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
for entry in bucket.acl:
print '{}: {}'.format(entry['role'], entry['entity'])
|
[
"def",
"print_bucket_acl",
"(",
"bucket_name",
")",
":",
"storage_client",
"=",
"storage",
".",
"Client",
"(",
")",
"bucket",
"=",
"storage_client",
".",
"bucket",
"(",
"bucket_name",
")",
"for",
"entry",
"in",
"bucket",
".",
"acl",
":",
"print",
"'{}: {}'",
".",
"format",
"(",
"entry",
"[",
"'role'",
"]",
",",
"entry",
"[",
"'entity'",
"]",
")"
] |
prints out a buckets access control list .
|
train
| false
|
50,480
|
def cfnumber_to_number(cfnumber):
numeric_type = cf.CFNumberGetType(cfnumber)
cfnum_to_ctype = {kCFNumberSInt8Type: c_int8, kCFNumberSInt16Type: c_int16, kCFNumberSInt32Type: c_int32, kCFNumberSInt64Type: c_int64, kCFNumberFloat32Type: c_float, kCFNumberFloat64Type: c_double, kCFNumberCharType: c_byte, kCFNumberShortType: c_short, kCFNumberIntType: c_int, kCFNumberLongType: c_long, kCFNumberLongLongType: c_longlong, kCFNumberFloatType: c_float, kCFNumberDoubleType: c_double, kCFNumberCFIndexType: CFIndex, kCFNumberCGFloatType: CGFloat}
if (numeric_type in cfnum_to_ctype):
t = cfnum_to_ctype[numeric_type]
result = t()
if cf.CFNumberGetValue(cfnumber, numeric_type, byref(result)):
return result.value
else:
raise Exception(('cfnumber_to_number: unhandled CFNumber type %d' % numeric_type))
|
[
"def",
"cfnumber_to_number",
"(",
"cfnumber",
")",
":",
"numeric_type",
"=",
"cf",
".",
"CFNumberGetType",
"(",
"cfnumber",
")",
"cfnum_to_ctype",
"=",
"{",
"kCFNumberSInt8Type",
":",
"c_int8",
",",
"kCFNumberSInt16Type",
":",
"c_int16",
",",
"kCFNumberSInt32Type",
":",
"c_int32",
",",
"kCFNumberSInt64Type",
":",
"c_int64",
",",
"kCFNumberFloat32Type",
":",
"c_float",
",",
"kCFNumberFloat64Type",
":",
"c_double",
",",
"kCFNumberCharType",
":",
"c_byte",
",",
"kCFNumberShortType",
":",
"c_short",
",",
"kCFNumberIntType",
":",
"c_int",
",",
"kCFNumberLongType",
":",
"c_long",
",",
"kCFNumberLongLongType",
":",
"c_longlong",
",",
"kCFNumberFloatType",
":",
"c_float",
",",
"kCFNumberDoubleType",
":",
"c_double",
",",
"kCFNumberCFIndexType",
":",
"CFIndex",
",",
"kCFNumberCGFloatType",
":",
"CGFloat",
"}",
"if",
"(",
"numeric_type",
"in",
"cfnum_to_ctype",
")",
":",
"t",
"=",
"cfnum_to_ctype",
"[",
"numeric_type",
"]",
"result",
"=",
"t",
"(",
")",
"if",
"cf",
".",
"CFNumberGetValue",
"(",
"cfnumber",
",",
"numeric_type",
",",
"byref",
"(",
"result",
")",
")",
":",
"return",
"result",
".",
"value",
"else",
":",
"raise",
"Exception",
"(",
"(",
"'cfnumber_to_number: unhandled CFNumber type %d'",
"%",
"numeric_type",
")",
")"
] |
convert cfnumber to python int or float .
|
train
| true
|
50,481
|
def drawGibbs(vals, temperature=1.0):
if (temperature == 0):
m = max(vals)
best = []
for (i, v) in enumerate(vals):
if (v == m):
best.append(i)
return choice(best)
else:
temp = (vals / temperature)
temp += (20 - max(temp))
if (min(temp) < (-20)):
for (i, v) in enumerate(temp):
if (v < (-20)):
temp[i] = (-20)
temp = exp(temp)
temp /= sum(temp)
return drawIndex(temp)
|
[
"def",
"drawGibbs",
"(",
"vals",
",",
"temperature",
"=",
"1.0",
")",
":",
"if",
"(",
"temperature",
"==",
"0",
")",
":",
"m",
"=",
"max",
"(",
"vals",
")",
"best",
"=",
"[",
"]",
"for",
"(",
"i",
",",
"v",
")",
"in",
"enumerate",
"(",
"vals",
")",
":",
"if",
"(",
"v",
"==",
"m",
")",
":",
"best",
".",
"append",
"(",
"i",
")",
"return",
"choice",
"(",
"best",
")",
"else",
":",
"temp",
"=",
"(",
"vals",
"/",
"temperature",
")",
"temp",
"+=",
"(",
"20",
"-",
"max",
"(",
"temp",
")",
")",
"if",
"(",
"min",
"(",
"temp",
")",
"<",
"(",
"-",
"20",
")",
")",
":",
"for",
"(",
"i",
",",
"v",
")",
"in",
"enumerate",
"(",
"temp",
")",
":",
"if",
"(",
"v",
"<",
"(",
"-",
"20",
")",
")",
":",
"temp",
"[",
"i",
"]",
"=",
"(",
"-",
"20",
")",
"temp",
"=",
"exp",
"(",
"temp",
")",
"temp",
"/=",
"sum",
"(",
"temp",
")",
"return",
"drawIndex",
"(",
"temp",
")"
] |
return the index of the sample drawn by a softmax .
|
train
| false
|
50,482
|
def salt_key():
import salt.cli.key
try:
client = salt.cli.key.SaltKey()
_install_signal_handlers(client)
client.run()
except Exception as err:
sys.stderr.write('Error: {0}\n'.format(err))
|
[
"def",
"salt_key",
"(",
")",
":",
"import",
"salt",
".",
"cli",
".",
"key",
"try",
":",
"client",
"=",
"salt",
".",
"cli",
".",
"key",
".",
"SaltKey",
"(",
")",
"_install_signal_handlers",
"(",
"client",
")",
"client",
".",
"run",
"(",
")",
"except",
"Exception",
"as",
"err",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"'Error: {0}\\n'",
".",
"format",
"(",
"err",
")",
")"
] |
manage the authentication keys with salt-key .
|
train
| true
|
50,484
|
def fixed_ip_get(context, id, get_network=False):
return IMPL.fixed_ip_get(context, id, get_network)
|
[
"def",
"fixed_ip_get",
"(",
"context",
",",
"id",
",",
"get_network",
"=",
"False",
")",
":",
"return",
"IMPL",
".",
"fixed_ip_get",
"(",
"context",
",",
"id",
",",
"get_network",
")"
] |
get fixed ip by id or raise if it does not exist .
|
train
| false
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.