repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
theolind/pymysensors
mysensors/ota.py
prepare_fw
def prepare_fw(bin_string): """Check that firmware is valid and return dict with binary data.""" pads = len(bin_string) % 128 # 128 bytes per page for atmega328 for _ in range(128 - pads): # pad up to even 128 bytes bin_string += b'\xff' fware = { 'blocks': int(len(bin_string) / FIRMWA...
python
def prepare_fw(bin_string): """Check that firmware is valid and return dict with binary data.""" pads = len(bin_string) % 128 # 128 bytes per page for atmega328 for _ in range(128 - pads): # pad up to even 128 bytes bin_string += b'\xff' fware = { 'blocks': int(len(bin_string) / FIRMWA...
[ "def", "prepare_fw", "(", "bin_string", ")", ":", "pads", "=", "len", "(", "bin_string", ")", "%", "128", "# 128 bytes per page for atmega328", "for", "_", "in", "range", "(", "128", "-", "pads", ")", ":", "# pad up to even 128 bytes", "bin_string", "+=", "b'\...
Check that firmware is valid and return dict with binary data.
[ "Check", "that", "firmware", "is", "valid", "and", "return", "dict", "with", "binary", "data", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/ota.py#L59-L69
train
62,600
theolind/pymysensors
mysensors/ota.py
OTAFirmware._get_fw
def _get_fw(self, msg, updates, req_fw_type=None, req_fw_ver=None): """Get firmware type, version and a dict holding binary data.""" fw_type = None fw_ver = None if not isinstance(updates, tuple): updates = (updates, ) for store in updates: fw_id = store.p...
python
def _get_fw(self, msg, updates, req_fw_type=None, req_fw_ver=None): """Get firmware type, version and a dict holding binary data.""" fw_type = None fw_ver = None if not isinstance(updates, tuple): updates = (updates, ) for store in updates: fw_id = store.p...
[ "def", "_get_fw", "(", "self", ",", "msg", ",", "updates", ",", "req_fw_type", "=", "None", ",", "req_fw_ver", "=", "None", ")", ":", "fw_type", "=", "None", "fw_ver", "=", "None", "if", "not", "isinstance", "(", "updates", ",", "tuple", ")", ":", "u...
Get firmware type, version and a dict holding binary data.
[ "Get", "firmware", "type", "version", "and", "a", "dict", "holding", "binary", "data", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/ota.py#L84-L108
train
62,601
theolind/pymysensors
mysensors/ota.py
OTAFirmware.respond_fw
def respond_fw(self, msg): """Respond to a firmware request.""" req_fw_type, req_fw_ver, req_blk = fw_hex_to_int(msg.payload, 3) _LOGGER.debug( 'Received firmware request with firmware type %s, ' 'firmware version %s, block index %s', req_fw_type, req_fw_ver, ...
python
def respond_fw(self, msg): """Respond to a firmware request.""" req_fw_type, req_fw_ver, req_blk = fw_hex_to_int(msg.payload, 3) _LOGGER.debug( 'Received firmware request with firmware type %s, ' 'firmware version %s, block index %s', req_fw_type, req_fw_ver, ...
[ "def", "respond_fw", "(", "self", ",", "msg", ")", ":", "req_fw_type", ",", "req_fw_ver", ",", "req_blk", "=", "fw_hex_to_int", "(", "msg", ".", "payload", ",", "3", ")", "_LOGGER", ".", "debug", "(", "'Received firmware request with firmware type %s, '", "'firm...
Respond to a firmware request.
[ "Respond", "to", "a", "firmware", "request", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/ota.py#L110-L128
train
62,602
theolind/pymysensors
mysensors/ota.py
OTAFirmware.respond_fw_config
def respond_fw_config(self, msg): """Respond to a firmware config request.""" (req_fw_type, req_fw_ver, req_blocks, req_crc, bloader_ver) = fw_hex_to_int(msg.payload, 5) _LOGGER.debug( 'Received firmware config request with firmware type %s, ' ...
python
def respond_fw_config(self, msg): """Respond to a firmware config request.""" (req_fw_type, req_fw_ver, req_blocks, req_crc, bloader_ver) = fw_hex_to_int(msg.payload, 5) _LOGGER.debug( 'Received firmware config request with firmware type %s, ' ...
[ "def", "respond_fw_config", "(", "self", ",", "msg", ")", ":", "(", "req_fw_type", ",", "req_fw_ver", ",", "req_blocks", ",", "req_crc", ",", "bloader_ver", ")", "=", "fw_hex_to_int", "(", "msg", ".", "payload", ",", "5", ")", "_LOGGER", ".", "debug", "(...
Respond to a firmware config request.
[ "Respond", "to", "a", "firmware", "config", "request", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/ota.py#L130-L157
train
62,603
theolind/pymysensors
mysensors/ota.py
OTAFirmware.make_update
def make_update(self, nids, fw_type, fw_ver, fw_bin=None): """Start firmware update process for one or more node_id.""" try: fw_type, fw_ver = int(fw_type), int(fw_ver) except ValueError: _LOGGER.error( 'Firmware type %s or version %s not valid, ' ...
python
def make_update(self, nids, fw_type, fw_ver, fw_bin=None): """Start firmware update process for one or more node_id.""" try: fw_type, fw_ver = int(fw_type), int(fw_ver) except ValueError: _LOGGER.error( 'Firmware type %s or version %s not valid, ' ...
[ "def", "make_update", "(", "self", ",", "nids", ",", "fw_type", ",", "fw_ver", ",", "fw_bin", "=", "None", ")", ":", "try", ":", "fw_type", ",", "fw_ver", "=", "int", "(", "fw_type", ")", ",", "int", "(", "fw_ver", ")", "except", "ValueError", ":", ...
Start firmware update process for one or more node_id.
[ "Start", "firmware", "update", "process", "for", "one", "or", "more", "node_id", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/ota.py#L159-L184
train
62,604
theolind/pymysensors
mysensors/handler.py
handle_smartsleep
def handle_smartsleep(msg): """Process a message before going back to smartsleep.""" while msg.gateway.sensors[msg.node_id].queue: msg.gateway.add_job( str, msg.gateway.sensors[msg.node_id].queue.popleft()) for child in msg.gateway.sensors[msg.node_id].children.values(): new_chil...
python
def handle_smartsleep(msg): """Process a message before going back to smartsleep.""" while msg.gateway.sensors[msg.node_id].queue: msg.gateway.add_job( str, msg.gateway.sensors[msg.node_id].queue.popleft()) for child in msg.gateway.sensors[msg.node_id].children.values(): new_chil...
[ "def", "handle_smartsleep", "(", "msg", ")", ":", "while", "msg", ".", "gateway", ".", "sensors", "[", "msg", ".", "node_id", "]", ".", "queue", ":", "msg", ".", "gateway", ".", "add_job", "(", "str", ",", "msg", ".", "gateway", ".", "sensors", "[", ...
Process a message before going back to smartsleep.
[ "Process", "a", "message", "before", "going", "back", "to", "smartsleep", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L14-L28
train
62,605
theolind/pymysensors
mysensors/handler.py
handle_presentation
def handle_presentation(msg): """Process a presentation message.""" if msg.child_id == SYSTEM_CHILD_ID: # this is a presentation of the sensor platform sensorid = msg.gateway.add_sensor(msg.node_id) if sensorid is None: return None msg.gateway.sensors[msg.node_id].typ...
python
def handle_presentation(msg): """Process a presentation message.""" if msg.child_id == SYSTEM_CHILD_ID: # this is a presentation of the sensor platform sensorid = msg.gateway.add_sensor(msg.node_id) if sensorid is None: return None msg.gateway.sensors[msg.node_id].typ...
[ "def", "handle_presentation", "(", "msg", ")", ":", "if", "msg", ".", "child_id", "==", "SYSTEM_CHILD_ID", ":", "# this is a presentation of the sensor platform", "sensorid", "=", "msg", ".", "gateway", ".", "add_sensor", "(", "msg", ".", "node_id", ")", "if", "...
Process a presentation message.
[ "Process", "a", "presentation", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L32-L55
train
62,606
theolind/pymysensors
mysensors/handler.py
handle_set
def handle_set(msg): """Process a set message.""" if not msg.gateway.is_sensor(msg.node_id, msg.child_id): return None msg.gateway.sensors[msg.node_id].set_child_value( msg.child_id, msg.sub_type, msg.payload) if msg.gateway.sensors[msg.node_id].new_state: msg.gateway.sensors[msg...
python
def handle_set(msg): """Process a set message.""" if not msg.gateway.is_sensor(msg.node_id, msg.child_id): return None msg.gateway.sensors[msg.node_id].set_child_value( msg.child_id, msg.sub_type, msg.payload) if msg.gateway.sensors[msg.node_id].new_state: msg.gateway.sensors[msg...
[ "def", "handle_set", "(", "msg", ")", ":", "if", "not", "msg", ".", "gateway", ".", "is_sensor", "(", "msg", ".", "node_id", ",", "msg", ".", "child_id", ")", ":", "return", "None", "msg", ".", "gateway", ".", "sensors", "[", "msg", ".", "node_id", ...
Process a set message.
[ "Process", "a", "set", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L59-L76
train
62,607
theolind/pymysensors
mysensors/handler.py
handle_req
def handle_req(msg): """Process a req message. This will return the value if it exists. If no value exists, nothing is returned. """ if not msg.gateway.is_sensor(msg.node_id, msg.child_id): return None value = msg.gateway.sensors[msg.node_id].children[ msg.child_id].values.get(m...
python
def handle_req(msg): """Process a req message. This will return the value if it exists. If no value exists, nothing is returned. """ if not msg.gateway.is_sensor(msg.node_id, msg.child_id): return None value = msg.gateway.sensors[msg.node_id].children[ msg.child_id].values.get(m...
[ "def", "handle_req", "(", "msg", ")", ":", "if", "not", "msg", ".", "gateway", ".", "is_sensor", "(", "msg", ".", "node_id", ",", "msg", ".", "child_id", ")", ":", "return", "None", "value", "=", "msg", ".", "gateway", ".", "sensors", "[", "msg", "...
Process a req message. This will return the value if it exists. If no value exists, nothing is returned.
[ "Process", "a", "req", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L80-L93
train
62,608
theolind/pymysensors
mysensors/handler.py
handle_internal
def handle_internal(msg): """Process an internal message.""" internal = msg.gateway.const.Internal(msg.sub_type) handler = internal.get_handler(msg.gateway.handlers) if handler is None: return None return handler(msg)
python
def handle_internal(msg): """Process an internal message.""" internal = msg.gateway.const.Internal(msg.sub_type) handler = internal.get_handler(msg.gateway.handlers) if handler is None: return None return handler(msg)
[ "def", "handle_internal", "(", "msg", ")", ":", "internal", "=", "msg", ".", "gateway", ".", "const", ".", "Internal", "(", "msg", ".", "sub_type", ")", "handler", "=", "internal", ".", "get_handler", "(", "msg", ".", "gateway", ".", "handlers", ")", "...
Process an internal message.
[ "Process", "an", "internal", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L97-L103
train
62,609
theolind/pymysensors
mysensors/handler.py
handle_stream
def handle_stream(msg): """Process a stream type message.""" if not msg.gateway.is_sensor(msg.node_id): return None stream = msg.gateway.const.Stream(msg.sub_type) handler = stream.get_handler(msg.gateway.handlers) if handler is None: return None return handler(msg)
python
def handle_stream(msg): """Process a stream type message.""" if not msg.gateway.is_sensor(msg.node_id): return None stream = msg.gateway.const.Stream(msg.sub_type) handler = stream.get_handler(msg.gateway.handlers) if handler is None: return None return handler(msg)
[ "def", "handle_stream", "(", "msg", ")", ":", "if", "not", "msg", ".", "gateway", ".", "is_sensor", "(", "msg", ".", "node_id", ")", ":", "return", "None", "stream", "=", "msg", ".", "gateway", ".", "const", ".", "Stream", "(", "msg", ".", "sub_type"...
Process a stream type message.
[ "Process", "a", "stream", "type", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L107-L115
train
62,610
theolind/pymysensors
mysensors/handler.py
handle_id_request
def handle_id_request(msg): """Process an internal id request message.""" node_id = msg.gateway.add_sensor() return msg.copy( ack=0, sub_type=msg.gateway.const.Internal['I_ID_RESPONSE'], payload=node_id) if node_id is not None else None
python
def handle_id_request(msg): """Process an internal id request message.""" node_id = msg.gateway.add_sensor() return msg.copy( ack=0, sub_type=msg.gateway.const.Internal['I_ID_RESPONSE'], payload=node_id) if node_id is not None else None
[ "def", "handle_id_request", "(", "msg", ")", ":", "node_id", "=", "msg", ".", "gateway", ".", "add_sensor", "(", ")", "return", "msg", ".", "copy", "(", "ack", "=", "0", ",", "sub_type", "=", "msg", ".", "gateway", ".", "const", ".", "Internal", "[",...
Process an internal id request message.
[ "Process", "an", "internal", "id", "request", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L131-L136
train
62,611
theolind/pymysensors
mysensors/handler.py
handle_time
def handle_time(msg): """Process an internal time request message.""" return msg.copy(ack=0, payload=calendar.timegm(time.localtime()))
python
def handle_time(msg): """Process an internal time request message.""" return msg.copy(ack=0, payload=calendar.timegm(time.localtime()))
[ "def", "handle_time", "(", "msg", ")", ":", "return", "msg", ".", "copy", "(", "ack", "=", "0", ",", "payload", "=", "calendar", ".", "timegm", "(", "time", ".", "localtime", "(", ")", ")", ")" ]
Process an internal time request message.
[ "Process", "an", "internal", "time", "request", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L146-L148
train
62,612
theolind/pymysensors
mysensors/handler.py
handle_battery_level
def handle_battery_level(msg): """Process an internal battery level message.""" if not msg.gateway.is_sensor(msg.node_id): return None msg.gateway.sensors[msg.node_id].battery_level = msg.payload msg.gateway.alert(msg) return None
python
def handle_battery_level(msg): """Process an internal battery level message.""" if not msg.gateway.is_sensor(msg.node_id): return None msg.gateway.sensors[msg.node_id].battery_level = msg.payload msg.gateway.alert(msg) return None
[ "def", "handle_battery_level", "(", "msg", ")", ":", "if", "not", "msg", ".", "gateway", ".", "is_sensor", "(", "msg", ".", "node_id", ")", ":", "return", "None", "msg", ".", "gateway", ".", "sensors", "[", "msg", ".", "node_id", "]", ".", "battery_lev...
Process an internal battery level message.
[ "Process", "an", "internal", "battery", "level", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L152-L158
train
62,613
theolind/pymysensors
mysensors/handler.py
handle_sketch_name
def handle_sketch_name(msg): """Process an internal sketch name message.""" if not msg.gateway.is_sensor(msg.node_id): return None msg.gateway.sensors[msg.node_id].sketch_name = msg.payload msg.gateway.alert(msg) return None
python
def handle_sketch_name(msg): """Process an internal sketch name message.""" if not msg.gateway.is_sensor(msg.node_id): return None msg.gateway.sensors[msg.node_id].sketch_name = msg.payload msg.gateway.alert(msg) return None
[ "def", "handle_sketch_name", "(", "msg", ")", ":", "if", "not", "msg", ".", "gateway", ".", "is_sensor", "(", "msg", ".", "node_id", ")", ":", "return", "None", "msg", ".", "gateway", ".", "sensors", "[", "msg", ".", "node_id", "]", ".", "sketch_name",...
Process an internal sketch name message.
[ "Process", "an", "internal", "sketch", "name", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L162-L168
train
62,614
theolind/pymysensors
mysensors/handler.py
handle_sketch_version
def handle_sketch_version(msg): """Process an internal sketch version message.""" if not msg.gateway.is_sensor(msg.node_id): return None msg.gateway.sensors[msg.node_id].sketch_version = msg.payload msg.gateway.alert(msg) return None
python
def handle_sketch_version(msg): """Process an internal sketch version message.""" if not msg.gateway.is_sensor(msg.node_id): return None msg.gateway.sensors[msg.node_id].sketch_version = msg.payload msg.gateway.alert(msg) return None
[ "def", "handle_sketch_version", "(", "msg", ")", ":", "if", "not", "msg", ".", "gateway", ".", "is_sensor", "(", "msg", ".", "node_id", ")", ":", "return", "None", "msg", ".", "gateway", ".", "sensors", "[", "msg", ".", "node_id", "]", ".", "sketch_ver...
Process an internal sketch version message.
[ "Process", "an", "internal", "sketch", "version", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L172-L178
train
62,615
theolind/pymysensors
mysensors/handler.py
handle_log_message
def handle_log_message(msg): # pylint: disable=useless-return """Process an internal log message.""" msg.gateway.can_log = True _LOGGER.debug( 'n:%s c:%s t:%s s:%s p:%s', msg.node_id, msg.child_id, msg.type, msg.sub_type, msg.payload) return None
python
def handle_log_message(msg): # pylint: disable=useless-return """Process an internal log message.""" msg.gateway.can_log = True _LOGGER.debug( 'n:%s c:%s t:%s s:%s p:%s', msg.node_id, msg.child_id, msg.type, msg.sub_type, msg.payload) return None
[ "def", "handle_log_message", "(", "msg", ")", ":", "# pylint: disable=useless-return", "msg", ".", "gateway", ".", "can_log", "=", "True", "_LOGGER", ".", "debug", "(", "'n:%s c:%s t:%s s:%s p:%s'", ",", "msg", ".", "node_id", ",", "msg", ".", "child_id", ",", ...
Process an internal log message.
[ "Process", "an", "internal", "log", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L182-L188
train
62,616
theolind/pymysensors
mqtt.py
MQTT.publish
def publish(self, topic, payload, qos, retain): """Publish an MQTT message.""" self._mqttc.publish(topic, payload, qos, retain)
python
def publish(self, topic, payload, qos, retain): """Publish an MQTT message.""" self._mqttc.publish(topic, payload, qos, retain)
[ "def", "publish", "(", "self", ",", "topic", ",", "payload", ",", "qos", ",", "retain", ")", ":", "self", ".", "_mqttc", ".", "publish", "(", "topic", ",", "payload", ",", "qos", ",", "retain", ")" ]
Publish an MQTT message.
[ "Publish", "an", "MQTT", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mqtt.py#L18-L20
train
62,617
theolind/pymysensors
mqtt.py
MQTT.subscribe
def subscribe(self, topic, callback, qos): """Subscribe to an MQTT topic.""" if topic in self.topics: return def _message_callback(mqttc, userdata, msg): """Callback added to callback list for received message.""" callback(msg.topic, msg.payload.decode('utf-8...
python
def subscribe(self, topic, callback, qos): """Subscribe to an MQTT topic.""" if topic in self.topics: return def _message_callback(mqttc, userdata, msg): """Callback added to callback list for received message.""" callback(msg.topic, msg.payload.decode('utf-8...
[ "def", "subscribe", "(", "self", ",", "topic", ",", "callback", ",", "qos", ")", ":", "if", "topic", "in", "self", ".", "topics", ":", "return", "def", "_message_callback", "(", "mqttc", ",", "userdata", ",", "msg", ")", ":", "\"\"\"Callback added to callb...
Subscribe to an MQTT topic.
[ "Subscribe", "to", "an", "MQTT", "topic", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mqtt.py#L22-L33
train
62,618
theolind/pymysensors
mysensors/gateway_serial.py
SerialGateway._connect
def _connect(self): """Connect to the serial port. This should be run in a new thread.""" while self.protocol: _LOGGER.info('Trying to connect to %s', self.port) try: ser = serial.serial_for_url( self.port, self.baud, timeout=self.timeout) ...
python
def _connect(self): """Connect to the serial port. This should be run in a new thread.""" while self.protocol: _LOGGER.info('Trying to connect to %s', self.port) try: ser = serial.serial_for_url( self.port, self.baud, timeout=self.timeout) ...
[ "def", "_connect", "(", "self", ")", ":", "while", "self", ".", "protocol", ":", "_LOGGER", ".", "info", "(", "'Trying to connect to %s'", ",", "self", ".", "port", ")", "try", ":", "ser", "=", "serial", ".", "serial_for_url", "(", "self", ".", "port", ...
Connect to the serial port. This should be run in a new thread.
[ "Connect", "to", "the", "serial", "port", ".", "This", "should", "be", "run", "in", "a", "new", "thread", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/gateway_serial.py#L44-L66
train
62,619
theolind/pymysensors
mysensors/gateway_serial.py
AsyncSerialGateway._connect
def _connect(self): """Connect to the serial port.""" try: while True: _LOGGER.info('Trying to connect to %s', self.port) try: yield from serial_asyncio.create_serial_connection( self.loop, lambda: self.protocol, sel...
python
def _connect(self): """Connect to the serial port.""" try: while True: _LOGGER.info('Trying to connect to %s', self.port) try: yield from serial_asyncio.create_serial_connection( self.loop, lambda: self.protocol, sel...
[ "def", "_connect", "(", "self", ")", ":", "try", ":", "while", "True", ":", "_LOGGER", ".", "info", "(", "'Trying to connect to %s'", ",", "self", ".", "port", ")", "try", ":", "yield", "from", "serial_asyncio", ".", "create_serial_connection", "(", "self", ...
Connect to the serial port.
[ "Connect", "to", "the", "serial", "port", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/gateway_serial.py#L79-L96
train
62,620
theolind/pymysensors
mysensors/validation.py
is_version
def is_version(value): """Validate that value is a valid version string.""" try: value = str(value) if not parse_ver('1.4') <= parse_ver(value): raise ValueError() return value except (AttributeError, TypeError, ValueError): raise vol.Invalid( '{} is n...
python
def is_version(value): """Validate that value is a valid version string.""" try: value = str(value) if not parse_ver('1.4') <= parse_ver(value): raise ValueError() return value except (AttributeError, TypeError, ValueError): raise vol.Invalid( '{} is n...
[ "def", "is_version", "(", "value", ")", ":", "try", ":", "value", "=", "str", "(", "value", ")", "if", "not", "parse_ver", "(", "'1.4'", ")", "<=", "parse_ver", "(", "value", ")", ":", "raise", "ValueError", "(", ")", "return", "value", "except", "("...
Validate that value is a valid version string.
[ "Validate", "that", "value", "is", "a", "valid", "version", "string", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/validation.py#L15-L24
train
62,621
theolind/pymysensors
mysensors/validation.py
is_battery_level
def is_battery_level(value): """Validate that value is a valid battery level integer.""" try: value = percent_int(value) return value except vol.Invalid: _LOGGER.warning( '%s is not a valid battery level, falling back to battery level 0', value) return...
python
def is_battery_level(value): """Validate that value is a valid battery level integer.""" try: value = percent_int(value) return value except vol.Invalid: _LOGGER.warning( '%s is not a valid battery level, falling back to battery level 0', value) return...
[ "def", "is_battery_level", "(", "value", ")", ":", "try", ":", "value", "=", "percent_int", "(", "value", ")", "return", "value", "except", "vol", ".", "Invalid", ":", "_LOGGER", ".", "warning", "(", "'%s is not a valid battery level, falling back to battery level 0...
Validate that value is a valid battery level integer.
[ "Validate", "that", "value", "is", "a", "valid", "battery", "level", "integer", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/validation.py#L38-L47
train
62,622
theolind/pymysensors
mysensors/validation.py
is_heartbeat
def is_heartbeat(value): """Validate that value is a valid heartbeat integer.""" try: value = vol.Coerce(int)(value) return value except vol.Invalid: _LOGGER.warning( '%s is not a valid heartbeat value, falling back to heartbeat 0', value) return 0
python
def is_heartbeat(value): """Validate that value is a valid heartbeat integer.""" try: value = vol.Coerce(int)(value) return value except vol.Invalid: _LOGGER.warning( '%s is not a valid heartbeat value, falling back to heartbeat 0', value) return 0
[ "def", "is_heartbeat", "(", "value", ")", ":", "try", ":", "value", "=", "vol", ".", "Coerce", "(", "int", ")", "(", "value", ")", "return", "value", "except", "vol", ".", "Invalid", ":", "_LOGGER", ".", "warning", "(", "'%s is not a valid heartbeat value,...
Validate that value is a valid heartbeat integer.
[ "Validate", "that", "value", "is", "a", "valid", "heartbeat", "integer", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/validation.py#L50-L59
train
62,623
thusoy/python-crypt
pcrypt.py
mksalt
def mksalt(method=None, rounds=None): """Generate a salt for the specified method. If not specified, the strongest available method will be used. """ if method is None: method = methods[0] salt = ['${0}$'.format(method.ident) if method.ident else ''] if rounds: salt.append('round...
python
def mksalt(method=None, rounds=None): """Generate a salt for the specified method. If not specified, the strongest available method will be used. """ if method is None: method = methods[0] salt = ['${0}$'.format(method.ident) if method.ident else ''] if rounds: salt.append('round...
[ "def", "mksalt", "(", "method", "=", "None", ",", "rounds", "=", "None", ")", ":", "if", "method", "is", "None", ":", "method", "=", "methods", "[", "0", "]", "salt", "=", "[", "'${0}$'", ".", "format", "(", "method", ".", "ident", ")", "if", "me...
Generate a salt for the specified method. If not specified, the strongest available method will be used.
[ "Generate", "a", "salt", "for", "the", "specified", "method", ".", "If", "not", "specified", "the", "strongest", "available", "method", "will", "be", "used", "." ]
0835f7568c14762890cea70b7605d04b3459e4a0
https://github.com/thusoy/python-crypt/blob/0835f7568c14762890cea70b7605d04b3459e4a0/pcrypt.py#L46-L56
train
62,624
thusoy/python-crypt
pcrypt.py
double_prompt_for_plaintext_password
def double_prompt_for_plaintext_password(): """Get the desired password from the user through a double prompt.""" password = 1 password_repeat = 2 while password != password_repeat: password = getpass.getpass('Enter password: ') password_repeat = getpass.getpass('Repeat password: ') ...
python
def double_prompt_for_plaintext_password(): """Get the desired password from the user through a double prompt.""" password = 1 password_repeat = 2 while password != password_repeat: password = getpass.getpass('Enter password: ') password_repeat = getpass.getpass('Repeat password: ') ...
[ "def", "double_prompt_for_plaintext_password", "(", ")", ":", "password", "=", "1", "password_repeat", "=", "2", "while", "password", "!=", "password_repeat", ":", "password", "=", "getpass", ".", "getpass", "(", "'Enter password: '", ")", "password_repeat", "=", ...
Get the desired password from the user through a double prompt.
[ "Get", "the", "desired", "password", "from", "the", "user", "through", "a", "double", "prompt", "." ]
0835f7568c14762890cea70b7605d04b3459e4a0
https://github.com/thusoy/python-crypt/blob/0835f7568c14762890cea70b7605d04b3459e4a0/pcrypt.py#L286-L295
train
62,625
theolind/pymysensors
mysensors/__init__.py
Gateway.logic
def logic(self, data): """Parse the data and respond to it appropriately. Response is returned to the caller and has to be sent data as a mysensors command string. """ try: msg = Message(data, self) msg.validate(self.protocol_version) except (Valu...
python
def logic(self, data): """Parse the data and respond to it appropriately. Response is returned to the caller and has to be sent data as a mysensors command string. """ try: msg = Message(data, self) msg.validate(self.protocol_version) except (Valu...
[ "def", "logic", "(", "self", ",", "data", ")", ":", "try", ":", "msg", "=", "Message", "(", "data", ",", "self", ")", "msg", ".", "validate", "(", "self", ".", "protocol_version", ")", "except", "(", "ValueError", ",", "vol", ".", "Invalid", ")", "...
Parse the data and respond to it appropriately. Response is returned to the caller and has to be sent data as a mysensors command string.
[ "Parse", "the", "data", "and", "respond", "to", "it", "appropriately", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L57-L75
train
62,626
theolind/pymysensors
mysensors/__init__.py
Gateway.alert
def alert(self, msg): """Tell anyone who wants to know that a sensor was updated.""" if self.event_callback is not None: try: self.event_callback(msg) except Exception as exception: # pylint: disable=broad-except _LOGGER.exception(exception) ...
python
def alert(self, msg): """Tell anyone who wants to know that a sensor was updated.""" if self.event_callback is not None: try: self.event_callback(msg) except Exception as exception: # pylint: disable=broad-except _LOGGER.exception(exception) ...
[ "def", "alert", "(", "self", ",", "msg", ")", ":", "if", "self", ".", "event_callback", "is", "not", "None", ":", "try", ":", "self", ".", "event_callback", "(", "msg", ")", "except", "Exception", "as", "exception", ":", "# pylint: disable=broad-except", "...
Tell anyone who wants to know that a sensor was updated.
[ "Tell", "anyone", "who", "wants", "to", "know", "that", "a", "sensor", "was", "updated", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L77-L86
train
62,627
theolind/pymysensors
mysensors/__init__.py
Gateway._get_next_id
def _get_next_id(self): """Return the next available sensor id.""" if self.sensors: next_id = max(self.sensors.keys()) + 1 else: next_id = 1 if next_id <= self.const.MAX_NODE_ID: return next_id return None
python
def _get_next_id(self): """Return the next available sensor id.""" if self.sensors: next_id = max(self.sensors.keys()) + 1 else: next_id = 1 if next_id <= self.const.MAX_NODE_ID: return next_id return None
[ "def", "_get_next_id", "(", "self", ")", ":", "if", "self", ".", "sensors", ":", "next_id", "=", "max", "(", "self", ".", "sensors", ".", "keys", "(", ")", ")", "+", "1", "else", ":", "next_id", "=", "1", "if", "next_id", "<=", "self", ".", "cons...
Return the next available sensor id.
[ "Return", "the", "next", "available", "sensor", "id", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L88-L96
train
62,628
theolind/pymysensors
mysensors/__init__.py
Gateway.add_sensor
def add_sensor(self, sensorid=None): """Add a sensor to the gateway.""" if sensorid is None: sensorid = self._get_next_id() if sensorid is not None and sensorid not in self.sensors: self.sensors[sensorid] = Sensor(sensorid) return sensorid if sensorid in self.sens...
python
def add_sensor(self, sensorid=None): """Add a sensor to the gateway.""" if sensorid is None: sensorid = self._get_next_id() if sensorid is not None and sensorid not in self.sensors: self.sensors[sensorid] = Sensor(sensorid) return sensorid if sensorid in self.sens...
[ "def", "add_sensor", "(", "self", ",", "sensorid", "=", "None", ")", ":", "if", "sensorid", "is", "None", ":", "sensorid", "=", "self", ".", "_get_next_id", "(", ")", "if", "sensorid", "is", "not", "None", "and", "sensorid", "not", "in", "self", ".", ...
Add a sensor to the gateway.
[ "Add", "a", "sensor", "to", "the", "gateway", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L98-L104
train
62,629
theolind/pymysensors
mysensors/__init__.py
Gateway.is_sensor
def is_sensor(self, sensorid, child_id=None): """Return True if a sensor and its child exist.""" ret = sensorid in self.sensors if not ret: _LOGGER.warning('Node %s is unknown', sensorid) if ret and child_id is not None: ret = child_id in self.sensors[sensorid].ch...
python
def is_sensor(self, sensorid, child_id=None): """Return True if a sensor and its child exist.""" ret = sensorid in self.sensors if not ret: _LOGGER.warning('Node %s is unknown', sensorid) if ret and child_id is not None: ret = child_id in self.sensors[sensorid].ch...
[ "def", "is_sensor", "(", "self", ",", "sensorid", ",", "child_id", "=", "None", ")", ":", "ret", "=", "sensorid", "in", "self", ".", "sensors", "if", "not", "ret", ":", "_LOGGER", ".", "warning", "(", "'Node %s is unknown'", ",", "sensorid", ")", "if", ...
Return True if a sensor and its child exist.
[ "Return", "True", "if", "a", "sensor", "and", "its", "child", "exist", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L106-L124
train
62,630
theolind/pymysensors
mysensors/__init__.py
Gateway.run_job
def run_job(self, job=None): """Run a job, either passed in or from the queue. A job is a tuple of function and optional args. Keyword arguments can be passed via use of functools.partial. The job should return a string that should be sent by the gateway protocol. The function will ...
python
def run_job(self, job=None): """Run a job, either passed in or from the queue. A job is a tuple of function and optional args. Keyword arguments can be passed via use of functools.partial. The job should return a string that should be sent by the gateway protocol. The function will ...
[ "def", "run_job", "(", "self", ",", "job", "=", "None", ")", ":", "if", "job", "is", "None", ":", "if", "not", "self", ".", "queue", ":", "return", "None", "job", "=", "self", ".", "queue", ".", "popleft", "(", ")", "start", "=", "timer", "(", ...
Run a job, either passed in or from the queue. A job is a tuple of function and optional args. Keyword arguments can be passed via use of functools.partial. The job should return a string that should be sent by the gateway protocol. The function will be called with the arguments and the...
[ "Run", "a", "job", "either", "passed", "in", "or", "from", "the", "queue", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L137-L157
train
62,631
theolind/pymysensors
mysensors/__init__.py
Gateway.set_child_value
def set_child_value( self, sensor_id, child_id, value_type, value, **kwargs): """Add a command to set a sensor value, to the queue. A queued command will be sent to the sensor when the gateway thread has sent all previously queued commands. If the sensor attribute new_state...
python
def set_child_value( self, sensor_id, child_id, value_type, value, **kwargs): """Add a command to set a sensor value, to the queue. A queued command will be sent to the sensor when the gateway thread has sent all previously queued commands. If the sensor attribute new_state...
[ "def", "set_child_value", "(", "self", ",", "sensor_id", ",", "child_id", ",", "value_type", ",", "value", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "is_sensor", "(", "sensor_id", ",", "child_id", ")", ":", "return", "if", "self", "....
Add a command to set a sensor value, to the queue. A queued command will be sent to the sensor when the gateway thread has sent all previously queued commands. If the sensor attribute new_state returns True, the command will be buffered in a queue on the sensor, and only the internal s...
[ "Add", "a", "command", "to", "set", "a", "sensor", "value", "to", "the", "queue", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L168-L189
train
62,632
theolind/pymysensors
mysensors/__init__.py
ThreadingGateway._poll_queue
def _poll_queue(self): """Poll the queue for work.""" while not self._stop_event.is_set(): reply = self.run_job() self.send(reply) if self.queue: continue time.sleep(0.02)
python
def _poll_queue(self): """Poll the queue for work.""" while not self._stop_event.is_set(): reply = self.run_job() self.send(reply) if self.queue: continue time.sleep(0.02)
[ "def", "_poll_queue", "(", "self", ")", ":", "while", "not", "self", ".", "_stop_event", ".", "is_set", "(", ")", ":", "reply", "=", "self", ".", "run_job", "(", ")", "self", ".", "send", "(", "reply", ")", "if", "self", ".", "queue", ":", "continu...
Poll the queue for work.
[ "Poll", "the", "queue", "for", "work", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L236-L243
train
62,633
theolind/pymysensors
mysensors/__init__.py
ThreadingGateway.stop
def stop(self): """Stop the background thread.""" self._stop_event.set() if not self.persistence: return if self._cancel_save is not None: self._cancel_save() self._cancel_save = None self.persistence.save_sensors()
python
def stop(self): """Stop the background thread.""" self._stop_event.set() if not self.persistence: return if self._cancel_save is not None: self._cancel_save() self._cancel_save = None self.persistence.save_sensors()
[ "def", "stop", "(", "self", ")", ":", "self", ".", "_stop_event", ".", "set", "(", ")", "if", "not", "self", ".", "persistence", ":", "return", "if", "self", ".", "_cancel_save", "is", "not", "None", ":", "self", ".", "_cancel_save", "(", ")", "self"...
Stop the background thread.
[ "Stop", "the", "background", "thread", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L262-L270
train
62,634
theolind/pymysensors
mysensors/__init__.py
ThreadingGateway.update_fw
def update_fw(self, nids, fw_type, fw_ver, fw_path=None): """Update firwmare of all node_ids in nids.""" fw_bin = None if fw_path: fw_bin = load_fw(fw_path) if not fw_bin: return self.ota.make_update(nids, fw_type, fw_ver, fw_bin)
python
def update_fw(self, nids, fw_type, fw_ver, fw_path=None): """Update firwmare of all node_ids in nids.""" fw_bin = None if fw_path: fw_bin = load_fw(fw_path) if not fw_bin: return self.ota.make_update(nids, fw_type, fw_ver, fw_bin)
[ "def", "update_fw", "(", "self", ",", "nids", ",", "fw_type", ",", "fw_ver", ",", "fw_path", "=", "None", ")", ":", "fw_bin", "=", "None", "if", "fw_path", ":", "fw_bin", "=", "load_fw", "(", "fw_path", ")", "if", "not", "fw_bin", ":", "return", "sel...
Update firwmare of all node_ids in nids.
[ "Update", "firwmare", "of", "all", "node_ids", "in", "nids", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L272-L279
train
62,635
theolind/pymysensors
mysensors/__init__.py
BaseTransportGateway._disconnect
def _disconnect(self): """Disconnect from the transport.""" if not self.protocol or not self.protocol.transport: self.protocol = None # Make sure protocol is None return _LOGGER.info('Disconnecting from gateway') self.protocol.transport.close() self.proto...
python
def _disconnect(self): """Disconnect from the transport.""" if not self.protocol or not self.protocol.transport: self.protocol = None # Make sure protocol is None return _LOGGER.info('Disconnecting from gateway') self.protocol.transport.close() self.proto...
[ "def", "_disconnect", "(", "self", ")", ":", "if", "not", "self", ".", "protocol", "or", "not", "self", ".", "protocol", ".", "transport", ":", "self", ".", "protocol", "=", "None", "# Make sure protocol is None", "return", "_LOGGER", ".", "info", "(", "'D...
Disconnect from the transport.
[ "Disconnect", "from", "the", "transport", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L294-L301
train
62,636
theolind/pymysensors
mysensors/__init__.py
BaseTransportGateway.send
def send(self, message): """Write a message to the gateway.""" if not message or not self.protocol or not self.protocol.transport: return if not self.can_log: _LOGGER.debug('Sending %s', message.strip()) try: self.protocol.transport.write(message.encod...
python
def send(self, message): """Write a message to the gateway.""" if not message or not self.protocol or not self.protocol.transport: return if not self.can_log: _LOGGER.debug('Sending %s', message.strip()) try: self.protocol.transport.write(message.encod...
[ "def", "send", "(", "self", ",", "message", ")", ":", "if", "not", "message", "or", "not", "self", ".", "protocol", "or", "not", "self", ".", "protocol", ".", "transport", ":", "return", "if", "not", "self", ".", "can_log", ":", "_LOGGER", ".", "debu...
Write a message to the gateway.
[ "Write", "a", "message", "to", "the", "gateway", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L303-L316
train
62,637
theolind/pymysensors
mysensors/__init__.py
BaseAsyncGateway.stop
def stop(self): """Stop the gateway.""" _LOGGER.info('Stopping gateway') self._disconnect() if self.connect_task and not self.connect_task.cancelled(): self.connect_task.cancel() self.connect_task = None if not self.persistence: return ...
python
def stop(self): """Stop the gateway.""" _LOGGER.info('Stopping gateway') self._disconnect() if self.connect_task and not self.connect_task.cancelled(): self.connect_task.cancel() self.connect_task = None if not self.persistence: return ...
[ "def", "stop", "(", "self", ")", ":", "_LOGGER", ".", "info", "(", "'Stopping gateway'", ")", "self", ".", "_disconnect", "(", ")", "if", "self", ".", "connect_task", "and", "not", "self", ".", "connect_task", ".", "cancelled", "(", ")", ":", "self", "...
Stop the gateway.
[ "Stop", "the", "gateway", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L350-L363
train
62,638
theolind/pymysensors
mysensors/__init__.py
BaseAsyncGateway.add_job
def add_job(self, func, *args): """Add a job that should return a reply to be sent. A job is a tuple of function and optional args. Keyword arguments can be passed via use of functools.partial. The job should return a string that should be sent by the gateway protocol. The asyn...
python
def add_job(self, func, *args): """Add a job that should return a reply to be sent. A job is a tuple of function and optional args. Keyword arguments can be passed via use of functools.partial. The job should return a string that should be sent by the gateway protocol. The asyn...
[ "def", "add_job", "(", "self", ",", "func", ",", "*", "args", ")", ":", "job", "=", "func", ",", "args", "reply", "=", "self", ".", "run_job", "(", "job", ")", "self", ".", "send", "(", "reply", ")" ]
Add a job that should return a reply to be sent. A job is a tuple of function and optional args. Keyword arguments can be passed via use of functools.partial. The job should return a string that should be sent by the gateway protocol. The async version of this method will send the repl...
[ "Add", "a", "job", "that", "should", "return", "a", "reply", "to", "be", "sent", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L365-L376
train
62,639
theolind/pymysensors
mysensors/__init__.py
BaseMySensorsProtocol.connection_made
def connection_made(self, transport): """Handle created connection.""" super().connection_made(transport) if hasattr(self.transport, 'serial'): _LOGGER.info('Connected to %s', self.transport.serial) else: _LOGGER.info('Connected to %s', self.transport)
python
def connection_made(self, transport): """Handle created connection.""" super().connection_made(transport) if hasattr(self.transport, 'serial'): _LOGGER.info('Connected to %s', self.transport.serial) else: _LOGGER.info('Connected to %s', self.transport)
[ "def", "connection_made", "(", "self", ",", "transport", ")", ":", "super", "(", ")", ".", "connection_made", "(", "transport", ")", "if", "hasattr", "(", "self", ".", "transport", ",", "'serial'", ")", ":", "_LOGGER", ".", "info", "(", "'Connected to %s'"...
Handle created connection.
[ "Handle", "created", "connection", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L425-L431
train
62,640
theolind/pymysensors
mysensors/__init__.py
BaseMySensorsProtocol.handle_line
def handle_line(self, line): """Handle incoming string data one line at a time.""" if not self.gateway.can_log: _LOGGER.debug('Receiving %s', line) self.gateway.add_job(self.gateway.logic, line)
python
def handle_line(self, line): """Handle incoming string data one line at a time.""" if not self.gateway.can_log: _LOGGER.debug('Receiving %s', line) self.gateway.add_job(self.gateway.logic, line)
[ "def", "handle_line", "(", "self", ",", "line", ")", ":", "if", "not", "self", ".", "gateway", ".", "can_log", ":", "_LOGGER", ".", "debug", "(", "'Receiving %s'", ",", "line", ")", "self", ".", "gateway", ".", "add_job", "(", "self", ".", "gateway", ...
Handle incoming string data one line at a time.
[ "Handle", "incoming", "string", "data", "one", "line", "at", "a", "time", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L433-L437
train
62,641
theolind/pymysensors
mysensors/sensor.py
Sensor.add_child_sensor
def add_child_sensor(self, child_id, child_type, description=''): """Create and add a child sensor.""" if child_id in self.children: _LOGGER.warning( 'child_id %s already exists in children of node %s, ' 'cannot add child', child_id, self.sensor_id) ...
python
def add_child_sensor(self, child_id, child_type, description=''): """Create and add a child sensor.""" if child_id in self.children: _LOGGER.warning( 'child_id %s already exists in children of node %s, ' 'cannot add child', child_id, self.sensor_id) ...
[ "def", "add_child_sensor", "(", "self", ",", "child_id", ",", "child_type", ",", "description", "=", "''", ")", ":", "if", "child_id", "in", "self", ".", "children", ":", "_LOGGER", ".", "warning", "(", "'child_id %s already exists in children of node %s, '", "'ca...
Create and add a child sensor.
[ "Create", "and", "add", "a", "child", "sensor", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/sensor.py#L93-L102
train
62,642
theolind/pymysensors
mysensors/sensor.py
Sensor.set_child_value
def set_child_value(self, child_id, value_type, value, **kwargs): """Set a child sensor's value.""" children = kwargs.get('children', self.children) if not isinstance(children, dict) or child_id not in children: return None msg_type = kwargs.get('msg_type', 1) ack = k...
python
def set_child_value(self, child_id, value_type, value, **kwargs): """Set a child sensor's value.""" children = kwargs.get('children', self.children) if not isinstance(children, dict) or child_id not in children: return None msg_type = kwargs.get('msg_type', 1) ack = k...
[ "def", "set_child_value", "(", "self", ",", "child_id", ",", "value_type", ",", "value", ",", "*", "*", "kwargs", ")", ":", "children", "=", "kwargs", ".", "get", "(", "'children'", ",", "self", ".", "children", ")", "if", "not", "isinstance", "(", "ch...
Set a child sensor's value.
[ "Set", "a", "child", "sensor", "s", "value", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/sensor.py#L104-L129
train
62,643
theolind/pymysensors
mysensors/sensor.py
ChildSensor.get_schema
def get_schema(self, protocol_version): """Return the child schema for the correct const version.""" const = get_const(protocol_version) custom_schema = vol.Schema({ typ.value: const.VALID_SETREQ[typ] for typ in const.VALID_TYPES[const.Presentation.S_CUSTOM]}) ret...
python
def get_schema(self, protocol_version): """Return the child schema for the correct const version.""" const = get_const(protocol_version) custom_schema = vol.Schema({ typ.value: const.VALID_SETREQ[typ] for typ in const.VALID_TYPES[const.Presentation.S_CUSTOM]}) ret...
[ "def", "get_schema", "(", "self", ",", "protocol_version", ")", ":", "const", "=", "get_const", "(", "protocol_version", ")", "custom_schema", "=", "vol", ".", "Schema", "(", "{", "typ", ".", "value", ":", "const", ".", "VALID_SETREQ", "[", "typ", "]", "...
Return the child schema for the correct const version.
[ "Return", "the", "child", "schema", "for", "the", "correct", "const", "version", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/sensor.py#L157-L165
train
62,644
theolind/pymysensors
mysensors/sensor.py
ChildSensor.validate
def validate(self, protocol_version, values=None): """Validate child value types and values against protocol_version.""" if values is None: values = self.values return self.get_schema(protocol_version)(values)
python
def validate(self, protocol_version, values=None): """Validate child value types and values against protocol_version.""" if values is None: values = self.values return self.get_schema(protocol_version)(values)
[ "def", "validate", "(", "self", ",", "protocol_version", ",", "values", "=", "None", ")", ":", "if", "values", "is", "None", ":", "values", "=", "self", ".", "values", "return", "self", ".", "get_schema", "(", "protocol_version", ")", "(", "values", ")" ...
Validate child value types and values against protocol_version.
[ "Validate", "child", "value", "types", "and", "values", "against", "protocol_version", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/sensor.py#L167-L171
train
62,645
happyleavesaoc/python-myusps
myusps/__init__.py
_get_shipped_from
def _get_shipped_from(row): """Get where package was shipped from.""" try: spans = row.find('div', {'id': 'coltextR2'}).find_all('span') if len(spans) < 2: return None return spans[1].string except AttributeError: return None
python
def _get_shipped_from(row): """Get where package was shipped from.""" try: spans = row.find('div', {'id': 'coltextR2'}).find_all('span') if len(spans) < 2: return None return spans[1].string except AttributeError: return None
[ "def", "_get_shipped_from", "(", "row", ")", ":", "try", ":", "spans", "=", "row", ".", "find", "(", "'div'", ",", "{", "'id'", ":", "'coltextR2'", "}", ")", ".", "find_all", "(", "'span'", ")", "if", "len", "(", "spans", ")", "<", "2", ":", "ret...
Get where package was shipped from.
[ "Get", "where", "package", "was", "shipped", "from", "." ]
827e74f25d1c1ef0149bb7fda7c606297b743c02
https://github.com/happyleavesaoc/python-myusps/blob/827e74f25d1c1ef0149bb7fda7c606297b743c02/myusps/__init__.py#L78-L86
train
62,646
happyleavesaoc/python-myusps
myusps/__init__.py
_get_status_timestamp
def _get_status_timestamp(row): """Get latest package timestamp.""" try: divs = row.find('div', {'id': 'coltextR3'}).find_all('div') if len(divs) < 2: return None timestamp_string = divs[1].string except AttributeError: return None try: return parse(ti...
python
def _get_status_timestamp(row): """Get latest package timestamp.""" try: divs = row.find('div', {'id': 'coltextR3'}).find_all('div') if len(divs) < 2: return None timestamp_string = divs[1].string except AttributeError: return None try: return parse(ti...
[ "def", "_get_status_timestamp", "(", "row", ")", ":", "try", ":", "divs", "=", "row", ".", "find", "(", "'div'", ",", "{", "'id'", ":", "'coltextR3'", "}", ")", ".", "find_all", "(", "'div'", ")", "if", "len", "(", "divs", ")", "<", "2", ":", "re...
Get latest package timestamp.
[ "Get", "latest", "package", "timestamp", "." ]
827e74f25d1c1ef0149bb7fda7c606297b743c02
https://github.com/happyleavesaoc/python-myusps/blob/827e74f25d1c1ef0149bb7fda7c606297b743c02/myusps/__init__.py#L89-L101
train
62,647
happyleavesaoc/python-myusps
myusps/__init__.py
_get_driver
def _get_driver(driver_type): """Get webdriver.""" if driver_type == 'phantomjs': return webdriver.PhantomJS(service_log_path=os.path.devnull) if driver_type == 'firefox': return webdriver.Firefox(firefox_options=FIREFOXOPTIONS) elif driver_type == 'chrome': chrome_options = webd...
python
def _get_driver(driver_type): """Get webdriver.""" if driver_type == 'phantomjs': return webdriver.PhantomJS(service_log_path=os.path.devnull) if driver_type == 'firefox': return webdriver.Firefox(firefox_options=FIREFOXOPTIONS) elif driver_type == 'chrome': chrome_options = webd...
[ "def", "_get_driver", "(", "driver_type", ")", ":", "if", "driver_type", "==", "'phantomjs'", ":", "return", "webdriver", ".", "PhantomJS", "(", "service_log_path", "=", "os", ".", "path", ".", "devnull", ")", "if", "driver_type", "==", "'firefox'", ":", "re...
Get webdriver.
[ "Get", "webdriver", "." ]
827e74f25d1c1ef0149bb7fda7c606297b743c02
https://github.com/happyleavesaoc/python-myusps/blob/827e74f25d1c1ef0149bb7fda7c606297b743c02/myusps/__init__.py#L144-L156
train
62,648
happyleavesaoc/python-myusps
myusps/__init__.py
get_profile
def get_profile(session): """Get profile data.""" response = session.get(PROFILE_URL, allow_redirects=False) if response.status_code == 302: raise USPSError('expired session') parsed = BeautifulSoup(response.text, HTML_PARSER) profile = parsed.find('div', {'class': 'atg_store_myProfileInfo'}...
python
def get_profile(session): """Get profile data.""" response = session.get(PROFILE_URL, allow_redirects=False) if response.status_code == 302: raise USPSError('expired session') parsed = BeautifulSoup(response.text, HTML_PARSER) profile = parsed.find('div', {'class': 'atg_store_myProfileInfo'}...
[ "def", "get_profile", "(", "session", ")", ":", "response", "=", "session", ".", "get", "(", "PROFILE_URL", ",", "allow_redirects", "=", "False", ")", "if", "response", ".", "status_code", "==", "302", ":", "raise", "USPSError", "(", "'expired session'", ")"...
Get profile data.
[ "Get", "profile", "data", "." ]
827e74f25d1c1ef0149bb7fda7c606297b743c02
https://github.com/happyleavesaoc/python-myusps/blob/827e74f25d1c1ef0149bb7fda7c606297b743c02/myusps/__init__.py#L221-L235
train
62,649
happyleavesaoc/python-myusps
myusps/__init__.py
get_packages
def get_packages(session): """Get package data.""" _LOGGER.info("attempting to get package data") response = _get_dashboard(session) parsed = BeautifulSoup(response.text, HTML_PARSER) packages = [] for row in parsed.find_all('div', {'class': 'pack_row'}): packages.append({ 't...
python
def get_packages(session): """Get package data.""" _LOGGER.info("attempting to get package data") response = _get_dashboard(session) parsed = BeautifulSoup(response.text, HTML_PARSER) packages = [] for row in parsed.find_all('div', {'class': 'pack_row'}): packages.append({ 't...
[ "def", "get_packages", "(", "session", ")", ":", "_LOGGER", ".", "info", "(", "\"attempting to get package data\"", ")", "response", "=", "_get_dashboard", "(", "session", ")", "parsed", "=", "BeautifulSoup", "(", "response", ".", "text", ",", "HTML_PARSER", ")"...
Get package data.
[ "Get", "package", "data", "." ]
827e74f25d1c1ef0149bb7fda7c606297b743c02
https://github.com/happyleavesaoc/python-myusps/blob/827e74f25d1c1ef0149bb7fda7c606297b743c02/myusps/__init__.py#L239-L254
train
62,650
happyleavesaoc/python-myusps
myusps/__init__.py
get_mail
def get_mail(session, date=None): """Get mail data.""" _LOGGER.info("attempting to get mail data") if not date: date = datetime.datetime.now().date() response = _get_dashboard(session, date) parsed = BeautifulSoup(response.text, HTML_PARSER) mail = [] for row in parsed.find_all('div'...
python
def get_mail(session, date=None): """Get mail data.""" _LOGGER.info("attempting to get mail data") if not date: date = datetime.datetime.now().date() response = _get_dashboard(session, date) parsed = BeautifulSoup(response.text, HTML_PARSER) mail = [] for row in parsed.find_all('div'...
[ "def", "get_mail", "(", "session", ",", "date", "=", "None", ")", ":", "_LOGGER", ".", "info", "(", "\"attempting to get mail data\"", ")", "if", "not", "date", ":", "date", "=", "datetime", ".", "datetime", ".", "now", "(", ")", ".", "date", "(", ")",...
Get mail data.
[ "Get", "mail", "data", "." ]
827e74f25d1c1ef0149bb7fda7c606297b743c02
https://github.com/happyleavesaoc/python-myusps/blob/827e74f25d1c1ef0149bb7fda7c606297b743c02/myusps/__init__.py#L258-L275
train
62,651
happyleavesaoc/python-myusps
myusps/__init__.py
get_session
def get_session(username, password, cookie_path=COOKIE_PATH, cache=True, cache_expiry=300, cache_path=CACHE_PATH, driver='phantomjs'): """Get session, existing or new.""" class USPSAuth(AuthBase): # pylint: disable=too-few-public-methods """USPS authorization storage.""" def __...
python
def get_session(username, password, cookie_path=COOKIE_PATH, cache=True, cache_expiry=300, cache_path=CACHE_PATH, driver='phantomjs'): """Get session, existing or new.""" class USPSAuth(AuthBase): # pylint: disable=too-few-public-methods """USPS authorization storage.""" def __...
[ "def", "get_session", "(", "username", ",", "password", ",", "cookie_path", "=", "COOKIE_PATH", ",", "cache", "=", "True", ",", "cache_expiry", "=", "300", ",", "cache_path", "=", "CACHE_PATH", ",", "driver", "=", "'phantomjs'", ")", ":", "class", "USPSAuth"...
Get session, existing or new.
[ "Get", "session", "existing", "or", "new", "." ]
827e74f25d1c1ef0149bb7fda7c606297b743c02
https://github.com/happyleavesaoc/python-myusps/blob/827e74f25d1c1ef0149bb7fda7c606297b743c02/myusps/__init__.py#L278-L306
train
62,652
jbremer/rc4
rc4/__init__.py
rc4
def rc4(data, key): """RC4 encryption and decryption method.""" S, j, out = list(range(256)), 0, [] for i in range(256): j = (j + S[i] + ord(key[i % len(key)])) % 256 S[i], S[j] = S[j], S[i] i = j = 0 for ch in data: i = (i + 1) % 256 j = (j + S[i]) % 256 S[...
python
def rc4(data, key): """RC4 encryption and decryption method.""" S, j, out = list(range(256)), 0, [] for i in range(256): j = (j + S[i] + ord(key[i % len(key)])) % 256 S[i], S[j] = S[j], S[i] i = j = 0 for ch in data: i = (i + 1) % 256 j = (j + S[i]) % 256 S[...
[ "def", "rc4", "(", "data", ",", "key", ")", ":", "S", ",", "j", ",", "out", "=", "list", "(", "range", "(", "256", ")", ")", ",", "0", ",", "[", "]", "for", "i", "in", "range", "(", "256", ")", ":", "j", "=", "(", "j", "+", "S", "[", ...
RC4 encryption and decryption method.
[ "RC4", "encryption", "and", "decryption", "method", "." ]
49d6e916c96dcf990b5873c8389248436d443c13
https://github.com/jbremer/rc4/blob/49d6e916c96dcf990b5873c8389248436d443c13/rc4/__init__.py#L4-L19
train
62,653
vinta/django-email-confirm-la
email_confirm_la/models.py
EmailConfirmationManager.verify_email_for_object
def verify_email_for_object(self, email, content_object, email_field_name='email'): """ Create an email confirmation for `content_object` and send a confirmation mail. The email will be directly saved to `content_object.email_field_name` when `is_primary` and `skip_verify` both are true. ...
python
def verify_email_for_object(self, email, content_object, email_field_name='email'): """ Create an email confirmation for `content_object` and send a confirmation mail. The email will be directly saved to `content_object.email_field_name` when `is_primary` and `skip_verify` both are true. ...
[ "def", "verify_email_for_object", "(", "self", ",", "email", ",", "content_object", ",", "email_field_name", "=", "'email'", ")", ":", "confirmation_key", "=", "generate_random_token", "(", ")", "try", ":", "confirmation", "=", "EmailConfirmation", "(", ")", "conf...
Create an email confirmation for `content_object` and send a confirmation mail. The email will be directly saved to `content_object.email_field_name` when `is_primary` and `skip_verify` both are true.
[ "Create", "an", "email", "confirmation", "for", "content_object", "and", "send", "a", "confirmation", "mail", "." ]
7f6ed29f29325f91929c14b4e468a23be53354bb
https://github.com/vinta/django-email-confirm-la/blob/7f6ed29f29325f91929c14b4e468a23be53354bb/email_confirm_la/models.py#L24-L48
train
62,654
vinta/django-email-confirm-la
email_confirm_la/models.py
EmailConfirmation.clean
def clean(self): """ delete all confirmations for the same content_object and the same field """ EmailConfirmation.objects.filter(content_type=self.content_type, object_id=self.object_id, email_field_name=self.email_field_name).delete()
python
def clean(self): """ delete all confirmations for the same content_object and the same field """ EmailConfirmation.objects.filter(content_type=self.content_type, object_id=self.object_id, email_field_name=self.email_field_name).delete()
[ "def", "clean", "(", "self", ")", ":", "EmailConfirmation", ".", "objects", ".", "filter", "(", "content_type", "=", "self", ".", "content_type", ",", "object_id", "=", "self", ".", "object_id", ",", "email_field_name", "=", "self", ".", "email_field_name", ...
delete all confirmations for the same content_object and the same field
[ "delete", "all", "confirmations", "for", "the", "same", "content_object", "and", "the", "same", "field" ]
7f6ed29f29325f91929c14b4e468a23be53354bb
https://github.com/vinta/django-email-confirm-la/blob/7f6ed29f29325f91929c14b4e468a23be53354bb/email_confirm_la/models.py#L161-L166
train
62,655
aisayko/Django-tinymce-filebrowser
mce_filebrowser/utils.py
render_paginate
def render_paginate(request, template, objects, per_page, extra_context={}): """ Paginated list of objects. """ paginator = Paginator(objects, per_page) page = request.GET.get('page', 1) get_params = '&'.join(['%s=%s' % (k, request.GET[k]) for k in request.GET if k != ...
python
def render_paginate(request, template, objects, per_page, extra_context={}): """ Paginated list of objects. """ paginator = Paginator(objects, per_page) page = request.GET.get('page', 1) get_params = '&'.join(['%s=%s' % (k, request.GET[k]) for k in request.GET if k != ...
[ "def", "render_paginate", "(", "request", ",", "template", ",", "objects", ",", "per_page", ",", "extra_context", "=", "{", "}", ")", ":", "paginator", "=", "Paginator", "(", "objects", ",", "per_page", ")", "page", "=", "request", ".", "GET", ".", "get"...
Paginated list of objects.
[ "Paginated", "list", "of", "objects", "." ]
f34c9e8f8c5e32c1d1221270314f31ee07f24409
https://github.com/aisayko/Django-tinymce-filebrowser/blob/f34c9e8f8c5e32c1d1221270314f31ee07f24409/mce_filebrowser/utils.py#L9-L41
train
62,656
jbasko/configmanager
configmanager/changesets.py
_ChangesetContext.values
def values(self): """ Returns a mapping of items to their new values. The mapping includes only items whose value or raw string value has changed in the context. """ report = {} for k, k_changes in self._changes.items(): if len(k_changes) == 1: ...
python
def values(self): """ Returns a mapping of items to their new values. The mapping includes only items whose value or raw string value has changed in the context. """ report = {} for k, k_changes in self._changes.items(): if len(k_changes) == 1: ...
[ "def", "values", "(", "self", ")", ":", "report", "=", "{", "}", "for", "k", ",", "k_changes", "in", "self", ".", "_changes", ".", "items", "(", ")", ":", "if", "len", "(", "k_changes", ")", "==", "1", ":", "report", "[", "k", "]", "=", "k_chan...
Returns a mapping of items to their new values. The mapping includes only items whose value or raw string value has changed in the context.
[ "Returns", "a", "mapping", "of", "items", "to", "their", "new", "values", ".", "The", "mapping", "includes", "only", "items", "whose", "value", "or", "raw", "string", "value", "has", "changed", "in", "the", "context", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/changesets.py#L41-L52
train
62,657
jbasko/configmanager
configmanager/changesets.py
_ChangesetContext.changes
def changes(self): """ Returns a mapping of items to their effective change objects which include the old values and the new. The mapping includes only items whose value or raw string value has changed in the context. """ report = {} for k, k_changes in self._changes.item...
python
def changes(self): """ Returns a mapping of items to their effective change objects which include the old values and the new. The mapping includes only items whose value or raw string value has changed in the context. """ report = {} for k, k_changes in self._changes.item...
[ "def", "changes", "(", "self", ")", ":", "report", "=", "{", "}", "for", "k", ",", "k_changes", "in", "self", ".", "_changes", ".", "items", "(", ")", ":", "if", "len", "(", "k_changes", ")", "==", "1", ":", "report", "[", "k", "]", "=", "k_cha...
Returns a mapping of items to their effective change objects which include the old values and the new. The mapping includes only items whose value or raw string value has changed in the context.
[ "Returns", "a", "mapping", "of", "items", "to", "their", "effective", "change", "objects", "which", "include", "the", "old", "values", "and", "the", "new", ".", "The", "mapping", "includes", "only", "items", "whose", "value", "or", "raw", "string", "value", ...
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/changesets.py#L55-L74
train
62,658
jbasko/configmanager
configmanager/persistence.py
ConfigPersistenceAdapter.load
def load(self, source, as_defaults=False): """ Load configuration values from the specified source. Args: source: as_defaults (bool): if ``True``, contents of ``source`` will be treated as schema of configuration items. """ if isinstance(source, six.stri...
python
def load(self, source, as_defaults=False): """ Load configuration values from the specified source. Args: source: as_defaults (bool): if ``True``, contents of ``source`` will be treated as schema of configuration items. """ if isinstance(source, six.stri...
[ "def", "load", "(", "self", ",", "source", ",", "as_defaults", "=", "False", ")", ":", "if", "isinstance", "(", "source", ",", "six", ".", "string_types", ")", ":", "source", "=", "os", ".", "path", ".", "expanduser", "(", "source", ")", "with", "ope...
Load configuration values from the specified source. Args: source: as_defaults (bool): if ``True``, contents of ``source`` will be treated as schema of configuration items.
[ "Load", "configuration", "values", "from", "the", "specified", "source", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/persistence.py#L35-L55
train
62,659
jbasko/configmanager
configmanager/persistence.py
ConfigPersistenceAdapter.loads
def loads(self, config_str, as_defaults=False): """ Load configuration values from the specified source string. Args: config_str: as_defaults (bool): if ``True``, contents of ``source`` will be treated as schema of configuration items. """ self._rw.load_...
python
def loads(self, config_str, as_defaults=False): """ Load configuration values from the specified source string. Args: config_str: as_defaults (bool): if ``True``, contents of ``source`` will be treated as schema of configuration items. """ self._rw.load_...
[ "def", "loads", "(", "self", ",", "config_str", ",", "as_defaults", "=", "False", ")", ":", "self", ".", "_rw", ".", "load_config_from_string", "(", "self", ".", "_config", ",", "config_str", ",", "as_defaults", "=", "as_defaults", ")" ]
Load configuration values from the specified source string. Args: config_str: as_defaults (bool): if ``True``, contents of ``source`` will be treated as schema of configuration items.
[ "Load", "configuration", "values", "from", "the", "specified", "source", "string", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/persistence.py#L57-L66
train
62,660
jbasko/configmanager
configmanager/persistence.py
ConfigPersistenceAdapter.dump
def dump(self, destination, with_defaults=False): """ Write configuration values to the specified destination. Args: destination: with_defaults (bool): if ``True``, values of items with no custom values will be included in the output if they have a defaul...
python
def dump(self, destination, with_defaults=False): """ Write configuration values to the specified destination. Args: destination: with_defaults (bool): if ``True``, values of items with no custom values will be included in the output if they have a defaul...
[ "def", "dump", "(", "self", ",", "destination", ",", "with_defaults", "=", "False", ")", ":", "if", "isinstance", "(", "destination", ",", "six", ".", "string_types", ")", ":", "with", "open", "(", "destination", ",", "'w'", ",", "encoding", "=", "'utf-8...
Write configuration values to the specified destination. Args: destination: with_defaults (bool): if ``True``, values of items with no custom values will be included in the output if they have a default value set.
[ "Write", "configuration", "values", "to", "the", "specified", "destination", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/persistence.py#L68-L81
train
62,661
jbasko/configmanager
configmanager/persistence.py
ConfigPersistenceAdapter.dumps
def dumps(self, with_defaults=False): """ Generate a string representing all the configuration values. Args: with_defaults (bool): if ``True``, values of items with no custom values will be included in the output if they have a default value set. """ ...
python
def dumps(self, with_defaults=False): """ Generate a string representing all the configuration values. Args: with_defaults (bool): if ``True``, values of items with no custom values will be included in the output if they have a default value set. """ ...
[ "def", "dumps", "(", "self", ",", "with_defaults", "=", "False", ")", ":", "return", "self", ".", "_rw", ".", "dump_config_to_string", "(", "self", ".", "_config", ",", "with_defaults", "=", "with_defaults", ")" ]
Generate a string representing all the configuration values. Args: with_defaults (bool): if ``True``, values of items with no custom values will be included in the output if they have a default value set.
[ "Generate", "a", "string", "representing", "all", "the", "configuration", "values", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/persistence.py#L83-L91
train
62,662
jbasko/configmanager
configmanager/sections.py
Section._default_key_setter
def _default_key_setter(self, name, subject): """ This method is used only when there is a custom key_setter set. Do not override this method. """ if is_config_item(subject): self.add_item(name, subject) elif is_config_section(subject): self.add_s...
python
def _default_key_setter(self, name, subject): """ This method is used only when there is a custom key_setter set. Do not override this method. """ if is_config_item(subject): self.add_item(name, subject) elif is_config_section(subject): self.add_s...
[ "def", "_default_key_setter", "(", "self", ",", "name", ",", "subject", ")", ":", "if", "is_config_item", "(", "subject", ")", ":", "self", ".", "add_item", "(", "name", ",", "subject", ")", "elif", "is_config_section", "(", "subject", ")", ":", "self", ...
This method is used only when there is a custom key_setter set. Do not override this method.
[ "This", "method", "is", "used", "only", "when", "there", "is", "a", "custom", "key_setter", "set", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L127-L144
train
62,663
jbasko/configmanager
configmanager/sections.py
Section.get_section
def get_section(self, *key): """ The recommended way of retrieving a section by key when extending configmanager's behaviour. """ section = self._get_item_or_section(key) if not section.is_section: raise RuntimeError('{} is an item, not a section'.format(key)) ...
python
def get_section(self, *key): """ The recommended way of retrieving a section by key when extending configmanager's behaviour. """ section = self._get_item_or_section(key) if not section.is_section: raise RuntimeError('{} is an item, not a section'.format(key)) ...
[ "def", "get_section", "(", "self", ",", "*", "key", ")", ":", "section", "=", "self", ".", "_get_item_or_section", "(", "key", ")", "if", "not", "section", ".", "is_section", ":", "raise", "RuntimeError", "(", "'{} is an item, not a section'", ".", "format", ...
The recommended way of retrieving a section by key when extending configmanager's behaviour.
[ "The", "recommended", "way", "of", "retrieving", "a", "section", "by", "key", "when", "extending", "configmanager", "s", "behaviour", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L246-L253
train
62,664
jbasko/configmanager
configmanager/sections.py
Section.add_item
def add_item(self, alias, item): """ Add a config item to this section. """ if not isinstance(alias, six.string_types): raise TypeError('Item name must be a string, got a {!r}'.format(type(alias))) item = copy.deepcopy(item) if item.name is not_set: ...
python
def add_item(self, alias, item): """ Add a config item to this section. """ if not isinstance(alias, six.string_types): raise TypeError('Item name must be a string, got a {!r}'.format(type(alias))) item = copy.deepcopy(item) if item.name is not_set: ...
[ "def", "add_item", "(", "self", ",", "alias", ",", "item", ")", ":", "if", "not", "isinstance", "(", "alias", ",", "six", ".", "string_types", ")", ":", "raise", "TypeError", "(", "'Item name must be a string, got a {!r}'", ".", "format", "(", "type", "(", ...
Add a config item to this section.
[ "Add", "a", "config", "item", "to", "this", "section", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L289-L317
train
62,665
jbasko/configmanager
configmanager/sections.py
Section.add_section
def add_section(self, alias, section): """ Add a sub-section to this section. """ if not isinstance(alias, six.string_types): raise TypeError('Section name must be a string, got a {!r}'.format(type(alias))) self._tree[alias] = section if self.settings.str_pa...
python
def add_section(self, alias, section): """ Add a sub-section to this section. """ if not isinstance(alias, six.string_types): raise TypeError('Section name must be a string, got a {!r}'.format(type(alias))) self._tree[alias] = section if self.settings.str_pa...
[ "def", "add_section", "(", "self", ",", "alias", ",", "section", ")", ":", "if", "not", "isinstance", "(", "alias", ",", "six", ".", "string_types", ")", ":", "raise", "TypeError", "(", "'Section name must be a string, got a {!r}'", ".", "format", "(", "type",...
Add a sub-section to this section.
[ "Add", "a", "sub", "-", "section", "to", "this", "section", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L319-L337
train
62,666
jbasko/configmanager
configmanager/sections.py
Section._get_recursive_iterator
def _get_recursive_iterator(self, recursive=False): """ Basic recursive iterator whose only purpose is to yield all items and sections in order, with their full paths as keys. Main challenge is to de-duplicate items and sections which have aliases. Do not add any new fe...
python
def _get_recursive_iterator(self, recursive=False): """ Basic recursive iterator whose only purpose is to yield all items and sections in order, with their full paths as keys. Main challenge is to de-duplicate items and sections which have aliases. Do not add any new fe...
[ "def", "_get_recursive_iterator", "(", "self", ",", "recursive", "=", "False", ")", ":", "names_yielded", "=", "set", "(", ")", "for", "obj_alias", ",", "obj", "in", "self", ".", "_tree", ".", "items", "(", ")", ":", "if", "obj", ".", "is_section", ":"...
Basic recursive iterator whose only purpose is to yield all items and sections in order, with their full paths as keys. Main challenge is to de-duplicate items and sections which have aliases. Do not add any new features to this iterator, instead build others that extend this o...
[ "Basic", "recursive", "iterator", "whose", "only", "purpose", "is", "to", "yield", "all", "items", "and", "sections", "in", "order", "with", "their", "full", "paths", "as", "keys", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L366-L401
train
62,667
jbasko/configmanager
configmanager/sections.py
Section.reset
def reset(self): """ Recursively resets values of all items contained in this section and its subsections to their default values. """ for _, item in self.iter_items(recursive=True): item.reset()
python
def reset(self): """ Recursively resets values of all items contained in this section and its subsections to their default values. """ for _, item in self.iter_items(recursive=True): item.reset()
[ "def", "reset", "(", "self", ")", ":", "for", "_", ",", "item", "in", "self", ".", "iter_items", "(", "recursive", "=", "True", ")", ":", "item", ".", "reset", "(", ")" ]
Recursively resets values of all items contained in this section and its subsections to their default values.
[ "Recursively", "resets", "values", "of", "all", "items", "contained", "in", "this", "section", "and", "its", "subsections", "to", "their", "default", "values", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L487-L493
train
62,668
jbasko/configmanager
configmanager/sections.py
Section.is_default
def is_default(self): """ ``True`` if values of all config items in this section and its subsections have their values equal to defaults or have no value set. """ for _, item in self.iter_items(recursive=True): if not item.is_default: return False ...
python
def is_default(self): """ ``True`` if values of all config items in this section and its subsections have their values equal to defaults or have no value set. """ for _, item in self.iter_items(recursive=True): if not item.is_default: return False ...
[ "def", "is_default", "(", "self", ")", ":", "for", "_", ",", "item", "in", "self", ".", "iter_items", "(", "recursive", "=", "True", ")", ":", "if", "not", "item", ".", "is_default", ":", "return", "False", "return", "True" ]
``True`` if values of all config items in this section and its subsections have their values equal to defaults or have no value set.
[ "True", "if", "values", "of", "all", "config", "items", "in", "this", "section", "and", "its", "subsections", "have", "their", "values", "equal", "to", "defaults", "or", "have", "no", "value", "set", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L496-L504
train
62,669
jbasko/configmanager
configmanager/sections.py
Section.dump_values
def dump_values(self, with_defaults=True, dict_cls=dict, flat=False): """ Export values of all items contained in this section to a dictionary. Items with no values set (and no defaults set if ``with_defaults=True``) will be excluded. Returns: dict: A dictionary of key-valu...
python
def dump_values(self, with_defaults=True, dict_cls=dict, flat=False): """ Export values of all items contained in this section to a dictionary. Items with no values set (and no defaults set if ``with_defaults=True``) will be excluded. Returns: dict: A dictionary of key-valu...
[ "def", "dump_values", "(", "self", ",", "with_defaults", "=", "True", ",", "dict_cls", "=", "dict", ",", "flat", "=", "False", ")", ":", "values", "=", "dict_cls", "(", ")", "if", "flat", ":", "for", "str_path", ",", "item", "in", "self", ".", "iter_...
Export values of all items contained in this section to a dictionary. Items with no values set (and no defaults set if ``with_defaults=True``) will be excluded. Returns: dict: A dictionary of key-value pairs, where for sections values are dictionaries of their contents.
[ "Export", "values", "of", "all", "items", "contained", "in", "this", "section", "to", "a", "dictionary", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L506-L534
train
62,670
jbasko/configmanager
configmanager/sections.py
Section.load_values
def load_values(self, dictionary, as_defaults=False, flat=False): """ Import config values from a dictionary. When ``as_defaults`` is set to ``True``, the values imported will be set as defaults. This can be used to declare the sections and items of configuration. Values...
python
def load_values(self, dictionary, as_defaults=False, flat=False): """ Import config values from a dictionary. When ``as_defaults`` is set to ``True``, the values imported will be set as defaults. This can be used to declare the sections and items of configuration. Values...
[ "def", "load_values", "(", "self", ",", "dictionary", ",", "as_defaults", "=", "False", ",", "flat", "=", "False", ")", ":", "if", "flat", ":", "# Deflatten the dictionary and then pass on to the normal case.", "separator", "=", "self", ".", "settings", ".", "str_...
Import config values from a dictionary. When ``as_defaults`` is set to ``True``, the values imported will be set as defaults. This can be used to declare the sections and items of configuration. Values of sections and items in ``dictionary`` can be dictionaries as well as instan...
[ "Import", "config", "values", "from", "a", "dictionary", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L536-L587
train
62,671
jbasko/configmanager
configmanager/sections.py
Section.create_section
def create_section(self, *args, **kwargs): """ Internal factory method used to create an instance of configuration section. Should only be used when extending or modifying configmanager's functionality. Under normal circumstances you should let configmanager create sections and ...
python
def create_section(self, *args, **kwargs): """ Internal factory method used to create an instance of configuration section. Should only be used when extending or modifying configmanager's functionality. Under normal circumstances you should let configmanager create sections and ...
[ "def", "create_section", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'section'", ",", "self", ")", "return", "self", ".", "settings", ".", "section_factory", "(", "*", "args", ",", "*", "*", "k...
Internal factory method used to create an instance of configuration section. Should only be used when extending or modifying configmanager's functionality. Under normal circumstances you should let configmanager create sections and items when parsing configuration schemas. Do not overr...
[ "Internal", "factory", "method", "used", "to", "create", "an", "instance", "of", "configuration", "section", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L603-L616
train
62,672
jbasko/configmanager
configmanager/sections.py
Section.item_attribute
def item_attribute(self, f=None, name=None): """ A decorator to register a dynamic item attribute provider. By default, uses function name for attribute name. Override that with ``name=``. """ def decorator(func): attr_name = name or func.__name__ if attr...
python
def item_attribute(self, f=None, name=None): """ A decorator to register a dynamic item attribute provider. By default, uses function name for attribute name. Override that with ``name=``. """ def decorator(func): attr_name = name or func.__name__ if attr...
[ "def", "item_attribute", "(", "self", ",", "f", "=", "None", ",", "name", "=", "None", ")", ":", "def", "decorator", "(", "func", ")", ":", "attr_name", "=", "name", "or", "func", ".", "__name__", "if", "attr_name", ".", "startswith", "(", "'_'", ")"...
A decorator to register a dynamic item attribute provider. By default, uses function name for attribute name. Override that with ``name=``.
[ "A", "decorator", "to", "register", "a", "dynamic", "item", "attribute", "provider", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L668-L684
train
62,673
jbasko/configmanager
configmanager/sections.py
Section.get_item_attribute
def get_item_attribute(self, item, name): """ Method called by item when an attribute is not found. """ if name in self.__item_attributes: return self.__item_attributes[name](item) elif self.section: return self.section.get_item_attribute(item, name) ...
python
def get_item_attribute(self, item, name): """ Method called by item when an attribute is not found. """ if name in self.__item_attributes: return self.__item_attributes[name](item) elif self.section: return self.section.get_item_attribute(item, name) ...
[ "def", "get_item_attribute", "(", "self", ",", "item", ",", "name", ")", ":", "if", "name", "in", "self", ".", "__item_attributes", ":", "return", "self", ".", "__item_attributes", "[", "name", "]", "(", "item", ")", "elif", "self", ".", "section", ":", ...
Method called by item when an attribute is not found.
[ "Method", "called", "by", "item", "when", "an", "attribute", "is", "not", "found", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L686-L695
train
62,674
jbasko/configmanager
configmanager/sections.py
Section.dispatch_event
def dispatch_event(self, event_, **kwargs): """ Dispatch section event. Notes: You MUST NOT call event.trigger() directly because it will circumvent the section settings as well as ignore the section tree. If hooks are disabled somewhere up in th...
python
def dispatch_event(self, event_, **kwargs): """ Dispatch section event. Notes: You MUST NOT call event.trigger() directly because it will circumvent the section settings as well as ignore the section tree. If hooks are disabled somewhere up in th...
[ "def", "dispatch_event", "(", "self", ",", "event_", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "settings", ".", "hooks_enabled", ":", "result", "=", "self", ".", "hooks", ".", "dispatch_event", "(", "event_", ",", "*", "*", "kwargs", ")", ...
Dispatch section event. Notes: You MUST NOT call event.trigger() directly because it will circumvent the section settings as well as ignore the section tree. If hooks are disabled somewhere up in the tree, and enabled down below, events will still be...
[ "Dispatch", "section", "event", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L701-L726
train
62,675
jbasko/configmanager
configmanager/managers.py
Config.load
def load(self): """ Load user configuration based on settings. """ # Must reverse because we want the sources assigned to higher-up Config instances # to overrides sources assigned to lower Config instances. for section in reversed(list(self.iter_sections(recursive=True,...
python
def load(self): """ Load user configuration based on settings. """ # Must reverse because we want the sources assigned to higher-up Config instances # to overrides sources assigned to lower Config instances. for section in reversed(list(self.iter_sections(recursive=True,...
[ "def", "load", "(", "self", ")", ":", "# Must reverse because we want the sources assigned to higher-up Config instances", "# to overrides sources assigned to lower Config instances.", "for", "section", "in", "reversed", "(", "list", "(", "self", ".", "iter_sections", "(", "rec...
Load user configuration based on settings.
[ "Load", "user", "configuration", "based", "on", "settings", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/managers.py#L214-L228
train
62,676
jbasko/configmanager
configmanager/click_ext.py
ClickExtension.option
def option(self, *args, **kwargs): """ Registers a click.option which falls back to a configmanager Item if user hasn't provided a value in the command line. Item must be the last of ``args``. Examples:: config = Config({'greeting': 'Hello'}) @click.co...
python
def option(self, *args, **kwargs): """ Registers a click.option which falls back to a configmanager Item if user hasn't provided a value in the command line. Item must be the last of ``args``. Examples:: config = Config({'greeting': 'Hello'}) @click.co...
[ "def", "option", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "args", ",", "kwargs", "=", "_config_parameter", "(", "args", ",", "kwargs", ")", "return", "self", ".", "_click", ".", "option", "(", "*", "args", ",", "*", "*", ...
Registers a click.option which falls back to a configmanager Item if user hasn't provided a value in the command line. Item must be the last of ``args``. Examples:: config = Config({'greeting': 'Hello'}) @click.command() @config.click.option('--greeting', ...
[ "Registers", "a", "click", ".", "option", "which", "falls", "back", "to", "a", "configmanager", "Item", "if", "user", "hasn", "t", "provided", "a", "value", "in", "the", "command", "line", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/click_ext.py#L42-L60
train
62,677
jbasko/configmanager
configmanager/click_ext.py
ClickExtension.argument
def argument(self, *args, **kwargs): """ Registers a click.argument which falls back to a configmanager Item if user hasn't provided a value in the command line. Item must be the last of ``args``. """ if kwargs.get('required', True): raise TypeError( ...
python
def argument(self, *args, **kwargs): """ Registers a click.argument which falls back to a configmanager Item if user hasn't provided a value in the command line. Item must be the last of ``args``. """ if kwargs.get('required', True): raise TypeError( ...
[ "def", "argument", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ".", "get", "(", "'required'", ",", "True", ")", ":", "raise", "TypeError", "(", "'In click framework, arguments are mandatory, unless marked required=False. '", ...
Registers a click.argument which falls back to a configmanager Item if user hasn't provided a value in the command line. Item must be the last of ``args``.
[ "Registers", "a", "click", ".", "argument", "which", "falls", "back", "to", "a", "configmanager", "Item", "if", "user", "hasn", "t", "provided", "a", "value", "in", "the", "command", "line", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/click_ext.py#L62-L78
train
62,678
jbasko/configmanager
configmanager/items.py
Item._get_kwarg
def _get_kwarg(self, name, kwargs): """ Helper to get value of a named attribute irrespective of whether it is passed with or without "@" prefix. """ at_name = '@{}'.format(name) if name in kwargs: if at_name in kwargs: raise ValueError('Both ...
python
def _get_kwarg(self, name, kwargs): """ Helper to get value of a named attribute irrespective of whether it is passed with or without "@" prefix. """ at_name = '@{}'.format(name) if name in kwargs: if at_name in kwargs: raise ValueError('Both ...
[ "def", "_get_kwarg", "(", "self", ",", "name", ",", "kwargs", ")", ":", "at_name", "=", "'@{}'", ".", "format", "(", "name", ")", "if", "name", "in", "kwargs", ":", "if", "at_name", "in", "kwargs", ":", "raise", "ValueError", "(", "'Both {!r} and {!r} sp...
Helper to get value of a named attribute irrespective of whether it is passed with or without "@" prefix.
[ "Helper", "to", "get", "value", "of", "a", "named", "attribute", "irrespective", "of", "whether", "it", "is", "passed", "with", "or", "without" ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/items.py#L61-L76
train
62,679
jbasko/configmanager
configmanager/items.py
Item._get_envvar_value
def _get_envvar_value(self): """ Internal helper to get item value from an environment variable if item is controlled by one, and if the variable is set. Returns not_set otherwise. """ envvar_name = None if self.envvar is True: envvar_name = self.env...
python
def _get_envvar_value(self): """ Internal helper to get item value from an environment variable if item is controlled by one, and if the variable is set. Returns not_set otherwise. """ envvar_name = None if self.envvar is True: envvar_name = self.env...
[ "def", "_get_envvar_value", "(", "self", ")", ":", "envvar_name", "=", "None", "if", "self", ".", "envvar", "is", "True", ":", "envvar_name", "=", "self", ".", "envvar_name", "if", "envvar_name", "is", "None", ":", "envvar_name", "=", "'_'", ".", "join", ...
Internal helper to get item value from an environment variable if item is controlled by one, and if the variable is set. Returns not_set otherwise.
[ "Internal", "helper", "to", "get", "item", "value", "from", "an", "environment", "variable", "if", "item", "is", "controlled", "by", "one", "and", "if", "the", "variable", "is", "set", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/items.py#L178-L197
train
62,680
jbasko/configmanager
configmanager/items.py
Item.get
def get(self, fallback=not_set): """ Returns config value. See Also: :meth:`.set` and :attr:`.value` """ envvar_value = self._get_envvar_value() if envvar_value is not not_set: return envvar_value if self.has_value: if self._...
python
def get(self, fallback=not_set): """ Returns config value. See Also: :meth:`.set` and :attr:`.value` """ envvar_value = self._get_envvar_value() if envvar_value is not not_set: return envvar_value if self.has_value: if self._...
[ "def", "get", "(", "self", ",", "fallback", "=", "not_set", ")", ":", "envvar_value", "=", "self", ".", "_get_envvar_value", "(", ")", "if", "envvar_value", "is", "not", "not_set", ":", "return", "envvar_value", "if", "self", ".", "has_value", ":", "if", ...
Returns config value. See Also: :meth:`.set` and :attr:`.value`
[ "Returns", "config", "value", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/items.py#L199-L220
train
62,681
jbasko/configmanager
configmanager/items.py
Item.set
def set(self, value): """ Sets config value. """ old_value = self._value old_raw_str_value = self.raw_str_value self.type.set_item_value(self, value) new_value = self._value if old_value is not_set and new_value is not_set: # Nothing to repo...
python
def set(self, value): """ Sets config value. """ old_value = self._value old_raw_str_value = self.raw_str_value self.type.set_item_value(self, value) new_value = self._value if old_value is not_set and new_value is not_set: # Nothing to repo...
[ "def", "set", "(", "self", ",", "value", ")", ":", "old_value", "=", "self", ".", "_value", "old_raw_str_value", "=", "self", ".", "raw_str_value", "self", ".", "type", ".", "set_item_value", "(", "self", ",", "value", ")", "new_value", "=", "self", ".",...
Sets config value.
[ "Sets", "config", "value", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/items.py#L231-L254
train
62,682
jbasko/configmanager
configmanager/items.py
Item.reset
def reset(self): """ Resets the value of config item to its default value. """ old_value = self._value old_raw_str_value = self.raw_str_value self._value = not_set self.raw_str_value = not_set new_value = self._value if old_value is not_set: ...
python
def reset(self): """ Resets the value of config item to its default value. """ old_value = self._value old_raw_str_value = self.raw_str_value self._value = not_set self.raw_str_value = not_set new_value = self._value if old_value is not_set: ...
[ "def", "reset", "(", "self", ")", ":", "old_value", "=", "self", ".", "_value", "old_raw_str_value", "=", "self", ".", "raw_str_value", "self", ".", "_value", "=", "not_set", "self", ".", "raw_str_value", "=", "not_set", "new_value", "=", "self", ".", "_va...
Resets the value of config item to its default value.
[ "Resets", "the", "value", "of", "config", "item", "to", "its", "default", "value", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/items.py#L256-L280
train
62,683
jbasko/configmanager
configmanager/items.py
Item.is_default
def is_default(self): """ ``True`` if the item's value is its default value or if no value and no default value are set. If the item is backed by an environment variable, this will be ``True`` only if the environment variable is set and is different to the default value of the i...
python
def is_default(self): """ ``True`` if the item's value is its default value or if no value and no default value are set. If the item is backed by an environment variable, this will be ``True`` only if the environment variable is set and is different to the default value of the i...
[ "def", "is_default", "(", "self", ")", ":", "envvar_value", "=", "self", ".", "_get_envvar_value", "(", ")", "if", "envvar_value", "is", "not", "not_set", ":", "return", "envvar_value", "==", "self", ".", "default", "else", ":", "return", "self", ".", "_va...
``True`` if the item's value is its default value or if no value and no default value are set. If the item is backed by an environment variable, this will be ``True`` only if the environment variable is set and is different to the default value of the item.
[ "True", "if", "the", "item", "s", "value", "is", "its", "default", "value", "or", "if", "no", "value", "and", "no", "default", "value", "are", "set", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/items.py#L283-L295
train
62,684
jbasko/configmanager
configmanager/items.py
Item.has_value
def has_value(self): """ ``True`` if item has a default value or custom value set. """ if self._get_envvar_value() is not not_set: return True else: return self.default is not not_set or self._value is not not_set
python
def has_value(self): """ ``True`` if item has a default value or custom value set. """ if self._get_envvar_value() is not not_set: return True else: return self.default is not not_set or self._value is not not_set
[ "def", "has_value", "(", "self", ")", ":", "if", "self", ".", "_get_envvar_value", "(", ")", "is", "not", "not_set", ":", "return", "True", "else", ":", "return", "self", ".", "default", "is", "not", "not_set", "or", "self", ".", "_value", "is", "not",...
``True`` if item has a default value or custom value set.
[ "True", "if", "item", "has", "a", "default", "value", "or", "custom", "value", "set", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/items.py#L298-L305
train
62,685
jbasko/configmanager
configmanager/items.py
Item.validate
def validate(self): """ Validate item. """ if self.required and not self.has_value: raise RequiredValueMissing(name=self.name, item=self)
python
def validate(self): """ Validate item. """ if self.required and not self.has_value: raise RequiredValueMissing(name=self.name, item=self)
[ "def", "validate", "(", "self", ")", ":", "if", "self", ".", "required", "and", "not", "self", ".", "has_value", ":", "raise", "RequiredValueMissing", "(", "name", "=", "self", ".", "name", ",", "item", "=", "self", ")" ]
Validate item.
[ "Validate", "item", "." ]
1d7229ce367143c7210d8e5f0782de03945a1721
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/items.py#L329-L334
train
62,686
aisayko/Django-tinymce-filebrowser
mce_filebrowser/views.py
filebrowser
def filebrowser(request, file_type): """ Trigger view for filebrowser """ template = 'filebrowser.html' upload_form = FileUploadForm() uploaded_file = None upload_tab_active = False is_images_dialog = (file_type == 'img') is_documents_dialog = (file_type == 'doc') files = FileBrowse...
python
def filebrowser(request, file_type): """ Trigger view for filebrowser """ template = 'filebrowser.html' upload_form = FileUploadForm() uploaded_file = None upload_tab_active = False is_images_dialog = (file_type == 'img') is_documents_dialog = (file_type == 'doc') files = FileBrowse...
[ "def", "filebrowser", "(", "request", ",", "file_type", ")", ":", "template", "=", "'filebrowser.html'", "upload_form", "=", "FileUploadForm", "(", ")", "uploaded_file", "=", "None", "upload_tab_active", "=", "False", "is_images_dialog", "=", "(", "file_type", "==...
Trigger view for filebrowser
[ "Trigger", "view", "for", "filebrowser" ]
f34c9e8f8c5e32c1d1221270314f31ee07f24409
https://github.com/aisayko/Django-tinymce-filebrowser/blob/f34c9e8f8c5e32c1d1221270314f31ee07f24409/mce_filebrowser/views.py#L15-L43
train
62,687
saippuakauppias/temp-mail
tempmail.py
TempMail.available_domains
def available_domains(self): """ Return list of available domains for use in email address. """ if not hasattr(self, '_available_domains'): url = 'http://{0}/request/domains/format/json/'.format( self.api_domain) req = requests.get(url) ...
python
def available_domains(self): """ Return list of available domains for use in email address. """ if not hasattr(self, '_available_domains'): url = 'http://{0}/request/domains/format/json/'.format( self.api_domain) req = requests.get(url) ...
[ "def", "available_domains", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_available_domains'", ")", ":", "url", "=", "'http://{0}/request/domains/format/json/'", ".", "format", "(", "self", ".", "api_domain", ")", "req", "=", "requests", ...
Return list of available domains for use in email address.
[ "Return", "list", "of", "available", "domains", "for", "use", "in", "email", "address", "." ]
52254a6d614043ffd47a8c6b929fce77596d5053
https://github.com/saippuakauppias/temp-mail/blob/52254a6d614043ffd47a8c6b929fce77596d5053/tempmail.py#L28-L38
train
62,688
saippuakauppias/temp-mail
tempmail.py
TempMail.generate_login
def generate_login(self, min_length=6, max_length=10, digits=True): """ Generate string for email address login with defined length and alphabet. :param min_length: (optional) min login length. Default value is ``6``. :param max_length: (optional) max login length. ...
python
def generate_login(self, min_length=6, max_length=10, digits=True): """ Generate string for email address login with defined length and alphabet. :param min_length: (optional) min login length. Default value is ``6``. :param max_length: (optional) max login length. ...
[ "def", "generate_login", "(", "self", ",", "min_length", "=", "6", ",", "max_length", "=", "10", ",", "digits", "=", "True", ")", ":", "chars", "=", "string", ".", "ascii_lowercase", "if", "digits", ":", "chars", "+=", "string", ".", "digits", "length", ...
Generate string for email address login with defined length and alphabet. :param min_length: (optional) min login length. Default value is ``6``. :param max_length: (optional) max login length. Default value is ``10``. :param digits: (optional) use digits in login genera...
[ "Generate", "string", "for", "email", "address", "login", "with", "defined", "length", "and", "alphabet", "." ]
52254a6d614043ffd47a8c6b929fce77596d5053
https://github.com/saippuakauppias/temp-mail/blob/52254a6d614043ffd47a8c6b929fce77596d5053/tempmail.py#L40-L56
train
62,689
saippuakauppias/temp-mail
tempmail.py
TempMail.get_email_address
def get_email_address(self): """ Return full email address from login and domain from params in class initialization or generate new. """ if self.login is None: self.login = self.generate_login() available_domains = self.available_domains if self.doma...
python
def get_email_address(self): """ Return full email address from login and domain from params in class initialization or generate new. """ if self.login is None: self.login = self.generate_login() available_domains = self.available_domains if self.doma...
[ "def", "get_email_address", "(", "self", ")", ":", "if", "self", ".", "login", "is", "None", ":", "self", ".", "login", "=", "self", ".", "generate_login", "(", ")", "available_domains", "=", "self", ".", "available_domains", "if", "self", ".", "domain", ...
Return full email address from login and domain from params in class initialization or generate new.
[ "Return", "full", "email", "address", "from", "login", "and", "domain", "from", "params", "in", "class", "initialization", "or", "generate", "new", "." ]
52254a6d614043ffd47a8c6b929fce77596d5053
https://github.com/saippuakauppias/temp-mail/blob/52254a6d614043ffd47a8c6b929fce77596d5053/tempmail.py#L58-L71
train
62,690
saippuakauppias/temp-mail
tempmail.py
TempMail.get_mailbox
def get_mailbox(self, email=None, email_hash=None): """ Return list of emails in given email address or dict with `error` key if mail box is empty. :param email: (optional) email address. :param email_hash: (optional) md5 hash from email address. """ if email is ...
python
def get_mailbox(self, email=None, email_hash=None): """ Return list of emails in given email address or dict with `error` key if mail box is empty. :param email: (optional) email address. :param email_hash: (optional) md5 hash from email address. """ if email is ...
[ "def", "get_mailbox", "(", "self", ",", "email", "=", "None", ",", "email_hash", "=", "None", ")", ":", "if", "email", "is", "None", ":", "email", "=", "self", ".", "get_email_address", "(", ")", "if", "email_hash", "is", "None", ":", "email_hash", "="...
Return list of emails in given email address or dict with `error` key if mail box is empty. :param email: (optional) email address. :param email_hash: (optional) md5 hash from email address.
[ "Return", "list", "of", "emails", "in", "given", "email", "address", "or", "dict", "with", "error", "key", "if", "mail", "box", "is", "empty", "." ]
52254a6d614043ffd47a8c6b929fce77596d5053
https://github.com/saippuakauppias/temp-mail/blob/52254a6d614043ffd47a8c6b929fce77596d5053/tempmail.py#L81-L97
train
62,691
leonjza/pytel
pytel/utils/sockets.py
setup_domain_socket
def setup_domain_socket(location): ''' Setup Domain Socket Setup a connection to a Unix Domain Socket -- @param location:str The path to the Unix Domain Socket to connect to. @return <class 'socket._socketobject'> ''' clientsocket = socket.socket(socket.AF_UNI...
python
def setup_domain_socket(location): ''' Setup Domain Socket Setup a connection to a Unix Domain Socket -- @param location:str The path to the Unix Domain Socket to connect to. @return <class 'socket._socketobject'> ''' clientsocket = socket.socket(socket.AF_UNI...
[ "def", "setup_domain_socket", "(", "location", ")", ":", "clientsocket", "=", "socket", ".", "socket", "(", "socket", ".", "AF_UNIX", ",", "socket", ".", "SOCK_STREAM", ")", "clientsocket", ".", "settimeout", "(", "timeout", ")", "clientsocket", ".", "connect"...
Setup Domain Socket Setup a connection to a Unix Domain Socket -- @param location:str The path to the Unix Domain Socket to connect to. @return <class 'socket._socketobject'>
[ "Setup", "Domain", "Socket" ]
db9bca21d1ce0b2dfb6bf5068d65fc7309265e28
https://github.com/leonjza/pytel/blob/db9bca21d1ce0b2dfb6bf5068d65fc7309265e28/pytel/utils/sockets.py#L33-L49
train
62,692
leonjza/pytel
pytel/utils/sockets.py
setup_tcp_socket
def setup_tcp_socket(location, port): ''' Setup TCP Socket Setup a connection to a TCP Socket -- @param location:str The Hostname / IP Address of the remote TCP Socket. @param port:int The TCP Port the remote Socket is listening on. @return <class 'sock...
python
def setup_tcp_socket(location, port): ''' Setup TCP Socket Setup a connection to a TCP Socket -- @param location:str The Hostname / IP Address of the remote TCP Socket. @param port:int The TCP Port the remote Socket is listening on. @return <class 'sock...
[ "def", "setup_tcp_socket", "(", "location", ",", "port", ")", ":", "clientsocket", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "clientsocket", ".", "settimeout", "(", "timeout", ")", "clientsocket", "....
Setup TCP Socket Setup a connection to a TCP Socket -- @param location:str The Hostname / IP Address of the remote TCP Socket. @param port:int The TCP Port the remote Socket is listening on. @return <class 'socket._socketobject'>
[ "Setup", "TCP", "Socket" ]
db9bca21d1ce0b2dfb6bf5068d65fc7309265e28
https://github.com/leonjza/pytel/blob/db9bca21d1ce0b2dfb6bf5068d65fc7309265e28/pytel/utils/sockets.py#L51-L68
train
62,693
ultradns/python_rest_api_client
ultra_rest_client/ultra_rest_client.py
RestApiClient.create_primary_zone
def create_primary_zone(self, account_name, zone_name): """Creates a new primary zone. Arguments: account_name -- The name of the account that will contain this zone. zone_name -- The name of the zone. It must be unique. """ zone_properties = {"name": zone_name, "accou...
python
def create_primary_zone(self, account_name, zone_name): """Creates a new primary zone. Arguments: account_name -- The name of the account that will contain this zone. zone_name -- The name of the zone. It must be unique. """ zone_properties = {"name": zone_name, "accou...
[ "def", "create_primary_zone", "(", "self", ",", "account_name", ",", "zone_name", ")", ":", "zone_properties", "=", "{", "\"name\"", ":", "zone_name", ",", "\"accountName\"", ":", "account_name", ",", "\"type\"", ":", "\"PRIMARY\"", "}", "primary_zone_info", "=", ...
Creates a new primary zone. Arguments: account_name -- The name of the account that will contain this zone. zone_name -- The name of the zone. It must be unique.
[ "Creates", "a", "new", "primary", "zone", "." ]
e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec
https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L29-L40
train
62,694
ultradns/python_rest_api_client
ultra_rest_client/ultra_rest_client.py
RestApiClient.create_primary_zone_by_upload
def create_primary_zone_by_upload(self, account_name, zone_name, bind_file): """Creates a new primary zone by uploading a bind file Arguments: account_name -- The name of the account that will contain this zone. zone_name -- The name of the zone. It must be unique. bind_file --...
python
def create_primary_zone_by_upload(self, account_name, zone_name, bind_file): """Creates a new primary zone by uploading a bind file Arguments: account_name -- The name of the account that will contain this zone. zone_name -- The name of the zone. It must be unique. bind_file --...
[ "def", "create_primary_zone_by_upload", "(", "self", ",", "account_name", ",", "zone_name", ",", "bind_file", ")", ":", "zone_properties", "=", "{", "\"name\"", ":", "zone_name", ",", "\"accountName\"", ":", "account_name", ",", "\"type\"", ":", "\"PRIMARY\"", "}"...
Creates a new primary zone by uploading a bind file Arguments: account_name -- The name of the account that will contain this zone. zone_name -- The name of the zone. It must be unique. bind_file -- The file to upload.
[ "Creates", "a", "new", "primary", "zone", "by", "uploading", "a", "bind", "file" ]
e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec
https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L43-L57
train
62,695
ultradns/python_rest_api_client
ultra_rest_client/ultra_rest_client.py
RestApiClient.create_primary_zone_by_axfr
def create_primary_zone_by_axfr(self, account_name, zone_name, master, tsig_key=None, key_value=None): """Creates a new primary zone by zone transferring off a master. Arguments: account_name -- The name of the account that will contain this zone. zone_name -- The name of the zone. It ...
python
def create_primary_zone_by_axfr(self, account_name, zone_name, master, tsig_key=None, key_value=None): """Creates a new primary zone by zone transferring off a master. Arguments: account_name -- The name of the account that will contain this zone. zone_name -- The name of the zone. It ...
[ "def", "create_primary_zone_by_axfr", "(", "self", ",", "account_name", ",", "zone_name", ",", "master", ",", "tsig_key", "=", "None", ",", "key_value", "=", "None", ")", ":", "zone_properties", "=", "{", "\"name\"", ":", "zone_name", ",", "\"accountName\"", "...
Creates a new primary zone by zone transferring off a master. Arguments: account_name -- The name of the account that will contain this zone. zone_name -- The name of the zone. It must be unique. master -- Primary name server IP address. Keyword Arguments: tsig_key -- ...
[ "Creates", "a", "new", "primary", "zone", "by", "zone", "transferring", "off", "a", "master", "." ]
e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec
https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L60-L81
train
62,696
ultradns/python_rest_api_client
ultra_rest_client/ultra_rest_client.py
RestApiClient.create_secondary_zone
def create_secondary_zone(self, account_name, zone_name, master, tsig_key=None, key_value=None): """Creates a new secondary zone. Arguments: account_name -- The name of the account. zone_name -- The name of the zone. master -- Primary name server IP address. Keyword Arg...
python
def create_secondary_zone(self, account_name, zone_name, master, tsig_key=None, key_value=None): """Creates a new secondary zone. Arguments: account_name -- The name of the account. zone_name -- The name of the zone. master -- Primary name server IP address. Keyword Arg...
[ "def", "create_secondary_zone", "(", "self", ",", "account_name", ",", "zone_name", ",", "master", ",", "tsig_key", "=", "None", ",", "key_value", "=", "None", ")", ":", "zone_properties", "=", "{", "\"name\"", ":", "zone_name", ",", "\"accountName\"", ":", ...
Creates a new secondary zone. Arguments: account_name -- The name of the account. zone_name -- The name of the zone. master -- Primary name server IP address. Keyword Arguments: tsig_key -- For TSIG-enabled zones: The transaction signature key. NOTE:...
[ "Creates", "a", "new", "secondary", "zone", "." ]
e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec
https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L84-L107
train
62,697
ultradns/python_rest_api_client
ultra_rest_client/ultra_rest_client.py
RestApiClient.get_zones_of_account
def get_zones_of_account(self, account_name, q=None, **kwargs): """Returns a list of zones for the specified account. Arguments: account_name -- The name of the account. Keyword Arguments: q -- The search parameters, in a dict. Valid keys are: name - substring mat...
python
def get_zones_of_account(self, account_name, q=None, **kwargs): """Returns a list of zones for the specified account. Arguments: account_name -- The name of the account. Keyword Arguments: q -- The search parameters, in a dict. Valid keys are: name - substring mat...
[ "def", "get_zones_of_account", "(", "self", ",", "account_name", ",", "q", "=", "None", ",", "*", "*", "kwargs", ")", ":", "uri", "=", "\"/v1/accounts/\"", "+", "account_name", "+", "\"/zones\"", "params", "=", "build_params", "(", "q", ",", "kwargs", ")",...
Returns a list of zones for the specified account. Arguments: account_name -- The name of the account. Keyword Arguments: q -- The search parameters, in a dict. Valid keys are: name - substring match of the zone name zone_type - one of: PRIMAR...
[ "Returns", "a", "list", "of", "zones", "for", "the", "specified", "account", "." ]
e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec
https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L130-L155
train
62,698
ultradns/python_rest_api_client
ultra_rest_client/ultra_rest_client.py
RestApiClient.get_zones
def get_zones(self, q=None, **kwargs): """Returns a list of zones across all of the user's accounts. Keyword Arguments: q -- The search parameters, in a dict. Valid keys are: name - substring match of the zone name zone_type - one of: PRIMARY ...
python
def get_zones(self, q=None, **kwargs): """Returns a list of zones across all of the user's accounts. Keyword Arguments: q -- The search parameters, in a dict. Valid keys are: name - substring match of the zone name zone_type - one of: PRIMARY ...
[ "def", "get_zones", "(", "self", ",", "q", "=", "None", ",", "*", "*", "kwargs", ")", ":", "uri", "=", "\"/v1/zones\"", "params", "=", "build_params", "(", "q", ",", "kwargs", ")", "return", "self", ".", "rest_api_connection", ".", "get", "(", "uri", ...
Returns a list of zones across all of the user's accounts. Keyword Arguments: q -- The search parameters, in a dict. Valid keys are: name - substring match of the zone name zone_type - one of: PRIMARY SECONDARY ALIAS sor...
[ "Returns", "a", "list", "of", "zones", "across", "all", "of", "the", "user", "s", "accounts", "." ]
e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec
https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L158-L180
train
62,699