id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
49,000 | romana/vpc-router | vpcrouter/currentstate/__init__.py | _CurrentState.as_json | def as_json(self, path="", with_indent=False):
"""
Return a rendering of the current state in JSON.
"""
if path not in self.top_level_links:
raise StateError("Unknown path")
return json.dumps(self.get_state_repr(path),
indent=4 if with_inde... | python | def as_json(self, path="", with_indent=False):
"""
Return a rendering of the current state in JSON.
"""
if path not in self.top_level_links:
raise StateError("Unknown path")
return json.dumps(self.get_state_repr(path),
indent=4 if with_inde... | [
"def",
"as_json",
"(",
"self",
",",
"path",
"=",
"\"\"",
",",
"with_indent",
"=",
"False",
")",
":",
"if",
"path",
"not",
"in",
"self",
".",
"top_level_links",
":",
"raise",
"StateError",
"(",
"\"Unknown path\"",
")",
"return",
"json",
".",
"dumps",
"(",... | Return a rendering of the current state in JSON. | [
"Return",
"a",
"rendering",
"of",
"the",
"current",
"state",
"in",
"JSON",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/currentstate/__init__.py#L126-L135 |
49,001 | romana/vpc-router | vpcrouter/currentstate/__init__.py | _CurrentState.as_html | def as_html(self, path=""):
"""
Return a rendering of the current state in HTML.
"""
if path not in self.top_level_links:
raise StateError("Unknown path")
header = """
<html>
<head>
<title>VPC-router state</title>
</he... | python | def as_html(self, path=""):
"""
Return a rendering of the current state in HTML.
"""
if path not in self.top_level_links:
raise StateError("Unknown path")
header = """
<html>
<head>
<title>VPC-router state</title>
</he... | [
"def",
"as_html",
"(",
"self",
",",
"path",
"=",
"\"\"",
")",
":",
"if",
"path",
"not",
"in",
"self",
".",
"top_level_links",
":",
"raise",
"StateError",
"(",
"\"Unknown path\"",
")",
"header",
"=",
"\"\"\"\n <html>\n <head>\n <title... | Return a rendering of the current state in HTML. | [
"Return",
"a",
"rendering",
"of",
"the",
"current",
"state",
"in",
"HTML",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/currentstate/__init__.py#L137-L184 |
49,002 | romana/vpc-router | vpcrouter/watcher/plugins/fixedconf.py | Fixedconf.start | def start(self):
"""
Start the config watch thread or process.
"""
# Normally, we should start a thread or process here, pass the message
# queue self.q_route_spec to that thread and let it send route
# configurations through that queue. But since we're just sending a
... | python | def start(self):
"""
Start the config watch thread or process.
"""
# Normally, we should start a thread or process here, pass the message
# queue self.q_route_spec to that thread and let it send route
# configurations through that queue. But since we're just sending a
... | [
"def",
"start",
"(",
"self",
")",
":",
"# Normally, we should start a thread or process here, pass the message",
"# queue self.q_route_spec to that thread and let it send route",
"# configurations through that queue. But since we're just sending a",
"# single, fixed configuration, we can just do t... | Start the config watch thread or process. | [
"Start",
"the",
"config",
"watch",
"thread",
"or",
"process",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/watcher/plugins/fixedconf.py#L38-L64 |
49,003 | romana/vpc-router | vpcrouter/watcher/plugins/fixedconf.py | Fixedconf.add_arguments | def add_arguments(cls, parser, sys_arg_list=None):
"""
Callback to add command line options for this plugin to the argparse
parser.
"""
parser.add_argument('--fixed_cidr', dest="fixed_cidr", required=True,
help="specify the route CIDR "
... | python | def add_arguments(cls, parser, sys_arg_list=None):
"""
Callback to add command line options for this plugin to the argparse
parser.
"""
parser.add_argument('--fixed_cidr', dest="fixed_cidr", required=True,
help="specify the route CIDR "
... | [
"def",
"add_arguments",
"(",
"cls",
",",
"parser",
",",
"sys_arg_list",
"=",
"None",
")",
":",
"parser",
".",
"add_argument",
"(",
"'--fixed_cidr'",
",",
"dest",
"=",
"\"fixed_cidr\"",
",",
"required",
"=",
"True",
",",
"help",
"=",
"\"specify the route CIDR \... | Callback to add command line options for this plugin to the argparse
parser. | [
"Callback",
"to",
"add",
"command",
"line",
"options",
"for",
"this",
"plugin",
"to",
"the",
"argparse",
"parser",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/watcher/plugins/fixedconf.py#L90-L102 |
49,004 | romana/vpc-router | vpcrouter/watcher/plugins/fixedconf.py | Fixedconf.check_arguments | def check_arguments(cls, conf):
"""
Callback to perform sanity checking for the plugin's specific
parameters.
"""
# Perform sanity checking on CIDR
utils.ip_check(conf['fixed_cidr'], netmask_expected=True)
# Perform sanity checking on host list
for host ... | python | def check_arguments(cls, conf):
"""
Callback to perform sanity checking for the plugin's specific
parameters.
"""
# Perform sanity checking on CIDR
utils.ip_check(conf['fixed_cidr'], netmask_expected=True)
# Perform sanity checking on host list
for host ... | [
"def",
"check_arguments",
"(",
"cls",
",",
"conf",
")",
":",
"# Perform sanity checking on CIDR",
"utils",
".",
"ip_check",
"(",
"conf",
"[",
"'fixed_cidr'",
"]",
",",
"netmask_expected",
"=",
"True",
")",
"# Perform sanity checking on host list",
"for",
"host",
"in... | Callback to perform sanity checking for the plugin's specific
parameters. | [
"Callback",
"to",
"perform",
"sanity",
"checking",
"for",
"the",
"plugin",
"s",
"specific",
"parameters",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/watcher/plugins/fixedconf.py#L105-L116 |
49,005 | romana/vpc-router | vpcrouter/monitor/common.py | MonitorPlugin.get_new_working_set | def get_new_working_set(self):
"""
Get a new list of IPs to work with from the queue.
This returns None if there is no update.
Read all the messages from the queue on which we get the IP addresses
that we have to monitor. We will ignore all of them, except the last
one,... | python | def get_new_working_set(self):
"""
Get a new list of IPs to work with from the queue.
This returns None if there is no update.
Read all the messages from the queue on which we get the IP addresses
that we have to monitor. We will ignore all of them, except the last
one,... | [
"def",
"get_new_working_set",
"(",
"self",
")",
":",
"new_list_of_ips",
"=",
"None",
"while",
"True",
":",
"try",
":",
"new_list_of_ips",
"=",
"self",
".",
"q_monitor_ips",
".",
"get_nowait",
"(",
")",
"self",
".",
"q_monitor_ips",
".",
"task_done",
"(",
")"... | Get a new list of IPs to work with from the queue.
This returns None if there is no update.
Read all the messages from the queue on which we get the IP addresses
that we have to monitor. We will ignore all of them, except the last
one, since maybe we received two updates in a row, but ... | [
"Get",
"a",
"new",
"list",
"of",
"IPs",
"to",
"work",
"with",
"from",
"the",
"queue",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/monitor/common.py#L100-L127 |
49,006 | romana/vpc-router | vpcrouter/monitor/common.py | MonitorPlugin.start_monitoring | def start_monitoring(self):
"""
Monitor IP addresses and send notifications if one of them has failed.
This function will continuously monitor q_monitor_ips for new lists of
IP addresses to monitor. Each message received there is the full state
(the complete lists of addresses t... | python | def start_monitoring(self):
"""
Monitor IP addresses and send notifications if one of them has failed.
This function will continuously monitor q_monitor_ips for new lists of
IP addresses to monitor. Each message received there is the full state
(the complete lists of addresses t... | [
"def",
"start_monitoring",
"(",
"self",
")",
":",
"time",
".",
"sleep",
"(",
"1",
")",
"# This is our working set. This list may be updated occasionally when",
"# we receive messages on the q_monitor_ips queue. But irrespective of",
"# any received updates, the list of IPs in here is reg... | Monitor IP addresses and send notifications if one of them has failed.
This function will continuously monitor q_monitor_ips for new lists of
IP addresses to monitor. Each message received there is the full state
(the complete lists of addresses to monitor).
Push out (return) any faile... | [
"Monitor",
"IP",
"addresses",
"and",
"send",
"notifications",
"if",
"one",
"of",
"them",
"has",
"failed",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/monitor/common.py#L165-L268 |
49,007 | romana/vpc-router | vpcrouter/watcher/common.py | parse_route_spec_config | def parse_route_spec_config(data):
"""
Parse and sanity check the route spec config.
The config data is a blob of JSON that needs to be in this format:
{
"<CIDR-1>" : [ "host-1-ip", "host-2-ip", "host-3-ip" ],
"<CIDR-2>" : [ "host-4-ip", "host-5-ip" ],
"<CIDR-3>" : [ "host-6-ip... | python | def parse_route_spec_config(data):
"""
Parse and sanity check the route spec config.
The config data is a blob of JSON that needs to be in this format:
{
"<CIDR-1>" : [ "host-1-ip", "host-2-ip", "host-3-ip" ],
"<CIDR-2>" : [ "host-4-ip", "host-5-ip" ],
"<CIDR-3>" : [ "host-6-ip... | [
"def",
"parse_route_spec_config",
"(",
"data",
")",
":",
"# Sanity checking on the data object",
"if",
"type",
"(",
"data",
")",
"is",
"not",
"dict",
":",
"raise",
"ValueError",
"(",
"\"Expected dictionary at top level\"",
")",
"try",
":",
"for",
"k",
",",
"v",
... | Parse and sanity check the route spec config.
The config data is a blob of JSON that needs to be in this format:
{
"<CIDR-1>" : [ "host-1-ip", "host-2-ip", "host-3-ip" ],
"<CIDR-2>" : [ "host-4-ip", "host-5-ip" ],
"<CIDR-3>" : [ "host-6-ip", "host-7-ip", "host-8-ip", "host-9-ip" ]
... | [
"Parse",
"and",
"sanity",
"check",
"the",
"route",
"spec",
"config",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/watcher/common.py#L140-L177 |
49,008 | romana/vpc-router | vpcrouter/watcher/__init__.py | _update_health_monitor_with_new_ips | def _update_health_monitor_with_new_ips(route_spec, all_ips,
q_monitor_ips):
"""
Take the current route spec and compare to the current list of known IP
addresses. If the route spec mentiones a different set of IPs, update the
monitoring thread with that new list.... | python | def _update_health_monitor_with_new_ips(route_spec, all_ips,
q_monitor_ips):
"""
Take the current route spec and compare to the current list of known IP
addresses. If the route spec mentiones a different set of IPs, update the
monitoring thread with that new list.... | [
"def",
"_update_health_monitor_with_new_ips",
"(",
"route_spec",
",",
"all_ips",
",",
"q_monitor_ips",
")",
":",
"# Extract all the IP addresses from the route spec, unique and sorted.",
"new_all_ips",
"=",
"sorted",
"(",
"set",
"(",
"itertools",
".",
"chain",
".",
"from_it... | Take the current route spec and compare to the current list of known IP
addresses. If the route spec mentiones a different set of IPs, update the
monitoring thread with that new list.
Return the current set of IPs mentioned in the route spec. | [
"Take",
"the",
"current",
"route",
"spec",
"and",
"compare",
"to",
"the",
"current",
"list",
"of",
"known",
"IP",
"addresses",
".",
"If",
"the",
"route",
"spec",
"mentiones",
"a",
"different",
"set",
"of",
"IPs",
"update",
"the",
"monitoring",
"thread",
"w... | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/watcher/__init__.py#L33-L58 |
49,009 | romana/vpc-router | vpcrouter/watcher/__init__.py | _event_monitor_loop | def _event_monitor_loop(region_name, vpc_id,
watcher_plugin, health_plugin,
iterations, sleep_time,
route_check_time_interval=30):
"""
Monitor queues to receive updates about new route specs or any detected
failed IPs.
If any of th... | python | def _event_monitor_loop(region_name, vpc_id,
watcher_plugin, health_plugin,
iterations, sleep_time,
route_check_time_interval=30):
"""
Monitor queues to receive updates about new route specs or any detected
failed IPs.
If any of th... | [
"def",
"_event_monitor_loop",
"(",
"region_name",
",",
"vpc_id",
",",
"watcher_plugin",
",",
"health_plugin",
",",
"iterations",
",",
"sleep_time",
",",
"route_check_time_interval",
"=",
"30",
")",
":",
"q_route_spec",
"=",
"watcher_plugin",
".",
"get_route_spec_queue... | Monitor queues to receive updates about new route specs or any detected
failed IPs.
If any of those have updates, notify the health-monitor thread with a
message on a special queue and also re-process the entire routing table.
The 'iterations' argument allows us to limit the running time of the watch
... | [
"Monitor",
"queues",
"to",
"receive",
"updates",
"about",
"new",
"route",
"specs",
"or",
"any",
"detected",
"failed",
"IPs",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/watcher/__init__.py#L61-L163 |
49,010 | romana/vpc-router | vpcrouter/watcher/__init__.py | stop_plugins | def stop_plugins(watcher_plugin, health_plugin):
"""
Stops all plugins.
"""
logging.debug("Stopping health-check monitor...")
health_plugin.stop()
logging.debug("Stopping config change observer...")
watcher_plugin.stop() | python | def stop_plugins(watcher_plugin, health_plugin):
"""
Stops all plugins.
"""
logging.debug("Stopping health-check monitor...")
health_plugin.stop()
logging.debug("Stopping config change observer...")
watcher_plugin.stop() | [
"def",
"stop_plugins",
"(",
"watcher_plugin",
",",
"health_plugin",
")",
":",
"logging",
".",
"debug",
"(",
"\"Stopping health-check monitor...\"",
")",
"health_plugin",
".",
"stop",
"(",
")",
"logging",
".",
"debug",
"(",
"\"Stopping config change observer...\"",
")"... | Stops all plugins. | [
"Stops",
"all",
"plugins",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/watcher/__init__.py#L190-L199 |
49,011 | romana/vpc-router | vpcrouter/watcher/__init__.py | start_watcher | def start_watcher(conf, watcher_plugin_class, health_plugin_class,
iterations=None, sleep_time=1):
"""
Start watcher loop, listening for config changes or failed hosts.
Also starts the various service threads.
VPC router watches for any changes in the config and updates/adds/deletes
... | python | def start_watcher(conf, watcher_plugin_class, health_plugin_class,
iterations=None, sleep_time=1):
"""
Start watcher loop, listening for config changes or failed hosts.
Also starts the various service threads.
VPC router watches for any changes in the config and updates/adds/deletes
... | [
"def",
"start_watcher",
"(",
"conf",
",",
"watcher_plugin_class",
",",
"health_plugin_class",
",",
"iterations",
"=",
"None",
",",
"sleep_time",
"=",
"1",
")",
":",
"if",
"CURRENT_STATE",
".",
"_stop_all",
":",
"logging",
".",
"debug",
"(",
"\"Not starting plugi... | Start watcher loop, listening for config changes or failed hosts.
Also starts the various service threads.
VPC router watches for any changes in the config and updates/adds/deletes
routes as necessary. If failed hosts are reported, routes are also updated
as needed.
This function starts a few wor... | [
"Start",
"watcher",
"loop",
"listening",
"for",
"config",
"changes",
"or",
"failed",
"hosts",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/watcher/__init__.py#L202-L244 |
49,012 | mozilla/python-zeppelin | zeppelin/converters/markdown.py | MarkdownConverter.build_header | def build_header(self, title):
"""Generate the header for the Markdown file."""
header = ['---',
'title: ' + title,
'author(s): ' + self.user,
'tags: ',
'created_at: ' + str(self.date_created),
'updated_at: ' + str... | python | def build_header(self, title):
"""Generate the header for the Markdown file."""
header = ['---',
'title: ' + title,
'author(s): ' + self.user,
'tags: ',
'created_at: ' + str(self.date_created),
'updated_at: ' + str... | [
"def",
"build_header",
"(",
"self",
",",
"title",
")",
":",
"header",
"=",
"[",
"'---'",
",",
"'title: '",
"+",
"title",
",",
"'author(s): '",
"+",
"self",
".",
"user",
",",
"'tags: '",
",",
"'created_at: '",
"+",
"str",
"(",
"self",
".",
"date_created",... | Generate the header for the Markdown file. | [
"Generate",
"the",
"header",
"for",
"the",
"Markdown",
"file",
"."
] | 76ce6b7608ef6cf7b807bd5d850a58ea6a59ef07 | https://github.com/mozilla/python-zeppelin/blob/76ce6b7608ef6cf7b807bd5d850a58ea6a59ef07/zeppelin/converters/markdown.py#L41-L53 |
49,013 | mozilla/python-zeppelin | zeppelin/converters/markdown.py | MarkdownConverter.build_code | def build_code(self, lang, body):
"""Wrap text with markdown specific flavour."""
self.out.append("```" + lang)
self.build_markdown(lang, body)
self.out.append("```") | python | def build_code(self, lang, body):
"""Wrap text with markdown specific flavour."""
self.out.append("```" + lang)
self.build_markdown(lang, body)
self.out.append("```") | [
"def",
"build_code",
"(",
"self",
",",
"lang",
",",
"body",
")",
":",
"self",
".",
"out",
".",
"append",
"(",
"\"```\"",
"+",
"lang",
")",
"self",
".",
"build_markdown",
"(",
"lang",
",",
"body",
")",
"self",
".",
"out",
".",
"append",
"(",
"\"```\... | Wrap text with markdown specific flavour. | [
"Wrap",
"text",
"with",
"markdown",
"specific",
"flavour",
"."
] | 76ce6b7608ef6cf7b807bd5d850a58ea6a59ef07 | https://github.com/mozilla/python-zeppelin/blob/76ce6b7608ef6cf7b807bd5d850a58ea6a59ef07/zeppelin/converters/markdown.py#L60-L64 |
49,014 | mozilla/python-zeppelin | zeppelin/converters/markdown.py | MarkdownConverter.process_input | def process_input(self, paragraph):
"""Parse paragraph for the language of the code and the code itself."""
try:
lang, body = paragraph.split(None, 1)
except ValueError:
lang, body = paragraph, None
if not lang.strip().startswith('%'):
lang = 'scala'
... | python | def process_input(self, paragraph):
"""Parse paragraph for the language of the code and the code itself."""
try:
lang, body = paragraph.split(None, 1)
except ValueError:
lang, body = paragraph, None
if not lang.strip().startswith('%'):
lang = 'scala'
... | [
"def",
"process_input",
"(",
"self",
",",
"paragraph",
")",
":",
"try",
":",
"lang",
",",
"body",
"=",
"paragraph",
".",
"split",
"(",
"None",
",",
"1",
")",
"except",
"ValueError",
":",
"lang",
",",
"body",
"=",
"paragraph",
",",
"None",
"if",
"not"... | Parse paragraph for the language of the code and the code itself. | [
"Parse",
"paragraph",
"for",
"the",
"language",
"of",
"the",
"code",
"and",
"the",
"code",
"itself",
"."
] | 76ce6b7608ef6cf7b807bd5d850a58ea6a59ef07 | https://github.com/mozilla/python-zeppelin/blob/76ce6b7608ef6cf7b807bd5d850a58ea6a59ef07/zeppelin/converters/markdown.py#L66-L83 |
49,015 | mozilla/python-zeppelin | zeppelin/converters/markdown.py | MarkdownConverter.create_md_row | def create_md_row(self, row, header=False):
"""Translate row into markdown format."""
if not row:
return
cols = row.split('\t')
if len(cols) == 1:
self.out.append(cols[0])
else:
col_md = '|'
underline_md = '|'
if cols:
... | python | def create_md_row(self, row, header=False):
"""Translate row into markdown format."""
if not row:
return
cols = row.split('\t')
if len(cols) == 1:
self.out.append(cols[0])
else:
col_md = '|'
underline_md = '|'
if cols:
... | [
"def",
"create_md_row",
"(",
"self",
",",
"row",
",",
"header",
"=",
"False",
")",
":",
"if",
"not",
"row",
":",
"return",
"cols",
"=",
"row",
".",
"split",
"(",
"'\\t'",
")",
"if",
"len",
"(",
"cols",
")",
"==",
"1",
":",
"self",
".",
"out",
"... | Translate row into markdown format. | [
"Translate",
"row",
"into",
"markdown",
"format",
"."
] | 76ce6b7608ef6cf7b807bd5d850a58ea6a59ef07 | https://github.com/mozilla/python-zeppelin/blob/76ce6b7608ef6cf7b807bd5d850a58ea6a59ef07/zeppelin/converters/markdown.py#L85-L104 |
49,016 | mozilla/python-zeppelin | zeppelin/converters/markdown.py | MarkdownConverter.build_output | def build_output(self, fout):
"""Squash self.out into string.
Join every line in self.out with a new line and write the
result to the output file.
"""
fout.write('\n'.join([s for s in self.out])) | python | def build_output(self, fout):
"""Squash self.out into string.
Join every line in self.out with a new line and write the
result to the output file.
"""
fout.write('\n'.join([s for s in self.out])) | [
"def",
"build_output",
"(",
"self",
",",
"fout",
")",
":",
"fout",
".",
"write",
"(",
"'\\n'",
".",
"join",
"(",
"[",
"s",
"for",
"s",
"in",
"self",
".",
"out",
"]",
")",
")"
] | Squash self.out into string.
Join every line in self.out with a new line and write the
result to the output file. | [
"Squash",
"self",
".",
"out",
"into",
"string",
"."
] | 76ce6b7608ef6cf7b807bd5d850a58ea6a59ef07 | https://github.com/mozilla/python-zeppelin/blob/76ce6b7608ef6cf7b807bd5d850a58ea6a59ef07/zeppelin/converters/markdown.py#L129-L135 |
49,017 | mozilla/python-zeppelin | zeppelin/converters/markdown.py | MarkdownConverter.convert | def convert(self, json, fout):
"""Convert json to markdown.
Takes in a .json file as input and convert it to Markdown format,
saving the generated .png images into ./images.
"""
self.build_markdown_body(json) # create the body
self.build_header(json['name']) # create t... | python | def convert(self, json, fout):
"""Convert json to markdown.
Takes in a .json file as input and convert it to Markdown format,
saving the generated .png images into ./images.
"""
self.build_markdown_body(json) # create the body
self.build_header(json['name']) # create t... | [
"def",
"convert",
"(",
"self",
",",
"json",
",",
"fout",
")",
":",
"self",
".",
"build_markdown_body",
"(",
"json",
")",
"# create the body",
"self",
".",
"build_header",
"(",
"json",
"[",
"'name'",
"]",
")",
"# create the md header",
"self",
".",
"build_out... | Convert json to markdown.
Takes in a .json file as input and convert it to Markdown format,
saving the generated .png images into ./images. | [
"Convert",
"json",
"to",
"markdown",
"."
] | 76ce6b7608ef6cf7b807bd5d850a58ea6a59ef07 | https://github.com/mozilla/python-zeppelin/blob/76ce6b7608ef6cf7b807bd5d850a58ea6a59ef07/zeppelin/converters/markdown.py#L137-L145 |
49,018 | mozilla/python-zeppelin | zeppelin/converters/markdown.py | MarkdownConverter.build_markdown_body | def build_markdown_body(self, text):
"""Generate the body for the Markdown file.
- processes each json block one by one
- for each block, process:
- the creator of the notebook (user)
- the date the notebook was created
- the date the notebook was last update... | python | def build_markdown_body(self, text):
"""Generate the body for the Markdown file.
- processes each json block one by one
- for each block, process:
- the creator of the notebook (user)
- the date the notebook was created
- the date the notebook was last update... | [
"def",
"build_markdown_body",
"(",
"self",
",",
"text",
")",
":",
"key_options",
"=",
"{",
"'dateCreated'",
":",
"self",
".",
"process_date_created",
",",
"'dateUpdated'",
":",
"self",
".",
"process_date_updated",
",",
"'title'",
":",
"self",
".",
"process_title... | Generate the body for the Markdown file.
- processes each json block one by one
- for each block, process:
- the creator of the notebook (user)
- the date the notebook was created
- the date the notebook was last updated
- the input by detecting the edito... | [
"Generate",
"the",
"body",
"for",
"the",
"Markdown",
"file",
"."
] | 76ce6b7608ef6cf7b807bd5d850a58ea6a59ef07 | https://github.com/mozilla/python-zeppelin/blob/76ce6b7608ef6cf7b807bd5d850a58ea6a59ef07/zeppelin/converters/markdown.py#L147-L174 |
49,019 | mozilla/python-zeppelin | zeppelin/converters/markdown.py | MarkdownConverter.build_image | def build_image(self, msg):
"""Convert base64 encoding to png.
Strips msg of the base64 image encoding and outputs
the images to the specified directory.
"""
result = self.find_message(msg)
if result is None:
return
self.index += 1
images_pa... | python | def build_image(self, msg):
"""Convert base64 encoding to png.
Strips msg of the base64 image encoding and outputs
the images to the specified directory.
"""
result = self.find_message(msg)
if result is None:
return
self.index += 1
images_pa... | [
"def",
"build_image",
"(",
"self",
",",
"msg",
")",
":",
"result",
"=",
"self",
".",
"find_message",
"(",
"msg",
")",
"if",
"result",
"is",
"None",
":",
"return",
"self",
".",
"index",
"+=",
"1",
"images_path",
"=",
"'images'",
"if",
"self",
".",
"di... | Convert base64 encoding to png.
Strips msg of the base64 image encoding and outputs
the images to the specified directory. | [
"Convert",
"base64",
"encoding",
"to",
"png",
"."
] | 76ce6b7608ef6cf7b807bd5d850a58ea6a59ef07 | https://github.com/mozilla/python-zeppelin/blob/76ce6b7608ef6cf7b807bd5d850a58ea6a59ef07/zeppelin/converters/markdown.py#L189-L213 |
49,020 | mozilla/python-zeppelin | zeppelin/converters/markdown.py | LegacyConverter.process_results | def process_results(self, paragraph):
"""Route Zeppelin output types to corresponding handlers."""
if 'result' in paragraph and paragraph['result']['msg']:
msg = paragraph['result']['msg']
self.output_options[paragraph['result']['type']](msg) | python | def process_results(self, paragraph):
"""Route Zeppelin output types to corresponding handlers."""
if 'result' in paragraph and paragraph['result']['msg']:
msg = paragraph['result']['msg']
self.output_options[paragraph['result']['type']](msg) | [
"def",
"process_results",
"(",
"self",
",",
"paragraph",
")",
":",
"if",
"'result'",
"in",
"paragraph",
"and",
"paragraph",
"[",
"'result'",
"]",
"[",
"'msg'",
"]",
":",
"msg",
"=",
"paragraph",
"[",
"'result'",
"]",
"[",
"'msg'",
"]",
"self",
".",
"ou... | Route Zeppelin output types to corresponding handlers. | [
"Route",
"Zeppelin",
"output",
"types",
"to",
"corresponding",
"handlers",
"."
] | 76ce6b7608ef6cf7b807bd5d850a58ea6a59ef07 | https://github.com/mozilla/python-zeppelin/blob/76ce6b7608ef6cf7b807bd5d850a58ea6a59ef07/zeppelin/converters/markdown.py#L241-L245 |
49,021 | mozilla/python-zeppelin | zeppelin/converters/markdown.py | NewConverter.process_results | def process_results(self, paragraph):
"""Routes Zeppelin output types to corresponding handlers."""
if 'editorMode' in paragraph['config']:
mode = paragraph['config']['editorMode'].split('/')[-1]
if 'results' in paragraph and paragraph['results']['msg']:
msg = par... | python | def process_results(self, paragraph):
"""Routes Zeppelin output types to corresponding handlers."""
if 'editorMode' in paragraph['config']:
mode = paragraph['config']['editorMode'].split('/')[-1]
if 'results' in paragraph and paragraph['results']['msg']:
msg = par... | [
"def",
"process_results",
"(",
"self",
",",
"paragraph",
")",
":",
"if",
"'editorMode'",
"in",
"paragraph",
"[",
"'config'",
"]",
":",
"mode",
"=",
"paragraph",
"[",
"'config'",
"]",
"[",
"'editorMode'",
"]",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1... | Routes Zeppelin output types to corresponding handlers. | [
"Routes",
"Zeppelin",
"output",
"types",
"to",
"corresponding",
"handlers",
"."
] | 76ce6b7608ef6cf7b807bd5d850a58ea6a59ef07 | https://github.com/mozilla/python-zeppelin/blob/76ce6b7608ef6cf7b807bd5d850a58ea6a59ef07/zeppelin/converters/markdown.py#L261-L268 |
49,022 | romana/vpc-router | vpcrouter/watcher/plugins/http.py | handle_route_spec_request | def handle_route_spec_request():
"""
Process request for route spec.
Either a new one is posted or the current one is to be retrieved.
"""
try:
if bottle.request.method == 'GET':
# Just return what we currenty have cached as the route spec
data = CURRENT_STATE.route... | python | def handle_route_spec_request():
"""
Process request for route spec.
Either a new one is posted or the current one is to be retrieved.
"""
try:
if bottle.request.method == 'GET':
# Just return what we currenty have cached as the route spec
data = CURRENT_STATE.route... | [
"def",
"handle_route_spec_request",
"(",
")",
":",
"try",
":",
"if",
"bottle",
".",
"request",
".",
"method",
"==",
"'GET'",
":",
"# Just return what we currenty have cached as the route spec",
"data",
"=",
"CURRENT_STATE",
".",
"route_spec",
"if",
"not",
"data",
":... | Process request for route spec.
Either a new one is posted or the current one is to be retrieved. | [
"Process",
"request",
"for",
"route",
"spec",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/watcher/plugins/http.py#L44-L83 |
49,023 | romana/vpc-router | vpcrouter/watcher/plugins/http.py | Http.start | def start(self):
"""
Start the HTTP change monitoring thread.
"""
# Store reference to message queue in module global variable, so that
# our Bottle app handler functions have easy access to it.
global _Q_ROUTE_SPEC
_Q_ROUTE_SPEC = self.q_route_spec
logg... | python | def start(self):
"""
Start the HTTP change monitoring thread.
"""
# Store reference to message queue in module global variable, so that
# our Bottle app handler functions have easy access to it.
global _Q_ROUTE_SPEC
_Q_ROUTE_SPEC = self.q_route_spec
logg... | [
"def",
"start",
"(",
"self",
")",
":",
"# Store reference to message queue in module global variable, so that",
"# our Bottle app handler functions have easy access to it.",
"global",
"_Q_ROUTE_SPEC",
"_Q_ROUTE_SPEC",
"=",
"self",
".",
"q_route_spec",
"logging",
".",
"info",
"(",... | Start the HTTP change monitoring thread. | [
"Start",
"the",
"HTTP",
"change",
"monitoring",
"thread",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/watcher/plugins/http.py#L93-L106 |
49,024 | bboe/update_checker | update_checker.py | cache_results | def cache_results(function):
"""Return decorated function that caches the results."""
def save_to_permacache():
"""Save the in-memory cache data to the permacache.
There is a race condition here between two processes updating at the
same time. It's perfectly acceptable to lose and/or co... | python | def cache_results(function):
"""Return decorated function that caches the results."""
def save_to_permacache():
"""Save the in-memory cache data to the permacache.
There is a race condition here between two processes updating at the
same time. It's perfectly acceptable to lose and/or co... | [
"def",
"cache_results",
"(",
"function",
")",
":",
"def",
"save_to_permacache",
"(",
")",
":",
"\"\"\"Save the in-memory cache data to the permacache.\n\n There is a race condition here between two processes updating at the\n same time. It's perfectly acceptable to lose and/or co... | Return decorated function that caches the results. | [
"Return",
"decorated",
"function",
"that",
"caches",
"the",
"results",
"."
] | 48e1b8f260e7cfbdc90e6b4dc756813e4149495d | https://github.com/bboe/update_checker/blob/48e1b8f260e7cfbdc90e6b4dc756813e4149495d/update_checker.py#L26-L77 |
49,025 | bboe/update_checker | update_checker.py | pretty_date | def pretty_date(the_datetime):
"""Attempt to return a human-readable time delta string."""
# Source modified from
# http://stackoverflow.com/a/5164027/176978
diff = datetime.utcnow() - the_datetime
if diff.days > 7 or diff.days < 0:
return the_datetime.strftime('%A %B %d, %Y')
elif diff.... | python | def pretty_date(the_datetime):
"""Attempt to return a human-readable time delta string."""
# Source modified from
# http://stackoverflow.com/a/5164027/176978
diff = datetime.utcnow() - the_datetime
if diff.days > 7 or diff.days < 0:
return the_datetime.strftime('%A %B %d, %Y')
elif diff.... | [
"def",
"pretty_date",
"(",
"the_datetime",
")",
":",
"# Source modified from",
"# http://stackoverflow.com/a/5164027/176978",
"diff",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"-",
"the_datetime",
"if",
"diff",
".",
"days",
">",
"7",
"or",
"diff",
".",
"days",
"... | Attempt to return a human-readable time delta string. | [
"Attempt",
"to",
"return",
"a",
"human",
"-",
"readable",
"time",
"delta",
"string",
"."
] | 48e1b8f260e7cfbdc90e6b4dc756813e4149495d | https://github.com/bboe/update_checker/blob/48e1b8f260e7cfbdc90e6b4dc756813e4149495d/update_checker.py#L151-L173 |
49,026 | bboe/update_checker | update_checker.py | update_check | def update_check(package_name, package_version, bypass_cache=False, url=None,
**extra_data):
"""Convenience method that outputs to stdout if an update is available."""
checker = UpdateChecker(url)
checker.bypass_cache = bypass_cache
result = checker.check(package_name, package_version, ... | python | def update_check(package_name, package_version, bypass_cache=False, url=None,
**extra_data):
"""Convenience method that outputs to stdout if an update is available."""
checker = UpdateChecker(url)
checker.bypass_cache = bypass_cache
result = checker.check(package_name, package_version, ... | [
"def",
"update_check",
"(",
"package_name",
",",
"package_version",
",",
"bypass_cache",
"=",
"False",
",",
"url",
"=",
"None",
",",
"*",
"*",
"extra_data",
")",
":",
"checker",
"=",
"UpdateChecker",
"(",
"url",
")",
"checker",
".",
"bypass_cache",
"=",
"b... | Convenience method that outputs to stdout if an update is available. | [
"Convenience",
"method",
"that",
"outputs",
"to",
"stdout",
"if",
"an",
"update",
"is",
"available",
"."
] | 48e1b8f260e7cfbdc90e6b4dc756813e4149495d | https://github.com/bboe/update_checker/blob/48e1b8f260e7cfbdc90e6b4dc756813e4149495d/update_checker.py#L176-L183 |
49,027 | bboe/update_checker | update_checker.py | UpdateChecker.check | def check(self, package_name, package_version, **extra_data):
"""Return a UpdateResult object if there is a newer version."""
data = extra_data
data['package_name'] = package_name
data['package_version'] = package_version
data['python_version'] = sys.version.split()[0]
da... | python | def check(self, package_name, package_version, **extra_data):
"""Return a UpdateResult object if there is a newer version."""
data = extra_data
data['package_name'] = package_name
data['package_version'] = package_version
data['python_version'] = sys.version.split()[0]
da... | [
"def",
"check",
"(",
"self",
",",
"package_name",
",",
"package_version",
",",
"*",
"*",
"extra_data",
")",
":",
"data",
"=",
"extra_data",
"data",
"[",
"'package_name'",
"]",
"=",
"package_name",
"data",
"[",
"'package_version'",
"]",
"=",
"package_version",
... | Return a UpdateResult object if there is a newer version. | [
"Return",
"a",
"UpdateResult",
"object",
"if",
"there",
"is",
"a",
"newer",
"version",
"."
] | 48e1b8f260e7cfbdc90e6b4dc756813e4149495d | https://github.com/bboe/update_checker/blob/48e1b8f260e7cfbdc90e6b4dc756813e4149495d/update_checker.py#L121-L148 |
49,028 | CodeBradley/python-uptimerobot | uptimerobot/uptimerobot.py | UptimeRobot.addMonitor | def addMonitor(self, monitorFriendlyName, monitorURL):
"""
Returns True if Monitor was added, otherwise False.
"""
url = self.baseUrl
url += "newMonitor?apiKey=%s" % self.apiKey
url += "&monitorFriendlyName=%s" % monitorFriendlyName
url += "&monitorURL=%s&monitorT... | python | def addMonitor(self, monitorFriendlyName, monitorURL):
"""
Returns True if Monitor was added, otherwise False.
"""
url = self.baseUrl
url += "newMonitor?apiKey=%s" % self.apiKey
url += "&monitorFriendlyName=%s" % monitorFriendlyName
url += "&monitorURL=%s&monitorT... | [
"def",
"addMonitor",
"(",
"self",
",",
"monitorFriendlyName",
",",
"monitorURL",
")",
":",
"url",
"=",
"self",
".",
"baseUrl",
"url",
"+=",
"\"newMonitor?apiKey=%s\"",
"%",
"self",
".",
"apiKey",
"url",
"+=",
"\"&monitorFriendlyName=%s\"",
"%",
"monitorFriendlyNam... | Returns True if Monitor was added, otherwise False. | [
"Returns",
"True",
"if",
"Monitor",
"was",
"added",
"otherwise",
"False",
"."
] | 715ce082c0e966c44fd05b1624a40f0bb30fc6da | https://github.com/CodeBradley/python-uptimerobot/blob/715ce082c0e966c44fd05b1624a40f0bb30fc6da/uptimerobot/uptimerobot.py#L27-L41 |
49,029 | CodeBradley/python-uptimerobot | uptimerobot/uptimerobot.py | UptimeRobot.getMonitors | def getMonitors(self, response_times=0, logs=0, uptime_ratio=''):
"""
Returns status and response payload for all known monitors.
"""
url = self.baseUrl
url += "getMonitors?apiKey=%s" % (self.apiKey)
url += "&noJsonCallback=1&format=json"
# responseTimes - optiona... | python | def getMonitors(self, response_times=0, logs=0, uptime_ratio=''):
"""
Returns status and response payload for all known monitors.
"""
url = self.baseUrl
url += "getMonitors?apiKey=%s" % (self.apiKey)
url += "&noJsonCallback=1&format=json"
# responseTimes - optiona... | [
"def",
"getMonitors",
"(",
"self",
",",
"response_times",
"=",
"0",
",",
"logs",
"=",
"0",
",",
"uptime_ratio",
"=",
"''",
")",
":",
"url",
"=",
"self",
".",
"baseUrl",
"url",
"+=",
"\"getMonitors?apiKey=%s\"",
"%",
"(",
"self",
".",
"apiKey",
")",
"ur... | Returns status and response payload for all known monitors. | [
"Returns",
"status",
"and",
"response",
"payload",
"for",
"all",
"known",
"monitors",
"."
] | 715ce082c0e966c44fd05b1624a40f0bb30fc6da | https://github.com/CodeBradley/python-uptimerobot/blob/715ce082c0e966c44fd05b1624a40f0bb30fc6da/uptimerobot/uptimerobot.py#L44-L66 |
49,030 | CodeBradley/python-uptimerobot | uptimerobot/uptimerobot.py | UptimeRobot.getMonitorById | def getMonitorById(self, monitorId):
"""
Returns monitor status and alltimeuptimeratio for a MonitorId.
"""
url = self.baseUrl
url += "getMonitors?apiKey=%s&monitors=%s" % (self.apiKey, monitorId)
url += "&noJsonCallback=1&format=json"
success, response = self.req... | python | def getMonitorById(self, monitorId):
"""
Returns monitor status and alltimeuptimeratio for a MonitorId.
"""
url = self.baseUrl
url += "getMonitors?apiKey=%s&monitors=%s" % (self.apiKey, monitorId)
url += "&noJsonCallback=1&format=json"
success, response = self.req... | [
"def",
"getMonitorById",
"(",
"self",
",",
"monitorId",
")",
":",
"url",
"=",
"self",
".",
"baseUrl",
"url",
"+=",
"\"getMonitors?apiKey=%s&monitors=%s\"",
"%",
"(",
"self",
".",
"apiKey",
",",
"monitorId",
")",
"url",
"+=",
"\"&noJsonCallback=1&format=json\"",
... | Returns monitor status and alltimeuptimeratio for a MonitorId. | [
"Returns",
"monitor",
"status",
"and",
"alltimeuptimeratio",
"for",
"a",
"MonitorId",
"."
] | 715ce082c0e966c44fd05b1624a40f0bb30fc6da | https://github.com/CodeBradley/python-uptimerobot/blob/715ce082c0e966c44fd05b1624a40f0bb30fc6da/uptimerobot/uptimerobot.py#L69-L81 |
49,031 | CodeBradley/python-uptimerobot | uptimerobot/uptimerobot.py | UptimeRobot.getMonitorByName | def getMonitorByName(self, monitorFriendlyName):
"""
Returns monitor status and alltimeuptimeratio for a MonitorFriendlyName.
"""
url = self.baseUrl
url += "getMonitors?apiKey=%s" % self.apiKey
url += "&noJsonCallback=1&format=json"
success, response = self.reques... | python | def getMonitorByName(self, monitorFriendlyName):
"""
Returns monitor status and alltimeuptimeratio for a MonitorFriendlyName.
"""
url = self.baseUrl
url += "getMonitors?apiKey=%s" % self.apiKey
url += "&noJsonCallback=1&format=json"
success, response = self.reques... | [
"def",
"getMonitorByName",
"(",
"self",
",",
"monitorFriendlyName",
")",
":",
"url",
"=",
"self",
".",
"baseUrl",
"url",
"+=",
"\"getMonitors?apiKey=%s\"",
"%",
"self",
".",
"apiKey",
"url",
"+=",
"\"&noJsonCallback=1&format=json\"",
"success",
",",
"response",
"=... | Returns monitor status and alltimeuptimeratio for a MonitorFriendlyName. | [
"Returns",
"monitor",
"status",
"and",
"alltimeuptimeratio",
"for",
"a",
"MonitorFriendlyName",
"."
] | 715ce082c0e966c44fd05b1624a40f0bb30fc6da | https://github.com/CodeBradley/python-uptimerobot/blob/715ce082c0e966c44fd05b1624a40f0bb30fc6da/uptimerobot/uptimerobot.py#L84-L100 |
49,032 | CodeBradley/python-uptimerobot | uptimerobot/uptimerobot.py | UptimeRobot.editMonitor | def editMonitor(self, monitorID, monitorStatus=None, monitorFriendlyName=None, monitorURL=None, monitorType=None,
monitorSubType=None, monitorPort=None, monitorKeywordType=None, monitorKeywordValue=None,
monitorHTTPUsername=None, monitorHTTPPassword=None, monitorAlertContacts=Non... | python | def editMonitor(self, monitorID, monitorStatus=None, monitorFriendlyName=None, monitorURL=None, monitorType=None,
monitorSubType=None, monitorPort=None, monitorKeywordType=None, monitorKeywordValue=None,
monitorHTTPUsername=None, monitorHTTPPassword=None, monitorAlertContacts=Non... | [
"def",
"editMonitor",
"(",
"self",
",",
"monitorID",
",",
"monitorStatus",
"=",
"None",
",",
"monitorFriendlyName",
"=",
"None",
",",
"monitorURL",
"=",
"None",
",",
"monitorType",
"=",
"None",
",",
"monitorSubType",
"=",
"None",
",",
"monitorPort",
"=",
"No... | monitorID is the only required object. All others are optional and must be quoted.
Returns Response object from api. | [
"monitorID",
"is",
"the",
"only",
"required",
"object",
".",
"All",
"others",
"are",
"optional",
"and",
"must",
"be",
"quoted",
".",
"Returns",
"Response",
"object",
"from",
"api",
"."
] | 715ce082c0e966c44fd05b1624a40f0bb30fc6da | https://github.com/CodeBradley/python-uptimerobot/blob/715ce082c0e966c44fd05b1624a40f0bb30fc6da/uptimerobot/uptimerobot.py#L103-L149 |
49,033 | CodeBradley/python-uptimerobot | uptimerobot/uptimerobot.py | UptimeRobot.deleteMonitorById | def deleteMonitorById(self, monitorID):
"""
Returns True or False if monitor is deleted
"""
url = self.baseUrl
url += "deleteMonitor?apiKey=%s" % self.apiKey
url += "&monitorID=%s" % monitorID
url += "&noJsonCallback=1&format=json"
success, response = self... | python | def deleteMonitorById(self, monitorID):
"""
Returns True or False if monitor is deleted
"""
url = self.baseUrl
url += "deleteMonitor?apiKey=%s" % self.apiKey
url += "&monitorID=%s" % monitorID
url += "&noJsonCallback=1&format=json"
success, response = self... | [
"def",
"deleteMonitorById",
"(",
"self",
",",
"monitorID",
")",
":",
"url",
"=",
"self",
".",
"baseUrl",
"url",
"+=",
"\"deleteMonitor?apiKey=%s\"",
"%",
"self",
".",
"apiKey",
"url",
"+=",
"\"&monitorID=%s\"",
"%",
"monitorID",
"url",
"+=",
"\"&noJsonCallback=1... | Returns True or False if monitor is deleted | [
"Returns",
"True",
"or",
"False",
"if",
"monitor",
"is",
"deleted"
] | 715ce082c0e966c44fd05b1624a40f0bb30fc6da | https://github.com/CodeBradley/python-uptimerobot/blob/715ce082c0e966c44fd05b1624a40f0bb30fc6da/uptimerobot/uptimerobot.py#L152-L164 |
49,034 | CodeBradley/python-uptimerobot | uptimerobot/uptimerobot.py | UptimeRobot.getAlertContacts | def getAlertContacts(self, alertContacts=None, offset=None, limit=None):
"""
Get Alert Contacts
"""
url = self.baseUrl
url += "getAlertContacts?apiKey=%s" % self.apiKey
if alertContacts:
url += "&alertContacts=%s" % alertContacts
... | python | def getAlertContacts(self, alertContacts=None, offset=None, limit=None):
"""
Get Alert Contacts
"""
url = self.baseUrl
url += "getAlertContacts?apiKey=%s" % self.apiKey
if alertContacts:
url += "&alertContacts=%s" % alertContacts
... | [
"def",
"getAlertContacts",
"(",
"self",
",",
"alertContacts",
"=",
"None",
",",
"offset",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"baseUrl",
"url",
"+=",
"\"getAlertContacts?apiKey=%s\"",
"%",
"self",
".",
"apiKey",
"if",... | Get Alert Contacts | [
"Get",
"Alert",
"Contacts"
] | 715ce082c0e966c44fd05b1624a40f0bb30fc6da | https://github.com/CodeBradley/python-uptimerobot/blob/715ce082c0e966c44fd05b1624a40f0bb30fc6da/uptimerobot/uptimerobot.py#L177-L190 |
49,035 | ghackebeil/PyORAM | src/pyoram/storage/block_storage_ram.py | BlockStorageRAM.fromfile | def fromfile(file_,
threadpool_size=None,
ignore_lock=False):
"""
Instantiate BlockStorageRAM device from a file saved in block
storage format. The file_ argument can be a file object or a
string that represents a filename. If called with a file
... | python | def fromfile(file_,
threadpool_size=None,
ignore_lock=False):
"""
Instantiate BlockStorageRAM device from a file saved in block
storage format. The file_ argument can be a file object or a
string that represents a filename. If called with a file
... | [
"def",
"fromfile",
"(",
"file_",
",",
"threadpool_size",
"=",
"None",
",",
"ignore_lock",
"=",
"False",
")",
":",
"close_file",
"=",
"False",
"if",
"not",
"hasattr",
"(",
"file_",
",",
"'read'",
")",
":",
"file_",
"=",
"open",
"(",
"file_",
",",
"'rb'"... | Instantiate BlockStorageRAM device from a file saved in block
storage format. The file_ argument can be a file object or a
string that represents a filename. If called with a file
object, it should be opened in binary mode, and the caller is
responsible for closing the file.
Thi... | [
"Instantiate",
"BlockStorageRAM",
"device",
"from",
"a",
"file",
"saved",
"in",
"block",
"storage",
"format",
".",
"The",
"file_",
"argument",
"can",
"be",
"a",
"file",
"object",
"or",
"a",
"string",
"that",
"represents",
"a",
"filename",
".",
"If",
"called"... | b8832c1b753c0b2148ef7a143c5f5dd3bbbb61e7 | https://github.com/ghackebeil/PyORAM/blob/b8832c1b753c0b2148ef7a143c5f5dd3bbbb61e7/src/pyoram/storage/block_storage_ram.py#L93-L133 |
49,036 | ghackebeil/PyORAM | src/pyoram/storage/block_storage_ram.py | BlockStorageRAM.tofile | def tofile(self, file_):
"""
Dump all storage data to a file. The file_ argument can be a
file object or a string that represents a filename. If called
with a file object, it should be opened in binary mode, and
the caller is responsible for closing the file.
The method ... | python | def tofile(self, file_):
"""
Dump all storage data to a file. The file_ argument can be a
file object or a string that represents a filename. If called
with a file object, it should be opened in binary mode, and
the caller is responsible for closing the file.
The method ... | [
"def",
"tofile",
"(",
"self",
",",
"file_",
")",
":",
"close_file",
"=",
"False",
"if",
"not",
"hasattr",
"(",
"file_",
",",
"'write'",
")",
":",
"file_",
"=",
"open",
"(",
"file_",
",",
"'wb'",
")",
"close_file",
"=",
"True",
"file_",
".",
"write",
... | Dump all storage data to a file. The file_ argument can be a
file object or a string that represents a filename. If called
with a file object, it should be opened in binary mode, and
the caller is responsible for closing the file.
The method should only be called after the storage devic... | [
"Dump",
"all",
"storage",
"data",
"to",
"a",
"file",
".",
"The",
"file_",
"argument",
"can",
"be",
"a",
"file",
"object",
"or",
"a",
"string",
"that",
"represents",
"a",
"filename",
".",
"If",
"called",
"with",
"a",
"file",
"object",
"it",
"should",
"b... | b8832c1b753c0b2148ef7a143c5f5dd3bbbb61e7 | https://github.com/ghackebeil/PyORAM/blob/b8832c1b753c0b2148ef7a143c5f5dd3bbbb61e7/src/pyoram/storage/block_storage_ram.py#L135-L152 |
49,037 | romana/vpc-router | vpcrouter/main/http_server.py | log_to_logger | def log_to_logger(fn):
"""
Wrap a Bottle request so that a log line is emitted after it's handled.
"""
@wraps(fn)
def _log_to_logger(*args, **kwargs):
actual_response = fn(*args, **kwargs)
# modify this to log exactly what you need:
logger.info('%s %s %s %s' % (bottle.reques... | python | def log_to_logger(fn):
"""
Wrap a Bottle request so that a log line is emitted after it's handled.
"""
@wraps(fn)
def _log_to_logger(*args, **kwargs):
actual_response = fn(*args, **kwargs)
# modify this to log exactly what you need:
logger.info('%s %s %s %s' % (bottle.reques... | [
"def",
"log_to_logger",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"def",
"_log_to_logger",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"actual_response",
"=",
"fn",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"# modify this to l... | Wrap a Bottle request so that a log line is emitted after it's handled. | [
"Wrap",
"a",
"Bottle",
"request",
"so",
"that",
"a",
"log",
"line",
"is",
"emitted",
"after",
"it",
"s",
"handled",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/main/http_server.py#L45-L59 |
49,038 | romana/vpc-router | vpcrouter/main/http_server.py | handle_request | def handle_request(path):
"""
Return the current status.
"""
accept = bottle.request.get_header("accept", default="text/plain")
bottle.response.status = 200
try:
if "text/html" in accept:
ret = CURRENT_STATE.as_html(path=path)
bottle.response.content_type = "te... | python | def handle_request(path):
"""
Return the current status.
"""
accept = bottle.request.get_header("accept", default="text/plain")
bottle.response.status = 200
try:
if "text/html" in accept:
ret = CURRENT_STATE.as_html(path=path)
bottle.response.content_type = "te... | [
"def",
"handle_request",
"(",
"path",
")",
":",
"accept",
"=",
"bottle",
".",
"request",
".",
"get_header",
"(",
"\"accept\"",
",",
"default",
"=",
"\"text/plain\"",
")",
"bottle",
".",
"response",
".",
"status",
"=",
"200",
"try",
":",
"if",
"\"text/html\... | Return the current status. | [
"Return",
"the",
"current",
"status",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/main/http_server.py#L102-L131 |
49,039 | romana/vpc-router | vpcrouter/main/http_server.py | VpcRouterHttpServer.start | def start(self):
"""
Start the HTTP server thread.
"""
logging.info("HTTP server: "
"Starting to listen for requests on '%s:%s'..." %
(self.conf['addr'], self.conf['port']))
self.my_server = MyWSGIRefServer(host=self.conf['addr'],
... | python | def start(self):
"""
Start the HTTP server thread.
"""
logging.info("HTTP server: "
"Starting to listen for requests on '%s:%s'..." %
(self.conf['addr'], self.conf['port']))
self.my_server = MyWSGIRefServer(host=self.conf['addr'],
... | [
"def",
"start",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"\"HTTP server: \"",
"\"Starting to listen for requests on '%s:%s'...\"",
"%",
"(",
"self",
".",
"conf",
"[",
"'addr'",
"]",
",",
"self",
".",
"conf",
"[",
"'port'",
"]",
")",
")",
"self",
... | Start the HTTP server thread. | [
"Start",
"the",
"HTTP",
"server",
"thread",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/main/http_server.py#L176-L199 |
49,040 | romana/vpc-router | vpcrouter/main/http_server.py | VpcRouterHttpServer.stop | def stop(self):
"""
Stop the HTTP server thread.
"""
self.my_server.stop()
self.http_thread.join()
logging.info("HTTP server: Stopped") | python | def stop(self):
"""
Stop the HTTP server thread.
"""
self.my_server.stop()
self.http_thread.join()
logging.info("HTTP server: Stopped") | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"my_server",
".",
"stop",
"(",
")",
"self",
".",
"http_thread",
".",
"join",
"(",
")",
"logging",
".",
"info",
"(",
"\"HTTP server: Stopped\"",
")"
] | Stop the HTTP server thread. | [
"Stop",
"the",
"HTTP",
"server",
"thread",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/main/http_server.py#L201-L208 |
49,041 | romana/vpc-router | vpcrouter/monitor/plugins/icmpecho.py | Icmpecho.update_stats | def update_stats(self, responses, no_responses):
"""
Maintain some stats about our requests.
"""
slowest_rtt = 0.0
slowest_ip = None
fastest_rtt = 9999999.9
fastest_ip = None
rtt_total = 0.0
for ip, rtt in responses.items():
rtt_t... | python | def update_stats(self, responses, no_responses):
"""
Maintain some stats about our requests.
"""
slowest_rtt = 0.0
slowest_ip = None
fastest_rtt = 9999999.9
fastest_ip = None
rtt_total = 0.0
for ip, rtt in responses.items():
rtt_t... | [
"def",
"update_stats",
"(",
"self",
",",
"responses",
",",
"no_responses",
")",
":",
"slowest_rtt",
"=",
"0.0",
"slowest_ip",
"=",
"None",
"fastest_rtt",
"=",
"9999999.9",
"fastest_ip",
"=",
"None",
"rtt_total",
"=",
"0.0",
"for",
"ip",
",",
"rtt",
"in",
"... | Maintain some stats about our requests. | [
"Maintain",
"some",
"stats",
"about",
"our",
"requests",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/monitor/plugins/icmpecho.py#L50-L100 |
49,042 | romana/vpc-router | vpcrouter/monitor/plugins/icmpecho.py | Icmpecho.do_health_checks | def do_health_checks(self, list_of_ips):
"""
Perform a health check on a list of IP addresses, using ICMPecho.
Return tuple with list of failed IPs and questionable IPs.
"""
# Calculate a decent overall timeout time for a ping attempt: 3/4th of
# the monitoring interval... | python | def do_health_checks(self, list_of_ips):
"""
Perform a health check on a list of IP addresses, using ICMPecho.
Return tuple with list of failed IPs and questionable IPs.
"""
# Calculate a decent overall timeout time for a ping attempt: 3/4th of
# the monitoring interval... | [
"def",
"do_health_checks",
"(",
"self",
",",
"list_of_ips",
")",
":",
"# Calculate a decent overall timeout time for a ping attempt: 3/4th of",
"# the monitoring interval. That way, we know we're done with this ping",
"# attempt before the next monitoring attempt is started.",
"ping_timeout",
... | Perform a health check on a list of IP addresses, using ICMPecho.
Return tuple with list of failed IPs and questionable IPs. | [
"Perform",
"a",
"health",
"check",
"on",
"a",
"list",
"of",
"IP",
"addresses",
"using",
"ICMPecho",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/monitor/plugins/icmpecho.py#L102-L132 |
49,043 | romana/vpc-router | vpcrouter/monitor/plugins/icmpecho.py | Icmpecho.add_arguments | def add_arguments(cls, parser, sys_arg_list=None):
"""
Arguments for the ICMPecho health monitor plugin.
"""
parser.add_argument('--icmp_check_interval',
dest='icmp_check_interval',
required=False, default=2, type=float,
... | python | def add_arguments(cls, parser, sys_arg_list=None):
"""
Arguments for the ICMPecho health monitor plugin.
"""
parser.add_argument('--icmp_check_interval',
dest='icmp_check_interval',
required=False, default=2, type=float,
... | [
"def",
"add_arguments",
"(",
"cls",
",",
"parser",
",",
"sys_arg_list",
"=",
"None",
")",
":",
"parser",
".",
"add_argument",
"(",
"'--icmp_check_interval'",
",",
"dest",
"=",
"'icmp_check_interval'",
",",
"required",
"=",
"False",
",",
"default",
"=",
"2",
... | Arguments for the ICMPecho health monitor plugin. | [
"Arguments",
"for",
"the",
"ICMPecho",
"health",
"monitor",
"plugin",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/monitor/plugins/icmpecho.py#L186-L196 |
49,044 | romana/vpc-router | vpcrouter/utils/__init__.py | ip_check | def ip_check(ip, netmask_expected=False):
"""
Sanity check that the specified string is indeed an IP address or mask.
"""
try:
if netmask_expected:
if "/" not in ip:
raise netaddr.core.AddrFormatError()
netaddr.IPNetwork(ip)
else:
neta... | python | def ip_check(ip, netmask_expected=False):
"""
Sanity check that the specified string is indeed an IP address or mask.
"""
try:
if netmask_expected:
if "/" not in ip:
raise netaddr.core.AddrFormatError()
netaddr.IPNetwork(ip)
else:
neta... | [
"def",
"ip_check",
"(",
"ip",
",",
"netmask_expected",
"=",
"False",
")",
":",
"try",
":",
"if",
"netmask_expected",
":",
"if",
"\"/\"",
"not",
"in",
"ip",
":",
"raise",
"netaddr",
".",
"core",
".",
"AddrFormatError",
"(",
")",
"netaddr",
".",
"IPNetwork... | Sanity check that the specified string is indeed an IP address or mask. | [
"Sanity",
"check",
"that",
"the",
"specified",
"string",
"is",
"indeed",
"an",
"IP",
"address",
"or",
"mask",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/utils/__init__.py#L29-L47 |
49,045 | romana/vpc-router | vpcrouter/utils/__init__.py | check_valid_ip_or_cidr | def check_valid_ip_or_cidr(val, return_as_cidr=False):
"""
Checks that the value is a valid IP address or a valid CIDR.
Returns the specified value.
If 'return_as_cidr' is set then the return value will always be in the form
of a CIDR, even if a plain IP address was specified.
"""
is_ip =... | python | def check_valid_ip_or_cidr(val, return_as_cidr=False):
"""
Checks that the value is a valid IP address or a valid CIDR.
Returns the specified value.
If 'return_as_cidr' is set then the return value will always be in the form
of a CIDR, even if a plain IP address was specified.
"""
is_ip =... | [
"def",
"check_valid_ip_or_cidr",
"(",
"val",
",",
"return_as_cidr",
"=",
"False",
")",
":",
"is_ip",
"=",
"True",
"if",
"\"/\"",
"in",
"val",
":",
"ip_check",
"(",
"val",
",",
"netmask_expected",
"=",
"True",
")",
"is_ip",
"=",
"False",
"else",
":",
"ip_... | Checks that the value is a valid IP address or a valid CIDR.
Returns the specified value.
If 'return_as_cidr' is set then the return value will always be in the form
of a CIDR, even if a plain IP address was specified. | [
"Checks",
"that",
"the",
"value",
"is",
"a",
"valid",
"IP",
"address",
"or",
"a",
"valid",
"CIDR",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/utils/__init__.py#L50-L80 |
49,046 | romana/vpc-router | vpcrouter/utils/__init__.py | is_cidr_in_cidr | def is_cidr_in_cidr(small_cidr, big_cidr):
"""
Return True if the small CIDR is contained in the big CIDR.
"""
# The default route (0.0.0.0/0) is handled differently, since every route
# would always be contained in there. Instead, only a small CIDR of
# "0.0.0.0/0" can match against it. Other ... | python | def is_cidr_in_cidr(small_cidr, big_cidr):
"""
Return True if the small CIDR is contained in the big CIDR.
"""
# The default route (0.0.0.0/0) is handled differently, since every route
# would always be contained in there. Instead, only a small CIDR of
# "0.0.0.0/0" can match against it. Other ... | [
"def",
"is_cidr_in_cidr",
"(",
"small_cidr",
",",
"big_cidr",
")",
":",
"# The default route (0.0.0.0/0) is handled differently, since every route",
"# would always be contained in there. Instead, only a small CIDR of",
"# \"0.0.0.0/0\" can match against it. Other small CIDRs will always result ... | Return True if the small CIDR is contained in the big CIDR. | [
"Return",
"True",
"if",
"the",
"small",
"CIDR",
"is",
"contained",
"in",
"the",
"big",
"CIDR",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/utils/__init__.py#L83-L100 |
49,047 | romana/vpc-router | vpcrouter/utils/__init__.py | read_last_msg_from_queue | def read_last_msg_from_queue(q):
"""
Read all messages from a queue and return the last one.
This is useful in many cases where all messages are always the complete
state of things. Therefore, intermittent messages can be ignored.
Doesn't block, returns None if there is no message waiting in the q... | python | def read_last_msg_from_queue(q):
"""
Read all messages from a queue and return the last one.
This is useful in many cases where all messages are always the complete
state of things. Therefore, intermittent messages can be ignored.
Doesn't block, returns None if there is no message waiting in the q... | [
"def",
"read_last_msg_from_queue",
"(",
"q",
")",
":",
"msg",
"=",
"None",
"while",
"True",
":",
"try",
":",
"# The list of IPs is always a full list.",
"msg",
"=",
"q",
".",
"get_nowait",
"(",
")",
"q",
".",
"task_done",
"(",
")",
"except",
"Queue",
".",
... | Read all messages from a queue and return the last one.
This is useful in many cases where all messages are always the complete
state of things. Therefore, intermittent messages can be ignored.
Doesn't block, returns None if there is no message waiting in the queue. | [
"Read",
"all",
"messages",
"from",
"a",
"queue",
"and",
"return",
"the",
"last",
"one",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/utils/__init__.py#L103-L121 |
49,048 | romana/vpc-router | vpcrouter/utils/__init__.py | param_extract | def param_extract(args, short_form, long_form, default=None):
"""
Quick extraction of a parameter from the command line argument list.
In some cases we need to parse a few arguments before the official
arg-parser starts.
Returns parameter value, or None if not present.
"""
val = default
... | python | def param_extract(args, short_form, long_form, default=None):
"""
Quick extraction of a parameter from the command line argument list.
In some cases we need to parse a few arguments before the official
arg-parser starts.
Returns parameter value, or None if not present.
"""
val = default
... | [
"def",
"param_extract",
"(",
"args",
",",
"short_form",
",",
"long_form",
",",
"default",
"=",
"None",
")",
":",
"val",
"=",
"default",
"for",
"i",
",",
"a",
"in",
"enumerate",
"(",
"args",
")",
":",
"# Long form may use \"--xyz=foo\", so need to split on '=', b... | Quick extraction of a parameter from the command line argument list.
In some cases we need to parse a few arguments before the official
arg-parser starts.
Returns parameter value, or None if not present. | [
"Quick",
"extraction",
"of",
"a",
"parameter",
"from",
"the",
"command",
"line",
"argument",
"list",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/utils/__init__.py#L124-L150 |
49,049 | ghackebeil/PyORAM | src/pyoram/util/virtual_heap.py | base10_integer_to_basek_string | def base10_integer_to_basek_string(k, x):
"""Convert an integer into a base k string."""
if not (2 <= k <= max_k_labeled):
raise ValueError("k must be in range [2, %d]: %s"
% (max_k_labeled, k))
return ((x == 0) and numerals[0]) or \
(base10_integer_to_basek_string(k... | python | def base10_integer_to_basek_string(k, x):
"""Convert an integer into a base k string."""
if not (2 <= k <= max_k_labeled):
raise ValueError("k must be in range [2, %d]: %s"
% (max_k_labeled, k))
return ((x == 0) and numerals[0]) or \
(base10_integer_to_basek_string(k... | [
"def",
"base10_integer_to_basek_string",
"(",
"k",
",",
"x",
")",
":",
"if",
"not",
"(",
"2",
"<=",
"k",
"<=",
"max_k_labeled",
")",
":",
"raise",
"ValueError",
"(",
"\"k must be in range [2, %d]: %s\"",
"%",
"(",
"max_k_labeled",
",",
"k",
")",
")",
"return... | Convert an integer into a base k string. | [
"Convert",
"an",
"integer",
"into",
"a",
"base",
"k",
"string",
"."
] | b8832c1b753c0b2148ef7a143c5f5dd3bbbb61e7 | https://github.com/ghackebeil/PyORAM/blob/b8832c1b753c0b2148ef7a143c5f5dd3bbbb61e7/src/pyoram/util/virtual_heap.py#L27-L34 |
49,050 | ghackebeil/PyORAM | src/pyoram/util/virtual_heap.py | basek_string_to_base10_integer | def basek_string_to_base10_integer(k, x):
"""Convert a base k string into an integer."""
assert 1 < k <= max_k_labeled
return sum(numeral_index[c]*(k**i)
for i, c in enumerate(reversed(x))) | python | def basek_string_to_base10_integer(k, x):
"""Convert a base k string into an integer."""
assert 1 < k <= max_k_labeled
return sum(numeral_index[c]*(k**i)
for i, c in enumerate(reversed(x))) | [
"def",
"basek_string_to_base10_integer",
"(",
"k",
",",
"x",
")",
":",
"assert",
"1",
"<",
"k",
"<=",
"max_k_labeled",
"return",
"sum",
"(",
"numeral_index",
"[",
"c",
"]",
"*",
"(",
"k",
"**",
"i",
")",
"for",
"i",
",",
"c",
"in",
"enumerate",
"(",
... | Convert a base k string into an integer. | [
"Convert",
"a",
"base",
"k",
"string",
"into",
"an",
"integer",
"."
] | b8832c1b753c0b2148ef7a143c5f5dd3bbbb61e7 | https://github.com/ghackebeil/PyORAM/blob/b8832c1b753c0b2148ef7a143c5f5dd3bbbb61e7/src/pyoram/util/virtual_heap.py#L36-L40 |
49,051 | ghackebeil/PyORAM | src/pyoram/util/virtual_heap.py | calculate_bucket_level | def calculate_bucket_level(k, b):
"""
Calculate the level in which a 0-based bucket
lives inside of a k-ary heap.
"""
assert k >= 2
if k == 2:
return log2floor(b+1)
v = (k - 1) * (b + 1) + 1
h = 0
while k**(h+1) < v:
h += 1
return h | python | def calculate_bucket_level(k, b):
"""
Calculate the level in which a 0-based bucket
lives inside of a k-ary heap.
"""
assert k >= 2
if k == 2:
return log2floor(b+1)
v = (k - 1) * (b + 1) + 1
h = 0
while k**(h+1) < v:
h += 1
return h | [
"def",
"calculate_bucket_level",
"(",
"k",
",",
"b",
")",
":",
"assert",
"k",
">=",
"2",
"if",
"k",
"==",
"2",
":",
"return",
"log2floor",
"(",
"b",
"+",
"1",
")",
"v",
"=",
"(",
"k",
"-",
"1",
")",
"*",
"(",
"b",
"+",
"1",
")",
"+",
"1",
... | Calculate the level in which a 0-based bucket
lives inside of a k-ary heap. | [
"Calculate",
"the",
"level",
"in",
"which",
"a",
"0",
"-",
"based",
"bucket",
"lives",
"inside",
"of",
"a",
"k",
"-",
"ary",
"heap",
"."
] | b8832c1b753c0b2148ef7a143c5f5dd3bbbb61e7 | https://github.com/ghackebeil/PyORAM/blob/b8832c1b753c0b2148ef7a143c5f5dd3bbbb61e7/src/pyoram/util/virtual_heap.py#L43-L55 |
49,052 | ghackebeil/PyORAM | src/pyoram/util/virtual_heap.py | calculate_last_common_level | def calculate_last_common_level(k, b1, b2):
"""
Calculate the highest level after which the
paths from the root to these buckets diverge.
"""
l1 = calculate_bucket_level(k, b1)
l2 = calculate_bucket_level(k, b2)
while l1 > l2:
b1 = (b1-1)//k
l1 -= 1
while l2 > l1:
... | python | def calculate_last_common_level(k, b1, b2):
"""
Calculate the highest level after which the
paths from the root to these buckets diverge.
"""
l1 = calculate_bucket_level(k, b1)
l2 = calculate_bucket_level(k, b2)
while l1 > l2:
b1 = (b1-1)//k
l1 -= 1
while l2 > l1:
... | [
"def",
"calculate_last_common_level",
"(",
"k",
",",
"b1",
",",
"b2",
")",
":",
"l1",
"=",
"calculate_bucket_level",
"(",
"k",
",",
"b1",
")",
"l2",
"=",
"calculate_bucket_level",
"(",
"k",
",",
"b2",
")",
"while",
"l1",
">",
"l2",
":",
"b1",
"=",
"(... | Calculate the highest level after which the
paths from the root to these buckets diverge. | [
"Calculate",
"the",
"highest",
"level",
"after",
"which",
"the",
"paths",
"from",
"the",
"root",
"to",
"these",
"buckets",
"diverge",
"."
] | b8832c1b753c0b2148ef7a143c5f5dd3bbbb61e7 | https://github.com/ghackebeil/PyORAM/blob/b8832c1b753c0b2148ef7a143c5f5dd3bbbb61e7/src/pyoram/util/virtual_heap.py#L58-L75 |
49,053 | ghackebeil/PyORAM | src/pyoram/util/virtual_heap.py | SizedVirtualHeap.write_as_dot | def write_as_dot(self, f, data=None, max_levels=None):
"Write the tree in the dot language format to f."
assert (max_levels is None) or (max_levels >= 0)
def visit_node(n, levels):
lbl = "{"
if data is None:
if self.k <= max_k_labeled:
... | python | def write_as_dot(self, f, data=None, max_levels=None):
"Write the tree in the dot language format to f."
assert (max_levels is None) or (max_levels >= 0)
def visit_node(n, levels):
lbl = "{"
if data is None:
if self.k <= max_k_labeled:
... | [
"def",
"write_as_dot",
"(",
"self",
",",
"f",
",",
"data",
"=",
"None",
",",
"max_levels",
"=",
"None",
")",
":",
"assert",
"(",
"max_levels",
"is",
"None",
")",
"or",
"(",
"max_levels",
">=",
"0",
")",
"def",
"visit_node",
"(",
"n",
",",
"levels",
... | Write the tree in the dot language format to f. | [
"Write",
"the",
"tree",
"in",
"the",
"dot",
"language",
"format",
"to",
"f",
"."
] | b8832c1b753c0b2148ef7a143c5f5dd3bbbb61e7 | https://github.com/ghackebeil/PyORAM/blob/b8832c1b753c0b2148ef7a143c5f5dd3bbbb61e7/src/pyoram/util/virtual_heap.py#L379-L417 |
49,054 | ghackebeil/PyORAM | src/pyoram/util/virtual_heap.py | SizedVirtualHeap.save_image_as_pdf | def save_image_as_pdf(self, filename, data=None, max_levels=None):
"Write the heap as PDF file."
assert (max_levels is None) or (max_levels >= 0)
import os
if not filename.endswith('.pdf'):
filename = filename+'.pdf'
tmpfd, tmpname = tempfile.mkstemp(suffix='dot')
... | python | def save_image_as_pdf(self, filename, data=None, max_levels=None):
"Write the heap as PDF file."
assert (max_levels is None) or (max_levels >= 0)
import os
if not filename.endswith('.pdf'):
filename = filename+'.pdf'
tmpfd, tmpname = tempfile.mkstemp(suffix='dot')
... | [
"def",
"save_image_as_pdf",
"(",
"self",
",",
"filename",
",",
"data",
"=",
"None",
",",
"max_levels",
"=",
"None",
")",
":",
"assert",
"(",
"max_levels",
"is",
"None",
")",
"or",
"(",
"max_levels",
">=",
"0",
")",
"import",
"os",
"if",
"not",
"filenam... | Write the heap as PDF file. | [
"Write",
"the",
"heap",
"as",
"PDF",
"file",
"."
] | b8832c1b753c0b2148ef7a143c5f5dd3bbbb61e7 | https://github.com/ghackebeil/PyORAM/blob/b8832c1b753c0b2148ef7a143c5f5dd3bbbb61e7/src/pyoram/util/virtual_heap.py#L419-L441 |
49,055 | tdsmith/eleven | eleven/eleven.py | average_cq | def average_cq(seq, efficiency=1.0):
"""Given a set of Cq values, return the Cq value that represents the
average expression level of the input.
The intent is to average the expression levels of the samples,
since the average of Cq values is not biologically meaningful.
:param iterable seq: A sequ... | python | def average_cq(seq, efficiency=1.0):
"""Given a set of Cq values, return the Cq value that represents the
average expression level of the input.
The intent is to average the expression levels of the samples,
since the average of Cq values is not biologically meaningful.
:param iterable seq: A sequ... | [
"def",
"average_cq",
"(",
"seq",
",",
"efficiency",
"=",
"1.0",
")",
":",
"denominator",
"=",
"sum",
"(",
"[",
"pow",
"(",
"2.0",
"*",
"efficiency",
",",
"-",
"Ci",
")",
"for",
"Ci",
"in",
"seq",
"]",
")",
"return",
"log",
"(",
"len",
"(",
"seq",... | Given a set of Cq values, return the Cq value that represents the
average expression level of the input.
The intent is to average the expression levels of the samples,
since the average of Cq values is not biologically meaningful.
:param iterable seq: A sequence (e.g. list, array, or Series) of Cq val... | [
"Given",
"a",
"set",
"of",
"Cq",
"values",
"return",
"the",
"Cq",
"value",
"that",
"represents",
"the",
"average",
"expression",
"level",
"of",
"the",
"input",
"."
] | c79b7e784f6d4a76eb4371e69d5ee6f471fe56e1 | https://github.com/tdsmith/eleven/blob/c79b7e784f6d4a76eb4371e69d5ee6f471fe56e1/eleven/eleven.py#L14-L28 |
49,056 | tdsmith/eleven | eleven/eleven.py | validate_sample_frame | def validate_sample_frame(sample_frame):
"""Makes sure that `sample_frame` has the columns we expect.
:param DataFrame sample_frame: A sample data frame.
:return: True (or raises an exception)
:raises TypeError: if sample_frame is not a pandas DataFrame
:raises ValueError: if columns are missing or... | python | def validate_sample_frame(sample_frame):
"""Makes sure that `sample_frame` has the columns we expect.
:param DataFrame sample_frame: A sample data frame.
:return: True (or raises an exception)
:raises TypeError: if sample_frame is not a pandas DataFrame
:raises ValueError: if columns are missing or... | [
"def",
"validate_sample_frame",
"(",
"sample_frame",
")",
":",
"if",
"not",
"isinstance",
"(",
"sample_frame",
",",
"pd",
".",
"core",
".",
"frame",
".",
"DataFrame",
")",
":",
"raise",
"TypeError",
"(",
"\"Expected a pandas DataFrame, received {}\"",
".",
"format... | Makes sure that `sample_frame` has the columns we expect.
:param DataFrame sample_frame: A sample data frame.
:return: True (or raises an exception)
:raises TypeError: if sample_frame is not a pandas DataFrame
:raises ValueError: if columns are missing or the wrong type | [
"Makes",
"sure",
"that",
"sample_frame",
"has",
"the",
"columns",
"we",
"expect",
"."
] | c79b7e784f6d4a76eb4371e69d5ee6f471fe56e1 | https://github.com/tdsmith/eleven/blob/c79b7e784f6d4a76eb4371e69d5ee6f471fe56e1/eleven/eleven.py#L30-L45 |
49,057 | tdsmith/eleven | eleven/eleven.py | censor_background | def censor_background(sample_frame, ntc_samples=['NTC'], margin=log2(10)):
"""Selects rows from the sample data frame that fall `margin` or greater
cycles earlier than the NTC for that target. NTC wells are recognized by
string matching against the Sample column.
:param DataFrame sample_frame: A sample... | python | def censor_background(sample_frame, ntc_samples=['NTC'], margin=log2(10)):
"""Selects rows from the sample data frame that fall `margin` or greater
cycles earlier than the NTC for that target. NTC wells are recognized by
string matching against the Sample column.
:param DataFrame sample_frame: A sample... | [
"def",
"censor_background",
"(",
"sample_frame",
",",
"ntc_samples",
"=",
"[",
"'NTC'",
"]",
",",
"margin",
"=",
"log2",
"(",
"10",
")",
")",
":",
"ntcs",
"=",
"sample_frame",
".",
"loc",
"[",
"sample_frame",
"[",
"'Sample'",
"]",
".",
"apply",
"(",
"l... | Selects rows from the sample data frame that fall `margin` or greater
cycles earlier than the NTC for that target. NTC wells are recognized by
string matching against the Sample column.
:param DataFrame sample_frame: A sample data frame.
:param iterable ntc_samples: A sequence of strings giving the sam... | [
"Selects",
"rows",
"from",
"the",
"sample",
"data",
"frame",
"that",
"fall",
"margin",
"or",
"greater",
"cycles",
"earlier",
"than",
"the",
"NTC",
"for",
"that",
"target",
".",
"NTC",
"wells",
"are",
"recognized",
"by",
"string",
"matching",
"against",
"the"... | c79b7e784f6d4a76eb4371e69d5ee6f471fe56e1 | https://github.com/tdsmith/eleven/blob/c79b7e784f6d4a76eb4371e69d5ee6f471fe56e1/eleven/eleven.py#L47-L68 |
49,058 | tdsmith/eleven | eleven/eleven.py | expression_nf | def expression_nf(sample_frame, nf_n, ref_sample):
"""Calculates expression of samples in a sample data frame relative to
pre-computed normalization factors.
ref_sample should be defined for all targets or the result will contain
many NaNs.
:param DataFrame sample_frame: A sample data frame.
:... | python | def expression_nf(sample_frame, nf_n, ref_sample):
"""Calculates expression of samples in a sample data frame relative to
pre-computed normalization factors.
ref_sample should be defined for all targets or the result will contain
many NaNs.
:param DataFrame sample_frame: A sample data frame.
:... | [
"def",
"expression_nf",
"(",
"sample_frame",
",",
"nf_n",
",",
"ref_sample",
")",
":",
"ref_sample_df",
"=",
"sample_frame",
".",
"ix",
"[",
"sample_frame",
"[",
"'Sample'",
"]",
"==",
"ref_sample",
",",
"[",
"'Target'",
",",
"'Cq'",
"]",
"]",
"ref_sample_cq... | Calculates expression of samples in a sample data frame relative to
pre-computed normalization factors.
ref_sample should be defined for all targets or the result will contain
many NaNs.
:param DataFrame sample_frame: A sample data frame.
:param Series nf_n: A Series of normalization factors index... | [
"Calculates",
"expression",
"of",
"samples",
"in",
"a",
"sample",
"data",
"frame",
"relative",
"to",
"pre",
"-",
"computed",
"normalization",
"factors",
"."
] | c79b7e784f6d4a76eb4371e69d5ee6f471fe56e1 | https://github.com/tdsmith/eleven/blob/c79b7e784f6d4a76eb4371e69d5ee6f471fe56e1/eleven/eleven.py#L106-L127 |
49,059 | tdsmith/eleven | eleven/eleven.py | collect_expression | def collect_expression(sample_frame, ref_targets, ref_sample):
"""Calculates the expression of all rows in the sample_frame relative to
each of the ref_targets. Used in rank_targets.
:param DataFrame sample_frame: A sample data frame.
:param iterable ref_targets: A sequence of targets from the Target c... | python | def collect_expression(sample_frame, ref_targets, ref_sample):
"""Calculates the expression of all rows in the sample_frame relative to
each of the ref_targets. Used in rank_targets.
:param DataFrame sample_frame: A sample data frame.
:param iterable ref_targets: A sequence of targets from the Target c... | [
"def",
"collect_expression",
"(",
"sample_frame",
",",
"ref_targets",
",",
"ref_sample",
")",
":",
"by_gene",
"=",
"{",
"'Sample'",
":",
"sample_frame",
"[",
"'Sample'",
"]",
",",
"'Target'",
":",
"sample_frame",
"[",
"'Target'",
"]",
"}",
"for",
"target",
"... | Calculates the expression of all rows in the sample_frame relative to
each of the ref_targets. Used in rank_targets.
:param DataFrame sample_frame: A sample data frame.
:param iterable ref_targets: A sequence of targets from the Target column of
the sample frame.
:param string ref_sample: The n... | [
"Calculates",
"the",
"expression",
"of",
"all",
"rows",
"in",
"the",
"sample_frame",
"relative",
"to",
"each",
"of",
"the",
"ref_targets",
".",
"Used",
"in",
"rank_targets",
"."
] | c79b7e784f6d4a76eb4371e69d5ee6f471fe56e1 | https://github.com/tdsmith/eleven/blob/c79b7e784f6d4a76eb4371e69d5ee6f471fe56e1/eleven/eleven.py#L129-L145 |
49,060 | tdsmith/eleven | eleven/eleven.py | rank_targets | def rank_targets(sample_frame, ref_targets, ref_sample):
"""Uses the geNorm algorithm to determine the most stably expressed
genes from amongst ref_targets in your sample.
See Vandesompele et al.'s 2002 Genome Biology paper for information about
the algorithm: http://dx.doi.org/10.1186/gb-2002-3-7-rese... | python | def rank_targets(sample_frame, ref_targets, ref_sample):
"""Uses the geNorm algorithm to determine the most stably expressed
genes from amongst ref_targets in your sample.
See Vandesompele et al.'s 2002 Genome Biology paper for information about
the algorithm: http://dx.doi.org/10.1186/gb-2002-3-7-rese... | [
"def",
"rank_targets",
"(",
"sample_frame",
",",
"ref_targets",
",",
"ref_sample",
")",
":",
"table",
"=",
"collect_expression",
"(",
"sample_frame",
",",
"ref_targets",
",",
"ref_sample",
")",
"all_samples",
"=",
"sample_frame",
"[",
"'Sample'",
"]",
".",
"uniq... | Uses the geNorm algorithm to determine the most stably expressed
genes from amongst ref_targets in your sample.
See Vandesompele et al.'s 2002 Genome Biology paper for information about
the algorithm: http://dx.doi.org/10.1186/gb-2002-3-7-research0034
:param DataFrame sample_frame: A sample data frame... | [
"Uses",
"the",
"geNorm",
"algorithm",
"to",
"determine",
"the",
"most",
"stably",
"expressed",
"genes",
"from",
"amongst",
"ref_targets",
"in",
"your",
"sample",
"."
] | c79b7e784f6d4a76eb4371e69d5ee6f471fe56e1 | https://github.com/tdsmith/eleven/blob/c79b7e784f6d4a76eb4371e69d5ee6f471fe56e1/eleven/eleven.py#L147-L188 |
49,061 | tdsmith/eleven | eleven/eleven.py | calculate_nf | def calculate_nf(sample_frame, ref_targets, ref_sample):
"""Calculates a normalization factor from the geometric mean of the
expression of all ref_targets, normalized to a reference sample.
:param DataFrame sample_frame: A sample data frame.
:param iterable ref_targets: A list or Series of target names... | python | def calculate_nf(sample_frame, ref_targets, ref_sample):
"""Calculates a normalization factor from the geometric mean of the
expression of all ref_targets, normalized to a reference sample.
:param DataFrame sample_frame: A sample data frame.
:param iterable ref_targets: A list or Series of target names... | [
"def",
"calculate_nf",
"(",
"sample_frame",
",",
"ref_targets",
",",
"ref_sample",
")",
":",
"grouped",
"=",
"sample_frame",
".",
"groupby",
"(",
"[",
"'Target'",
",",
"'Sample'",
"]",
")",
"[",
"'Cq'",
"]",
".",
"aggregate",
"(",
"average_cq",
")",
"sampl... | Calculates a normalization factor from the geometric mean of the
expression of all ref_targets, normalized to a reference sample.
:param DataFrame sample_frame: A sample data frame.
:param iterable ref_targets: A list or Series of target names.
:param string ref_sample: The name of the sample to normal... | [
"Calculates",
"a",
"normalization",
"factor",
"from",
"the",
"geometric",
"mean",
"of",
"the",
"expression",
"of",
"all",
"ref_targets",
"normalized",
"to",
"a",
"reference",
"sample",
"."
] | c79b7e784f6d4a76eb4371e69d5ee6f471fe56e1 | https://github.com/tdsmith/eleven/blob/c79b7e784f6d4a76eb4371e69d5ee6f471fe56e1/eleven/eleven.py#L215-L228 |
49,062 | romana/vpc-router | vpcrouter/vpc/__init__.py | get_ec2_meta_data | def get_ec2_meta_data():
"""
Get meta data about ourselves, if we are on an EC2 instance.
In particular, this returns the VPC ID and region of this instance.
If we are not on an EC2 instance it returns an empty dict.
"""
# The timeout is just for the connection attempt, but between retries th... | python | def get_ec2_meta_data():
"""
Get meta data about ourselves, if we are on an EC2 instance.
In particular, this returns the VPC ID and region of this instance.
If we are not on an EC2 instance it returns an empty dict.
"""
# The timeout is just for the connection attempt, but between retries th... | [
"def",
"get_ec2_meta_data",
"(",
")",
":",
"# The timeout is just for the connection attempt, but between retries there",
"# is an exponential back off in seconds. So, too many retries and it can",
"# possibly block for a very long time here. Main contributor to waiting",
"# time here is the number ... | Get meta data about ourselves, if we are on an EC2 instance.
In particular, this returns the VPC ID and region of this instance.
If we are not on an EC2 instance it returns an empty dict. | [
"Get",
"meta",
"data",
"about",
"ourselves",
"if",
"we",
"are",
"on",
"an",
"EC2",
"instance",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/vpc/__init__.py#L34-L55 |
49,063 | romana/vpc-router | vpcrouter/vpc/__init__.py | connect_to_region | def connect_to_region(region_name):
"""
Establish connection to AWS API.
"""
logging.debug("Connecting to AWS region '%s'" % region_name)
con = boto.vpc.connect_to_region(region_name)
if not con:
raise VpcRouteSetError("Could not establish connection to "
... | python | def connect_to_region(region_name):
"""
Establish connection to AWS API.
"""
logging.debug("Connecting to AWS region '%s'" % region_name)
con = boto.vpc.connect_to_region(region_name)
if not con:
raise VpcRouteSetError("Could not establish connection to "
... | [
"def",
"connect_to_region",
"(",
"region_name",
")",
":",
"logging",
".",
"debug",
"(",
"\"Connecting to AWS region '%s'\"",
"%",
"region_name",
")",
"con",
"=",
"boto",
".",
"vpc",
".",
"connect_to_region",
"(",
"region_name",
")",
"if",
"not",
"con",
":",
"r... | Establish connection to AWS API. | [
"Establish",
"connection",
"to",
"AWS",
"API",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/vpc/__init__.py#L58-L68 |
49,064 | romana/vpc-router | vpcrouter/vpc/__init__.py | _make_ip_subnet_lookup | def _make_ip_subnet_lookup(vpc_info):
"""
Updates the vpc-info object with a lookup for IP -> subnet.
"""
# We create a reverse lookup from the instances private IP addresses to the
# subnets they are associated with. This is used later on in order to
# determine whether routes should be set in... | python | def _make_ip_subnet_lookup(vpc_info):
"""
Updates the vpc-info object with a lookup for IP -> subnet.
"""
# We create a reverse lookup from the instances private IP addresses to the
# subnets they are associated with. This is used later on in order to
# determine whether routes should be set in... | [
"def",
"_make_ip_subnet_lookup",
"(",
"vpc_info",
")",
":",
"# We create a reverse lookup from the instances private IP addresses to the",
"# subnets they are associated with. This is used later on in order to",
"# determine whether routes should be set in an RT: Is the RT's subnet",
"# associated... | Updates the vpc-info object with a lookup for IP -> subnet. | [
"Updates",
"the",
"vpc",
"-",
"info",
"object",
"with",
"a",
"lookup",
"for",
"IP",
"-",
">",
"subnet",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/vpc/__init__.py#L71-L91 |
49,065 | romana/vpc-router | vpcrouter/vpc/__init__.py | get_vpc_overview | def get_vpc_overview(con, vpc_id, region_name):
"""
Retrieve information for the specified VPC.
If no VPC ID was specified then just pick the first VPC we find.
Returns a dict with the VPC's zones, subnets, route tables and
instances.
"""
logging.debug("Retrieving information for VPC '%s'... | python | def get_vpc_overview(con, vpc_id, region_name):
"""
Retrieve information for the specified VPC.
If no VPC ID was specified then just pick the first VPC we find.
Returns a dict with the VPC's zones, subnets, route tables and
instances.
"""
logging.debug("Retrieving information for VPC '%s'... | [
"def",
"get_vpc_overview",
"(",
"con",
",",
"vpc_id",
",",
"region_name",
")",
":",
"logging",
".",
"debug",
"(",
"\"Retrieving information for VPC '%s'\"",
"%",
"vpc_id",
")",
"d",
"=",
"{",
"}",
"d",
"[",
"'zones'",
"]",
"=",
"con",
".",
"get_all_zones",
... | Retrieve information for the specified VPC.
If no VPC ID was specified then just pick the first VPC we find.
Returns a dict with the VPC's zones, subnets, route tables and
instances. | [
"Retrieve",
"information",
"for",
"the",
"specified",
"VPC",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/vpc/__init__.py#L94-L165 |
49,066 | romana/vpc-router | vpcrouter/vpc/__init__.py | find_instance_and_eni_by_ip | def find_instance_and_eni_by_ip(vpc_info, ip):
"""
Given a specific IP address, find the EC2 instance and ENI.
We need this information for setting the route.
Returns instance and emi in a tuple.
"""
for instance in vpc_info['instances']:
for eni in instance.interfaces:
fo... | python | def find_instance_and_eni_by_ip(vpc_info, ip):
"""
Given a specific IP address, find the EC2 instance and ENI.
We need this information for setting the route.
Returns instance and emi in a tuple.
"""
for instance in vpc_info['instances']:
for eni in instance.interfaces:
fo... | [
"def",
"find_instance_and_eni_by_ip",
"(",
"vpc_info",
",",
"ip",
")",
":",
"for",
"instance",
"in",
"vpc_info",
"[",
"'instances'",
"]",
":",
"for",
"eni",
"in",
"instance",
".",
"interfaces",
":",
"for",
"pa",
"in",
"eni",
".",
"private_ip_addresses",
":",... | Given a specific IP address, find the EC2 instance and ENI.
We need this information for setting the route.
Returns instance and emi in a tuple. | [
"Given",
"a",
"specific",
"IP",
"address",
"find",
"the",
"EC2",
"instance",
"and",
"ENI",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/vpc/__init__.py#L168-L183 |
49,067 | romana/vpc-router | vpcrouter/vpc/__init__.py | get_instance_private_ip_from_route | def get_instance_private_ip_from_route(instance, route):
"""
Find the private IP and ENI of an instance that's pointed to in a route.
Returns (ipaddr, eni) tuple.
"""
ipaddr = None
for eni in instance.interfaces:
if eni.id == route.interface_id:
ipaddr = eni.private_ip_addr... | python | def get_instance_private_ip_from_route(instance, route):
"""
Find the private IP and ENI of an instance that's pointed to in a route.
Returns (ipaddr, eni) tuple.
"""
ipaddr = None
for eni in instance.interfaces:
if eni.id == route.interface_id:
ipaddr = eni.private_ip_addr... | [
"def",
"get_instance_private_ip_from_route",
"(",
"instance",
",",
"route",
")",
":",
"ipaddr",
"=",
"None",
"for",
"eni",
"in",
"instance",
".",
"interfaces",
":",
"if",
"eni",
".",
"id",
"==",
"route",
".",
"interface_id",
":",
"ipaddr",
"=",
"eni",
".",... | Find the private IP and ENI of an instance that's pointed to in a route.
Returns (ipaddr, eni) tuple. | [
"Find",
"the",
"private",
"IP",
"and",
"ENI",
"of",
"an",
"instance",
"that",
"s",
"pointed",
"to",
"in",
"a",
"route",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/vpc/__init__.py#L186-L198 |
49,068 | romana/vpc-router | vpcrouter/vpc/__init__.py | _choose_different_host | def _choose_different_host(old_ip, ip_list, failed_ips, questionable_ips):
"""
Randomly choose a different host from a list of hosts.
Pick from fully healthy IPs first (neither failed nor questionable).
If we don't have any of those, pick from questionable ones next.
If no suitable hosts can be fo... | python | def _choose_different_host(old_ip, ip_list, failed_ips, questionable_ips):
"""
Randomly choose a different host from a list of hosts.
Pick from fully healthy IPs first (neither failed nor questionable).
If we don't have any of those, pick from questionable ones next.
If no suitable hosts can be fo... | [
"def",
"_choose_different_host",
"(",
"old_ip",
",",
"ip_list",
",",
"failed_ips",
",",
"questionable_ips",
")",
":",
"if",
"not",
"ip_list",
":",
"# We don't have any hosts to choose from.",
"return",
"None",
"ip_set",
"=",
"set",
"(",
"ip_list",
")",
"failed_set",... | Randomly choose a different host from a list of hosts.
Pick from fully healthy IPs first (neither failed nor questionable).
If we don't have any of those, pick from questionable ones next.
If no suitable hosts can be found in the list (if it's empty or all hosts
are in the failed_ips list) it will ret... | [
"Randomly",
"choose",
"a",
"different",
"host",
"from",
"a",
"list",
"of",
"hosts",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/vpc/__init__.py#L201-L247 |
49,069 | romana/vpc-router | vpcrouter/vpc/__init__.py | _rt_state_update | def _rt_state_update(route_table_id, dcidr, router_ip="(none)",
instance_id="(none)", eni_id="(none)",
old_router_ip="(none)", msg="(none)"):
"""
Store a message about a VPC route in the current state.
"""
buf = "inst: %s, eni: %s, r_ip: %-15s, o_r_ip: %-15s, m... | python | def _rt_state_update(route_table_id, dcidr, router_ip="(none)",
instance_id="(none)", eni_id="(none)",
old_router_ip="(none)", msg="(none)"):
"""
Store a message about a VPC route in the current state.
"""
buf = "inst: %s, eni: %s, r_ip: %-15s, o_r_ip: %-15s, m... | [
"def",
"_rt_state_update",
"(",
"route_table_id",
",",
"dcidr",
",",
"router_ip",
"=",
"\"(none)\"",
",",
"instance_id",
"=",
"\"(none)\"",
",",
"eni_id",
"=",
"\"(none)\"",
",",
"old_router_ip",
"=",
"\"(none)\"",
",",
"msg",
"=",
"\"(none)\"",
")",
":",
"buf... | Store a message about a VPC route in the current state. | [
"Store",
"a",
"message",
"about",
"a",
"VPC",
"route",
"in",
"the",
"current",
"state",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/vpc/__init__.py#L250-L260 |
49,070 | romana/vpc-router | vpcrouter/vpc/__init__.py | _update_route | def _update_route(dcidr, router_ip, old_router_ip,
vpc_info, con, route_table_id, update_reason):
"""
Update an existing route entry in the route table.
"""
instance = eni = None
try:
instance, eni = find_instance_and_eni_by_ip(vpc_info, router_ip)
logging.info("-... | python | def _update_route(dcidr, router_ip, old_router_ip,
vpc_info, con, route_table_id, update_reason):
"""
Update an existing route entry in the route table.
"""
instance = eni = None
try:
instance, eni = find_instance_and_eni_by_ip(vpc_info, router_ip)
logging.info("-... | [
"def",
"_update_route",
"(",
"dcidr",
",",
"router_ip",
",",
"old_router_ip",
",",
"vpc_info",
",",
"con",
",",
"route_table_id",
",",
"update_reason",
")",
":",
"instance",
"=",
"eni",
"=",
"None",
"try",
":",
"instance",
",",
"eni",
"=",
"find_instance_and... | Update an existing route entry in the route table. | [
"Update",
"an",
"existing",
"route",
"entry",
"in",
"the",
"route",
"table",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/vpc/__init__.py#L263-L297 |
49,071 | romana/vpc-router | vpcrouter/vpc/__init__.py | _add_new_route | def _add_new_route(dcidr, router_ip, vpc_info, con, route_table_id):
"""
Add a new route to the route table.
"""
try:
instance, eni = find_instance_and_eni_by_ip(vpc_info, router_ip)
# Only set the route if the RT is associated with any of the subnets
# used for the cluster.
... | python | def _add_new_route(dcidr, router_ip, vpc_info, con, route_table_id):
"""
Add a new route to the route table.
"""
try:
instance, eni = find_instance_and_eni_by_ip(vpc_info, router_ip)
# Only set the route if the RT is associated with any of the subnets
# used for the cluster.
... | [
"def",
"_add_new_route",
"(",
"dcidr",
",",
"router_ip",
",",
"vpc_info",
",",
"con",
",",
"route_table_id",
")",
":",
"try",
":",
"instance",
",",
"eni",
"=",
"find_instance_and_eni_by_ip",
"(",
"vpc_info",
",",
"router_ip",
")",
"# Only set the route if the RT i... | Add a new route to the route table. | [
"Add",
"a",
"new",
"route",
"to",
"the",
"route",
"table",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/vpc/__init__.py#L300-L340 |
49,072 | romana/vpc-router | vpcrouter/vpc/__init__.py | _get_real_instance_if_mismatch | def _get_real_instance_if_mismatch(vpc_info, ipaddr, instance, eni):
"""
Return the real instance for the given IP address, if that instance is
different than the passed in instance or has a different eni.
If the ipaddr belongs to the same instance and eni that was passed in then
this returns None.... | python | def _get_real_instance_if_mismatch(vpc_info, ipaddr, instance, eni):
"""
Return the real instance for the given IP address, if that instance is
different than the passed in instance or has a different eni.
If the ipaddr belongs to the same instance and eni that was passed in then
this returns None.... | [
"def",
"_get_real_instance_if_mismatch",
"(",
"vpc_info",
",",
"ipaddr",
",",
"instance",
",",
"eni",
")",
":",
"# Careful! A route may be a black-hole route, which still has instance and",
"# ENI information for an instance that doesn't exist anymore. If a host was",
"# terminated and a... | Return the real instance for the given IP address, if that instance is
different than the passed in instance or has a different eni.
If the ipaddr belongs to the same instance and eni that was passed in then
this returns None. | [
"Return",
"the",
"real",
"instance",
"for",
"the",
"given",
"IP",
"address",
"if",
"that",
"instance",
"is",
"different",
"than",
"the",
"passed",
"in",
"instance",
"or",
"has",
"a",
"different",
"eni",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/vpc/__init__.py#L343-L364 |
49,073 | romana/vpc-router | vpcrouter/vpc/__init__.py | _get_host_for_route | def _get_host_for_route(vpc_info, route, route_table, dcidr):
"""
Given a specific route, return information about the instance to which it
points.
Returns 3-tuple: instance-id, ipaddr, eni-id
Need to take care of scenarios where the instance isn't set anymore in the
route (the instance may ha... | python | def _get_host_for_route(vpc_info, route, route_table, dcidr):
"""
Given a specific route, return information about the instance to which it
points.
Returns 3-tuple: instance-id, ipaddr, eni-id
Need to take care of scenarios where the instance isn't set anymore in the
route (the instance may ha... | [
"def",
"_get_host_for_route",
"(",
"vpc_info",
",",
"route",
",",
"route_table",
",",
"dcidr",
")",
":",
"class",
"_CouldNotIdentifyHost",
"(",
"Exception",
")",
":",
"# If we can't find both the instance as well as an eni for the route,",
"# we will raise this exception. In th... | Given a specific route, return information about the instance to which it
points.
Returns 3-tuple: instance-id, ipaddr, eni-id
Need to take care of scenarios where the instance isn't set anymore in the
route (the instance may have disappeared). | [
"Given",
"a",
"specific",
"route",
"return",
"information",
"about",
"the",
"instance",
"to",
"which",
"it",
"points",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/vpc/__init__.py#L367-L433 |
49,074 | romana/vpc-router | vpcrouter/vpc/__init__.py | _is_cidr_in_ignore_routes | def _is_cidr_in_ignore_routes(cidr):
"""
Checks the CIDR to see if it falls into any CIDRs specified via the
ignore_routes parameter.
This is used mostly to protect special routes to specific instances (for
example proxies, etc.), so that the vpc-router does not clean those up.
Only used to go... | python | def _is_cidr_in_ignore_routes(cidr):
"""
Checks the CIDR to see if it falls into any CIDRs specified via the
ignore_routes parameter.
This is used mostly to protect special routes to specific instances (for
example proxies, etc.), so that the vpc-router does not clean those up.
Only used to go... | [
"def",
"_is_cidr_in_ignore_routes",
"(",
"cidr",
")",
":",
"for",
"ignore_cidr",
"in",
"CURRENT_STATE",
".",
"ignore_routes",
":",
"if",
"is_cidr_in_cidr",
"(",
"cidr",
",",
"ignore_cidr",
")",
":",
"return",
"True",
"return",
"False"
] | Checks the CIDR to see if it falls into any CIDRs specified via the
ignore_routes parameter.
This is used mostly to protect special routes to specific instances (for
example proxies, etc.), so that the vpc-router does not clean those up.
Only used to govern cleanup of routes, is not consulted when cre... | [
"Checks",
"the",
"CIDR",
"to",
"see",
"if",
"it",
"falls",
"into",
"any",
"CIDRs",
"specified",
"via",
"the",
"ignore_routes",
"parameter",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/vpc/__init__.py#L436-L451 |
49,075 | romana/vpc-router | vpcrouter/vpc/__init__.py | _add_missing_routes | def _add_missing_routes(route_spec, failed_ips, questionable_ips,
chosen_routers, vpc_info, con, routes_in_rts):
"""
Iterate over route spec and add all the routes we haven't set yet.
This relies on being told what routes we HAVE already. This is passed
in via the routes_in_rts ... | python | def _add_missing_routes(route_spec, failed_ips, questionable_ips,
chosen_routers, vpc_info, con, routes_in_rts):
"""
Iterate over route spec and add all the routes we haven't set yet.
This relies on being told what routes we HAVE already. This is passed
in via the routes_in_rts ... | [
"def",
"_add_missing_routes",
"(",
"route_spec",
",",
"failed_ips",
",",
"questionable_ips",
",",
"chosen_routers",
",",
"vpc_info",
",",
"con",
",",
"routes_in_rts",
")",
":",
"for",
"dcidr",
",",
"hosts",
"in",
"route_spec",
".",
"items",
"(",
")",
":",
"n... | Iterate over route spec and add all the routes we haven't set yet.
This relies on being told what routes we HAVE already. This is passed
in via the routes_in_rts dict.
Furthermore, some routes may be set in some RTs, but not in others. In that
case, we may already have seen which router was chosen for... | [
"Iterate",
"over",
"route",
"spec",
"and",
"add",
"all",
"the",
"routes",
"we",
"haven",
"t",
"set",
"yet",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/vpc/__init__.py#L617-L648 |
49,076 | romana/vpc-router | vpcrouter/vpc/__init__.py | process_route_spec_config | def process_route_spec_config(con, vpc_info, route_spec,
failed_ips, questionable_ips):
"""
Look through the route spec and update routes accordingly.
Idea: Make sure we have a route for each CIDR.
If we have a route to any of the IP addresses for a given CIDR then we are... | python | def process_route_spec_config(con, vpc_info, route_spec,
failed_ips, questionable_ips):
"""
Look through the route spec and update routes accordingly.
Idea: Make sure we have a route for each CIDR.
If we have a route to any of the IP addresses for a given CIDR then we are... | [
"def",
"process_route_spec_config",
"(",
"con",
",",
"vpc_info",
",",
"route_spec",
",",
"failed_ips",
",",
"questionable_ips",
")",
":",
"if",
"CURRENT_STATE",
".",
"_stop_all",
":",
"logging",
".",
"debug",
"(",
"\"Routespec processing. Stop requested, abort operation... | Look through the route spec and update routes accordingly.
Idea: Make sure we have a route for each CIDR.
If we have a route to any of the IP addresses for a given CIDR then we are
good. Otherwise, pick one (usually the first) IP and create a route to that
IP.
If a route points at a failed or que... | [
"Look",
"through",
"the",
"route",
"spec",
"and",
"update",
"routes",
"accordingly",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/vpc/__init__.py#L651-L697 |
49,077 | romana/vpc-router | vpcrouter/vpc/__init__.py | handle_spec | def handle_spec(region_name, vpc_id, route_spec, failed_ips, questionable_ips):
"""
Connect to region and update routes according to route spec.
"""
if CURRENT_STATE._stop_all:
logging.debug("handle_spec: Stop requested, abort operation")
return
if not route_spec:
logging.d... | python | def handle_spec(region_name, vpc_id, route_spec, failed_ips, questionable_ips):
"""
Connect to region and update routes according to route spec.
"""
if CURRENT_STATE._stop_all:
logging.debug("handle_spec: Stop requested, abort operation")
return
if not route_spec:
logging.d... | [
"def",
"handle_spec",
"(",
"region_name",
",",
"vpc_id",
",",
"route_spec",
",",
"failed_ips",
",",
"questionable_ips",
")",
":",
"if",
"CURRENT_STATE",
".",
"_stop_all",
":",
"logging",
".",
"debug",
"(",
"\"handle_spec: Stop requested, abort operation\"",
")",
"re... | Connect to region and update routes according to route spec. | [
"Connect",
"to",
"region",
"and",
"update",
"routes",
"according",
"to",
"route",
"spec",
"."
] | d696c2e023f1111ceb61f9c6fbabfafed8e14040 | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/vpc/__init__.py#L730-L759 |
49,078 | smartfile/client-python | smartfile/sync.py | LocalFile.signature | def signature(self, block_size=None):
"Calculates signature for local file."
kwargs = {}
if block_size:
kwargs['block_size'] = block_size
return librsync.signature(open(self.path, 'rb'), **kwargs) | python | def signature(self, block_size=None):
"Calculates signature for local file."
kwargs = {}
if block_size:
kwargs['block_size'] = block_size
return librsync.signature(open(self.path, 'rb'), **kwargs) | [
"def",
"signature",
"(",
"self",
",",
"block_size",
"=",
"None",
")",
":",
"kwargs",
"=",
"{",
"}",
"if",
"block_size",
":",
"kwargs",
"[",
"'block_size'",
"]",
"=",
"block_size",
"return",
"librsync",
".",
"signature",
"(",
"open",
"(",
"self",
".",
"... | Calculates signature for local file. | [
"Calculates",
"signature",
"for",
"local",
"file",
"."
] | f9ccc40a2870df447c65b53dc0747e37cab62d63 | https://github.com/smartfile/client-python/blob/f9ccc40a2870df447c65b53dc0747e37cab62d63/smartfile/sync.py#L25-L30 |
49,079 | smartfile/client-python | smartfile/sync.py | LocalFile.patch | def patch(self, delta):
"Applies remote delta to local file."
# Create a temp file in which to store our synced copy. We will handle
# deleting it manually, since we may move it instead.
with (tempfile.NamedTemporaryFile(prefix='.sync',
suffix=os.path.basename(self.path),
... | python | def patch(self, delta):
"Applies remote delta to local file."
# Create a temp file in which to store our synced copy. We will handle
# deleting it manually, since we may move it instead.
with (tempfile.NamedTemporaryFile(prefix='.sync',
suffix=os.path.basename(self.path),
... | [
"def",
"patch",
"(",
"self",
",",
"delta",
")",
":",
"# Create a temp file in which to store our synced copy. We will handle",
"# deleting it manually, since we may move it instead.",
"with",
"(",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"prefix",
"=",
"'.sync'",
",",
"suf... | Applies remote delta to local file. | [
"Applies",
"remote",
"delta",
"to",
"local",
"file",
"."
] | f9ccc40a2870df447c65b53dc0747e37cab62d63 | https://github.com/smartfile/client-python/blob/f9ccc40a2870df447c65b53dc0747e37cab62d63/smartfile/sync.py#L36-L55 |
49,080 | smartfile/client-python | smartfile/sync.py | RemoteFile.signature | def signature(self, block_size=None):
"Requests a signature for remote file via API."
kwargs = {}
if block_size:
kwargs['block_size'] = block_size
return self.api.get('path/sync/signature', self.path, **kwargs) | python | def signature(self, block_size=None):
"Requests a signature for remote file via API."
kwargs = {}
if block_size:
kwargs['block_size'] = block_size
return self.api.get('path/sync/signature', self.path, **kwargs) | [
"def",
"signature",
"(",
"self",
",",
"block_size",
"=",
"None",
")",
":",
"kwargs",
"=",
"{",
"}",
"if",
"block_size",
":",
"kwargs",
"[",
"'block_size'",
"]",
"=",
"block_size",
"return",
"self",
".",
"api",
".",
"get",
"(",
"'path/sync/signature'",
",... | Requests a signature for remote file via API. | [
"Requests",
"a",
"signature",
"for",
"remote",
"file",
"via",
"API",
"."
] | f9ccc40a2870df447c65b53dc0747e37cab62d63 | https://github.com/smartfile/client-python/blob/f9ccc40a2870df447c65b53dc0747e37cab62d63/smartfile/sync.py#L67-L72 |
49,081 | smartfile/client-python | smartfile/sync.py | RemoteFile.delta | def delta(self, signature):
"Generates delta for remote file via API using local file's signature."
return self.api.post('path/sync/delta', self.path, signature=signature) | python | def delta(self, signature):
"Generates delta for remote file via API using local file's signature."
return self.api.post('path/sync/delta', self.path, signature=signature) | [
"def",
"delta",
"(",
"self",
",",
"signature",
")",
":",
"return",
"self",
".",
"api",
".",
"post",
"(",
"'path/sync/delta'",
",",
"self",
".",
"path",
",",
"signature",
"=",
"signature",
")"
] | Generates delta for remote file via API using local file's signature. | [
"Generates",
"delta",
"for",
"remote",
"file",
"via",
"API",
"using",
"local",
"file",
"s",
"signature",
"."
] | f9ccc40a2870df447c65b53dc0747e37cab62d63 | https://github.com/smartfile/client-python/blob/f9ccc40a2870df447c65b53dc0747e37cab62d63/smartfile/sync.py#L74-L76 |
49,082 | smartfile/client-python | smartfile/sync.py | RemoteFile.patch | def patch(self, delta):
"Applies delta for local file to remote file via API."
return self.api.post('path/sync/patch', self.path, delta=delta) | python | def patch(self, delta):
"Applies delta for local file to remote file via API."
return self.api.post('path/sync/patch', self.path, delta=delta) | [
"def",
"patch",
"(",
"self",
",",
"delta",
")",
":",
"return",
"self",
".",
"api",
".",
"post",
"(",
"'path/sync/patch'",
",",
"self",
".",
"path",
",",
"delta",
"=",
"delta",
")"
] | Applies delta for local file to remote file via API. | [
"Applies",
"delta",
"for",
"local",
"file",
"to",
"remote",
"file",
"via",
"API",
"."
] | f9ccc40a2870df447c65b53dc0747e37cab62d63 | https://github.com/smartfile/client-python/blob/f9ccc40a2870df447c65b53dc0747e37cab62d63/smartfile/sync.py#L78-L80 |
49,083 | smartfile/client-python | smartfile/sync.py | SyncClient.upload | def upload(self, local, remote):
"""
Performs synchronization from a local file to a remote file. The local
path is the source and remote path is the destination.
"""
self.sync(LocalFile(local), RemoteFile(remote, self.api)) | python | def upload(self, local, remote):
"""
Performs synchronization from a local file to a remote file. The local
path is the source and remote path is the destination.
"""
self.sync(LocalFile(local), RemoteFile(remote, self.api)) | [
"def",
"upload",
"(",
"self",
",",
"local",
",",
"remote",
")",
":",
"self",
".",
"sync",
"(",
"LocalFile",
"(",
"local",
")",
",",
"RemoteFile",
"(",
"remote",
",",
"self",
".",
"api",
")",
")"
] | Performs synchronization from a local file to a remote file. The local
path is the source and remote path is the destination. | [
"Performs",
"synchronization",
"from",
"a",
"local",
"file",
"to",
"a",
"remote",
"file",
".",
"The",
"local",
"path",
"is",
"the",
"source",
"and",
"remote",
"path",
"is",
"the",
"destination",
"."
] | f9ccc40a2870df447c65b53dc0747e37cab62d63 | https://github.com/smartfile/client-python/blob/f9ccc40a2870df447c65b53dc0747e37cab62d63/smartfile/sync.py#L109-L114 |
49,084 | smartfile/client-python | smartfile/sync.py | SyncClient.download | def download(self, local, remote):
"""
Performs synchronization from a remote file to a local file. The
remote path is the source and the local path is the destination.
"""
self.sync(RemoteFile(remote, self.api), LocalFile(local)) | python | def download(self, local, remote):
"""
Performs synchronization from a remote file to a local file. The
remote path is the source and the local path is the destination.
"""
self.sync(RemoteFile(remote, self.api), LocalFile(local)) | [
"def",
"download",
"(",
"self",
",",
"local",
",",
"remote",
")",
":",
"self",
".",
"sync",
"(",
"RemoteFile",
"(",
"remote",
",",
"self",
".",
"api",
")",
",",
"LocalFile",
"(",
"local",
")",
")"
] | Performs synchronization from a remote file to a local file. The
remote path is the source and the local path is the destination. | [
"Performs",
"synchronization",
"from",
"a",
"remote",
"file",
"to",
"a",
"local",
"file",
".",
"The",
"remote",
"path",
"is",
"the",
"source",
"and",
"the",
"local",
"path",
"is",
"the",
"destination",
"."
] | f9ccc40a2870df447c65b53dc0747e37cab62d63 | https://github.com/smartfile/client-python/blob/f9ccc40a2870df447c65b53dc0747e37cab62d63/smartfile/sync.py#L116-L121 |
49,085 | praekelt/django-export | export/fields.py | DateField.to_python | def to_python(self, value):
"""
Validates that the input can be converted to a date. Returns a
Python datetime.date object.
"""
if value in validators.EMPTY_VALUES:
return None
if isinstance(value, datetime.datetime):
return value.date()
if... | python | def to_python(self, value):
"""
Validates that the input can be converted to a date. Returns a
Python datetime.date object.
"""
if value in validators.EMPTY_VALUES:
return None
if isinstance(value, datetime.datetime):
return value.date()
if... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"in",
"validators",
".",
"EMPTY_VALUES",
":",
"return",
"None",
"if",
"isinstance",
"(",
"value",
",",
"datetime",
".",
"datetime",
")",
":",
"return",
"value",
".",
"date",
"(",
"... | Validates that the input can be converted to a date. Returns a
Python datetime.date object. | [
"Validates",
"that",
"the",
"input",
"can",
"be",
"converted",
"to",
"a",
"date",
".",
"Returns",
"a",
"Python",
"datetime",
".",
"date",
"object",
"."
] | e2facdd53c9cbfa84d1409c7f0efe5d638812946 | https://github.com/praekelt/django-export/blob/e2facdd53c9cbfa84d1409c7f0efe5d638812946/export/fields.py#L143-L186 |
49,086 | praekelt/django-export | export/fields.py | DateTimeField.to_python | def to_python(self, value):
"""
Validates that the input can be converted to a datetime. Returns a
Python datetime.datetime object.
"""
if value in validators.EMPTY_VALUES:
return None
if isinstance(value, datetime.datetime):
return value
i... | python | def to_python(self, value):
"""
Validates that the input can be converted to a datetime. Returns a
Python datetime.datetime object.
"""
if value in validators.EMPTY_VALUES:
return None
if isinstance(value, datetime.datetime):
return value
i... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"in",
"validators",
".",
"EMPTY_VALUES",
":",
"return",
"None",
"if",
"isinstance",
"(",
"value",
",",
"datetime",
".",
"datetime",
")",
":",
"return",
"value",
"if",
"isinstance",
"... | Validates that the input can be converted to a datetime. Returns a
Python datetime.datetime object. | [
"Validates",
"that",
"the",
"input",
"can",
"be",
"converted",
"to",
"a",
"datetime",
".",
"Returns",
"a",
"Python",
"datetime",
".",
"datetime",
"object",
"."
] | e2facdd53c9cbfa84d1409c7f0efe5d638812946 | https://github.com/praekelt/django-export/blob/e2facdd53c9cbfa84d1409c7f0efe5d638812946/export/fields.py#L209-L251 |
49,087 | praekelt/django-export | export/fields.py | TimeField.to_python | def to_python(self, value):
"""
Validates that the input can be converted to a time. Returns a
Python datetime.time object.
"""
if value in validators.EMPTY_VALUES:
return None
if isinstance(value, datetime.datetime):
return value.time()
if... | python | def to_python(self, value):
"""
Validates that the input can be converted to a time. Returns a
Python datetime.time object.
"""
if value in validators.EMPTY_VALUES:
return None
if isinstance(value, datetime.datetime):
return value.time()
if... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"in",
"validators",
".",
"EMPTY_VALUES",
":",
"return",
"None",
"if",
"isinstance",
"(",
"value",
",",
"datetime",
".",
"datetime",
")",
":",
"return",
"value",
".",
"time",
"(",
"... | Validates that the input can be converted to a time. Returns a
Python datetime.time object. | [
"Validates",
"that",
"the",
"input",
"can",
"be",
"converted",
"to",
"a",
"time",
".",
"Returns",
"a",
"Python",
"datetime",
".",
"time",
"object",
"."
] | e2facdd53c9cbfa84d1409c7f0efe5d638812946 | https://github.com/praekelt/django-export/blob/e2facdd53c9cbfa84d1409c7f0efe5d638812946/export/fields.py#L506-L556 |
49,088 | pudo/googlesheets | googlesheets/connection.py | Connection.docs_client | def docs_client(self):
""" A DocsClient singleton, used to look up spreadsheets
by name. """
if not hasattr(self, '_docs_client'):
client = DocsClient()
client.ClientLogin(self.google_user, self.google_password,
SOURCE_NAME)
self... | python | def docs_client(self):
""" A DocsClient singleton, used to look up spreadsheets
by name. """
if not hasattr(self, '_docs_client'):
client = DocsClient()
client.ClientLogin(self.google_user, self.google_password,
SOURCE_NAME)
self... | [
"def",
"docs_client",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_docs_client'",
")",
":",
"client",
"=",
"DocsClient",
"(",
")",
"client",
".",
"ClientLogin",
"(",
"self",
".",
"google_user",
",",
"self",
".",
"google_password",
... | A DocsClient singleton, used to look up spreadsheets
by name. | [
"A",
"DocsClient",
"singleton",
"used",
"to",
"look",
"up",
"spreadsheets",
"by",
"name",
"."
] | c38725d79bfe048c0519a674019ba313dfc5bfb0 | https://github.com/pudo/googlesheets/blob/c38725d79bfe048c0519a674019ba313dfc5bfb0/googlesheets/connection.py#L29-L37 |
49,089 | pudo/googlesheets | googlesheets/connection.py | Connection.sheets_service | def sheets_service(self):
""" A SpreadsheetsService singleton, used to perform
operations on the actual spreadsheet. """
if not hasattr(self, '_sheets_service'):
service = SpreadsheetsService()
service.email = self.google_user
service.password = self.google_pa... | python | def sheets_service(self):
""" A SpreadsheetsService singleton, used to perform
operations on the actual spreadsheet. """
if not hasattr(self, '_sheets_service'):
service = SpreadsheetsService()
service.email = self.google_user
service.password = self.google_pa... | [
"def",
"sheets_service",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_sheets_service'",
")",
":",
"service",
"=",
"SpreadsheetsService",
"(",
")",
"service",
".",
"email",
"=",
"self",
".",
"google_user",
"service",
".",
"password",
... | A SpreadsheetsService singleton, used to perform
operations on the actual spreadsheet. | [
"A",
"SpreadsheetsService",
"singleton",
"used",
"to",
"perform",
"operations",
"on",
"the",
"actual",
"spreadsheet",
"."
] | c38725d79bfe048c0519a674019ba313dfc5bfb0 | https://github.com/pudo/googlesheets/blob/c38725d79bfe048c0519a674019ba313dfc5bfb0/googlesheets/connection.py#L40-L50 |
49,090 | inveniosoftware/invenio-pidstore | invenio_pidstore/fetchers.py | recid_fetcher | def recid_fetcher(record_uuid, data):
"""Fetch a record's identifiers.
:param record_uuid: The record UUID.
:param data: The record metadata.
:returns: A :data:`invenio_pidstore.fetchers.FetchedPID` instance.
"""
pid_field = current_app.config['PIDSTORE_RECID_FIELD']
return FetchedPID(
... | python | def recid_fetcher(record_uuid, data):
"""Fetch a record's identifiers.
:param record_uuid: The record UUID.
:param data: The record metadata.
:returns: A :data:`invenio_pidstore.fetchers.FetchedPID` instance.
"""
pid_field = current_app.config['PIDSTORE_RECID_FIELD']
return FetchedPID(
... | [
"def",
"recid_fetcher",
"(",
"record_uuid",
",",
"data",
")",
":",
"pid_field",
"=",
"current_app",
".",
"config",
"[",
"'PIDSTORE_RECID_FIELD'",
"]",
"return",
"FetchedPID",
"(",
"provider",
"=",
"RecordIdProvider",
",",
"pid_type",
"=",
"RecordIdProvider",
".",
... | Fetch a record's identifiers.
:param record_uuid: The record UUID.
:param data: The record metadata.
:returns: A :data:`invenio_pidstore.fetchers.FetchedPID` instance. | [
"Fetch",
"a",
"record",
"s",
"identifiers",
"."
] | 8bf35f4e62d5dcaf1a2cfe5803245ba5220a9b78 | https://github.com/inveniosoftware/invenio-pidstore/blob/8bf35f4e62d5dcaf1a2cfe5803245ba5220a9b78/invenio_pidstore/fetchers.py#L40-L52 |
49,091 | pudo/googlesheets | googlesheets/sheet.py | Sheet._add_column | def _add_column(self, label, field):
""" Add a new column to the table. It will have the header
text ``label``, but for data inserts and queries, the
``field`` name must be used. If necessary, this will expand
the size of the sheet itself to allow for the new column. """
# Don't ... | python | def _add_column(self, label, field):
""" Add a new column to the table. It will have the header
text ``label``, but for data inserts and queries, the
``field`` name must be used. If necessary, this will expand
the size of the sheet itself to allow for the new column. """
# Don't ... | [
"def",
"_add_column",
"(",
"self",
",",
"label",
",",
"field",
")",
":",
"# Don't call this directly.",
"assert",
"self",
".",
"headers",
"is",
"not",
"None",
"cols",
"=",
"0",
"if",
"len",
"(",
"self",
".",
"_headers",
")",
">",
"0",
":",
"cols",
"=",... | Add a new column to the table. It will have the header
text ``label``, but for data inserts and queries, the
``field`` name must be used. If necessary, this will expand
the size of the sheet itself to allow for the new column. | [
"Add",
"a",
"new",
"column",
"to",
"the",
"table",
".",
"It",
"will",
"have",
"the",
"header",
"text",
"label",
"but",
"for",
"data",
"inserts",
"and",
"queries",
"the",
"field",
"name",
"must",
"be",
"used",
".",
"If",
"necessary",
"this",
"will",
"ex... | c38725d79bfe048c0519a674019ba313dfc5bfb0 | https://github.com/pudo/googlesheets/blob/c38725d79bfe048c0519a674019ba313dfc5bfb0/googlesheets/sheet.py#L24-L41 |
49,092 | pudo/googlesheets | googlesheets/sheet.py | Sheet.headers | def headers(self):
""" Return the name of all headers currently defined for the
table. """
if self._headers is None:
query = CellQuery()
query.max_row = '1'
feed = self._service.GetCellsFeed(self._ss.id, self.id,
q... | python | def headers(self):
""" Return the name of all headers currently defined for the
table. """
if self._headers is None:
query = CellQuery()
query.max_row = '1'
feed = self._service.GetCellsFeed(self._ss.id, self.id,
q... | [
"def",
"headers",
"(",
"self",
")",
":",
"if",
"self",
".",
"_headers",
"is",
"None",
":",
"query",
"=",
"CellQuery",
"(",
")",
"query",
".",
"max_row",
"=",
"'1'",
"feed",
"=",
"self",
".",
"_service",
".",
"GetCellsFeed",
"(",
"self",
".",
"_ss",
... | Return the name of all headers currently defined for the
table. | [
"Return",
"the",
"name",
"of",
"all",
"headers",
"currently",
"defined",
"for",
"the",
"table",
"."
] | c38725d79bfe048c0519a674019ba313dfc5bfb0 | https://github.com/pudo/googlesheets/blob/c38725d79bfe048c0519a674019ba313dfc5bfb0/googlesheets/sheet.py#L61-L70 |
49,093 | pudo/googlesheets | googlesheets/sheet.py | Sheet.insert | def insert(self, row):
""" Insert a new row. The row will be added to the end of the
spreadsheet. Before inserting, the field names in the given
row will be normalized and values with empty field names
removed. """
data = self._convert_value(row)
self._service.InsertRow... | python | def insert(self, row):
""" Insert a new row. The row will be added to the end of the
spreadsheet. Before inserting, the field names in the given
row will be normalized and values with empty field names
removed. """
data = self._convert_value(row)
self._service.InsertRow... | [
"def",
"insert",
"(",
"self",
",",
"row",
")",
":",
"data",
"=",
"self",
".",
"_convert_value",
"(",
"row",
")",
"self",
".",
"_service",
".",
"InsertRow",
"(",
"data",
",",
"self",
".",
"_ss",
".",
"id",
",",
"self",
".",
"id",
")"
] | Insert a new row. The row will be added to the end of the
spreadsheet. Before inserting, the field names in the given
row will be normalized and values with empty field names
removed. | [
"Insert",
"a",
"new",
"row",
".",
"The",
"row",
"will",
"be",
"added",
"to",
"the",
"end",
"of",
"the",
"spreadsheet",
".",
"Before",
"inserting",
"the",
"field",
"names",
"in",
"the",
"given",
"row",
"will",
"be",
"normalized",
"and",
"values",
"with",
... | c38725d79bfe048c0519a674019ba313dfc5bfb0 | https://github.com/pudo/googlesheets/blob/c38725d79bfe048c0519a674019ba313dfc5bfb0/googlesheets/sheet.py#L75-L81 |
49,094 | pudo/googlesheets | googlesheets/sheet.py | Sheet.remove | def remove(self, _query=None, **kwargs):
""" Remove all rows matching the current query. If no query
is given, this will truncate the entire table. """
for entry in self._find_entries(_query=_query, **kwargs):
self._service.DeleteRow(entry) | python | def remove(self, _query=None, **kwargs):
""" Remove all rows matching the current query. If no query
is given, this will truncate the entire table. """
for entry in self._find_entries(_query=_query, **kwargs):
self._service.DeleteRow(entry) | [
"def",
"remove",
"(",
"self",
",",
"_query",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"entry",
"in",
"self",
".",
"_find_entries",
"(",
"_query",
"=",
"_query",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_service",
".",
"DeleteR... | Remove all rows matching the current query. If no query
is given, this will truncate the entire table. | [
"Remove",
"all",
"rows",
"matching",
"the",
"current",
"query",
".",
"If",
"no",
"query",
"is",
"given",
"this",
"will",
"truncate",
"the",
"entire",
"table",
"."
] | c38725d79bfe048c0519a674019ba313dfc5bfb0 | https://github.com/pudo/googlesheets/blob/c38725d79bfe048c0519a674019ba313dfc5bfb0/googlesheets/sheet.py#L99-L103 |
49,095 | pudo/googlesheets | googlesheets/util.py | normalize_header | def normalize_header(name, existing=[]):
""" Try to emulate the way in which Google does normalization
on the column names to transform them into headers. """
name = re.sub('\W+', '', name, flags=re.UNICODE).lower()
# TODO handle multiple columns with the same name.
return name | python | def normalize_header(name, existing=[]):
""" Try to emulate the way in which Google does normalization
on the column names to transform them into headers. """
name = re.sub('\W+', '', name, flags=re.UNICODE).lower()
# TODO handle multiple columns with the same name.
return name | [
"def",
"normalize_header",
"(",
"name",
",",
"existing",
"=",
"[",
"]",
")",
":",
"name",
"=",
"re",
".",
"sub",
"(",
"'\\W+'",
",",
"''",
",",
"name",
",",
"flags",
"=",
"re",
".",
"UNICODE",
")",
".",
"lower",
"(",
")",
"# TODO handle multiple colu... | Try to emulate the way in which Google does normalization
on the column names to transform them into headers. | [
"Try",
"to",
"emulate",
"the",
"way",
"in",
"which",
"Google",
"does",
"normalization",
"on",
"the",
"column",
"names",
"to",
"transform",
"them",
"into",
"headers",
"."
] | c38725d79bfe048c0519a674019ba313dfc5bfb0 | https://github.com/pudo/googlesheets/blob/c38725d79bfe048c0519a674019ba313dfc5bfb0/googlesheets/util.py#L6-L11 |
49,096 | alorence/pysvg-py3 | pysvg/core.py | BaseElement.getAllElementsOfHirarchy | def getAllElementsOfHirarchy(self):
""" returns ALL elements of the complete hirarchy as a flat list
"""
allElements=[]
for element in self.getAllElements():
allElements.append(element)
if isinstance(element, BaseElement):
allElements.extend(elemen... | python | def getAllElementsOfHirarchy(self):
""" returns ALL elements of the complete hirarchy as a flat list
"""
allElements=[]
for element in self.getAllElements():
allElements.append(element)
if isinstance(element, BaseElement):
allElements.extend(elemen... | [
"def",
"getAllElementsOfHirarchy",
"(",
"self",
")",
":",
"allElements",
"=",
"[",
"]",
"for",
"element",
"in",
"self",
".",
"getAllElements",
"(",
")",
":",
"allElements",
".",
"append",
"(",
"element",
")",
"if",
"isinstance",
"(",
"element",
",",
"BaseE... | returns ALL elements of the complete hirarchy as a flat list | [
"returns",
"ALL",
"elements",
"of",
"the",
"complete",
"hirarchy",
"as",
"a",
"flat",
"list"
] | ce217a4da3ada44a71d3e2f391d37c67d95c724e | https://github.com/alorence/pysvg-py3/blob/ce217a4da3ada44a71d3e2f391d37c67d95c724e/pysvg/core.py#L42-L50 |
49,097 | alorence/pysvg-py3 | pysvg/core.py | BaseElement.getElementByID | def getElementByID(self, id):
""" returns an element with the specific id and the position of that element within the svg elements array
"""
pos=0
for element in self._subElements:
if element.get_id()==id:
return (element,pos)
pos+=1 | python | def getElementByID(self, id):
""" returns an element with the specific id and the position of that element within the svg elements array
"""
pos=0
for element in self._subElements:
if element.get_id()==id:
return (element,pos)
pos+=1 | [
"def",
"getElementByID",
"(",
"self",
",",
"id",
")",
":",
"pos",
"=",
"0",
"for",
"element",
"in",
"self",
".",
"_subElements",
":",
"if",
"element",
".",
"get_id",
"(",
")",
"==",
"id",
":",
"return",
"(",
"element",
",",
"pos",
")",
"pos",
"+=",... | returns an element with the specific id and the position of that element within the svg elements array | [
"returns",
"an",
"element",
"with",
"the",
"specific",
"id",
"and",
"the",
"position",
"of",
"that",
"element",
"within",
"the",
"svg",
"elements",
"array"
] | ce217a4da3ada44a71d3e2f391d37c67d95c724e | https://github.com/alorence/pysvg-py3/blob/ce217a4da3ada44a71d3e2f391d37c67d95c724e/pysvg/core.py#L52-L59 |
49,098 | alorence/pysvg-py3 | pysvg/core.py | BaseElement.getElementsByType | def getElementsByType(self, type):
"""
retrieves all Elements that are of type type
@type type: class
@param type: type of the element
"""
foundElements=[]
for element in self.getAllElementsOfHirarchy():
if isinstance(element, type):
... | python | def getElementsByType(self, type):
"""
retrieves all Elements that are of type type
@type type: class
@param type: type of the element
"""
foundElements=[]
for element in self.getAllElementsOfHirarchy():
if isinstance(element, type):
... | [
"def",
"getElementsByType",
"(",
"self",
",",
"type",
")",
":",
"foundElements",
"=",
"[",
"]",
"for",
"element",
"in",
"self",
".",
"getAllElementsOfHirarchy",
"(",
")",
":",
"if",
"isinstance",
"(",
"element",
",",
"type",
")",
":",
"foundElements",
".",... | retrieves all Elements that are of type type
@type type: class
@param type: type of the element | [
"retrieves",
"all",
"Elements",
"that",
"are",
"of",
"type",
"type"
] | ce217a4da3ada44a71d3e2f391d37c67d95c724e | https://github.com/alorence/pysvg-py3/blob/ce217a4da3ada44a71d3e2f391d37c67d95c724e/pysvg/core.py#L61-L72 |
49,099 | alorence/pysvg-py3 | pysvg/core.py | BaseElement.getXML | def getXML(self):
"""
Return a XML representation of the current element.
This function can be used for debugging purposes. It is also used by getXML in SVG
@return: the representation of the current element as an xml string
"""
xml='<'+self._elementName+' '
... | python | def getXML(self):
"""
Return a XML representation of the current element.
This function can be used for debugging purposes. It is also used by getXML in SVG
@return: the representation of the current element as an xml string
"""
xml='<'+self._elementName+' '
... | [
"def",
"getXML",
"(",
"self",
")",
":",
"xml",
"=",
"'<'",
"+",
"self",
".",
"_elementName",
"+",
"' '",
"for",
"key",
",",
"value",
"in",
"list",
"(",
"self",
".",
"_attributes",
".",
"items",
"(",
")",
")",
":",
"if",
"value",
"!=",
"None",
":"... | Return a XML representation of the current element.
This function can be used for debugging purposes. It is also used by getXML in SVG
@return: the representation of the current element as an xml string | [
"Return",
"a",
"XML",
"representation",
"of",
"the",
"current",
"element",
".",
"This",
"function",
"can",
"be",
"used",
"for",
"debugging",
"purposes",
".",
"It",
"is",
"also",
"used",
"by",
"getXML",
"in",
"SVG"
] | ce217a4da3ada44a71d3e2f391d37c67d95c724e | https://github.com/alorence/pysvg-py3/blob/ce217a4da3ada44a71d3e2f391d37c67d95c724e/pysvg/core.py#L78-L105 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.