repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
rsmuc/health_monitoring_plugins
health_monitoring_plugins/check_snmp_port/check_snmp_port.py
check_udp
def check_udp(helper, host, port, session): """ the check logic for UDP ports """ open_ports = walk_data(session, '.1.3.6.1.2.1.7.5.1.2', helper)[0] # the udpLocaLPort from UDP-MIB.mib (deprecated) # here we show all open UDP ports if scan: print "All open UDP ports at host " + host...
python
def check_udp(helper, host, port, session): """ the check logic for UDP ports """ open_ports = walk_data(session, '.1.3.6.1.2.1.7.5.1.2', helper)[0] # the udpLocaLPort from UDP-MIB.mib (deprecated) # here we show all open UDP ports if scan: print "All open UDP ports at host " + host...
[ "def", "check_udp", "(", "helper", ",", "host", ",", "port", ",", "session", ")", ":", "open_ports", "=", "walk_data", "(", "session", ",", "'.1.3.6.1.2.1.7.5.1.2'", ",", "helper", ")", "[", "0", "]", "# the udpLocaLPort from UDP-MIB.mib (deprecated)", "# here we ...
the check logic for UDP ports
[ "the", "check", "logic", "for", "UDP", "ports" ]
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/check_snmp_port/check_snmp_port.py#L72-L90
rsmuc/health_monitoring_plugins
health_monitoring_plugins/check_snmp_port/check_snmp_port.py
check_tcp
def check_tcp(helper, host, port, warning_param, critical_param, session): """ the check logic for check TCP ports """ # from tcpConnState from TCP-MIB tcp_translate = { "1" : "closed", "2" : "listen", "3" : "synSent", "4" : "synReceived", "5" : "established",...
python
def check_tcp(helper, host, port, warning_param, critical_param, session): """ the check logic for check TCP ports """ # from tcpConnState from TCP-MIB tcp_translate = { "1" : "closed", "2" : "listen", "3" : "synSent", "4" : "synReceived", "5" : "established",...
[ "def", "check_tcp", "(", "helper", ",", "host", ",", "port", ",", "warning_param", ",", "critical_param", ",", "session", ")", ":", "# from tcpConnState from TCP-MIB", "tcp_translate", "=", "{", "\"1\"", ":", "\"closed\"", ",", "\"2\"", ":", "\"listen\"", ",", ...
the check logic for check TCP ports
[ "the", "check", "logic", "for", "check", "TCP", "ports" ]
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/check_snmp_port/check_snmp_port.py#L92-L150
niligulmohar/python-symmetric-jsonrpc
symmetricjsonrpc/json.py
to_json
def to_json(obj): """Return a json string representing the python object obj.""" i = StringIO.StringIO() w = Writer(i, encoding='UTF-8') w.write_value(obj) return i.getvalue()
python
def to_json(obj): """Return a json string representing the python object obj.""" i = StringIO.StringIO() w = Writer(i, encoding='UTF-8') w.write_value(obj) return i.getvalue()
[ "def", "to_json", "(", "obj", ")", ":", "i", "=", "StringIO", ".", "StringIO", "(", ")", "w", "=", "Writer", "(", "i", ",", "encoding", "=", "'UTF-8'", ")", "w", ".", "write_value", "(", "obj", ")", "return", "i", ".", "getvalue", "(", ")" ]
Return a json string representing the python object obj.
[ "Return", "a", "json", "string", "representing", "the", "python", "object", "obj", "." ]
train
https://github.com/niligulmohar/python-symmetric-jsonrpc/blob/f0730bef5c19a1631d58927c0f13d29f16cd1330/symmetricjsonrpc/json.py#L37-L42
rsmuc/health_monitoring_plugins
health_monitoring_plugins/newtecmodem.py
NewtecModem.get_data
def get_data(self): "Get SNMP values from host" alarm_oids = [netsnmp.Varbind(alarms[alarm_id]['oid']) for alarm_id in self.models[self.modem_type]['alarms']] metric_oids = [netsnmp.Varbind(metrics[metric_id]['oid']) for metric_id in self.models[self.modem_type]['metrics']] response = se...
python
def get_data(self): "Get SNMP values from host" alarm_oids = [netsnmp.Varbind(alarms[alarm_id]['oid']) for alarm_id in self.models[self.modem_type]['alarms']] metric_oids = [netsnmp.Varbind(metrics[metric_id]['oid']) for metric_id in self.models[self.modem_type]['metrics']] response = se...
[ "def", "get_data", "(", "self", ")", ":", "alarm_oids", "=", "[", "netsnmp", ".", "Varbind", "(", "alarms", "[", "alarm_id", "]", "[", "'oid'", "]", ")", "for", "alarm_id", "in", "self", ".", "models", "[", "self", ".", "modem_type", "]", "[", "'alar...
Get SNMP values from host
[ "Get", "SNMP", "values", "from", "host" ]
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/newtecmodem.py#L64-L72
rsmuc/health_monitoring_plugins
health_monitoring_plugins/newtecmodem.py
NewtecModem.process_alarms
def process_alarms(self, snmp_data): "Build list with active alarms" self.active_alarms = [] for i in range(0, len(self.models[self.modem_type]['alarms'])): if bool(int(snmp_data[i])) == True: self.active_alarms.append(self.models[self.modem_type]['alarms'][i])
python
def process_alarms(self, snmp_data): "Build list with active alarms" self.active_alarms = [] for i in range(0, len(self.models[self.modem_type]['alarms'])): if bool(int(snmp_data[i])) == True: self.active_alarms.append(self.models[self.modem_type]['alarms'][i])
[ "def", "process_alarms", "(", "self", ",", "snmp_data", ")", ":", "self", ".", "active_alarms", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "len", "(", "self", ".", "models", "[", "self", ".", "modem_type", "]", "[", "'alarms'", "]", "...
Build list with active alarms
[ "Build", "list", "with", "active", "alarms" ]
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/newtecmodem.py#L74-L79
rsmuc/health_monitoring_plugins
health_monitoring_plugins/newtecmodem.py
NewtecModem.process_metrics
def process_metrics(self, snmp_data): "Build list with metrics" self.metrics = {} for i in range(0, len(snmp_data)): metric_id = self.models[self.modem_type]['metrics'][i] value = int(snmp_data[i]) self.metrics[metric_id] = value
python
def process_metrics(self, snmp_data): "Build list with metrics" self.metrics = {} for i in range(0, len(snmp_data)): metric_id = self.models[self.modem_type]['metrics'][i] value = int(snmp_data[i]) self.metrics[metric_id] = value
[ "def", "process_metrics", "(", "self", ",", "snmp_data", ")", ":", "self", ".", "metrics", "=", "{", "}", "for", "i", "in", "range", "(", "0", ",", "len", "(", "snmp_data", ")", ")", ":", "metric_id", "=", "self", ".", "models", "[", "self", ".", ...
Build list with metrics
[ "Build", "list", "with", "metrics" ]
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/newtecmodem.py#L81-L87
rsmuc/health_monitoring_plugins
health_monitoring_plugins/check_snmp_service/check_snmp_service.py
convert_in_oid
def convert_in_oid(service_name): """ calculate the correct OID for the service name """ s = service_name # convert the service_name to ascci service_ascii = [ord(c) for c in s] # we need the length of the service name length = str(len(s)) # make the oid oid = base_oid + "." + l...
python
def convert_in_oid(service_name): """ calculate the correct OID for the service name """ s = service_name # convert the service_name to ascci service_ascii = [ord(c) for c in s] # we need the length of the service name length = str(len(s)) # make the oid oid = base_oid + "." + l...
[ "def", "convert_in_oid", "(", "service_name", ")", ":", "s", "=", "service_name", "# convert the service_name to ascci", "service_ascii", "=", "[", "ord", "(", "c", ")", "for", "c", "in", "s", "]", "# we need the length of the service name", "length", "=", "str", ...
calculate the correct OID for the service name
[ "calculate", "the", "correct", "OID", "for", "the", "service", "name" ]
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/check_snmp_service/check_snmp_service.py#L55-L66
rsmuc/health_monitoring_plugins
health_monitoring_plugins/microwavemodem.py
MicrowaveModem.get_data
def get_data(self): "Return one SNMP response list for all status OIDs, and one list for all metric OIDs." alarm_oids = [netsnmp.Varbind(status_mib[alarm_id]['oid']) for alarm_id in self.models[self.modem_type]['alarms']] metric_oids = [netsnmp.Varbind(metric_mib[metric_id]['oid']) for metric_id...
python
def get_data(self): "Return one SNMP response list for all status OIDs, and one list for all metric OIDs." alarm_oids = [netsnmp.Varbind(status_mib[alarm_id]['oid']) for alarm_id in self.models[self.modem_type]['alarms']] metric_oids = [netsnmp.Varbind(metric_mib[metric_id]['oid']) for metric_id...
[ "def", "get_data", "(", "self", ")", ":", "alarm_oids", "=", "[", "netsnmp", ".", "Varbind", "(", "status_mib", "[", "alarm_id", "]", "[", "'oid'", "]", ")", "for", "alarm_id", "in", "self", ".", "models", "[", "self", ".", "modem_type", "]", "[", "'...
Return one SNMP response list for all status OIDs, and one list for all metric OIDs.
[ "Return", "one", "SNMP", "response", "list", "for", "all", "status", "OIDs", "and", "one", "list", "for", "all", "metric", "OIDs", "." ]
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/microwavemodem.py#L97-L105
rsmuc/health_monitoring_plugins
health_monitoring_plugins/microwavemodem.py
MicrowaveModem.process_alarms
def process_alarms(self, snmp_data): "Build list with active alarms" self.active_alarms = {} for i in range(0, len(self.models[self.modem_type]['alarms'])): mib_name = self.models[self.modem_type]['alarms'][i] conv = status_mib[mib_name]['conv'] self.active_al...
python
def process_alarms(self, snmp_data): "Build list with active alarms" self.active_alarms = {} for i in range(0, len(self.models[self.modem_type]['alarms'])): mib_name = self.models[self.modem_type]['alarms'][i] conv = status_mib[mib_name]['conv'] self.active_al...
[ "def", "process_alarms", "(", "self", ",", "snmp_data", ")", ":", "self", ".", "active_alarms", "=", "{", "}", "for", "i", "in", "range", "(", "0", ",", "len", "(", "self", ".", "models", "[", "self", ".", "modem_type", "]", "[", "'alarms'", "]", "...
Build list with active alarms
[ "Build", "list", "with", "active", "alarms" ]
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/microwavemodem.py#L107-L113
rsmuc/health_monitoring_plugins
health_monitoring_plugins/microwavemodem.py
MicrowaveModem.process_metrics
def process_metrics(self, snmp_data): "Build list with metrics" self.metrics = {} for i in range(0, len(snmp_data)): mib_name = self.models[self.modem_type]['metrics'][i] conv = metric_mib[mib_name]['conv'] self.metrics[mib_name] = conv(snmp_data[i])
python
def process_metrics(self, snmp_data): "Build list with metrics" self.metrics = {} for i in range(0, len(snmp_data)): mib_name = self.models[self.modem_type]['metrics'][i] conv = metric_mib[mib_name]['conv'] self.metrics[mib_name] = conv(snmp_data[i])
[ "def", "process_metrics", "(", "self", ",", "snmp_data", ")", ":", "self", ".", "metrics", "=", "{", "}", "for", "i", "in", "range", "(", "0", ",", "len", "(", "snmp_data", ")", ")", ":", "mib_name", "=", "self", ".", "models", "[", "self", ".", ...
Build list with metrics
[ "Build", "list", "with", "metrics" ]
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/microwavemodem.py#L115-L121
rsmuc/health_monitoring_plugins
health_monitoring_plugins/raritan.py
real_value
def real_value(value, digit): """ function to calculate the real value we need to devide the value by the digit e.g. value = 100 digit = 2 return: "1.0" """ return str(float(value) / math.pow(10, float(digit)))
python
def real_value(value, digit): """ function to calculate the real value we need to devide the value by the digit e.g. value = 100 digit = 2 return: "1.0" """ return str(float(value) / math.pow(10, float(digit)))
[ "def", "real_value", "(", "value", ",", "digit", ")", ":", "return", "str", "(", "float", "(", "value", ")", "/", "math", ".", "pow", "(", "10", ",", "float", "(", "digit", ")", ")", ")" ]
function to calculate the real value we need to devide the value by the digit e.g. value = 100 digit = 2 return: "1.0"
[ "function", "to", "calculate", "the", "real", "value", "we", "need", "to", "devide", "the", "value", "by", "the", "digit", "e", ".", "g", ".", "value", "=", "100", "digit", "=", "2", "return", ":", "1", ".", "0" ]
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/raritan.py#L68-L77
rsmuc/health_monitoring_plugins
health_monitoring_plugins/raritan.py
Raritan.check_inlet
def check_inlet(self, helper): """ check the Inlets of Raritan PDUs """ # walk the data try: inlet_values = self.sess.walk_oid(self.oids['oid_inlet_value']) inlet_units = self.sess.walk_oid(self.oids['oid_inlet_unit']) inlet_digits = self.sess....
python
def check_inlet(self, helper): """ check the Inlets of Raritan PDUs """ # walk the data try: inlet_values = self.sess.walk_oid(self.oids['oid_inlet_value']) inlet_units = self.sess.walk_oid(self.oids['oid_inlet_unit']) inlet_digits = self.sess....
[ "def", "check_inlet", "(", "self", ",", "helper", ")", ":", "# walk the data", "try", ":", "inlet_values", "=", "self", ".", "sess", ".", "walk_oid", "(", "self", ".", "oids", "[", "'oid_inlet_value'", "]", ")", "inlet_units", "=", "self", ".", "sess", "...
check the Inlets of Raritan PDUs
[ "check", "the", "Inlets", "of", "Raritan", "PDUs" ]
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/raritan.py#L112-L155
rsmuc/health_monitoring_plugins
health_monitoring_plugins/raritan.py
Raritan.check_outlet
def check_outlet(self, helper): """ check the status of the specified outlet """ try: outlet_name, outlet_state = self.sess.get_oids(self.oids['oid_outlet_name'], self.oids['oid_outlet_state']) except health_monitoring_plugins.SnmpException as e: helper.ex...
python
def check_outlet(self, helper): """ check the status of the specified outlet """ try: outlet_name, outlet_state = self.sess.get_oids(self.oids['oid_outlet_name'], self.oids['oid_outlet_state']) except health_monitoring_plugins.SnmpException as e: helper.ex...
[ "def", "check_outlet", "(", "self", ",", "helper", ")", ":", "try", ":", "outlet_name", ",", "outlet_state", "=", "self", ".", "sess", ".", "get_oids", "(", "self", ".", "oids", "[", "'oid_outlet_name'", "]", ",", "self", ".", "oids", "[", "'oid_outlet_s...
check the status of the specified outlet
[ "check", "the", "status", "of", "the", "specified", "outlet" ]
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/raritan.py#L157-L172
rsmuc/health_monitoring_plugins
health_monitoring_plugins/raritan.py
Raritan.check_sensor
def check_sensor(self, helper): """ check the status of the specified sensor """ try: sensor_name, sensor_state, sensor_type = self.sess.get_oids( self.oids['oid_sensor_name'], self.oids['oid_sensor_state'], self.oids['oid_sensor_type']) except health_...
python
def check_sensor(self, helper): """ check the status of the specified sensor """ try: sensor_name, sensor_state, sensor_type = self.sess.get_oids( self.oids['oid_sensor_name'], self.oids['oid_sensor_state'], self.oids['oid_sensor_type']) except health_...
[ "def", "check_sensor", "(", "self", ",", "helper", ")", ":", "try", ":", "sensor_name", ",", "sensor_state", ",", "sensor_type", "=", "self", ".", "sess", ".", "get_oids", "(", "self", ".", "oids", "[", "'oid_sensor_name'", "]", ",", "self", ".", "oids",...
check the status of the specified sensor
[ "check", "the", "status", "of", "the", "specified", "sensor" ]
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/raritan.py#L174-L248
rsmuc/health_monitoring_plugins
health_monitoring_plugins/snmpSessionBaseClass.py
dev_null_wrapper
def dev_null_wrapper(func, *a, **kwargs): """ Temporarily swap stdout with /dev/null, and execute given function while stdout goes to /dev/null. This is useful because netsnmp writes to stdout and disturbes Icinga result in some cases. """ os.dup2(dev_null, sys.stdout.fileno()) return_object = f...
python
def dev_null_wrapper(func, *a, **kwargs): """ Temporarily swap stdout with /dev/null, and execute given function while stdout goes to /dev/null. This is useful because netsnmp writes to stdout and disturbes Icinga result in some cases. """ os.dup2(dev_null, sys.stdout.fileno()) return_object = f...
[ "def", "dev_null_wrapper", "(", "func", ",", "*", "a", ",", "*", "*", "kwargs", ")", ":", "os", ".", "dup2", "(", "dev_null", ",", "sys", ".", "stdout", ".", "fileno", "(", ")", ")", "return_object", "=", "func", "(", "*", "a", ",", "*", "*", "...
Temporarily swap stdout with /dev/null, and execute given function while stdout goes to /dev/null. This is useful because netsnmp writes to stdout and disturbes Icinga result in some cases.
[ "Temporarily", "swap", "stdout", "with", "/", "dev", "/", "null", "and", "execute", "given", "function", "while", "stdout", "goes", "to", "/", "dev", "/", "null", ".", "This", "is", "useful", "because", "netsnmp", "writes", "to", "stdout", "and", "disturbe...
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/snmpSessionBaseClass.py#L28-L37
rsmuc/health_monitoring_plugins
health_monitoring_plugins/snmpSessionBaseClass.py
state_summary
def state_summary(value, name, state_list, helper, ok_value = 'ok', info = None): """ Always add the status to the long output, and if the status is not ok (or ok_value), we show it in the summary and set the status to critical """ # translate the value (integer) we receive to a human readable valu...
python
def state_summary(value, name, state_list, helper, ok_value = 'ok', info = None): """ Always add the status to the long output, and if the status is not ok (or ok_value), we show it in the summary and set the status to critical """ # translate the value (integer) we receive to a human readable valu...
[ "def", "state_summary", "(", "value", ",", "name", ",", "state_list", ",", "helper", ",", "ok_value", "=", "'ok'", ",", "info", "=", "None", ")", ":", "# translate the value (integer) we receive to a human readable value (e.g. ok, critical etc.) with the given state_list", ...
Always add the status to the long output, and if the status is not ok (or ok_value), we show it in the summary and set the status to critical
[ "Always", "add", "the", "status", "to", "the", "long", "output", "and", "if", "the", "status", "is", "not", "ok", "(", "or", "ok_value", ")", "we", "show", "it", "in", "the", "summary", "and", "set", "the", "status", "to", "critical" ]
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/snmpSessionBaseClass.py#L152-L167
rsmuc/health_monitoring_plugins
health_monitoring_plugins/snmpSessionBaseClass.py
add_output
def add_output(summary_output, long_output, helper): """ if the summary output is empty, we don't add it as summary, otherwise we would have empty spaces (e.g.: '. . . . .') in our summary report """ if summary_output != '': helper.add_summary(summary_output) helper.add_long_output(long_outp...
python
def add_output(summary_output, long_output, helper): """ if the summary output is empty, we don't add it as summary, otherwise we would have empty spaces (e.g.: '. . . . .') in our summary report """ if summary_output != '': helper.add_summary(summary_output) helper.add_long_output(long_outp...
[ "def", "add_output", "(", "summary_output", ",", "long_output", ",", "helper", ")", ":", "if", "summary_output", "!=", "''", ":", "helper", ".", "add_summary", "(", "summary_output", ")", "helper", ".", "add_long_output", "(", "long_output", ")" ]
if the summary output is empty, we don't add it as summary, otherwise we would have empty spaces (e.g.: '. . . . .') in our summary report
[ "if", "the", "summary", "output", "is", "empty", "we", "don", "t", "add", "it", "as", "summary", "otherwise", "we", "would", "have", "empty", "spaces", "(", "e", ".", "g", ".", ":", ".", ".", ".", ".", ".", ")", "in", "our", "summary", "report" ]
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/snmpSessionBaseClass.py#L169-L175
rsmuc/health_monitoring_plugins
health_monitoring_plugins/meinberg.py
Meinberg.process_gps_position
def process_gps_position(self, helper, sess): """ just print the current GPS position """ gps_position = helper.get_snmp_value(sess, helper, self.oids['oid_gps_position']) if gps_position: helper.add_summary(gps_position) else: helper.add_summary...
python
def process_gps_position(self, helper, sess): """ just print the current GPS position """ gps_position = helper.get_snmp_value(sess, helper, self.oids['oid_gps_position']) if gps_position: helper.add_summary(gps_position) else: helper.add_summary...
[ "def", "process_gps_position", "(", "self", ",", "helper", ",", "sess", ")", ":", "gps_position", "=", "helper", ".", "get_snmp_value", "(", "sess", ",", "helper", ",", "self", ".", "oids", "[", "'oid_gps_position'", "]", ")", "if", "gps_position", ":", "h...
just print the current GPS position
[ "just", "print", "the", "current", "GPS", "position" ]
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/meinberg.py#L108-L119
rsmuc/health_monitoring_plugins
health_monitoring_plugins/meinberg.py
Meinberg.process_status
def process_status(self, helper, sess, check): """ get the snmp value, check the status and update the helper""" if check == 'ntp_current_state': ntp_status_int = helper.get_snmp_value(sess, helper, self.oids['oid_ntp_current_state_int']) result = self.check_ntp_status(ntp_statu...
python
def process_status(self, helper, sess, check): """ get the snmp value, check the status and update the helper""" if check == 'ntp_current_state': ntp_status_int = helper.get_snmp_value(sess, helper, self.oids['oid_ntp_current_state_int']) result = self.check_ntp_status(ntp_statu...
[ "def", "process_status", "(", "self", ",", "helper", ",", "sess", ",", "check", ")", ":", "if", "check", "==", "'ntp_current_state'", ":", "ntp_status_int", "=", "helper", ".", "get_snmp_value", "(", "sess", ",", "helper", ",", "self", ".", "oids", "[", ...
get the snmp value, check the status and update the helper
[ "get", "the", "snmp", "value", "check", "the", "status", "and", "update", "the", "helper" ]
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/meinberg.py#L121-L133
rsmuc/health_monitoring_plugins
health_monitoring_plugins/meinberg.py
Meinberg.check_ntp_status
def check_ntp_status(self, ntp_status_int): """ check the NTP status """ # convert the ntp_status integer value in a human readable value ntp_status_string = self.ntp_status.get(ntp_status_int, "unknown") if ntp_status_string == "unknown": return unknown, ("N...
python
def check_ntp_status(self, ntp_status_int): """ check the NTP status """ # convert the ntp_status integer value in a human readable value ntp_status_string = self.ntp_status.get(ntp_status_int, "unknown") if ntp_status_string == "unknown": return unknown, ("N...
[ "def", "check_ntp_status", "(", "self", ",", "ntp_status_int", ")", ":", "# convert the ntp_status integer value in a human readable value", "ntp_status_string", "=", "self", ".", "ntp_status", ".", "get", "(", "ntp_status_int", ",", "\"unknown\"", ")", "if", "ntp_status_...
check the NTP status
[ "check", "the", "NTP", "status" ]
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/meinberg.py#L135-L150
rsmuc/health_monitoring_plugins
health_monitoring_plugins/meinberg.py
Meinberg.check_gps_status
def check_gps_status(self, gps_status_int): """ check the GPS status """ gps_mode_string = self.gps_mode.get(gps_status_int, "unknown") if gps_mode_string == "unknown": return unknown, ("GPS status: " + gps_mode_string) elif gps_mode_string != "normalOperati...
python
def check_gps_status(self, gps_status_int): """ check the GPS status """ gps_mode_string = self.gps_mode.get(gps_status_int, "unknown") if gps_mode_string == "unknown": return unknown, ("GPS status: " + gps_mode_string) elif gps_mode_string != "normalOperati...
[ "def", "check_gps_status", "(", "self", ",", "gps_status_int", ")", ":", "gps_mode_string", "=", "self", ".", "gps_mode", ".", "get", "(", "gps_status_int", ",", "\"unknown\"", ")", "if", "gps_mode_string", "==", "\"unknown\"", ":", "return", "unknown", ",", "...
check the GPS status
[ "check", "the", "GPS", "status" ]
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/meinberg.py#L152-L166
rsmuc/health_monitoring_plugins
health_monitoring_plugins/meinberg.py
Meinberg.process_satellites
def process_satellites(self, helper, sess): """ check and show the good satellites """ good_satellites = helper.get_snmp_value(sess, helper, self.oids['oid_gps_satellites_good']) # Show the summary and add the metric and afterwards check the metric helper.add_summary("Go...
python
def process_satellites(self, helper, sess): """ check and show the good satellites """ good_satellites = helper.get_snmp_value(sess, helper, self.oids['oid_gps_satellites_good']) # Show the summary and add the metric and afterwards check the metric helper.add_summary("Go...
[ "def", "process_satellites", "(", "self", ",", "helper", ",", "sess", ")", ":", "good_satellites", "=", "helper", ".", "get_snmp_value", "(", "sess", ",", "helper", ",", "self", ".", "oids", "[", "'oid_gps_satellites_good'", "]", ")", "# Show the summary and add...
check and show the good satellites
[ "check", "and", "show", "the", "good", "satellites" ]
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/meinberg.py#L168-L176
mozilla/fxapom
fxapom/pages/sign_in.py
SignIn.login_password
def login_password(self, value): """Set the value of the login password field.""" password = self.selenium.find_element(*self._password_input_locator) password.clear() password.send_keys(value)
python
def login_password(self, value): """Set the value of the login password field.""" password = self.selenium.find_element(*self._password_input_locator) password.clear() password.send_keys(value)
[ "def", "login_password", "(", "self", ",", "value", ")", ":", "password", "=", "self", ".", "selenium", ".", "find_element", "(", "*", "self", ".", "_password_input_locator", ")", "password", ".", "clear", "(", ")", "password", ".", "send_keys", "(", "valu...
Set the value of the login password field.
[ "Set", "the", "value", "of", "the", "login", "password", "field", "." ]
train
https://github.com/mozilla/fxapom/blob/d09ee84c21b46c1b27dd19b65490bebe038005c4/fxapom/pages/sign_in.py#L32-L36
mozilla/fxapom
fxapom/pages/sign_in.py
SignIn.email
def email(self, value): """Set the value of the email field.""" email = self.wait.until(expected.visibility_of_element_located( self._email_input_locator)) email.clear() email.send_keys(value)
python
def email(self, value): """Set the value of the email field.""" email = self.wait.until(expected.visibility_of_element_located( self._email_input_locator)) email.clear() email.send_keys(value)
[ "def", "email", "(", "self", ",", "value", ")", ":", "email", "=", "self", ".", "wait", ".", "until", "(", "expected", ".", "visibility_of_element_located", "(", "self", ".", "_email_input_locator", ")", ")", "email", ".", "clear", "(", ")", "email", "."...
Set the value of the email field.
[ "Set", "the", "value", "of", "the", "email", "field", "." ]
train
https://github.com/mozilla/fxapom/blob/d09ee84c21b46c1b27dd19b65490bebe038005c4/fxapom/pages/sign_in.py#L47-L52
mozilla/fxapom
fxapom/pages/sign_in.py
SignIn.sign_in
def sign_in(self, email, password): """Signs in using the specified email address and password.""" self.email = email self.login_password = password if self.is_element_present(*self._next_button_locator): self.wait.until(expected.visibility_of_element_located( ...
python
def sign_in(self, email, password): """Signs in using the specified email address and password.""" self.email = email self.login_password = password if self.is_element_present(*self._next_button_locator): self.wait.until(expected.visibility_of_element_located( ...
[ "def", "sign_in", "(", "self", ",", "email", ",", "password", ")", ":", "self", ".", "email", "=", "email", "self", ".", "login_password", "=", "password", "if", "self", ".", "is_element_present", "(", "*", "self", ".", "_next_button_locator", ")", ":", ...
Signs in using the specified email address and password.
[ "Signs", "in", "using", "the", "specified", "email", "address", "and", "password", "." ]
train
https://github.com/mozilla/fxapom/blob/d09ee84c21b46c1b27dd19b65490bebe038005c4/fxapom/pages/sign_in.py#L74-L82
mozilla/fxapom
fxapom/fxapom.py
WebDriverFxA.sign_in
def sign_in(self, email=None, password=None): """Signs in a user, either with the specified email address and password, or a returning user.""" from .pages.sign_in import SignIn sign_in = SignIn(self.selenium, self.timeout) sign_in.sign_in(email, password)
python
def sign_in(self, email=None, password=None): """Signs in a user, either with the specified email address and password, or a returning user.""" from .pages.sign_in import SignIn sign_in = SignIn(self.selenium, self.timeout) sign_in.sign_in(email, password)
[ "def", "sign_in", "(", "self", ",", "email", "=", "None", ",", "password", "=", "None", ")", ":", "from", ".", "pages", ".", "sign_in", "import", "SignIn", "sign_in", "=", "SignIn", "(", "self", ".", "selenium", ",", "self", ".", "timeout", ")", "sig...
Signs in a user, either with the specified email address and password, or a returning user.
[ "Signs", "in", "a", "user", "either", "with", "the", "specified", "email", "address", "and", "password", "or", "a", "returning", "user", "." ]
train
https://github.com/mozilla/fxapom/blob/d09ee84c21b46c1b27dd19b65490bebe038005c4/fxapom/fxapom.py#L31-L35
xflr6/gsheets
gsheets/export.py
write_csv
def write_csv(fileobj, rows, encoding=ENCODING, dialect=DIALECT): """Dump rows to ``fileobj`` with the given ``encoding`` and CSV ``dialect``.""" csvwriter = csv.writer(fileobj, dialect=dialect) csv_writerows(csvwriter, rows, encoding)
python
def write_csv(fileobj, rows, encoding=ENCODING, dialect=DIALECT): """Dump rows to ``fileobj`` with the given ``encoding`` and CSV ``dialect``.""" csvwriter = csv.writer(fileobj, dialect=dialect) csv_writerows(csvwriter, rows, encoding)
[ "def", "write_csv", "(", "fileobj", ",", "rows", ",", "encoding", "=", "ENCODING", ",", "dialect", "=", "DIALECT", ")", ":", "csvwriter", "=", "csv", ".", "writer", "(", "fileobj", ",", "dialect", "=", "dialect", ")", "csv_writerows", "(", "csvwriter", "...
Dump rows to ``fileobj`` with the given ``encoding`` and CSV ``dialect``.
[ "Dump", "rows", "to", "fileobj", "with", "the", "given", "encoding", "and", "CSV", "dialect", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/export.py#L21-L24
xflr6/gsheets
gsheets/export.py
write_dataframe
def write_dataframe(rows, encoding=ENCODING, dialect=DIALECT, **kwargs): """Dump ``rows`` to string buffer and load with ``pandas.read_csv()`` using ``kwargs``.""" global pandas if pandas is None: # pragma: no cover import pandas with contextlib.closing(CsvBuffer()) as fd: write_csv(fd,...
python
def write_dataframe(rows, encoding=ENCODING, dialect=DIALECT, **kwargs): """Dump ``rows`` to string buffer and load with ``pandas.read_csv()`` using ``kwargs``.""" global pandas if pandas is None: # pragma: no cover import pandas with contextlib.closing(CsvBuffer()) as fd: write_csv(fd,...
[ "def", "write_dataframe", "(", "rows", ",", "encoding", "=", "ENCODING", ",", "dialect", "=", "DIALECT", ",", "*", "*", "kwargs", ")", ":", "global", "pandas", "if", "pandas", "is", "None", ":", "# pragma: no cover", "import", "pandas", "with", "contextlib",...
Dump ``rows`` to string buffer and load with ``pandas.read_csv()`` using ``kwargs``.
[ "Dump", "rows", "to", "string", "buffer", "and", "load", "with", "pandas", ".", "read_csv", "()", "using", "kwargs", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/export.py#L27-L36
xflr6/gsheets
gsheets/urls.py
SheetUrl.from_string
def from_string(cls, link): """Return a new SheetUrl instance from parsed URL string. >>> SheetUrl.from_string('https://docs.google.com/spreadsheets/d/spam') <SheetUrl id='spam' gid=0> """ ma = cls._pattern.search(link) if ma is None: raise ValueError(link) ...
python
def from_string(cls, link): """Return a new SheetUrl instance from parsed URL string. >>> SheetUrl.from_string('https://docs.google.com/spreadsheets/d/spam') <SheetUrl id='spam' gid=0> """ ma = cls._pattern.search(link) if ma is None: raise ValueError(link) ...
[ "def", "from_string", "(", "cls", ",", "link", ")", ":", "ma", "=", "cls", ".", "_pattern", ".", "search", "(", "link", ")", "if", "ma", "is", "None", ":", "raise", "ValueError", "(", "link", ")", "id", "=", "ma", ".", "group", "(", "'id'", ")", ...
Return a new SheetUrl instance from parsed URL string. >>> SheetUrl.from_string('https://docs.google.com/spreadsheets/d/spam') <SheetUrl id='spam' gid=0>
[ "Return", "a", "new", "SheetUrl", "instance", "from", "parsed", "URL", "string", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/urls.py#L18-L28
xflr6/gsheets
gsheets/tools.py
doctemplate
def doctemplate(*args): """Return a decorator putting ``args`` into the docstring of the decorated ``func``. >>> @doctemplate('spam', 'spam') ... def spam(): ... '''Returns %s, lovely %s.''' ... return 'Spam' >>> spam.__doc__ 'Returns spam, lovely spam.' """ def decorator(f...
python
def doctemplate(*args): """Return a decorator putting ``args`` into the docstring of the decorated ``func``. >>> @doctemplate('spam', 'spam') ... def spam(): ... '''Returns %s, lovely %s.''' ... return 'Spam' >>> spam.__doc__ 'Returns spam, lovely spam.' """ def decorator(f...
[ "def", "doctemplate", "(", "*", "args", ")", ":", "def", "decorator", "(", "func", ")", ":", "func", ".", "__doc__", "=", "func", ".", "__doc__", "%", "tuple", "(", "args", ")", "return", "func", "return", "decorator" ]
Return a decorator putting ``args`` into the docstring of the decorated ``func``. >>> @doctemplate('spam', 'spam') ... def spam(): ... '''Returns %s, lovely %s.''' ... return 'Spam' >>> spam.__doc__ 'Returns spam, lovely spam.'
[ "Return", "a", "decorator", "putting", "args", "into", "the", "docstring", "of", "the", "decorated", "func", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/tools.py#L43-L57
xflr6/gsheets
gsheets/tools.py
group_dict
def group_dict(items, keyfunc): """Return a list defaultdict with ``items`` grouped by ``keyfunc``. >>> sorted(group_dict('eggs', lambda x: x).items()) [('e', ['e']), ('g', ['g', 'g']), ('s', ['s'])] """ result = collections.defaultdict(list) for i in items: key = keyfunc(i) res...
python
def group_dict(items, keyfunc): """Return a list defaultdict with ``items`` grouped by ``keyfunc``. >>> sorted(group_dict('eggs', lambda x: x).items()) [('e', ['e']), ('g', ['g', 'g']), ('s', ['s'])] """ result = collections.defaultdict(list) for i in items: key = keyfunc(i) res...
[ "def", "group_dict", "(", "items", ",", "keyfunc", ")", ":", "result", "=", "collections", ".", "defaultdict", "(", "list", ")", "for", "i", "in", "items", ":", "key", "=", "keyfunc", "(", "i", ")", "result", "[", "key", "]", ".", "append", "(", "i...
Return a list defaultdict with ``items`` grouped by ``keyfunc``. >>> sorted(group_dict('eggs', lambda x: x).items()) [('e', ['e']), ('g', ['g', 'g']), ('s', ['s'])]
[ "Return", "a", "list", "defaultdict", "with", "items", "grouped", "by", "keyfunc", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/tools.py#L106-L116
xflr6/gsheets
gsheets/tools.py
uniqued
def uniqued(iterable): """Return unique list of ``iterable`` items preserving order. >>> uniqued('spameggs') ['s', 'p', 'a', 'm', 'e', 'g'] """ seen = set() return [item for item in iterable if item not in seen and not seen.add(item)]
python
def uniqued(iterable): """Return unique list of ``iterable`` items preserving order. >>> uniqued('spameggs') ['s', 'p', 'a', 'm', 'e', 'g'] """ seen = set() return [item for item in iterable if item not in seen and not seen.add(item)]
[ "def", "uniqued", "(", "iterable", ")", ":", "seen", "=", "set", "(", ")", "return", "[", "item", "for", "item", "in", "iterable", "if", "item", "not", "in", "seen", "and", "not", "seen", ".", "add", "(", "item", ")", "]" ]
Return unique list of ``iterable`` items preserving order. >>> uniqued('spameggs') ['s', 'p', 'a', 'm', 'e', 'g']
[ "Return", "unique", "list", "of", "iterable", "items", "preserving", "order", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/tools.py#L133-L140
xflr6/gsheets
gsheets/backend.py
build_service
def build_service(name=None, **kwargs): """Return a service endpoint for interacting with a Google API.""" if name is not None: for kw, value in iteritems(SERVICES[name]): kwargs.setdefault(kw, value) return apiclient.discovery.build(**kwargs)
python
def build_service(name=None, **kwargs): """Return a service endpoint for interacting with a Google API.""" if name is not None: for kw, value in iteritems(SERVICES[name]): kwargs.setdefault(kw, value) return apiclient.discovery.build(**kwargs)
[ "def", "build_service", "(", "name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "name", "is", "not", "None", ":", "for", "kw", ",", "value", "in", "iteritems", "(", "SERVICES", "[", "name", "]", ")", ":", "kwargs", ".", "setdefault", "("...
Return a service endpoint for interacting with a Google API.
[ "Return", "a", "service", "endpoint", "for", "interacting", "with", "a", "Google", "API", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/backend.py#L21-L26
xflr6/gsheets
gsheets/backend.py
iterfiles
def iterfiles(service, name=None, mimeType=SHEET, order=FILEORDER): """Fetch and yield ``(id, name)`` pairs for Google drive files.""" params = {'orderBy': order, 'pageToken': None} q = [] if name is not None: q.append("name='%s'" % name) if mimeType is not None: q.append("mimeType='...
python
def iterfiles(service, name=None, mimeType=SHEET, order=FILEORDER): """Fetch and yield ``(id, name)`` pairs for Google drive files.""" params = {'orderBy': order, 'pageToken': None} q = [] if name is not None: q.append("name='%s'" % name) if mimeType is not None: q.append("mimeType='...
[ "def", "iterfiles", "(", "service", ",", "name", "=", "None", ",", "mimeType", "=", "SHEET", ",", "order", "=", "FILEORDER", ")", ":", "params", "=", "{", "'orderBy'", ":", "order", ",", "'pageToken'", ":", "None", "}", "q", "=", "[", "]", "if", "n...
Fetch and yield ``(id, name)`` pairs for Google drive files.
[ "Fetch", "and", "yield", "(", "id", "name", ")", "pairs", "for", "Google", "drive", "files", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/backend.py#L29-L47
xflr6/gsheets
gsheets/backend.py
spreadsheet
def spreadsheet(service, id): """Fetch and return spreadsheet meta data with Google sheets API.""" request = service.spreadsheets().get(spreadsheetId=id) try: response = request.execute() except apiclient.errors.HttpError as e: if e.resp.status == 404: raise KeyError(id) ...
python
def spreadsheet(service, id): """Fetch and return spreadsheet meta data with Google sheets API.""" request = service.spreadsheets().get(spreadsheetId=id) try: response = request.execute() except apiclient.errors.HttpError as e: if e.resp.status == 404: raise KeyError(id) ...
[ "def", "spreadsheet", "(", "service", ",", "id", ")", ":", "request", "=", "service", ".", "spreadsheets", "(", ")", ".", "get", "(", "spreadsheetId", "=", "id", ")", "try", ":", "response", "=", "request", ".", "execute", "(", ")", "except", "apiclien...
Fetch and return spreadsheet meta data with Google sheets API.
[ "Fetch", "and", "return", "spreadsheet", "meta", "data", "with", "Google", "sheets", "API", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/backend.py#L50-L60
xflr6/gsheets
gsheets/backend.py
values
def values(service, id, ranges): """Fetch and return spreadsheet cell values with Google sheets API.""" params = {'majorDimension': 'ROWS', 'valueRenderOption': 'UNFORMATTED_VALUE', 'dateTimeRenderOption': 'FORMATTED_STRING'} params.update(spreadsheetId=id, ranges=ranges) response = servic...
python
def values(service, id, ranges): """Fetch and return spreadsheet cell values with Google sheets API.""" params = {'majorDimension': 'ROWS', 'valueRenderOption': 'UNFORMATTED_VALUE', 'dateTimeRenderOption': 'FORMATTED_STRING'} params.update(spreadsheetId=id, ranges=ranges) response = servic...
[ "def", "values", "(", "service", ",", "id", ",", "ranges", ")", ":", "params", "=", "{", "'majorDimension'", ":", "'ROWS'", ",", "'valueRenderOption'", ":", "'UNFORMATTED_VALUE'", ",", "'dateTimeRenderOption'", ":", "'FORMATTED_STRING'", "}", "params", ".", "upd...
Fetch and return spreadsheet cell values with Google sheets API.
[ "Fetch", "and", "return", "spreadsheet", "cell", "values", "with", "Google", "sheets", "API", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/backend.py#L63-L69
xflr6/gsheets
gsheets/oauth2.py
get_credentials
def get_credentials(scopes=None, secrets=None, storage=None, no_webserver=False): """Make OAuth 2.0 credentials for scopes from ``secrets`` and ``storage`` files. Args: scopes: scope URL(s) or ``'read'``, ``'write'`` (default: ``%r``) secrets: location of secrets file (default: ``%r``) ...
python
def get_credentials(scopes=None, secrets=None, storage=None, no_webserver=False): """Make OAuth 2.0 credentials for scopes from ``secrets`` and ``storage`` files. Args: scopes: scope URL(s) or ``'read'``, ``'write'`` (default: ``%r``) secrets: location of secrets file (default: ``%r``) ...
[ "def", "get_credentials", "(", "scopes", "=", "None", ",", "secrets", "=", "None", ",", "storage", "=", "None", ",", "no_webserver", "=", "False", ")", ":", "scopes", "=", "Scopes", ".", "get", "(", "scopes", ")", "if", "secrets", "is", "None", ":", ...
Make OAuth 2.0 credentials for scopes from ``secrets`` and ``storage`` files. Args: scopes: scope URL(s) or ``'read'``, ``'write'`` (default: ``%r``) secrets: location of secrets file (default: ``%r``) storage: location of storage file (default: ``%r``) no_webserver: url/code prompt...
[ "Make", "OAuth", "2", ".", "0", "credentials", "for", "scopes", "from", "secrets", "and", "storage", "files", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/oauth2.py#L23-L53
xflr6/gsheets
gsheets/oauth2.py
Scopes.get
def get(cls, scope=None): """Return default or predefined URLs from keyword, pass through ``scope``.""" if scope is None: scope = cls.default if isinstance(scope, string_types) and scope in cls._keywords: return getattr(cls, scope) return scope
python
def get(cls, scope=None): """Return default or predefined URLs from keyword, pass through ``scope``.""" if scope is None: scope = cls.default if isinstance(scope, string_types) and scope in cls._keywords: return getattr(cls, scope) return scope
[ "def", "get", "(", "cls", ",", "scope", "=", "None", ")", ":", "if", "scope", "is", "None", ":", "scope", "=", "cls", ".", "default", "if", "isinstance", "(", "scope", ",", "string_types", ")", "and", "scope", "in", "cls", ".", "_keywords", ":", "r...
Return default or predefined URLs from keyword, pass through ``scope``.
[ "Return", "default", "or", "predefined", "URLs", "from", "keyword", "pass", "through", "scope", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/oauth2.py#L93-L99
tristantao/py-bing-search
py_bing_search/py_bing_search.py
PyBingSearch.search_all
def search_all(self, limit=50, format='json'): ''' Returns a single list containing up to 'limit' Result objects''' desired_limit = limit results = self._search(limit, format) limit = limit - len(results) while len(results) < desired_limit: more_results = self._search...
python
def search_all(self, limit=50, format='json'): ''' Returns a single list containing up to 'limit' Result objects''' desired_limit = limit results = self._search(limit, format) limit = limit - len(results) while len(results) < desired_limit: more_results = self._search...
[ "def", "search_all", "(", "self", ",", "limit", "=", "50", ",", "format", "=", "'json'", ")", ":", "desired_limit", "=", "limit", "results", "=", "self", ".", "_search", "(", "limit", ",", "format", ")", "limit", "=", "limit", "-", "len", "(", "resul...
Returns a single list containing up to 'limit' Result objects
[ "Returns", "a", "single", "list", "containing", "up", "to", "limit", "Result", "objects" ]
train
https://github.com/tristantao/py-bing-search/blob/d18b8fcfe5a5502682c65dd458f50c0a29a510e9/py_bing_search/py_bing_search.py#L22-L34
tristantao/py-bing-search
py_bing_search/py_bing_search.py
PyBingVideoSearch._search
def _search(self, limit, format): ''' Returns a list of result objects, with the url for the next page bing search url. ''' url = self.QUERY_URL.format(requests.utils.quote("'{}'".format(self.query)), min(50, limit), self.current_offset, format) r = requests.get(url, auth=("", se...
python
def _search(self, limit, format): ''' Returns a list of result objects, with the url for the next page bing search url. ''' url = self.QUERY_URL.format(requests.utils.quote("'{}'".format(self.query)), min(50, limit), self.current_offset, format) r = requests.get(url, auth=("", se...
[ "def", "_search", "(", "self", ",", "limit", ",", "format", ")", ":", "url", "=", "self", ".", "QUERY_URL", ".", "format", "(", "requests", ".", "utils", ".", "quote", "(", "\"'{}'\"", ".", "format", "(", "self", ".", "query", ")", ")", ",", "min",...
Returns a list of result objects, with the url for the next page bing search url.
[ "Returns", "a", "list", "of", "result", "objects", "with", "the", "url", "for", "the", "next", "page", "bing", "search", "url", "." ]
train
https://github.com/tristantao/py-bing-search/blob/d18b8fcfe5a5502682c65dd458f50c0a29a510e9/py_bing_search/py_bing_search.py#L216-L232
xflr6/gsheets
gsheets/coordinates.py
base26int
def base26int(s, _start=1 - ord('A')): """Return string ``s`` as ``int`` in bijective base26 notation. >>> base26int('SPAM') 344799 """ return sum((_start + ord(c)) * 26**i for i, c in enumerate(reversed(s)))
python
def base26int(s, _start=1 - ord('A')): """Return string ``s`` as ``int`` in bijective base26 notation. >>> base26int('SPAM') 344799 """ return sum((_start + ord(c)) * 26**i for i, c in enumerate(reversed(s)))
[ "def", "base26int", "(", "s", ",", "_start", "=", "1", "-", "ord", "(", "'A'", ")", ")", ":", "return", "sum", "(", "(", "_start", "+", "ord", "(", "c", ")", ")", "*", "26", "**", "i", "for", "i", ",", "c", "in", "enumerate", "(", "reversed",...
Return string ``s`` as ``int`` in bijective base26 notation. >>> base26int('SPAM') 344799
[ "Return", "string", "s", "as", "int", "in", "bijective", "base26", "notation", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/coordinates.py#L13-L19
xflr6/gsheets
gsheets/coordinates.py
base26
def base26(x, _alphabet=string.ascii_uppercase): """Return positive ``int`` ``x`` as string in bijective base26 notation. >>> [base26(i) for i in [0, 1, 2, 26, 27, 28, 702, 703, 704]] ['', 'A', 'B', 'Z', 'AA', 'AB', 'ZZ', 'AAA', 'AAB'] >>> base26(344799) # 19 * 26**3 + 16 * 26**2 + 1 * 26**1 + 13 * 2...
python
def base26(x, _alphabet=string.ascii_uppercase): """Return positive ``int`` ``x`` as string in bijective base26 notation. >>> [base26(i) for i in [0, 1, 2, 26, 27, 28, 702, 703, 704]] ['', 'A', 'B', 'Z', 'AA', 'AB', 'ZZ', 'AAA', 'AAB'] >>> base26(344799) # 19 * 26**3 + 16 * 26**2 + 1 * 26**1 + 13 * 2...
[ "def", "base26", "(", "x", ",", "_alphabet", "=", "string", ".", "ascii_uppercase", ")", ":", "result", "=", "[", "]", "while", "x", ":", "x", ",", "digit", "=", "divmod", "(", "x", ",", "26", ")", "if", "not", "digit", ":", "x", "-=", "1", "di...
Return positive ``int`` ``x`` as string in bijective base26 notation. >>> [base26(i) for i in [0, 1, 2, 26, 27, 28, 702, 703, 704]] ['', 'A', 'B', 'Z', 'AA', 'AB', 'ZZ', 'AAA', 'AAB'] >>> base26(344799) # 19 * 26**3 + 16 * 26**2 + 1 * 26**1 + 13 * 26**0 'SPAM' >>> base26(256) 'IV'
[ "Return", "positive", "int", "x", "as", "string", "in", "bijective", "base26", "notation", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/coordinates.py#L22-L41
xflr6/gsheets
gsheets/coordinates.py
Coordinates._parse
def _parse(coord, _match=_regex.match): """Return match groups from single sheet coordinate. >>> Coordinates._parse('A1') ('A', '1', None, None) >>> Coordinates._parse('A'), Coordinates._parse('1') ((None, None, 'A', None), (None, None, None, '1')) >>> Coordinates._par...
python
def _parse(coord, _match=_regex.match): """Return match groups from single sheet coordinate. >>> Coordinates._parse('A1') ('A', '1', None, None) >>> Coordinates._parse('A'), Coordinates._parse('1') ((None, None, 'A', None), (None, None, None, '1')) >>> Coordinates._par...
[ "def", "_parse", "(", "coord", ",", "_match", "=", "_regex", ".", "match", ")", ":", "try", ":", "return", "_match", "(", "coord", ")", ".", "groups", "(", ")", "except", "AttributeError", ":", "raise", "ValueError", "(", "coord", ")" ]
Return match groups from single sheet coordinate. >>> Coordinates._parse('A1') ('A', '1', None, None) >>> Coordinates._parse('A'), Coordinates._parse('1') ((None, None, 'A', None), (None, None, None, '1')) >>> Coordinates._parse('spam') Traceback (most recent call last...
[ "Return", "match", "groups", "from", "single", "sheet", "coordinate", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/coordinates.py#L87-L104
xflr6/gsheets
gsheets/coordinates.py
Coordinates._cint
def _cint(col, _map={base26(i): i - 1 for i in range(1, 257)}): """Return zero-based column index from bijective base26 string. >>> Coordinates._cint('Ab') 27 >>> Coordinates._cint('spam') Traceback (most recent call last): ... ValueError: spam """ ...
python
def _cint(col, _map={base26(i): i - 1 for i in range(1, 257)}): """Return zero-based column index from bijective base26 string. >>> Coordinates._cint('Ab') 27 >>> Coordinates._cint('spam') Traceback (most recent call last): ... ValueError: spam """ ...
[ "def", "_cint", "(", "col", ",", "_map", "=", "{", "base26", "(", "i", ")", ":", "i", "-", "1", "for", "i", "in", "range", "(", "1", ",", "257", ")", "}", ")", ":", "try", ":", "return", "_map", "[", "col", ".", "upper", "(", ")", "]", "e...
Return zero-based column index from bijective base26 string. >>> Coordinates._cint('Ab') 27 >>> Coordinates._cint('spam') Traceback (most recent call last): ... ValueError: spam
[ "Return", "zero", "-", "based", "column", "index", "from", "bijective", "base26", "string", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/coordinates.py#L107-L121
xflr6/gsheets
gsheets/coordinates.py
Slice.from_slice
def from_slice(cls, coord): """Return a value fetching callable given a slice of coordinate strings.""" if coord.step is not None: raise NotImplementedError('no slice step support') elif coord.start is not None and coord.stop is not None: return DoubleSlice.from_slice(coo...
python
def from_slice(cls, coord): """Return a value fetching callable given a slice of coordinate strings.""" if coord.step is not None: raise NotImplementedError('no slice step support') elif coord.start is not None and coord.stop is not None: return DoubleSlice.from_slice(coo...
[ "def", "from_slice", "(", "cls", ",", "coord", ")", ":", "if", "coord", ".", "step", "is", "not", "None", ":", "raise", "NotImplementedError", "(", "'no slice step support'", ")", "elif", "coord", ".", "start", "is", "not", "None", "and", "coord", ".", "...
Return a value fetching callable given a slice of coordinate strings.
[ "Return", "a", "value", "fetching", "callable", "given", "a", "slice", "of", "coordinate", "strings", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/coordinates.py#L201-L221
xflr6/gsheets
gsheets/models.py
SpreadSheet.find
def find(self, title): """Return the first worksheet with the given title. Args: title(str): title/name of the worksheet to return Returns: WorkSheet: contained worksheet object Raises: KeyError: if the spreadsheet has no no worksheet with the given `...
python
def find(self, title): """Return the first worksheet with the given title. Args: title(str): title/name of the worksheet to return Returns: WorkSheet: contained worksheet object Raises: KeyError: if the spreadsheet has no no worksheet with the given `...
[ "def", "find", "(", "self", ",", "title", ")", ":", "if", "title", "not", "in", "self", ".", "_titles", ":", "raise", "KeyError", "(", "title", ")", "return", "self", ".", "_titles", "[", "title", "]", "[", "0", "]" ]
Return the first worksheet with the given title. Args: title(str): title/name of the worksheet to return Returns: WorkSheet: contained worksheet object Raises: KeyError: if the spreadsheet has no no worksheet with the given ``title``
[ "Return", "the", "first", "worksheet", "with", "the", "given", "title", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/models.py#L108-L120
xflr6/gsheets
gsheets/models.py
SpreadSheet.findall
def findall(self, title=None): """Return a list of worksheets with the given title. Args: title(str): title/name of the worksheets to return, or ``None`` for all Returns: list: list of contained worksheet instances (possibly empty) """ if title is None: ...
python
def findall(self, title=None): """Return a list of worksheets with the given title. Args: title(str): title/name of the worksheets to return, or ``None`` for all Returns: list: list of contained worksheet instances (possibly empty) """ if title is None: ...
[ "def", "findall", "(", "self", ",", "title", "=", "None", ")", ":", "if", "title", "is", "None", ":", "return", "list", "(", "self", ".", "_sheets", ")", "if", "title", "not", "in", "self", ".", "_titles", ":", "return", "[", "]", "return", "list",...
Return a list of worksheets with the given title. Args: title(str): title/name of the worksheets to return, or ``None`` for all Returns: list: list of contained worksheet instances (possibly empty)
[ "Return", "a", "list", "of", "worksheets", "with", "the", "given", "title", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/models.py#L122-L134
xflr6/gsheets
gsheets/models.py
SpreadSheet.to_csv
def to_csv(self, encoding=export.ENCODING, dialect=export.DIALECT, make_filename=export.MAKE_FILENAME): """Dump all worksheets of the spreadsheet to individual CSV files. Args: encoding (str): result string encoding dialect (str): :mod:`csv` dialect name or object...
python
def to_csv(self, encoding=export.ENCODING, dialect=export.DIALECT, make_filename=export.MAKE_FILENAME): """Dump all worksheets of the spreadsheet to individual CSV files. Args: encoding (str): result string encoding dialect (str): :mod:`csv` dialect name or object...
[ "def", "to_csv", "(", "self", ",", "encoding", "=", "export", ".", "ENCODING", ",", "dialect", "=", "export", ".", "DIALECT", ",", "make_filename", "=", "export", ".", "MAKE_FILENAME", ")", ":", "for", "s", "in", "self", ".", "_sheets", ":", "s", ".", ...
Dump all worksheets of the spreadsheet to individual CSV files. Args: encoding (str): result string encoding dialect (str): :mod:`csv` dialect name or object to use make_filename: template or one-argument callable returning the filename If ``make_filename`` is a str...
[ "Dump", "all", "worksheets", "of", "the", "spreadsheet", "to", "individual", "CSV", "files", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/models.py#L170-L190
xflr6/gsheets
gsheets/models.py
SheetsView.titles
def titles(self, unique=False): """Return a list of contained worksheet titles. Args: unique (bool): drop duplicates Returns: list: list of titles/name strings """ if unique: return tools.uniqued(s.title for s in self._items) return [s...
python
def titles(self, unique=False): """Return a list of contained worksheet titles. Args: unique (bool): drop duplicates Returns: list: list of titles/name strings """ if unique: return tools.uniqued(s.title for s in self._items) return [s...
[ "def", "titles", "(", "self", ",", "unique", "=", "False", ")", ":", "if", "unique", ":", "return", "tools", ".", "uniqued", "(", "s", ".", "title", "for", "s", "in", "self", ".", "_items", ")", "return", "[", "s", ".", "title", "for", "s", "in",...
Return a list of contained worksheet titles. Args: unique (bool): drop duplicates Returns: list: list of titles/name strings
[ "Return", "a", "list", "of", "contained", "worksheet", "titles", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/models.py#L226-L236
xflr6/gsheets
gsheets/models.py
WorkSheet.at
def at(self, row, col): """Return the value at the given cell position. Args: row (int): zero-based row number col (int): zero-based column number Returns: cell value Raises: TypeError: if ``row`` or ``col`` is not an ``int`` Ind...
python
def at(self, row, col): """Return the value at the given cell position. Args: row (int): zero-based row number col (int): zero-based column number Returns: cell value Raises: TypeError: if ``row`` or ``col`` is not an ``int`` Ind...
[ "def", "at", "(", "self", ",", "row", ",", "col", ")", ":", "if", "not", "(", "isinstance", "(", "row", ",", "int", ")", "and", "isinstance", "(", "col", ",", "int", ")", ")", ":", "raise", "TypeError", "(", "row", ",", "col", ")", "return", "s...
Return the value at the given cell position. Args: row (int): zero-based row number col (int): zero-based column number Returns: cell value Raises: TypeError: if ``row`` or ``col`` is not an ``int`` IndexError: if the position is out of ...
[ "Return", "the", "value", "at", "the", "given", "cell", "position", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/models.py#L287-L301
xflr6/gsheets
gsheets/models.py
WorkSheet.values
def values(self, column_major=False): """Return a nested list with the worksheet values. Args: column_major (bool): as list of columns (default list of rows) Returns: list: list of lists with values """ if column_major: return list(map(list, z...
python
def values(self, column_major=False): """Return a nested list with the worksheet values. Args: column_major (bool): as list of columns (default list of rows) Returns: list: list of lists with values """ if column_major: return list(map(list, z...
[ "def", "values", "(", "self", ",", "column_major", "=", "False", ")", ":", "if", "column_major", ":", "return", "list", "(", "map", "(", "list", ",", "zip", "(", "*", "self", ".", "_values", ")", ")", ")", "return", "[", "row", "[", ":", "]", "fo...
Return a nested list with the worksheet values. Args: column_major (bool): as list of columns (default list of rows) Returns: list: list of lists with values
[ "Return", "a", "nested", "list", "with", "the", "worksheet", "values", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/models.py#L303-L313
xflr6/gsheets
gsheets/models.py
WorkSheet.to_csv
def to_csv(self, filename=None, encoding=export.ENCODING, dialect=export.DIALECT, make_filename=export.MAKE_FILENAME): """Dump the worksheet to a CSV file. Args: filename (str): result filename (if ``None`` use ``make_filename``) encoding (str): res...
python
def to_csv(self, filename=None, encoding=export.ENCODING, dialect=export.DIALECT, make_filename=export.MAKE_FILENAME): """Dump the worksheet to a CSV file. Args: filename (str): result filename (if ``None`` use ``make_filename``) encoding (str): res...
[ "def", "to_csv", "(", "self", ",", "filename", "=", "None", ",", "encoding", "=", "export", ".", "ENCODING", ",", "dialect", "=", "export", ".", "DIALECT", ",", "make_filename", "=", "export", ".", "MAKE_FILENAME", ")", ":", "if", "filename", "is", "None...
Dump the worksheet to a CSV file. Args: filename (str): result filename (if ``None`` use ``make_filename``) encoding (str): result string encoding dialect (str): :mod:`csv` dialect name or object to use make_filename: template or one-argument callable returning t...
[ "Dump", "the", "worksheet", "to", "a", "CSV", "file", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/models.py#L358-L395
xflr6/gsheets
gsheets/models.py
WorkSheet.to_frame
def to_frame(self, **kwargs): r"""Return a pandas DataFrame loaded from the worksheet data. Args: \**kwargs: passed to ``pandas.read_csv()`` (e.g. ``header``, ``index_col``) Returns: pandas.DataFrame: new ``DataFrame`` instance """ df = export.write_dataf...
python
def to_frame(self, **kwargs): r"""Return a pandas DataFrame loaded from the worksheet data. Args: \**kwargs: passed to ``pandas.read_csv()`` (e.g. ``header``, ``index_col``) Returns: pandas.DataFrame: new ``DataFrame`` instance """ df = export.write_dataf...
[ "def", "to_frame", "(", "self", ",", "*", "*", "kwargs", ")", ":", "df", "=", "export", ".", "write_dataframe", "(", "self", ".", "_values", ",", "*", "*", "kwargs", ")", "df", ".", "name", "=", "self", ".", "title", "return", "df" ]
r"""Return a pandas DataFrame loaded from the worksheet data. Args: \**kwargs: passed to ``pandas.read_csv()`` (e.g. ``header``, ``index_col``) Returns: pandas.DataFrame: new ``DataFrame`` instance
[ "r", "Return", "a", "pandas", "DataFrame", "loaded", "from", "the", "worksheet", "data", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/models.py#L397-L407
xflr6/gsheets
gsheets/api.py
Sheets.from_files
def from_files(cls, secrets=None, storage=None, scopes=None, no_webserver=False): """Return a spreadsheet collection making OAauth 2.0 credentials. Args: secrets (str): location of secrets file (default: ``%r``) storage (str): location of storage file (default: ``%r``) ...
python
def from_files(cls, secrets=None, storage=None, scopes=None, no_webserver=False): """Return a spreadsheet collection making OAauth 2.0 credentials. Args: secrets (str): location of secrets file (default: ``%r``) storage (str): location of storage file (default: ``%r``) ...
[ "def", "from_files", "(", "cls", ",", "secrets", "=", "None", ",", "storage", "=", "None", ",", "scopes", "=", "None", ",", "no_webserver", "=", "False", ")", ":", "creds", "=", "oauth2", ".", "get_credentials", "(", "scopes", ",", "secrets", ",", "sto...
Return a spreadsheet collection making OAauth 2.0 credentials. Args: secrets (str): location of secrets file (default: ``%r``) storage (str): location of storage file (default: ``%r``) scopes: scope URL(s) or ``'read'`` or ``'write'`` (default: ``%r``) no_webserv...
[ "Return", "a", "spreadsheet", "collection", "making", "OAauth", "2", ".", "0", "credentials", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/api.py#L17-L29
xflr6/gsheets
gsheets/api.py
Sheets.get
def get(self, id_or_url, default=None): """Fetch and return the spreadsheet with the given id or url. Args: id_or_url (str): unique alphanumeric id or URL of the spreadsheet Returns: New SpreadSheet instance or given default if none is found Raises: V...
python
def get(self, id_or_url, default=None): """Fetch and return the spreadsheet with the given id or url. Args: id_or_url (str): unique alphanumeric id or URL of the spreadsheet Returns: New SpreadSheet instance or given default if none is found Raises: V...
[ "def", "get", "(", "self", ",", "id_or_url", ",", "default", "=", "None", ")", ":", "if", "'/'", "in", "id_or_url", ":", "id", "=", "urls", ".", "SheetUrl", ".", "from_string", "(", "id_or_url", ")", ".", "id", "else", ":", "id", "=", "id_or_url", ...
Fetch and return the spreadsheet with the given id or url. Args: id_or_url (str): unique alphanumeric id or URL of the spreadsheet Returns: New SpreadSheet instance or given default if none is found Raises: ValueError: if an URL is given from which no id coul...
[ "Fetch", "and", "return", "the", "spreadsheet", "with", "the", "given", "id", "or", "url", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/api.py#L92-L109
xflr6/gsheets
gsheets/api.py
Sheets.find
def find(self, title): """Fetch and return the first spreadsheet with the given title. Args: title(str): title/name of the spreadsheet to return Returns: SpreadSheet: new SpreadSheet instance Raises: KeyError: if no spreadsheet with the given ``title`...
python
def find(self, title): """Fetch and return the first spreadsheet with the given title. Args: title(str): title/name of the spreadsheet to return Returns: SpreadSheet: new SpreadSheet instance Raises: KeyError: if no spreadsheet with the given ``title`...
[ "def", "find", "(", "self", ",", "title", ")", ":", "files", "=", "backend", ".", "iterfiles", "(", "self", ".", "_drive", ",", "name", "=", "title", ")", "try", ":", "return", "next", "(", "self", "[", "id", "]", "for", "id", ",", "_", "in", "...
Fetch and return the first spreadsheet with the given title. Args: title(str): title/name of the spreadsheet to return Returns: SpreadSheet: new SpreadSheet instance Raises: KeyError: if no spreadsheet with the given ``title`` is found
[ "Fetch", "and", "return", "the", "first", "spreadsheet", "with", "the", "given", "title", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/api.py#L111-L125
xflr6/gsheets
gsheets/api.py
Sheets.findall
def findall(self, title=None): """Fetch and return a list of spreadsheets with the given title. Args: title(str): title/name of the spreadsheets to return, or ``None`` for all Returns: list: list of new SpreadSheet instances (possibly empty) """ if title ...
python
def findall(self, title=None): """Fetch and return a list of spreadsheets with the given title. Args: title(str): title/name of the spreadsheets to return, or ``None`` for all Returns: list: list of new SpreadSheet instances (possibly empty) """ if title ...
[ "def", "findall", "(", "self", ",", "title", "=", "None", ")", ":", "if", "title", "is", "None", ":", "return", "list", "(", "self", ")", "files", "=", "backend", ".", "iterfiles", "(", "self", ".", "_drive", ",", "name", "=", "title", ")", "return...
Fetch and return a list of spreadsheets with the given title. Args: title(str): title/name of the spreadsheets to return, or ``None`` for all Returns: list: list of new SpreadSheet instances (possibly empty)
[ "Fetch", "and", "return", "a", "list", "of", "spreadsheets", "with", "the", "given", "title", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/api.py#L127-L138
xflr6/gsheets
gsheets/api.py
Sheets.titles
def titles(self, unique=False): """Return a list of all available spreadsheet titles. Args: unique (bool): drop duplicates Returns: list: list of title/name strings """ if unique: return tools.uniqued(title for _, title in self.iterfiles()) ...
python
def titles(self, unique=False): """Return a list of all available spreadsheet titles. Args: unique (bool): drop duplicates Returns: list: list of title/name strings """ if unique: return tools.uniqued(title for _, title in self.iterfiles()) ...
[ "def", "titles", "(", "self", ",", "unique", "=", "False", ")", ":", "if", "unique", ":", "return", "tools", ".", "uniqued", "(", "title", "for", "_", ",", "title", "in", "self", ".", "iterfiles", "(", ")", ")", "return", "[", "title", "for", "_", ...
Return a list of all available spreadsheet titles. Args: unique (bool): drop duplicates Returns: list: list of title/name strings
[ "Return", "a", "list", "of", "all", "available", "spreadsheet", "titles", "." ]
train
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/api.py#L156-L166
openstack/python-saharaclient
saharaclient/api/data_sources.py
DataSourceManagerV1.create
def create(self, name, description, data_source_type, url, credential_user=None, credential_pass=None, is_public=None, is_protected=None, s3_credentials=None): """Create a Data Source.""" data = { 'name': name, 'description': description, ...
python
def create(self, name, description, data_source_type, url, credential_user=None, credential_pass=None, is_public=None, is_protected=None, s3_credentials=None): """Create a Data Source.""" data = { 'name': name, 'description': description, ...
[ "def", "create", "(", "self", ",", "name", ",", "description", ",", "data_source_type", ",", "url", ",", "credential_user", "=", "None", ",", "credential_pass", "=", "None", ",", "is_public", "=", "None", ",", "is_protected", "=", "None", ",", "s3_credential...
Create a Data Source.
[ "Create", "a", "Data", "Source", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/data_sources.py#L27-L47
openstack/python-saharaclient
saharaclient/api/data_sources.py
DataSourceManagerV1.update
def update(self, data_source_id, update_data): """Update a Data Source. :param dict update_data: dict that contains fields that should be updated with new values. Fields that can be updated: * name * description * type * url ...
python
def update(self, data_source_id, update_data): """Update a Data Source. :param dict update_data: dict that contains fields that should be updated with new values. Fields that can be updated: * name * description * type * url ...
[ "def", "update", "(", "self", ",", "data_source_id", ",", "update_data", ")", ":", "if", "self", ".", "version", ">=", "2", ":", "UPDATE_FUNC", "=", "self", ".", "_patch", "else", ":", "UPDATE_FUNC", "=", "self", ".", "_update", "return", "UPDATE_FUNC", ...
Update a Data Source. :param dict update_data: dict that contains fields that should be updated with new values. Fields that can be updated: * name * description * type * url * is_public * is_protected * credenti...
[ "Update", "a", "Data", "Source", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/data_sources.py#L65-L90
Enteee/pdml2flow
pdml2flow/autovivification.py
getitem_by_path
def getitem_by_path(d, path): """Access item in d using path. a = { 0: { 1: 'item' } } getitem_by_path(a, [0, 1]) == 'item' """ return reduce( lambda d, k: d[k], path, d )
python
def getitem_by_path(d, path): """Access item in d using path. a = { 0: { 1: 'item' } } getitem_by_path(a, [0, 1]) == 'item' """ return reduce( lambda d, k: d[k], path, d )
[ "def", "getitem_by_path", "(", "d", ",", "path", ")", ":", "return", "reduce", "(", "lambda", "d", ",", "k", ":", "d", "[", "k", "]", ",", "path", ",", "d", ")" ]
Access item in d using path. a = { 0: { 1: 'item' } } getitem_by_path(a, [0, 1]) == 'item'
[ "Access", "item", "in", "d", "using", "path", "." ]
train
https://github.com/Enteee/pdml2flow/blob/bc9efe379b0b2406bfbbbd8e0f678b1f63805c66/pdml2flow/autovivification.py#L7-L17
Enteee/pdml2flow
pdml2flow/autovivification.py
AutoVivification.clean_empty
def clean_empty(self, d=DEFAULT): """Returns a copy of d without empty leaves. https://stackoverflow.com/questions/27973988/python-how-to-remove-all-empty-fields-in-a-nested-dict/35263074 """ if d is DEFAULT: d = self if isinstance(d, list): return [v for...
python
def clean_empty(self, d=DEFAULT): """Returns a copy of d without empty leaves. https://stackoverflow.com/questions/27973988/python-how-to-remove-all-empty-fields-in-a-nested-dict/35263074 """ if d is DEFAULT: d = self if isinstance(d, list): return [v for...
[ "def", "clean_empty", "(", "self", ",", "d", "=", "DEFAULT", ")", ":", "if", "d", "is", "DEFAULT", ":", "d", "=", "self", "if", "isinstance", "(", "d", ",", "list", ")", ":", "return", "[", "v", "for", "v", "in", "(", "self", ".", "clean_empty", ...
Returns a copy of d without empty leaves. https://stackoverflow.com/questions/27973988/python-how-to-remove-all-empty-fields-in-a-nested-dict/35263074
[ "Returns", "a", "copy", "of", "d", "without", "empty", "leaves", "." ]
train
https://github.com/Enteee/pdml2flow/blob/bc9efe379b0b2406bfbbbd8e0f678b1f63805c66/pdml2flow/autovivification.py#L21-L34
Enteee/pdml2flow
pdml2flow/autovivification.py
AutoVivification.compress
def compress(self, d=DEFAULT): """Returns a copy of d with compressed leaves.""" if d is DEFAULT: d = self if isinstance(d, list): l = [v for v in (self.compress(v) for v in d)] try: return list(set(l)) except TypeError: ...
python
def compress(self, d=DEFAULT): """Returns a copy of d with compressed leaves.""" if d is DEFAULT: d = self if isinstance(d, list): l = [v for v in (self.compress(v) for v in d)] try: return list(set(l)) except TypeError: ...
[ "def", "compress", "(", "self", ",", "d", "=", "DEFAULT", ")", ":", "if", "d", "is", "DEFAULT", ":", "d", "=", "self", "if", "isinstance", "(", "d", ",", "list", ")", ":", "l", "=", "[", "v", "for", "v", "in", "(", "self", ".", "compress", "(...
Returns a copy of d with compressed leaves.
[ "Returns", "a", "copy", "of", "d", "with", "compressed", "leaves", "." ]
train
https://github.com/Enteee/pdml2flow/blob/bc9efe379b0b2406bfbbbd8e0f678b1f63805c66/pdml2flow/autovivification.py#L36-L55
Enteee/pdml2flow
pdml2flow/autovivification.py
AutoVivification.cast_dicts
def cast_dicts(self, to=DEFAULT, d=DEFAULT): """Returns a copy of d with all dicts casted to the type 'to'.""" if to is DEFAULT: to = type(self) if d is DEFAULT: d = self if isinstance(d, list): return [v for v in (self.cast_dicts(to, v) for v in d)] ...
python
def cast_dicts(self, to=DEFAULT, d=DEFAULT): """Returns a copy of d with all dicts casted to the type 'to'.""" if to is DEFAULT: to = type(self) if d is DEFAULT: d = self if isinstance(d, list): return [v for v in (self.cast_dicts(to, v) for v in d)] ...
[ "def", "cast_dicts", "(", "self", ",", "to", "=", "DEFAULT", ",", "d", "=", "DEFAULT", ")", ":", "if", "to", "is", "DEFAULT", ":", "to", "=", "type", "(", "self", ")", "if", "d", "is", "DEFAULT", ":", "d", "=", "self", "if", "isinstance", "(", ...
Returns a copy of d with all dicts casted to the type 'to'.
[ "Returns", "a", "copy", "of", "d", "with", "all", "dicts", "casted", "to", "the", "type", "to", "." ]
train
https://github.com/Enteee/pdml2flow/blob/bc9efe379b0b2406bfbbbd8e0f678b1f63805c66/pdml2flow/autovivification.py#L57-L67
Enteee/pdml2flow
pdml2flow/autovivification.py
AutoVivification.merge
def merge(self, b, a=DEFAULT): """Merges b into a recursively, if a is not given: merges into self. also merges lists and: * merge({a:a},{a:b}) = {a:[a,b]} * merge({a:[a]},{a:b}) = {a:[a,b]} * merge({a:a},{a:[b]}) = {a:[a,b]} * merge({a:[a]},{a:[b]}) = {a...
python
def merge(self, b, a=DEFAULT): """Merges b into a recursively, if a is not given: merges into self. also merges lists and: * merge({a:a},{a:b}) = {a:[a,b]} * merge({a:[a]},{a:b}) = {a:[a,b]} * merge({a:a},{a:[b]}) = {a:[a,b]} * merge({a:[a]},{a:[b]}) = {a...
[ "def", "merge", "(", "self", ",", "b", ",", "a", "=", "DEFAULT", ")", ":", "if", "a", "is", "DEFAULT", ":", "a", "=", "self", "for", "key", "in", "b", ":", "if", "key", "in", "a", ":", "if", "isinstance", "(", "a", "[", "key", "]", ",", "di...
Merges b into a recursively, if a is not given: merges into self. also merges lists and: * merge({a:a},{a:b}) = {a:[a,b]} * merge({a:[a]},{a:b}) = {a:[a,b]} * merge({a:a},{a:[b]}) = {a:[a,b]} * merge({a:[a]},{a:[b]}) = {a:[a,b]}
[ "Merges", "b", "into", "a", "recursively", "if", "a", "is", "not", "given", ":", "merges", "into", "self", "." ]
train
https://github.com/Enteee/pdml2flow/blob/bc9efe379b0b2406bfbbbd8e0f678b1f63805c66/pdml2flow/autovivification.py#L69-L95
openstack/python-saharaclient
saharaclient/api/job_binaries.py
JobBinariesManagerV1.create
def create(self, name, url, description=None, extra=None, is_public=None, is_protected=None): """Create a Job Binary. :param dict extra: authentication info needed for some job binaries, containing the keys `user` and `password` for job binary in Swift or the keys...
python
def create(self, name, url, description=None, extra=None, is_public=None, is_protected=None): """Create a Job Binary. :param dict extra: authentication info needed for some job binaries, containing the keys `user` and `password` for job binary in Swift or the keys...
[ "def", "create", "(", "self", ",", "name", ",", "url", ",", "description", "=", "None", ",", "extra", "=", "None", ",", "is_public", "=", "None", ",", "is_protected", "=", "None", ")", ":", "data", "=", "{", "\"name\"", ":", "name", ",", "\"url\"", ...
Create a Job Binary. :param dict extra: authentication info needed for some job binaries, containing the keys `user` and `password` for job binary in Swift or the keys `accesskey`, `secretkey`, and `endpoint` for job binary in S3
[ "Create", "a", "Job", "Binary", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/job_binaries.py#L27-L45
openstack/python-saharaclient
saharaclient/api/job_binaries.py
JobBinariesManagerV1.get_file
def get_file(self, job_binary_id): """Download a Job Binary.""" resp = self.api.get('/job-binaries/%s/data' % job_binary_id) if resp.status_code != 200: self._raise_api_exception(resp) return resp.content
python
def get_file(self, job_binary_id): """Download a Job Binary.""" resp = self.api.get('/job-binaries/%s/data' % job_binary_id) if resp.status_code != 200: self._raise_api_exception(resp) return resp.content
[ "def", "get_file", "(", "self", ",", "job_binary_id", ")", ":", "resp", "=", "self", ".", "api", ".", "get", "(", "'/job-binaries/%s/data'", "%", "job_binary_id", ")", "if", "resp", ".", "status_code", "!=", "200", ":", "self", ".", "_raise_api_exception", ...
Download a Job Binary.
[ "Download", "a", "Job", "Binary", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/job_binaries.py#L63-L69
openstack/python-saharaclient
saharaclient/api/job_binaries.py
JobBinariesManagerV1.update
def update(self, job_binary_id, data): """Update Job Binary. :param dict data: dict that contains fields that should be updated with new values. Fields that can be updated: * name * description * url * is_public * is_protected ...
python
def update(self, job_binary_id, data): """Update Job Binary. :param dict data: dict that contains fields that should be updated with new values. Fields that can be updated: * name * description * url * is_public * is_protected ...
[ "def", "update", "(", "self", ",", "job_binary_id", ",", "data", ")", ":", "if", "self", ".", "version", ">=", "2", ":", "UPDATE_FUNC", "=", "self", ".", "_patch", "else", ":", "UPDATE_FUNC", "=", "self", ".", "_update", "return", "UPDATE_FUNC", "(", "...
Update Job Binary. :param dict data: dict that contains fields that should be updated with new values. Fields that can be updated: * name * description * url * is_public * is_protected * extra - dict with the keys `user` and `passwo...
[ "Update", "Job", "Binary", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/job_binaries.py#L71-L95
Enteee/pdml2flow
pdml2flow/conf.py
Conf.set
def set(conf): """Applies a configuration to the global config object""" for name, value in conf.items(): if value is not None: setattr(Conf, name.upper(), value)
python
def set(conf): """Applies a configuration to the global config object""" for name, value in conf.items(): if value is not None: setattr(Conf, name.upper(), value)
[ "def", "set", "(", "conf", ")", ":", "for", "name", ",", "value", "in", "conf", ".", "items", "(", ")", ":", "if", "value", "is", "not", "None", ":", "setattr", "(", "Conf", ",", "name", ".", "upper", "(", ")", ",", "value", ")" ]
Applies a configuration to the global config object
[ "Applies", "a", "configuration", "to", "the", "global", "config", "object" ]
train
https://github.com/Enteee/pdml2flow/blob/bc9efe379b0b2406bfbbbd8e0f678b1f63805c66/pdml2flow/conf.py#L70-L74
Enteee/pdml2flow
pdml2flow/conf.py
Conf.get
def get(): """Gets the configuration as a dict""" return { attr: getattr(Conf, attr) for attr in dir(Conf()) if not callable(getattr(Conf, attr)) and not attr.startswith("__") }
python
def get(): """Gets the configuration as a dict""" return { attr: getattr(Conf, attr) for attr in dir(Conf()) if not callable(getattr(Conf, attr)) and not attr.startswith("__") }
[ "def", "get", "(", ")", ":", "return", "{", "attr", ":", "getattr", "(", "Conf", ",", "attr", ")", "for", "attr", "in", "dir", "(", "Conf", "(", ")", ")", "if", "not", "callable", "(", "getattr", "(", "Conf", ",", "attr", ")", ")", "and", "not"...
Gets the configuration as a dict
[ "Gets", "the", "configuration", "as", "a", "dict" ]
train
https://github.com/Enteee/pdml2flow/blob/bc9efe379b0b2406bfbbbd8e0f678b1f63805c66/pdml2flow/conf.py#L77-L82
Enteee/pdml2flow
pdml2flow/conf.py
Conf.load
def load(description, add_arguments_cb = lambda x: None, postprocess_conf_cb = lambda x: None): """Loads the global Conf object from command line arguments. Encode the next argument after +plugin to ensure that it does not start with a prefix_char """ argparser = ArgumentParser...
python
def load(description, add_arguments_cb = lambda x: None, postprocess_conf_cb = lambda x: None): """Loads the global Conf object from command line arguments. Encode the next argument after +plugin to ensure that it does not start with a prefix_char """ argparser = ArgumentParser...
[ "def", "load", "(", "description", ",", "add_arguments_cb", "=", "lambda", "x", ":", "None", ",", "postprocess_conf_cb", "=", "lambda", "x", ":", "None", ")", ":", "argparser", "=", "ArgumentParser", "(", "description", "=", "description", ",", "prefix_chars",...
Loads the global Conf object from command line arguments. Encode the next argument after +plugin to ensure that it does not start with a prefix_char
[ "Loads", "the", "global", "Conf", "object", "from", "command", "line", "arguments", "." ]
train
https://github.com/Enteee/pdml2flow/blob/bc9efe379b0b2406bfbbbd8e0f678b1f63805c66/pdml2flow/conf.py#L85-L180
openstack/python-saharaclient
doc/ext/parser.py
_format_usage_without_prefix
def _format_usage_without_prefix(parser): """ Use private argparse APIs to get the usage string without the 'usage: ' prefix. """ fmt = parser._get_formatter() fmt.add_usage(parser.usage, parser._actions, parser._mutually_exclusive_groups, prefix='') return fmt.format_help(...
python
def _format_usage_without_prefix(parser): """ Use private argparse APIs to get the usage string without the 'usage: ' prefix. """ fmt = parser._get_formatter() fmt.add_usage(parser.usage, parser._actions, parser._mutually_exclusive_groups, prefix='') return fmt.format_help(...
[ "def", "_format_usage_without_prefix", "(", "parser", ")", ":", "fmt", "=", "parser", ".", "_get_formatter", "(", ")", "fmt", ".", "add_usage", "(", "parser", ".", "usage", ",", "parser", ".", "_actions", ",", "parser", ".", "_mutually_exclusive_groups", ",", ...
Use private argparse APIs to get the usage string without the 'usage: ' prefix.
[ "Use", "private", "argparse", "APIs", "to", "get", "the", "usage", "string", "without", "the", "usage", ":", "prefix", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/doc/ext/parser.py#L56-L64
openstack/python-saharaclient
saharaclient/api/node_group_templates.py
NodeGroupTemplateManagerV1.update
def update(self, ng_template_id, name=NotUpdated, plugin_name=NotUpdated, hadoop_version=NotUpdated, flavor_id=NotUpdated, description=NotUpdated, volumes_per_node=NotUpdated, volumes_size=NotUpdated, node_processes=NotUpdated, node_configs=NotUpdated, floatin...
python
def update(self, ng_template_id, name=NotUpdated, plugin_name=NotUpdated, hadoop_version=NotUpdated, flavor_id=NotUpdated, description=NotUpdated, volumes_per_node=NotUpdated, volumes_size=NotUpdated, node_processes=NotUpdated, node_configs=NotUpdated, floatin...
[ "def", "update", "(", "self", ",", "ng_template_id", ",", "name", "=", "NotUpdated", ",", "plugin_name", "=", "NotUpdated", ",", "hadoop_version", "=", "NotUpdated", ",", "flavor_id", "=", "NotUpdated", ",", "description", "=", "NotUpdated", ",", "volumes_per_no...
Update a Node Group Template.
[ "Update", "a", "Node", "Group", "Template", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/node_group_templates.py#L100-L134
openstack/python-saharaclient
saharaclient/api/node_group_templates.py
NodeGroupTemplateManagerV2.create
def create(self, name, plugin_name, plugin_version, flavor_id, description=None, volumes_per_node=None, volumes_size=None, node_processes=None, node_configs=None, floating_ip_pool=None, security_groups=None, auto_security_group=None, availability_zone=None, vo...
python
def create(self, name, plugin_name, plugin_version, flavor_id, description=None, volumes_per_node=None, volumes_size=None, node_processes=None, node_configs=None, floating_ip_pool=None, security_groups=None, auto_security_group=None, availability_zone=None, vo...
[ "def", "create", "(", "self", ",", "name", ",", "plugin_name", ",", "plugin_version", ",", "flavor_id", ",", "description", "=", "None", ",", "volumes_per_node", "=", "None", ",", "volumes_size", "=", "None", ",", "node_processes", "=", "None", ",", "node_co...
Create a Node Group Template.
[ "Create", "a", "Node", "Group", "Template", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/node_group_templates.py#L161-L192
openstack/python-saharaclient
saharaclient/api/node_group_templates.py
NodeGroupTemplateManagerV2.update
def update(self, ng_template_id, name=NotUpdated, plugin_name=NotUpdated, plugin_version=NotUpdated, flavor_id=NotUpdated, description=NotUpdated, volumes_per_node=NotUpdated, volumes_size=NotUpdated, node_processes=NotUpdated, node_configs=NotUpdated, floatin...
python
def update(self, ng_template_id, name=NotUpdated, plugin_name=NotUpdated, plugin_version=NotUpdated, flavor_id=NotUpdated, description=NotUpdated, volumes_per_node=NotUpdated, volumes_size=NotUpdated, node_processes=NotUpdated, node_configs=NotUpdated, floatin...
[ "def", "update", "(", "self", ",", "ng_template_id", ",", "name", "=", "NotUpdated", ",", "plugin_name", "=", "NotUpdated", ",", "plugin_version", "=", "NotUpdated", ",", "flavor_id", "=", "NotUpdated", ",", "description", "=", "NotUpdated", ",", "volumes_per_no...
Update a Node Group Template.
[ "Update", "a", "Node", "Group", "Template", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/node_group_templates.py#L194-L236
openstack/python-saharaclient
saharaclient/api/images.py
_ImageManager.update_image
def update_image(self, image_id, user_name, desc=None): """Create or update an Image in Image Registry.""" desc = desc if desc else '' data = {"username": user_name, "description": desc} return self._post('/images/%s' % image_id, data)
python
def update_image(self, image_id, user_name, desc=None): """Create or update an Image in Image Registry.""" desc = desc if desc else '' data = {"username": user_name, "description": desc} return self._post('/images/%s' % image_id, data)
[ "def", "update_image", "(", "self", ",", "image_id", ",", "user_name", ",", "desc", "=", "None", ")", ":", "desc", "=", "desc", "if", "desc", "else", "''", "data", "=", "{", "\"username\"", ":", "user_name", ",", "\"description\"", ":", "desc", "}", "r...
Create or update an Image in Image Registry.
[ "Create", "or", "update", "an", "Image", "in", "Image", "Registry", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/images.py#L40-L46
openstack/python-saharaclient
saharaclient/api/images.py
ImageManagerV1.update_tags
def update_tags(self, image_id, new_tags): """Update an Image tags. :param new_tags: list of tags that will replace currently assigned tags """ # Do not add :param list in the docstring above until this is solved: # https://github.com/sphinx-doc/sp...
python
def update_tags(self, image_id, new_tags): """Update an Image tags. :param new_tags: list of tags that will replace currently assigned tags """ # Do not add :param list in the docstring above until this is solved: # https://github.com/sphinx-doc/sp...
[ "def", "update_tags", "(", "self", ",", "image_id", ",", "new_tags", ")", ":", "# Do not add :param list in the docstring above until this is solved:", "# https://github.com/sphinx-doc/sphinx/issues/2549", "old_image", "=", "self", ".", "get", "(", "image_id", ")", "old_tags"...
Update an Image tags. :param new_tags: list of tags that will replace currently assigned tags
[ "Update", "an", "Image", "tags", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/images.py#L50-L76
openstack/python-saharaclient
saharaclient/osc/plugin.py
build_option_parser
def build_option_parser(parser): """Hook to add global options.""" parser.add_argument( "--os-data-processing-api-version", metavar="<data-processing-api-version>", default=utils.env( 'OS_DATA_PROCESSING_API_VERSION', default=DEFAULT_DATA_PROCESSING_API_VERSION), ...
python
def build_option_parser(parser): """Hook to add global options.""" parser.add_argument( "--os-data-processing-api-version", metavar="<data-processing-api-version>", default=utils.env( 'OS_DATA_PROCESSING_API_VERSION', default=DEFAULT_DATA_PROCESSING_API_VERSION), ...
[ "def", "build_option_parser", "(", "parser", ")", ":", "parser", ".", "add_argument", "(", "\"--os-data-processing-api-version\"", ",", "metavar", "=", "\"<data-processing-api-version>\"", ",", "default", "=", "utils", ".", "env", "(", "'OS_DATA_PROCESSING_API_VERSION'", ...
Hook to add global options.
[ "Hook", "to", "add", "global", "options", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/osc/plugin.py#L51-L68
openstack/python-saharaclient
saharaclient/api/cluster_templates.py
ClusterTemplateManagerV1.create
def create(self, name, plugin_name, hadoop_version, description=None, cluster_configs=None, node_groups=None, anti_affinity=None, net_id=None, default_image_id=None, use_autoconfig=None, shares=None, is_public=None, is_protected=None, domain_name=None): ...
python
def create(self, name, plugin_name, hadoop_version, description=None, cluster_configs=None, node_groups=None, anti_affinity=None, net_id=None, default_image_id=None, use_autoconfig=None, shares=None, is_public=None, is_protected=None, domain_name=None): ...
[ "def", "create", "(", "self", ",", "name", ",", "plugin_name", ",", "hadoop_version", ",", "description", "=", "None", ",", "cluster_configs", "=", "None", ",", "node_groups", "=", "None", ",", "anti_affinity", "=", "None", ",", "net_id", "=", "None", ",",...
Create a Cluster Template.
[ "Create", "a", "Cluster", "Template", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/cluster_templates.py#L27-L43
openstack/python-saharaclient
saharaclient/api/cluster_templates.py
ClusterTemplateManagerV2.update
def update(self, cluster_template_id, name=NotUpdated, plugin_name=NotUpdated, plugin_version=NotUpdated, description=NotUpdated, cluster_configs=NotUpdated, node_groups=NotUpdated, anti_affinity=NotUpdated, net_id=NotUpdated, default_image_id=NotUpdated, ...
python
def update(self, cluster_template_id, name=NotUpdated, plugin_name=NotUpdated, plugin_version=NotUpdated, description=NotUpdated, cluster_configs=NotUpdated, node_groups=NotUpdated, anti_affinity=NotUpdated, net_id=NotUpdated, default_image_id=NotUpdated, ...
[ "def", "update", "(", "self", ",", "cluster_template_id", ",", "name", "=", "NotUpdated", ",", "plugin_name", "=", "NotUpdated", ",", "plugin_version", "=", "NotUpdated", ",", "description", "=", "NotUpdated", ",", "cluster_configs", "=", "NotUpdated", ",", "nod...
Update a Cluster Template.
[ "Update", "a", "Cluster", "Template", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/cluster_templates.py#L136-L163
openstack/python-saharaclient
saharaclient/api/clusters.py
ClusterManagerV1.get
def get(self, cluster_id, show_progress=False): """Get information about a Cluster.""" url = ('/clusters/%(cluster_id)s?%(params)s' % {"cluster_id": cluster_id, "params": parse.urlencode({"show_progress": show_progress})}) return self._get(url, 'cluster')
python
def get(self, cluster_id, show_progress=False): """Get information about a Cluster.""" url = ('/clusters/%(cluster_id)s?%(params)s' % {"cluster_id": cluster_id, "params": parse.urlencode({"show_progress": show_progress})}) return self._get(url, 'cluster')
[ "def", "get", "(", "self", ",", "cluster_id", ",", "show_progress", "=", "False", ")", ":", "url", "=", "(", "'/clusters/%(cluster_id)s?%(params)s'", "%", "{", "\"cluster_id\"", ":", "cluster_id", ",", "\"params\"", ":", "parse", ".", "urlencode", "(", "{", ...
Get information about a Cluster.
[ "Get", "information", "about", "a", "Cluster", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/clusters.py#L125-L131
openstack/python-saharaclient
saharaclient/api/clusters.py
ClusterManagerV1.update
def update(self, cluster_id, name=NotUpdated, description=NotUpdated, is_public=NotUpdated, is_protected=NotUpdated, shares=NotUpdated): """Update a Cluster.""" data = {} self._copy_if_updated(data, name=name, description=description, ...
python
def update(self, cluster_id, name=NotUpdated, description=NotUpdated, is_public=NotUpdated, is_protected=NotUpdated, shares=NotUpdated): """Update a Cluster.""" data = {} self._copy_if_updated(data, name=name, description=description, ...
[ "def", "update", "(", "self", ",", "cluster_id", ",", "name", "=", "NotUpdated", ",", "description", "=", "NotUpdated", ",", "is_public", "=", "NotUpdated", ",", "is_protected", "=", "NotUpdated", ",", "shares", "=", "NotUpdated", ")", ":", "data", "=", "{...
Update a Cluster.
[ "Update", "a", "Cluster", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/clusters.py#L137-L147
openstack/python-saharaclient
saharaclient/api/clusters.py
ClusterManagerV1.verification_update
def verification_update(self, cluster_id, status): """Start a verification for a Cluster.""" data = {'verification': {'status': status}} return self._patch("/clusters/%s" % cluster_id, data)
python
def verification_update(self, cluster_id, status): """Start a verification for a Cluster.""" data = {'verification': {'status': status}} return self._patch("/clusters/%s" % cluster_id, data)
[ "def", "verification_update", "(", "self", ",", "cluster_id", ",", "status", ")", ":", "data", "=", "{", "'verification'", ":", "{", "'status'", ":", "status", "}", "}", "return", "self", ".", "_patch", "(", "\"/clusters/%s\"", "%", "cluster_id", ",", "dat...
Start a verification for a Cluster.
[ "Start", "a", "verification", "for", "a", "Cluster", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/clusters.py#L149-L152
openstack/python-saharaclient
saharaclient/api/clusters.py
ClusterManagerV2.create
def create(self, name, plugin_name, plugin_version, cluster_template_id=None, default_image_id=None, is_transient=None, description=None, cluster_configs=None, node_groups=None, user_keypair_id=None, anti_affinity=None, net_id=None, count=None, ...
python
def create(self, name, plugin_name, plugin_version, cluster_template_id=None, default_image_id=None, is_transient=None, description=None, cluster_configs=None, node_groups=None, user_keypair_id=None, anti_affinity=None, net_id=None, count=None, ...
[ "def", "create", "(", "self", ",", "name", ",", "plugin_name", ",", "plugin_version", ",", "cluster_template_id", "=", "None", ",", "default_image_id", "=", "None", ",", "is_transient", "=", "None", ",", "description", "=", "None", ",", "cluster_configs", "=",...
Launch a Cluster.
[ "Launch", "a", "Cluster", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/clusters.py#L157-L176
openstack/python-saharaclient
doc/ext/cli.py
_get_command
def _get_command(classes): """Associates each command class with command depending on setup.cfg """ commands = {} setup_file = os.path.join( os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')), 'setup.cfg') for line in open(setup_file, 'r'): for cl in classes: ...
python
def _get_command(classes): """Associates each command class with command depending on setup.cfg """ commands = {} setup_file = os.path.join( os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')), 'setup.cfg') for line in open(setup_file, 'r'): for cl in classes: ...
[ "def", "_get_command", "(", "classes", ")", ":", "commands", "=", "{", "}", "setup_file", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(...
Associates each command class with command depending on setup.cfg
[ "Associates", "each", "command", "class", "with", "command", "depending", "on", "setup", ".", "cfg" ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/doc/ext/cli.py#L25-L37
openstack/python-saharaclient
saharaclient/api/base.py
get_json
def get_json(response): """Provide backward compatibility with old versions of requests library.""" json_field_or_function = getattr(response, 'json', None) if callable(json_field_or_function): return response.json() else: return jsonutils.loads(response.content)
python
def get_json(response): """Provide backward compatibility with old versions of requests library.""" json_field_or_function = getattr(response, 'json', None) if callable(json_field_or_function): return response.json() else: return jsonutils.loads(response.content)
[ "def", "get_json", "(", "response", ")", ":", "json_field_or_function", "=", "getattr", "(", "response", ",", "'json'", ",", "None", ")", "if", "callable", "(", "json_field_or_function", ")", ":", "return", "response", ".", "json", "(", ")", "else", ":", "...
Provide backward compatibility with old versions of requests library.
[ "Provide", "backward", "compatibility", "with", "old", "versions", "of", "requests", "library", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/base.py#L239-L246
openstack/python-saharaclient
saharaclient/api/job_binary_internals.py
JobBinaryInternalsManager.create
def create(self, name, data): """Create a Job Binary Internal. :param str data: raw data of script text """ return self._update('/job-binary-internals/%s' % urlparse.quote(name.encode('utf-8')), data, 'job_binary_internal', dump_js...
python
def create(self, name, data): """Create a Job Binary Internal. :param str data: raw data of script text """ return self._update('/job-binary-internals/%s' % urlparse.quote(name.encode('utf-8')), data, 'job_binary_internal', dump_js...
[ "def", "create", "(", "self", ",", "name", ",", "data", ")", ":", "return", "self", ".", "_update", "(", "'/job-binary-internals/%s'", "%", "urlparse", ".", "quote", "(", "name", ".", "encode", "(", "'utf-8'", ")", ")", ",", "data", ",", "'job_binary_int...
Create a Job Binary Internal. :param str data: raw data of script text
[ "Create", "a", "Job", "Binary", "Internal", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/job_binary_internals.py#L29-L36
openstack/python-saharaclient
saharaclient/api/job_binary_internals.py
JobBinaryInternalsManager.update
def update(self, job_binary_id, name=NotUpdated, is_public=NotUpdated, is_protected=NotUpdated): """Update a Job Binary Internal.""" data = {} self._copy_if_updated(data, name=name, is_public=is_public, is_protected=is_protected) return self...
python
def update(self, job_binary_id, name=NotUpdated, is_public=NotUpdated, is_protected=NotUpdated): """Update a Job Binary Internal.""" data = {} self._copy_if_updated(data, name=name, is_public=is_public, is_protected=is_protected) return self...
[ "def", "update", "(", "self", ",", "job_binary_id", ",", "name", "=", "NotUpdated", ",", "is_public", "=", "NotUpdated", ",", "is_protected", "=", "NotUpdated", ")", ":", "data", "=", "{", "}", "self", ".", "_copy_if_updated", "(", "data", ",", "name", "...
Update a Job Binary Internal.
[ "Update", "a", "Job", "Binary", "Internal", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/job_binary_internals.py#L55-L63
Enteee/pdml2flow
pdml2flow/utils.py
autoconvert
def autoconvert(string): """Try to convert variables into datatypes.""" for fn in (boolify, int, float): try: return fn(string) except ValueError: pass return string
python
def autoconvert(string): """Try to convert variables into datatypes.""" for fn in (boolify, int, float): try: return fn(string) except ValueError: pass return string
[ "def", "autoconvert", "(", "string", ")", ":", "for", "fn", "in", "(", "boolify", ",", "int", ",", "float", ")", ":", "try", ":", "return", "fn", "(", "string", ")", "except", "ValueError", ":", "pass", "return", "string" ]
Try to convert variables into datatypes.
[ "Try", "to", "convert", "variables", "into", "datatypes", "." ]
train
https://github.com/Enteee/pdml2flow/blob/bc9efe379b0b2406bfbbbd8e0f678b1f63805c66/pdml2flow/utils.py#L11-L18
Enteee/pdml2flow
pdml2flow/utils.py
call_plugin
def call_plugin(plugin, f, *args, **kwargs): """Calls function f from plugin, returns None if plugin does not implement f.""" try: getattr(plugin, f) except AttributeError: return None if kwargs: getattr(plugin, f)( *args, **kwargs ) else: ...
python
def call_plugin(plugin, f, *args, **kwargs): """Calls function f from plugin, returns None if plugin does not implement f.""" try: getattr(plugin, f) except AttributeError: return None if kwargs: getattr(plugin, f)( *args, **kwargs ) else: ...
[ "def", "call_plugin", "(", "plugin", ",", "f", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "getattr", "(", "plugin", ",", "f", ")", "except", "AttributeError", ":", "return", "None", "if", "kwargs", ":", "getattr", "(", "plugin",...
Calls function f from plugin, returns None if plugin does not implement f.
[ "Calls", "function", "f", "from", "plugin", "returns", "None", "if", "plugin", "does", "not", "implement", "f", "." ]
train
https://github.com/Enteee/pdml2flow/blob/bc9efe379b0b2406bfbbbd8e0f678b1f63805c66/pdml2flow/utils.py#L20-L34
openstack/python-saharaclient
saharaclient/api/job_executions.py
JobExecutionsManager.create
def create(self, job_id, cluster_id, input_id=None, output_id=None, configs=None, interface=None, is_public=None, is_protected=None): """Launch a Job.""" url = "/jobs/%s/execute" % job_id data = { "cluster_id": cluster_id, } self._copy_...
python
def create(self, job_id, cluster_id, input_id=None, output_id=None, configs=None, interface=None, is_public=None, is_protected=None): """Launch a Job.""" url = "/jobs/%s/execute" % job_id data = { "cluster_id": cluster_id, } self._copy_...
[ "def", "create", "(", "self", ",", "job_id", ",", "cluster_id", ",", "input_id", "=", "None", ",", "output_id", "=", "None", ",", "configs", "=", "None", ",", "interface", "=", "None", ",", "is_public", "=", "None", ",", "is_protected", "=", "None", ")...
Launch a Job.
[ "Launch", "a", "Job", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/job_executions.py#L43-L57
openstack/python-saharaclient
saharaclient/api/job_executions.py
JobExecutionsManager.update
def update(self, obj_id, is_public=NotUpdated, is_protected=NotUpdated): """Update a Job Execution.""" data = {} self._copy_if_updated(data, is_public=is_public, is_protected=is_protected) return self._patch('/job-executions/%s' % obj_id, data)
python
def update(self, obj_id, is_public=NotUpdated, is_protected=NotUpdated): """Update a Job Execution.""" data = {} self._copy_if_updated(data, is_public=is_public, is_protected=is_protected) return self._patch('/job-executions/%s' % obj_id, data)
[ "def", "update", "(", "self", ",", "obj_id", ",", "is_public", "=", "NotUpdated", ",", "is_protected", "=", "NotUpdated", ")", ":", "data", "=", "{", "}", "self", ".", "_copy_if_updated", "(", "data", ",", "is_public", "=", "is_public", ",", "is_protected"...
Update a Job Execution.
[ "Update", "a", "Job", "Execution", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/job_executions.py#L59-L65
datacamp/antlr-tsql
antlr_tsql/ast.py
AstVisitor.visitTerminal
def visitTerminal(self, ctx): """Converts case insensitive keywords and identifiers to lowercase Identifiers in quotes are not lowercased even though there is case sensitivity in quotes for identifiers, to prevent lowercasing quoted values. """ text = str(super().visitTerm...
python
def visitTerminal(self, ctx): """Converts case insensitive keywords and identifiers to lowercase Identifiers in quotes are not lowercased even though there is case sensitivity in quotes for identifiers, to prevent lowercasing quoted values. """ text = str(super().visitTerm...
[ "def", "visitTerminal", "(", "self", ",", "ctx", ")", ":", "text", "=", "str", "(", "super", "(", ")", ".", "visitTerminal", "(", "ctx", ")", ")", "quotes", "=", "[", "\"'\"", ",", "'\"'", "]", "if", "not", "(", "text", "[", "0", "]", "in", "qu...
Converts case insensitive keywords and identifiers to lowercase Identifiers in quotes are not lowercased even though there is case sensitivity in quotes for identifiers, to prevent lowercasing quoted values.
[ "Converts", "case", "insensitive", "keywords", "and", "identifiers", "to", "lowercase", "Identifiers", "in", "quotes", "are", "not", "lowercased", "even", "though", "there", "is", "case", "sensitivity", "in", "quotes", "for", "identifiers", "to", "prevent", "lower...
train
https://github.com/datacamp/antlr-tsql/blob/b048bfb084bad6b8e5f111a9127e38c2b07fd714/antlr_tsql/ast.py#L499-L508
openstack/python-saharaclient
saharaclient/api/plugins.py
_PluginManager.list
def list(self, search_opts=None): """Get a list of Plugins.""" query = base.get_query_string(search_opts) return self._list('/plugins%s' % query, 'plugins')
python
def list(self, search_opts=None): """Get a list of Plugins.""" query = base.get_query_string(search_opts) return self._list('/plugins%s' % query, 'plugins')
[ "def", "list", "(", "self", ",", "search_opts", "=", "None", ")", ":", "query", "=", "base", ".", "get_query_string", "(", "search_opts", ")", "return", "self", ".", "_list", "(", "'/plugins%s'", "%", "query", ",", "'plugins'", ")" ]
Get a list of Plugins.
[ "Get", "a", "list", "of", "Plugins", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/plugins.py#L34-L37
openstack/python-saharaclient
saharaclient/api/plugins.py
PluginManagerV1.convert_to_cluster_template
def convert_to_cluster_template(self, plugin_name, hadoop_version, template_name, filecontent): """Convert to cluster template Create Cluster Template directly, avoiding Cluster Template mechanism. """ resp = self.api.post('/plugins/%s/%s/conv...
python
def convert_to_cluster_template(self, plugin_name, hadoop_version, template_name, filecontent): """Convert to cluster template Create Cluster Template directly, avoiding Cluster Template mechanism. """ resp = self.api.post('/plugins/%s/%s/conv...
[ "def", "convert_to_cluster_template", "(", "self", ",", "plugin_name", ",", "hadoop_version", ",", "template_name", ",", "filecontent", ")", ":", "resp", "=", "self", ".", "api", ".", "post", "(", "'/plugins/%s/%s/convert-config/%s'", "%", "(", "plugin_name", ",",...
Convert to cluster template Create Cluster Template directly, avoiding Cluster Template mechanism.
[ "Convert", "to", "cluster", "template" ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/plugins.py#L60-L77
openstack/python-saharaclient
saharaclient/api/jobs.py
JobsManagerV1.create
def create(self, name, type, mains=None, libs=None, description=None, interface=None, is_public=None, is_protected=None): """Create a Job.""" data = { 'name': name, 'type': type } self._copy_if_defined(data, description=description, mains=mains, ...
python
def create(self, name, type, mains=None, libs=None, description=None, interface=None, is_public=None, is_protected=None): """Create a Job.""" data = { 'name': name, 'type': type } self._copy_if_defined(data, description=description, mains=mains, ...
[ "def", "create", "(", "self", ",", "name", ",", "type", ",", "mains", "=", "None", ",", "libs", "=", "None", ",", "description", "=", "None", ",", "interface", "=", "None", ",", "is_public", "=", "None", ",", "is_protected", "=", "None", ")", ":", ...
Create a Job.
[ "Create", "a", "Job", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/jobs.py#L27-L39
openstack/python-saharaclient
saharaclient/api/jobs.py
JobsManagerV1.list
def list(self, search_opts=None, limit=None, marker=None, sort_by=None, reverse=None): """Get a list of Jobs.""" query = base.get_query_string(search_opts, limit=limit, marker=marker, sort_by=sort_by, reverse=reverse) url = "/jobs%s" % query ...
python
def list(self, search_opts=None, limit=None, marker=None, sort_by=None, reverse=None): """Get a list of Jobs.""" query = base.get_query_string(search_opts, limit=limit, marker=marker, sort_by=sort_by, reverse=reverse) url = "/jobs%s" % query ...
[ "def", "list", "(", "self", ",", "search_opts", "=", "None", ",", "limit", "=", "None", ",", "marker", "=", "None", ",", "sort_by", "=", "None", ",", "reverse", "=", "None", ")", ":", "query", "=", "base", ".", "get_query_string", "(", "search_opts", ...
Get a list of Jobs.
[ "Get", "a", "list", "of", "Jobs", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/jobs.py#L41-L47
openstack/python-saharaclient
saharaclient/api/jobs.py
JobsManagerV1.update
def update(self, job_id, name=NotUpdated, description=NotUpdated, is_public=NotUpdated, is_protected=NotUpdated): """Update a Job.""" data = {} self._copy_if_updated(data, name=name, description=description, is_public=is_public, is_protected=is_prote...
python
def update(self, job_id, name=NotUpdated, description=NotUpdated, is_public=NotUpdated, is_protected=NotUpdated): """Update a Job.""" data = {} self._copy_if_updated(data, name=name, description=description, is_public=is_public, is_protected=is_prote...
[ "def", "update", "(", "self", ",", "job_id", ",", "name", "=", "NotUpdated", ",", "description", "=", "NotUpdated", ",", "is_public", "=", "NotUpdated", ",", "is_protected", "=", "NotUpdated", ")", ":", "data", "=", "{", "}", "self", ".", "_copy_if_updated...
Update a Job.
[ "Update", "a", "Job", "." ]
train
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/jobs.py#L61-L69
OpenCageData/python-opencage-geocoder
opencage/geocoder.py
_query_for_reverse_geocoding
def _query_for_reverse_geocoding(lat, lng): """ Given a lat & lng, what's the string search query. If the API changes, change this function. Only for internal use. """ # have to do some stupid f/Decimal/str stuff to (a) ensure we get as much # decimal places as the user already specified and (b...
python
def _query_for_reverse_geocoding(lat, lng): """ Given a lat & lng, what's the string search query. If the API changes, change this function. Only for internal use. """ # have to do some stupid f/Decimal/str stuff to (a) ensure we get as much # decimal places as the user already specified and (b...
[ "def", "_query_for_reverse_geocoding", "(", "lat", ",", "lng", ")", ":", "# have to do some stupid f/Decimal/str stuff to (a) ensure we get as much", "# decimal places as the user already specified and (b) to ensure we don't", "# get e-5 stuff", "return", "\"{0:f},{1:f}\"", ".", "format"...
Given a lat & lng, what's the string search query. If the API changes, change this function. Only for internal use.
[ "Given", "a", "lat", "&", "lng", "what", "s", "the", "string", "search", "query", "." ]
train
https://github.com/OpenCageData/python-opencage-geocoder/blob/21f102a33a036ed29e08e8375eceaa1bb4ec5009/opencage/geocoder.py#L155-L164
OpenCageData/python-opencage-geocoder
opencage/geocoder.py
floatify_latlng
def floatify_latlng(input_value): """ Work around a JSON dict with string, not float, lat/lngs. Given anything (list/dict/etc) it will return that thing again, *but* any dict (at any level) that has only 2 elements lat & lng, will be replaced with the lat & lng turned into floats. If the API r...
python
def floatify_latlng(input_value): """ Work around a JSON dict with string, not float, lat/lngs. Given anything (list/dict/etc) it will return that thing again, *but* any dict (at any level) that has only 2 elements lat & lng, will be replaced with the lat & lng turned into floats. If the API r...
[ "def", "floatify_latlng", "(", "input_value", ")", ":", "if", "isinstance", "(", "input_value", ",", "collections", ".", "Mapping", ")", ":", "if", "len", "(", "input_value", ")", "==", "2", "and", "sorted", "(", "input_value", ".", "keys", "(", ")", ")"...
Work around a JSON dict with string, not float, lat/lngs. Given anything (list/dict/etc) it will return that thing again, *but* any dict (at any level) that has only 2 elements lat & lng, will be replaced with the lat & lng turned into floats. If the API returns the lat/lng as strings, and not numbers...
[ "Work", "around", "a", "JSON", "dict", "with", "string", "not", "float", "lat", "/", "lngs", "." ]
train
https://github.com/OpenCageData/python-opencage-geocoder/blob/21f102a33a036ed29e08e8375eceaa1bb4ec5009/opencage/geocoder.py#L179-L199