repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
mvn23/pyotgw
pyotgw/protocol.py
protocol._dissect_msg
def _dissect_msg(self, match): """ Split messages into bytes and return a tuple of bytes. """ recvfrom = match.group(1) frame = bytes.fromhex(match.group(2)) if recvfrom == 'E': _LOGGER.warning("Received erroneous message, ignoring: %s", frame) ret...
python
def _dissect_msg(self, match): """ Split messages into bytes and return a tuple of bytes. """ recvfrom = match.group(1) frame = bytes.fromhex(match.group(2)) if recvfrom == 'E': _LOGGER.warning("Received erroneous message, ignoring: %s", frame) ret...
[ "def", "_dissect_msg", "(", "self", ",", "match", ")", ":", "recvfrom", "=", "match", ".", "group", "(", "1", ")", "frame", "=", "bytes", ".", "fromhex", "(", "match", ".", "group", "(", "2", ")", ")", "if", "recvfrom", "==", "'E'", ":", "_LOGGER",...
Split messages into bytes and return a tuple of bytes.
[ "Split", "messages", "into", "bytes", "and", "return", "a", "tuple", "of", "bytes", "." ]
7612378ef4332b250176505af33e7536d6c9da78
https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/protocol.py#L157-L175
train
mvn23/pyotgw
pyotgw/protocol.py
protocol._get_u16
def _get_u16(self, msb, lsb): """ Convert 2 bytes into an unsigned int. """ buf = struct.pack('>BB', self._get_u8(msb), self._get_u8(lsb)) return int(struct.unpack('>H', buf)[0])
python
def _get_u16(self, msb, lsb): """ Convert 2 bytes into an unsigned int. """ buf = struct.pack('>BB', self._get_u8(msb), self._get_u8(lsb)) return int(struct.unpack('>H', buf)[0])
[ "def", "_get_u16", "(", "self", ",", "msb", ",", "lsb", ")", ":", "buf", "=", "struct", ".", "pack", "(", "'>BB'", ",", "self", ".", "_get_u8", "(", "msb", ")", ",", "self", ".", "_get_u8", "(", "lsb", ")", ")", "return", "int", "(", "struct", ...
Convert 2 bytes into an unsigned int.
[ "Convert", "2", "bytes", "into", "an", "unsigned", "int", "." ]
7612378ef4332b250176505af33e7536d6c9da78
https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/protocol.py#L445-L450
train
mvn23/pyotgw
pyotgw/protocol.py
protocol._get_s16
def _get_s16(self, msb, lsb): """ Convert 2 bytes into a signed int. """ buf = struct.pack('>bB', self._get_s8(msb), self._get_u8(lsb)) return int(struct.unpack('>h', buf)[0])
python
def _get_s16(self, msb, lsb): """ Convert 2 bytes into a signed int. """ buf = struct.pack('>bB', self._get_s8(msb), self._get_u8(lsb)) return int(struct.unpack('>h', buf)[0])
[ "def", "_get_s16", "(", "self", ",", "msb", ",", "lsb", ")", ":", "buf", "=", "struct", ".", "pack", "(", "'>bB'", ",", "self", ".", "_get_s8", "(", "msb", ")", ",", "self", ".", "_get_u8", "(", "lsb", ")", ")", "return", "int", "(", "struct", ...
Convert 2 bytes into a signed int.
[ "Convert", "2", "bytes", "into", "a", "signed", "int", "." ]
7612378ef4332b250176505af33e7536d6c9da78
https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/protocol.py#L452-L457
train
mvn23/pyotgw
pyotgw/protocol.py
protocol._report
async def _report(self): """ Call _update_cb with the status dict as an argument whenever a status update occurs. This method is a coroutine """ while True: oldstatus = dict(self.status) stat = await self._updateq.get() if self._update...
python
async def _report(self): """ Call _update_cb with the status dict as an argument whenever a status update occurs. This method is a coroutine """ while True: oldstatus = dict(self.status) stat = await self._updateq.get() if self._update...
[ "async", "def", "_report", "(", "self", ")", ":", "while", "True", ":", "oldstatus", "=", "dict", "(", "self", ".", "status", ")", "stat", "=", "await", "self", ".", "_updateq", ".", "get", "(", ")", "if", "self", ".", "_update_cb", "is", "not", "N...
Call _update_cb with the status dict as an argument whenever a status update occurs. This method is a coroutine
[ "Call", "_update_cb", "with", "the", "status", "dict", "as", "an", "argument", "whenever", "a", "status", "update", "occurs", "." ]
7612378ef4332b250176505af33e7536d6c9da78
https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/protocol.py#L459-L471
train
mvn23/pyotgw
pyotgw/protocol.py
protocol.set_update_cb
async def set_update_cb(self, cb): """Register the update callback.""" if self._report_task is not None and not self._report_task.cancelled(): self.loop.create_task(self._report_task.cancel()) self._update_cb = cb if cb is not None: self._report_task = self.loop.c...
python
async def set_update_cb(self, cb): """Register the update callback.""" if self._report_task is not None and not self._report_task.cancelled(): self.loop.create_task(self._report_task.cancel()) self._update_cb = cb if cb is not None: self._report_task = self.loop.c...
[ "async", "def", "set_update_cb", "(", "self", ",", "cb", ")", ":", "if", "self", ".", "_report_task", "is", "not", "None", "and", "not", "self", ".", "_report_task", ".", "cancelled", "(", ")", ":", "self", ".", "loop", ".", "create_task", "(", "self",...
Register the update callback.
[ "Register", "the", "update", "callback", "." ]
7612378ef4332b250176505af33e7536d6c9da78
https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/protocol.py#L473-L479
train
mvn23/pyotgw
pyotgw/protocol.py
protocol.issue_cmd
async def issue_cmd(self, cmd, value, retry=3): """ Issue a command, then await and return the return value. This method is a coroutine """ async with self._cmd_lock: if not self.connected: _LOGGER.debug( "Serial transport closed, ...
python
async def issue_cmd(self, cmd, value, retry=3): """ Issue a command, then await and return the return value. This method is a coroutine """ async with self._cmd_lock: if not self.connected: _LOGGER.debug( "Serial transport closed, ...
[ "async", "def", "issue_cmd", "(", "self", ",", "cmd", ",", "value", ",", "retry", "=", "3", ")", ":", "async", "with", "self", ".", "_cmd_lock", ":", "if", "not", "self", ".", "connected", ":", "_LOGGER", ".", "debug", "(", "\"Serial transport closed, no...
Issue a command, then await and return the return value. This method is a coroutine
[ "Issue", "a", "command", "then", "await", "and", "return", "the", "return", "value", "." ]
7612378ef4332b250176505af33e7536d6c9da78
https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/protocol.py#L481-L554
train
mvn23/pyotgw
pyotgw/pyotgw.py
pyotgw.get_target_temp
def get_target_temp(self): """ Get the target temperature. """ if not self._connected: return temp_ovrd = self._protocol.status.get(DATA_ROOM_SETPOINT_OVRD) if temp_ovrd: return temp_ovrd return self._protocol.status.get(DATA_ROOM_SETPOINT)
python
def get_target_temp(self): """ Get the target temperature. """ if not self._connected: return temp_ovrd = self._protocol.status.get(DATA_ROOM_SETPOINT_OVRD) if temp_ovrd: return temp_ovrd return self._protocol.status.get(DATA_ROOM_SETPOINT)
[ "def", "get_target_temp", "(", "self", ")", ":", "if", "not", "self", ".", "_connected", ":", "return", "temp_ovrd", "=", "self", ".", "_protocol", ".", "status", ".", "get", "(", "DATA_ROOM_SETPOINT_OVRD", ")", "if", "temp_ovrd", ":", "return", "temp_ovrd",...
Get the target temperature.
[ "Get", "the", "target", "temperature", "." ]
7612378ef4332b250176505af33e7536d6c9da78
https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/pyotgw.py#L113-L122
train
mvn23/pyotgw
pyotgw/pyotgw.py
pyotgw.get_reports
async def get_reports(self): """ Update the pyotgw object with the information from all of the PR commands and return the updated status dict. This method is a coroutine """ cmd = OTGW_CMD_REPORT reports = {} for value in OTGW_REPORTS.keys(): ...
python
async def get_reports(self): """ Update the pyotgw object with the information from all of the PR commands and return the updated status dict. This method is a coroutine """ cmd = OTGW_CMD_REPORT reports = {} for value in OTGW_REPORTS.keys(): ...
[ "async", "def", "get_reports", "(", "self", ")", ":", "cmd", "=", "OTGW_CMD_REPORT", "reports", "=", "{", "}", "for", "value", "in", "OTGW_REPORTS", ".", "keys", "(", ")", ":", "ret", "=", "await", "self", ".", "_wait_for_cmd", "(", "cmd", ",", "value"...
Update the pyotgw object with the information from all of the PR commands and return the updated status dict. This method is a coroutine
[ "Update", "the", "pyotgw", "object", "with", "the", "information", "from", "all", "of", "the", "PR", "commands", "and", "return", "the", "updated", "status", "dict", "." ]
7612378ef4332b250176505af33e7536d6c9da78
https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/pyotgw.py#L218-L278
train
mvn23/pyotgw
pyotgw/pyotgw.py
pyotgw.add_alternative
async def add_alternative(self, alt, timeout=OTGW_DEFAULT_TIMEOUT): """ Add the specified Data-ID to the list of alternative commands to send to the boiler instead of a Data-ID that is known to be unsupported by the boiler. Alternative Data-IDs will always be sent to the boiler i...
python
async def add_alternative(self, alt, timeout=OTGW_DEFAULT_TIMEOUT): """ Add the specified Data-ID to the list of alternative commands to send to the boiler instead of a Data-ID that is known to be unsupported by the boiler. Alternative Data-IDs will always be sent to the boiler i...
[ "async", "def", "add_alternative", "(", "self", ",", "alt", ",", "timeout", "=", "OTGW_DEFAULT_TIMEOUT", ")", ":", "cmd", "=", "OTGW_CMD_ADD_ALT", "alt", "=", "int", "(", "alt", ")", "if", "alt", "<", "1", "or", "alt", ">", "255", ":", "return", "None"...
Add the specified Data-ID to the list of alternative commands to send to the boiler instead of a Data-ID that is known to be unsupported by the boiler. Alternative Data-IDs will always be sent to the boiler in a Read-Data request message with the data-value set to zero. The table of alte...
[ "Add", "the", "specified", "Data", "-", "ID", "to", "the", "list", "of", "alternative", "commands", "to", "send", "to", "the", "boiler", "instead", "of", "a", "Data", "-", "ID", "that", "is", "known", "to", "be", "unsupported", "by", "the", "boiler", "...
7612378ef4332b250176505af33e7536d6c9da78
https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/pyotgw.py#L528-L548
train
mvn23/pyotgw
pyotgw/pyotgw.py
pyotgw.del_alternative
async def del_alternative(self, alt, timeout=OTGW_DEFAULT_TIMEOUT): """ Remove the specified Data-ID from the list of alternative commands. Only one occurrence is deleted. If the Data-ID appears multiple times in the list of alternative commands, this command must be repeated to ...
python
async def del_alternative(self, alt, timeout=OTGW_DEFAULT_TIMEOUT): """ Remove the specified Data-ID from the list of alternative commands. Only one occurrence is deleted. If the Data-ID appears multiple times in the list of alternative commands, this command must be repeated to ...
[ "async", "def", "del_alternative", "(", "self", ",", "alt", ",", "timeout", "=", "OTGW_DEFAULT_TIMEOUT", ")", ":", "cmd", "=", "OTGW_CMD_DEL_ALT", "alt", "=", "int", "(", "alt", ")", "if", "alt", "<", "1", "or", "alt", ">", "255", ":", "return", "None"...
Remove the specified Data-ID from the list of alternative commands. Only one occurrence is deleted. If the Data-ID appears multiple times in the list of alternative commands, this command must be repeated to delete all occurrences. The table of alternative Data-IDs is stored in non-volat...
[ "Remove", "the", "specified", "Data", "-", "ID", "from", "the", "list", "of", "alternative", "commands", ".", "Only", "one", "occurrence", "is", "deleted", ".", "If", "the", "Data", "-", "ID", "appears", "multiple", "times", "in", "the", "list", "of", "a...
7612378ef4332b250176505af33e7536d6c9da78
https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/pyotgw.py#L550-L570
train
mvn23/pyotgw
pyotgw/pyotgw.py
pyotgw.add_unknown_id
async def add_unknown_id(self, unknown_id, timeout=OTGW_DEFAULT_TIMEOUT): """ Inform the gateway that the boiler doesn't support the specified Data-ID, even if the boiler doesn't indicate that by returning an Unknown-DataId response. Using this command allows the gateway to send ...
python
async def add_unknown_id(self, unknown_id, timeout=OTGW_DEFAULT_TIMEOUT): """ Inform the gateway that the boiler doesn't support the specified Data-ID, even if the boiler doesn't indicate that by returning an Unknown-DataId response. Using this command allows the gateway to send ...
[ "async", "def", "add_unknown_id", "(", "self", ",", "unknown_id", ",", "timeout", "=", "OTGW_DEFAULT_TIMEOUT", ")", ":", "cmd", "=", "OTGW_CMD_UNKNOWN_ID", "unknown_id", "=", "int", "(", "unknown_id", ")", "if", "unknown_id", "<", "1", "or", "unknown_id", ">",...
Inform the gateway that the boiler doesn't support the specified Data-ID, even if the boiler doesn't indicate that by returning an Unknown-DataId response. Using this command allows the gateway to send an alternative Data-ID to the boiler instead. Return the added ID, or None on ...
[ "Inform", "the", "gateway", "that", "the", "boiler", "doesn", "t", "support", "the", "specified", "Data", "-", "ID", "even", "if", "the", "boiler", "doesn", "t", "indicate", "that", "by", "returning", "an", "Unknown", "-", "DataId", "response", ".", "Using...
7612378ef4332b250176505af33e7536d6c9da78
https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/pyotgw.py#L572-L589
train
mvn23/pyotgw
pyotgw/pyotgw.py
pyotgw.del_unknown_id
async def del_unknown_id(self, unknown_id, timeout=OTGW_DEFAULT_TIMEOUT): """ Start forwarding the specified Data-ID to the boiler again. This command resets the counter used to determine if the specified Data-ID is supported by the boiler. Return the ID that was marked as suppor...
python
async def del_unknown_id(self, unknown_id, timeout=OTGW_DEFAULT_TIMEOUT): """ Start forwarding the specified Data-ID to the boiler again. This command resets the counter used to determine if the specified Data-ID is supported by the boiler. Return the ID that was marked as suppor...
[ "async", "def", "del_unknown_id", "(", "self", ",", "unknown_id", ",", "timeout", "=", "OTGW_DEFAULT_TIMEOUT", ")", ":", "cmd", "=", "OTGW_CMD_KNOWN_ID", "unknown_id", "=", "int", "(", "unknown_id", ")", "if", "unknown_id", "<", "1", "or", "unknown_id", ">", ...
Start forwarding the specified Data-ID to the boiler again. This command resets the counter used to determine if the specified Data-ID is supported by the boiler. Return the ID that was marked as supported, or None on failure. This method is a coroutine
[ "Start", "forwarding", "the", "specified", "Data", "-", "ID", "to", "the", "boiler", "again", ".", "This", "command", "resets", "the", "counter", "used", "to", "determine", "if", "the", "specified", "Data", "-", "ID", "is", "supported", "by", "the", "boile...
7612378ef4332b250176505af33e7536d6c9da78
https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/pyotgw.py#L591-L606
train
mvn23/pyotgw
pyotgw/pyotgw.py
pyotgw.set_max_ch_setpoint
async def set_max_ch_setpoint(self, temperature, timeout=OTGW_DEFAULT_TIMEOUT): """ Set the maximum central heating setpoint. This command is only available with boilers that support this function. Return the newly accepted setpoint, or None on failure. ...
python
async def set_max_ch_setpoint(self, temperature, timeout=OTGW_DEFAULT_TIMEOUT): """ Set the maximum central heating setpoint. This command is only available with boilers that support this function. Return the newly accepted setpoint, or None on failure. ...
[ "async", "def", "set_max_ch_setpoint", "(", "self", ",", "temperature", ",", "timeout", "=", "OTGW_DEFAULT_TIMEOUT", ")", ":", "cmd", "=", "OTGW_CMD_SET_MAX", "status", "=", "{", "}", "ret", "=", "await", "self", ".", "_wait_for_cmd", "(", "cmd", ",", "tempe...
Set the maximum central heating setpoint. This command is only available with boilers that support this function. Return the newly accepted setpoint, or None on failure. This method is a coroutine
[ "Set", "the", "maximum", "central", "heating", "setpoint", ".", "This", "command", "is", "only", "available", "with", "boilers", "that", "support", "this", "function", ".", "Return", "the", "newly", "accepted", "setpoint", "or", "None", "on", "failure", "." ]
7612378ef4332b250176505af33e7536d6c9da78
https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/pyotgw.py#L648-L665
train
mvn23/pyotgw
pyotgw/pyotgw.py
pyotgw.set_dhw_setpoint
async def set_dhw_setpoint(self, temperature, timeout=OTGW_DEFAULT_TIMEOUT): """ Set the domestic hot water setpoint. This command is only available with boilers that support this function. Return the newly accepted setpoint, or None on failure. Th...
python
async def set_dhw_setpoint(self, temperature, timeout=OTGW_DEFAULT_TIMEOUT): """ Set the domestic hot water setpoint. This command is only available with boilers that support this function. Return the newly accepted setpoint, or None on failure. Th...
[ "async", "def", "set_dhw_setpoint", "(", "self", ",", "temperature", ",", "timeout", "=", "OTGW_DEFAULT_TIMEOUT", ")", ":", "cmd", "=", "OTGW_CMD_SET_WATER", "status", "=", "{", "}", "ret", "=", "await", "self", ".", "_wait_for_cmd", "(", "cmd", ",", "temper...
Set the domestic hot water setpoint. This command is only available with boilers that support this function. Return the newly accepted setpoint, or None on failure. This method is a coroutine
[ "Set", "the", "domestic", "hot", "water", "setpoint", ".", "This", "command", "is", "only", "available", "with", "boilers", "that", "support", "this", "function", ".", "Return", "the", "newly", "accepted", "setpoint", "or", "None", "on", "failure", "." ]
7612378ef4332b250176505af33e7536d6c9da78
https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/pyotgw.py#L667-L684
train
mvn23/pyotgw
pyotgw/pyotgw.py
pyotgw.set_max_relative_mod
async def set_max_relative_mod(self, max_mod, timeout=OTGW_DEFAULT_TIMEOUT): """ Override the maximum relative modulation from the thermostat. Valid values are 0 through 100. Clear the setting by specifying a non-numeric value. Return the newly ...
python
async def set_max_relative_mod(self, max_mod, timeout=OTGW_DEFAULT_TIMEOUT): """ Override the maximum relative modulation from the thermostat. Valid values are 0 through 100. Clear the setting by specifying a non-numeric value. Return the newly ...
[ "async", "def", "set_max_relative_mod", "(", "self", ",", "max_mod", ",", "timeout", "=", "OTGW_DEFAULT_TIMEOUT", ")", ":", "if", "isinstance", "(", "max_mod", ",", "int", ")", "and", "not", "0", "<=", "max_mod", "<=", "100", ":", "return", "None", "cmd", ...
Override the maximum relative modulation from the thermostat. Valid values are 0 through 100. Clear the setting by specifying a non-numeric value. Return the newly accepted value, '-' if a previous value was cleared, or None on failure. This method is a coroutine
[ "Override", "the", "maximum", "relative", "modulation", "from", "the", "thermostat", ".", "Valid", "values", "are", "0", "through", "100", ".", "Clear", "the", "setting", "by", "specifying", "a", "non", "-", "numeric", "value", ".", "Return", "the", "newly",...
7612378ef4332b250176505af33e7536d6c9da78
https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/pyotgw.py#L686-L709
train
mvn23/pyotgw
pyotgw/pyotgw.py
pyotgw.set_control_setpoint
async def set_control_setpoint(self, setpoint, timeout=OTGW_DEFAULT_TIMEOUT): """ Manipulate the control setpoint being sent to the boiler. Set to 0 to pass along the value specified by the thermostat. Return the newly accepted value, or None on failure...
python
async def set_control_setpoint(self, setpoint, timeout=OTGW_DEFAULT_TIMEOUT): """ Manipulate the control setpoint being sent to the boiler. Set to 0 to pass along the value specified by the thermostat. Return the newly accepted value, or None on failure...
[ "async", "def", "set_control_setpoint", "(", "self", ",", "setpoint", ",", "timeout", "=", "OTGW_DEFAULT_TIMEOUT", ")", ":", "cmd", "=", "OTGW_CMD_CONTROL_SETPOINT", "status", "=", "{", "}", "ret", "=", "await", "self", ".", "_wait_for_cmd", "(", "cmd", ",", ...
Manipulate the control setpoint being sent to the boiler. Set to 0 to pass along the value specified by the thermostat. Return the newly accepted value, or None on failure. This method is a coroutine
[ "Manipulate", "the", "control", "setpoint", "being", "sent", "to", "the", "boiler", ".", "Set", "to", "0", "to", "pass", "along", "the", "value", "specified", "by", "the", "thermostat", ".", "Return", "the", "newly", "accepted", "value", "or", "None", "on"...
7612378ef4332b250176505af33e7536d6c9da78
https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/pyotgw.py#L711-L728
train
mvn23/pyotgw
pyotgw/pyotgw.py
pyotgw._send_report
async def _send_report(self, status): """ Call all subscribed coroutines in _notify whenever a status update occurs. This method is a coroutine """ if len(self._notify) > 0: # Each client gets its own copy of the dict. asyncio.gather(*[coro(dict(s...
python
async def _send_report(self, status): """ Call all subscribed coroutines in _notify whenever a status update occurs. This method is a coroutine """ if len(self._notify) > 0: # Each client gets its own copy of the dict. asyncio.gather(*[coro(dict(s...
[ "async", "def", "_send_report", "(", "self", ",", "status", ")", ":", "if", "len", "(", "self", ".", "_notify", ")", ">", "0", ":", "asyncio", ".", "gather", "(", "*", "[", "coro", "(", "dict", "(", "status", ")", ")", "for", "coro", "in", "self"...
Call all subscribed coroutines in _notify whenever a status update occurs. This method is a coroutine
[ "Call", "all", "subscribed", "coroutines", "in", "_notify", "whenever", "a", "status", "update", "occurs", "." ]
7612378ef4332b250176505af33e7536d6c9da78
https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/pyotgw.py#L800-L810
train
mvn23/pyotgw
pyotgw/pyotgw.py
pyotgw._poll_gpio
async def _poll_gpio(self, poll, interval=10): """ Start or stop polling GPIO states. GPIO states aren't being pushed by the gateway, we need to poll if we want updates. """ if poll and self._gpio_task is None: async def polling_routine(interval): ...
python
async def _poll_gpio(self, poll, interval=10): """ Start or stop polling GPIO states. GPIO states aren't being pushed by the gateway, we need to poll if we want updates. """ if poll and self._gpio_task is None: async def polling_routine(interval): ...
[ "async", "def", "_poll_gpio", "(", "self", ",", "poll", ",", "interval", "=", "10", ")", ":", "if", "poll", "and", "self", ".", "_gpio_task", "is", "None", ":", "async", "def", "polling_routine", "(", "interval", ")", ":", "while", "True", ":", "try", ...
Start or stop polling GPIO states. GPIO states aren't being pushed by the gateway, we need to poll if we want updates.
[ "Start", "or", "stop", "polling", "GPIO", "states", "." ]
7612378ef4332b250176505af33e7536d6c9da78
https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/pyotgw.py#L832-L865
train
mvn23/pyotgw
pyotgw/pyotgw.py
pyotgw._update_status
def _update_status(self, update): """Update the status dict and push it to subscribers.""" if isinstance(update, dict): self._protocol.status.update(update) self._protocol._updateq.put_nowait(self._protocol.status)
python
def _update_status(self, update): """Update the status dict and push it to subscribers.""" if isinstance(update, dict): self._protocol.status.update(update) self._protocol._updateq.put_nowait(self._protocol.status)
[ "def", "_update_status", "(", "self", ",", "update", ")", ":", "if", "isinstance", "(", "update", ",", "dict", ")", ":", "self", ".", "_protocol", ".", "status", ".", "update", "(", "update", ")", "self", ".", "_protocol", ".", "_updateq", ".", "put_no...
Update the status dict and push it to subscribers.
[ "Update", "the", "status", "dict", "and", "push", "it", "to", "subscribers", "." ]
7612378ef4332b250176505af33e7536d6c9da78
https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/pyotgw.py#L867-L871
train
avirshup/DockerMake
dockermake/builds.py
BuildTarget.write_dockerfile
def write_dockerfile(self, output_dir): """ Used only to write a Dockerfile that will NOT be built by docker-make """ if not os.path.exists(output_dir): os.makedirs(output_dir) lines = [] for istep, step in enumerate(self.steps): if istep == 0: ...
python
def write_dockerfile(self, output_dir): """ Used only to write a Dockerfile that will NOT be built by docker-make """ if not os.path.exists(output_dir): os.makedirs(output_dir) lines = [] for istep, step in enumerate(self.steps): if istep == 0: ...
[ "def", "write_dockerfile", "(", "self", ",", "output_dir", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "output_dir", ")", ":", "os", ".", "makedirs", "(", "output_dir", ")", "lines", "=", "[", "]", "for", "istep", ",", "step", "in",...
Used only to write a Dockerfile that will NOT be built by docker-make
[ "Used", "only", "to", "write", "a", "Dockerfile", "that", "will", "NOT", "be", "built", "by", "docker", "-", "make" ]
2173199904f086353ef539ea578788b99f6fea0a
https://github.com/avirshup/DockerMake/blob/2173199904f086353ef539ea578788b99f6fea0a/dockermake/builds.py#L47-L62
train
avirshup/DockerMake
dockermake/builds.py
BuildTarget.build
def build(self, client, nobuild=False, usecache=True, pull=False): """ Drives the build of the final image - get the list of steps and execute them. Args: client (docker.Client): docker client object that will build the image nob...
python
def build(self, client, nobuild=False, usecache=True, pull=False): """ Drives the build of the final image - get the list of steps and execute them. Args: client (docker.Client): docker client object that will build the image nob...
[ "def", "build", "(", "self", ",", "client", ",", "nobuild", "=", "False", ",", "usecache", "=", "True", ",", "pull", "=", "False", ")", ":", "if", "not", "nobuild", ":", "self", ".", "update_source_images", "(", "client", ",", "usecache", "=", "usecach...
Drives the build of the final image - get the list of steps and execute them. Args: client (docker.Client): docker client object that will build the image nobuild (bool): just create dockerfiles, don't actually build the image usecache (bool): use docker cache, or rebuild ev...
[ "Drives", "the", "build", "of", "the", "final", "image", "-", "get", "the", "list", "of", "steps", "and", "execute", "them", "." ]
2173199904f086353ef539ea578788b99f6fea0a
https://github.com/avirshup/DockerMake/blob/2173199904f086353ef539ea578788b99f6fea0a/dockermake/builds.py#L64-L119
train
avirshup/DockerMake
dockermake/builds.py
BuildTarget.finalizenames
def finalizenames(self, client, finalimage): """ Tag the built image with its final name and untag intermediate containers """ client.api.tag(finalimage, *self.targetname.split(':')) cprint('Tagged final image as "%s"' % self.targetname, 'green') if not self.keepbu...
python
def finalizenames(self, client, finalimage): """ Tag the built image with its final name and untag intermediate containers """ client.api.tag(finalimage, *self.targetname.split(':')) cprint('Tagged final image as "%s"' % self.targetname, 'green') if not self.keepbu...
[ "def", "finalizenames", "(", "self", ",", "client", ",", "finalimage", ")", ":", "client", ".", "api", ".", "tag", "(", "finalimage", ",", "*", "self", ".", "targetname", ".", "split", "(", "':'", ")", ")", "cprint", "(", "'Tagged final image as \"%s\"'", ...
Tag the built image with its final name and untag intermediate containers
[ "Tag", "the", "built", "image", "with", "its", "final", "name", "and", "untag", "intermediate", "containers" ]
2173199904f086353ef539ea578788b99f6fea0a
https://github.com/avirshup/DockerMake/blob/2173199904f086353ef539ea578788b99f6fea0a/dockermake/builds.py#L142-L153
train
avirshup/DockerMake
dockermake/step.py
BuildStep._resolve_squash_cache
def _resolve_squash_cache(self, client): """ Currently doing a "squash" basically negates the cache for any subsequent layers. But we can work around this by A) checking if the cache was successful for the _unsquashed_ version of the image, and B) if so, re-using an older squashed versio...
python
def _resolve_squash_cache(self, client): """ Currently doing a "squash" basically negates the cache for any subsequent layers. But we can work around this by A) checking if the cache was successful for the _unsquashed_ version of the image, and B) if so, re-using an older squashed versio...
[ "def", "_resolve_squash_cache", "(", "self", ",", "client", ")", ":", "from", ".", "staging", "import", "BUILD_CACHEDIR", "history", "=", "client", ".", "api", ".", "history", "(", "self", ".", "buildname", ")", "comment", "=", "history", "[", "0", "]", ...
Currently doing a "squash" basically negates the cache for any subsequent layers. But we can work around this by A) checking if the cache was successful for the _unsquashed_ version of the image, and B) if so, re-using an older squashed version of the image. Three ways to do this: 1...
[ "Currently", "doing", "a", "squash", "basically", "negates", "the", "cache", "for", "any", "subsequent", "layers", ".", "But", "we", "can", "work", "around", "this", "by", "A", ")", "checking", "if", "the", "cache", "was", "successful", "for", "the", "_uns...
2173199904f086353ef539ea578788b99f6fea0a
https://github.com/avirshup/DockerMake/blob/2173199904f086353ef539ea578788b99f6fea0a/dockermake/step.py#L183-L227
train
avirshup/DockerMake
dockermake/step.py
FileCopyStep.dockerfile_lines
def dockerfile_lines(self): """ Used only when printing dockerfiles, not for building """ w1 = colored( 'WARNING: this build includes files that are built in other images!!! The generated' '\n Dockerfile must be built in a directory that contains' ...
python
def dockerfile_lines(self): """ Used only when printing dockerfiles, not for building """ w1 = colored( 'WARNING: this build includes files that are built in other images!!! The generated' '\n Dockerfile must be built in a directory that contains' ...
[ "def", "dockerfile_lines", "(", "self", ")", ":", "w1", "=", "colored", "(", "'WARNING: this build includes files that are built in other images!!! The generated'", "'\\n Dockerfile must be built in a directory that contains'", "' the file/directory:'", ",", "'red'", ",", "at...
Used only when printing dockerfiles, not for building
[ "Used", "only", "when", "printing", "dockerfiles", "not", "for", "building" ]
2173199904f086353ef539ea578788b99f6fea0a
https://github.com/avirshup/DockerMake/blob/2173199904f086353ef539ea578788b99f6fea0a/dockermake/step.py#L335-L353
train
avirshup/DockerMake
dockermake/imagedefs.py
ImageDefs._check_yaml_and_paths
def _check_yaml_and_paths(ymlfilepath, yamldefs): """ Checks YAML for errors and resolves all paths """ relpath = os.path.relpath(ymlfilepath) if '/' not in relpath: relpath = './%s' % relpath pathroot = os.path.abspath(os.path.dirname(ymlfilepath)) for image...
python
def _check_yaml_and_paths(ymlfilepath, yamldefs): """ Checks YAML for errors and resolves all paths """ relpath = os.path.relpath(ymlfilepath) if '/' not in relpath: relpath = './%s' % relpath pathroot = os.path.abspath(os.path.dirname(ymlfilepath)) for image...
[ "def", "_check_yaml_and_paths", "(", "ymlfilepath", ",", "yamldefs", ")", ":", "relpath", "=", "os", ".", "path", ".", "relpath", "(", "ymlfilepath", ")", "if", "'/'", "not", "in", "relpath", ":", "relpath", "=", "'./%s'", "%", "relpath", "pathroot", "=", ...
Checks YAML for errors and resolves all paths
[ "Checks", "YAML", "for", "errors", "and", "resolves", "all", "paths" ]
2173199904f086353ef539ea578788b99f6fea0a
https://github.com/avirshup/DockerMake/blob/2173199904f086353ef539ea578788b99f6fea0a/dockermake/imagedefs.py#L82-L138
train
avirshup/DockerMake
dockermake/imagedefs.py
ImageDefs.generate_build
def generate_build(self, image, targetname, rebuilds=None, cache_repo='', cache_tag='', buildargs=None, **kwargs): """ Separate the build into a series of one or more intermediate steps. Each specified build directory gets its own step Args: image (str...
python
def generate_build(self, image, targetname, rebuilds=None, cache_repo='', cache_tag='', buildargs=None, **kwargs): """ Separate the build into a series of one or more intermediate steps. Each specified build directory gets its own step Args: image (str...
[ "def", "generate_build", "(", "self", ",", "image", ",", "targetname", ",", "rebuilds", "=", "None", ",", "cache_repo", "=", "''", ",", "cache_tag", "=", "''", ",", "buildargs", "=", "None", ",", "**", "kwargs", ")", ":", "from_image", "=", "self", "."...
Separate the build into a series of one or more intermediate steps. Each specified build directory gets its own step Args: image (str): name of the image as defined in the dockermake.py file targetname (str): name to tag the final built image with rebuilds (List[str]...
[ "Separate", "the", "build", "into", "a", "series", "of", "one", "or", "more", "intermediate", "steps", ".", "Each", "specified", "build", "directory", "gets", "its", "own", "step" ]
2173199904f086353ef539ea578788b99f6fea0a
https://github.com/avirshup/DockerMake/blob/2173199904f086353ef539ea578788b99f6fea0a/dockermake/imagedefs.py#L140-L221
train
avirshup/DockerMake
dockermake/imagedefs.py
ImageDefs.sort_dependencies
def sort_dependencies(self, image, dependencies=None): """ Topologically sort the docker commands by their requirements Note: Circular "requires" dependencies are assumed to have already been checked in get_external_base_image, they are not checked here Args: ...
python
def sort_dependencies(self, image, dependencies=None): """ Topologically sort the docker commands by their requirements Note: Circular "requires" dependencies are assumed to have already been checked in get_external_base_image, they are not checked here Args: ...
[ "def", "sort_dependencies", "(", "self", ",", "image", ",", "dependencies", "=", "None", ")", ":", "if", "dependencies", "is", "None", ":", "dependencies", "=", "OrderedDict", "(", ")", "if", "image", "in", "dependencies", ":", "return", "requires", "=", "...
Topologically sort the docker commands by their requirements Note: Circular "requires" dependencies are assumed to have already been checked in get_external_base_image, they are not checked here Args: image (str): process this docker image's dependencies d...
[ "Topologically", "sort", "the", "docker", "commands", "by", "their", "requirements" ]
2173199904f086353ef539ea578788b99f6fea0a
https://github.com/avirshup/DockerMake/blob/2173199904f086353ef539ea578788b99f6fea0a/dockermake/imagedefs.py#L223-L250
train
avirshup/DockerMake
dockermake/imagedefs.py
ImageDefs.get_external_base_image
def get_external_base_image(self, image, stack=None): """ Makes sure that this image has exactly one unique external base image """ if stack is None: stack = list() mydef = self.ymldefs[image] if image in stack: stack.append(image) raise erro...
python
def get_external_base_image(self, image, stack=None): """ Makes sure that this image has exactly one unique external base image """ if stack is None: stack = list() mydef = self.ymldefs[image] if image in stack: stack.append(image) raise erro...
[ "def", "get_external_base_image", "(", "self", ",", "image", ",", "stack", "=", "None", ")", ":", "if", "stack", "is", "None", ":", "stack", "=", "list", "(", ")", "mydef", "=", "self", ".", "ymldefs", "[", "image", "]", "if", "image", "in", "stack",...
Makes sure that this image has exactly one unique external base image
[ "Makes", "sure", "that", "this", "image", "has", "exactly", "one", "unique", "external", "base", "image" ]
2173199904f086353ef539ea578788b99f6fea0a
https://github.com/avirshup/DockerMake/blob/2173199904f086353ef539ea578788b99f6fea0a/dockermake/imagedefs.py#L252-L301
train
avirshup/DockerMake
dockermake/staging.py
StagedFile.stage
def stage(self, startimage, newimage): """ Copies the file from source to target Args: startimage (str): name of the image to stage these files into newimage (str): name of the created image """ client = utils.get_client() cprint(' Copying file from "%s:...
python
def stage(self, startimage, newimage): """ Copies the file from source to target Args: startimage (str): name of the image to stage these files into newimage (str): name of the created image """ client = utils.get_client() cprint(' Copying file from "%s:...
[ "def", "stage", "(", "self", ",", "startimage", ",", "newimage", ")", ":", "client", "=", "utils", ".", "get_client", "(", ")", "cprint", "(", "' Copying file from \"%s:/%s\" \\n to \"%s://%s/\"'", "%", "(", "self", ".", "sourceimage", ",", "self"...
Copies the file from source to target Args: startimage (str): name of the image to stage these files into newimage (str): name of the created image
[ "Copies", "the", "file", "from", "source", "to", "target" ]
2173199904f086353ef539ea578788b99f6fea0a
https://github.com/avirshup/DockerMake/blob/2173199904f086353ef539ea578788b99f6fea0a/dockermake/staging.py#L60-L115
train
avirshup/DockerMake
dockermake/__main__.py
_runargs
def _runargs(argstring): """ Entrypoint for debugging """ import shlex parser = cli.make_arg_parser() args = parser.parse_args(shlex.split(argstring)) run(args)
python
def _runargs(argstring): """ Entrypoint for debugging """ import shlex parser = cli.make_arg_parser() args = parser.parse_args(shlex.split(argstring)) run(args)
[ "def", "_runargs", "(", "argstring", ")", ":", "import", "shlex", "parser", "=", "cli", ".", "make_arg_parser", "(", ")", "args", "=", "parser", ".", "parse_args", "(", "shlex", ".", "split", "(", "argstring", ")", ")", "run", "(", "args", ")" ]
Entrypoint for debugging
[ "Entrypoint", "for", "debugging" ]
2173199904f086353ef539ea578788b99f6fea0a
https://github.com/avirshup/DockerMake/blob/2173199904f086353ef539ea578788b99f6fea0a/dockermake/__main__.py#L44-L50
train
Cue/scales
src/greplin/scales/util.py
lookup
def lookup(source, keys, fallback = None): """Traverses the source, looking up each key. Returns None if can't find anything instead of raising an exception.""" try: for key in keys: source = source[key] return source except (KeyError, AttributeError, TypeError): return fallback
python
def lookup(source, keys, fallback = None): """Traverses the source, looking up each key. Returns None if can't find anything instead of raising an exception.""" try: for key in keys: source = source[key] return source except (KeyError, AttributeError, TypeError): return fallback
[ "def", "lookup", "(", "source", ",", "keys", ",", "fallback", "=", "None", ")", ":", "try", ":", "for", "key", "in", "keys", ":", "source", "=", "source", "[", "key", "]", "return", "source", "except", "(", "KeyError", ",", "AttributeError", ",", "Ty...
Traverses the source, looking up each key. Returns None if can't find anything instead of raising an exception.
[ "Traverses", "the", "source", "looking", "up", "each", "key", ".", "Returns", "None", "if", "can", "t", "find", "anything", "instead", "of", "raising", "an", "exception", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/util.py#L30-L37
train
Cue/scales
src/greplin/scales/util.py
GraphiteReporter.run
def run(self): """Run the thread.""" while True: try: try: name, value, valueType, stamp = self.queue.get() except TypeError: break self.log(name, value, valueType, stamp) finally: self.queue.task_done()
python
def run(self): """Run the thread.""" while True: try: try: name, value, valueType, stamp = self.queue.get() except TypeError: break self.log(name, value, valueType, stamp) finally: self.queue.task_done()
[ "def", "run", "(", "self", ")", ":", "while", "True", ":", "try", ":", "try", ":", "name", ",", "value", ",", "valueType", ",", "stamp", "=", "self", ".", "queue", ".", "get", "(", ")", "except", "TypeError", ":", "break", "self", ".", "log", "("...
Run the thread.
[ "Run", "the", "thread", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/util.py#L55-L65
train
Cue/scales
src/greplin/scales/util.py
GraphiteReporter.connect
def connect(self): """Connects to the Graphite server if not already connected.""" if self.sock is not None: return backoff = 0.01 while True: try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(5) sock.connect((self.host, self.port)) ...
python
def connect(self): """Connects to the Graphite server if not already connected.""" if self.sock is not None: return backoff = 0.01 while True: try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(5) sock.connect((self.host, self.port)) ...
[ "def", "connect", "(", "self", ")", ":", "if", "self", ".", "sock", "is", "not", "None", ":", "return", "backoff", "=", "0.01", "while", "True", ":", "try", ":", "sock", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", "....
Connects to the Graphite server if not already connected.
[ "Connects", "to", "the", "Graphite", "server", "if", "not", "already", "connected", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/util.py#L68-L82
train
Cue/scales
src/greplin/scales/util.py
GraphiteReporter.disconnect
def disconnect(self): """Disconnect from the Graphite server if connected.""" if self.sock is not None: try: self.sock.close() except socket.error: pass finally: self.sock = None
python
def disconnect(self): """Disconnect from the Graphite server if connected.""" if self.sock is not None: try: self.sock.close() except socket.error: pass finally: self.sock = None
[ "def", "disconnect", "(", "self", ")", ":", "if", "self", ".", "sock", "is", "not", "None", ":", "try", ":", "self", ".", "sock", ".", "close", "(", ")", "except", "socket", ".", "error", ":", "pass", "finally", ":", "self", ".", "sock", "=", "No...
Disconnect from the Graphite server if connected.
[ "Disconnect", "from", "the", "Graphite", "server", "if", "connected", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/util.py#L85-L93
train
Cue/scales
src/greplin/scales/util.py
GraphiteReporter._sendMsg
def _sendMsg(self, msg): """Send a line to graphite. Retry with exponential backoff.""" if not self.sock: self.connect() if not isinstance(msg, binary_type): msg = msg.encode("UTF-8") backoff = 0.001 while True: try: self.sock.sendall(msg) break except socket...
python
def _sendMsg(self, msg): """Send a line to graphite. Retry with exponential backoff.""" if not self.sock: self.connect() if not isinstance(msg, binary_type): msg = msg.encode("UTF-8") backoff = 0.001 while True: try: self.sock.sendall(msg) break except socket...
[ "def", "_sendMsg", "(", "self", ",", "msg", ")", ":", "if", "not", "self", ".", "sock", ":", "self", ".", "connect", "(", ")", "if", "not", "isinstance", "(", "msg", ",", "binary_type", ")", ":", "msg", "=", "msg", ".", "encode", "(", "\"UTF-8\"", ...
Send a line to graphite. Retry with exponential backoff.
[ "Send", "a", "line", "to", "graphite", ".", "Retry", "with", "exponential", "backoff", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/util.py#L96-L113
train
Cue/scales
src/greplin/scales/util.py
GraphiteReporter.log
def log(self, name, value, valueType=None, stamp=None): """Log a named numeric value. The value type may be 'value', 'count', or None.""" if type(value) == float: form = "%s%s %2.2f %d\n" else: form = "%s%s %s %d\n" if valueType is not None and len(valueType) > 0 and valueType[0] != '.'...
python
def log(self, name, value, valueType=None, stamp=None): """Log a named numeric value. The value type may be 'value', 'count', or None.""" if type(value) == float: form = "%s%s %2.2f %d\n" else: form = "%s%s %s %d\n" if valueType is not None and len(valueType) > 0 and valueType[0] != '.'...
[ "def", "log", "(", "self", ",", "name", ",", "value", ",", "valueType", "=", "None", ",", "stamp", "=", "None", ")", ":", "if", "type", "(", "value", ")", "==", "float", ":", "form", "=", "\"%s%s %2.2f %d\\n\"", "else", ":", "form", "=", "\"%s%s %s %...
Log a named numeric value. The value type may be 'value', 'count', or None.
[ "Log", "a", "named", "numeric", "value", ".", "The", "value", "type", "may", "be", "value", "count", "or", "None", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/util.py#L121-L135
train
Cue/scales
src/greplin/scales/util.py
GraphiteReporter.enqueue
def enqueue(self, name, value, valueType=None, stamp=None): """Enqueue a call to log.""" # If queue is too large, refuse to log. if self.maxQueueSize and self.queue.qsize() > self.maxQueueSize: return # Stick arguments into the queue self.queue.put((name, value, valueType, stamp))
python
def enqueue(self, name, value, valueType=None, stamp=None): """Enqueue a call to log.""" # If queue is too large, refuse to log. if self.maxQueueSize and self.queue.qsize() > self.maxQueueSize: return # Stick arguments into the queue self.queue.put((name, value, valueType, stamp))
[ "def", "enqueue", "(", "self", ",", "name", ",", "value", ",", "valueType", "=", "None", ",", "stamp", "=", "None", ")", ":", "if", "self", ".", "maxQueueSize", "and", "self", ".", "queue", ".", "qsize", "(", ")", ">", "self", ".", "maxQueueSize", ...
Enqueue a call to log.
[ "Enqueue", "a", "call", "to", "log", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/util.py#L138-L144
train
Cue/scales
src/greplin/scales/util.py
AtomicValue.update
def update(self, function): """Atomically apply function to the value, and return the old and new values.""" with self.lock: oldValue = self.value self.value = function(oldValue) return oldValue, self.value
python
def update(self, function): """Atomically apply function to the value, and return the old and new values.""" with self.lock: oldValue = self.value self.value = function(oldValue) return oldValue, self.value
[ "def", "update", "(", "self", ",", "function", ")", ":", "with", "self", ".", "lock", ":", "oldValue", "=", "self", ".", "value", "self", ".", "value", "=", "function", "(", "oldValue", ")", "return", "oldValue", ",", "self", ".", "value" ]
Atomically apply function to the value, and return the old and new values.
[ "Atomically", "apply", "function", "to", "the", "value", "and", "return", "the", "old", "and", "new", "values", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/util.py#L167-L172
train
Cue/scales
src/greplin/scales/util.py
EWMA.tick
def tick(self): """Updates rates and decays""" count = self._uncounted.getAndSet(0) instantRate = float(count) / self.interval if self._initialized: self.rate += (self.alpha * (instantRate - self.rate)) else: self.rate = instantRate self._initialized = True
python
def tick(self): """Updates rates and decays""" count = self._uncounted.getAndSet(0) instantRate = float(count) / self.interval if self._initialized: self.rate += (self.alpha * (instantRate - self.rate)) else: self.rate = instantRate self._initialized = True
[ "def", "tick", "(", "self", ")", ":", "count", "=", "self", ".", "_uncounted", ".", "getAndSet", "(", "0", ")", "instantRate", "=", "float", "(", "count", ")", "/", "self", ".", "interval", "if", "self", ".", "_initialized", ":", "self", ".", "rate",...
Updates rates and decays
[ "Updates", "rates", "and", "decays" ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/util.py#L231-L240
train
Cue/scales
src/greplin/scales/__init__.py
statsId
def statsId(obj): """Gets a unique ID for each object.""" if hasattr(obj, ID_KEY): return getattr(obj, ID_KEY) newId = next(NEXT_ID) setattr(obj, ID_KEY, newId) return newId
python
def statsId(obj): """Gets a unique ID for each object.""" if hasattr(obj, ID_KEY): return getattr(obj, ID_KEY) newId = next(NEXT_ID) setattr(obj, ID_KEY, newId) return newId
[ "def", "statsId", "(", "obj", ")", ":", "if", "hasattr", "(", "obj", ",", "ID_KEY", ")", ":", "return", "getattr", "(", "obj", ",", "ID_KEY", ")", "newId", "=", "next", "(", "NEXT_ID", ")", "setattr", "(", "obj", ",", "ID_KEY", ",", "newId", ")", ...
Gets a unique ID for each object.
[ "Gets", "a", "unique", "ID", "for", "each", "object", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/__init__.py#L39-L45
train
Cue/scales
src/greplin/scales/__init__.py
filterCollapsedItems
def filterCollapsedItems(data): """Return a filtered iteration over a list of items.""" return ((key, value)\ for key, value in six.iteritems(data) \ if not (isinstance(value, StatContainer) and value.isCollapsed()))
python
def filterCollapsedItems(data): """Return a filtered iteration over a list of items.""" return ((key, value)\ for key, value in six.iteritems(data) \ if not (isinstance(value, StatContainer) and value.isCollapsed()))
[ "def", "filterCollapsedItems", "(", "data", ")", ":", "return", "(", "(", "key", ",", "value", ")", "for", "key", ",", "value", "in", "six", ".", "iteritems", "(", "data", ")", "if", "not", "(", "isinstance", "(", "value", ",", "StatContainer", ")", ...
Return a filtered iteration over a list of items.
[ "Return", "a", "filtered", "iteration", "over", "a", "list", "of", "items", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/__init__.py#L669-L673
train
Cue/scales
src/greplin/scales/__init__.py
dumpStatsTo
def dumpStatsTo(filename): """Writes the stats dict to filanem""" with open(filename, 'w') as f: latest = getStats() latest['last-updated'] = time.time() json.dump(getStats(), f, cls=StatContainerEncoder)
python
def dumpStatsTo(filename): """Writes the stats dict to filanem""" with open(filename, 'w') as f: latest = getStats() latest['last-updated'] = time.time() json.dump(getStats(), f, cls=StatContainerEncoder)
[ "def", "dumpStatsTo", "(", "filename", ")", ":", "with", "open", "(", "filename", ",", "'w'", ")", "as", "f", ":", "latest", "=", "getStats", "(", ")", "latest", "[", "'last-updated'", "]", "=", "time", ".", "time", "(", ")", "json", ".", "dump", "...
Writes the stats dict to filanem
[ "Writes", "the", "stats", "dict", "to", "filanem" ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/__init__.py#L692-L697
train
Cue/scales
src/greplin/scales/__init__.py
collection
def collection(path, *stats): """Creates a named stats collection object.""" def initMethod(self): """Init method for the underlying stat object's class.""" init(self, path) attributes = {'__init__': initMethod} for stat in stats: attributes[stat.getName()] = stat newClass = type('Stats:%s' % pa...
python
def collection(path, *stats): """Creates a named stats collection object.""" def initMethod(self): """Init method for the underlying stat object's class.""" init(self, path) attributes = {'__init__': initMethod} for stat in stats: attributes[stat.getName()] = stat newClass = type('Stats:%s' % pa...
[ "def", "collection", "(", "path", ",", "*", "stats", ")", ":", "def", "initMethod", "(", "self", ")", ":", "init", "(", "self", ",", "path", ")", "attributes", "=", "{", "'__init__'", ":", "initMethod", "}", "for", "stat", "in", "stats", ":", "attrib...
Creates a named stats collection object.
[ "Creates", "a", "named", "stats", "collection", "object", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/__init__.py#L701-L717
train
Cue/scales
src/greplin/scales/__init__.py
_Stats.reset
def reset(cls): """Resets the static state. Should only be called by tests.""" cls.stats = StatContainer() cls.parentMap = {} cls.containerMap = {} cls.subId = 0 for stat in gc.get_objects(): if isinstance(stat, Stat): stat._aggregators = {}
python
def reset(cls): """Resets the static state. Should only be called by tests.""" cls.stats = StatContainer() cls.parentMap = {} cls.containerMap = {} cls.subId = 0 for stat in gc.get_objects(): if isinstance(stat, Stat): stat._aggregators = {}
[ "def", "reset", "(", "cls", ")", ":", "cls", ".", "stats", "=", "StatContainer", "(", ")", "cls", ".", "parentMap", "=", "{", "}", "cls", ".", "containerMap", "=", "{", "}", "cls", ".", "subId", "=", "0", "for", "stat", "in", "gc", ".", "get_obje...
Resets the static state. Should only be called by tests.
[ "Resets", "the", "static", "state", ".", "Should", "only", "be", "called", "by", "tests", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/__init__.py#L111-L119
train
Cue/scales
src/greplin/scales/__init__.py
_Stats.init
def init(cls, obj, context): """Implementation of init.""" addr = statsId(obj) if addr not in cls.containerMap: cls.containerMap[addr] = cls.__getStatContainer(context) return cls.containerMap[addr]
python
def init(cls, obj, context): """Implementation of init.""" addr = statsId(obj) if addr not in cls.containerMap: cls.containerMap[addr] = cls.__getStatContainer(context) return cls.containerMap[addr]
[ "def", "init", "(", "cls", ",", "obj", ",", "context", ")", ":", "addr", "=", "statsId", "(", "obj", ")", "if", "addr", "not", "in", "cls", ".", "containerMap", ":", "cls", ".", "containerMap", "[", "addr", "]", "=", "cls", ".", "__getStatContainer",...
Implementation of init.
[ "Implementation", "of", "init", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/__init__.py#L123-L128
train
Cue/scales
src/greplin/scales/__init__.py
_Stats.initChild
def initChild(cls, obj, name, subContext, parent = None): """Implementation of initChild.""" addr = statsId(obj) if addr not in cls.containerMap: if not parent: # Find out the parent of the calling object by going back through the call stack until a self != this. f = inspect.currentfra...
python
def initChild(cls, obj, name, subContext, parent = None): """Implementation of initChild.""" addr = statsId(obj) if addr not in cls.containerMap: if not parent: # Find out the parent of the calling object by going back through the call stack until a self != this. f = inspect.currentfra...
[ "def", "initChild", "(", "cls", ",", "obj", ",", "name", ",", "subContext", ",", "parent", "=", "None", ")", ":", "addr", "=", "statsId", "(", "obj", ")", "if", "addr", "not", "in", "cls", ".", "containerMap", ":", "if", "not", "parent", ":", "f", ...
Implementation of initChild.
[ "Implementation", "of", "initChild", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/__init__.py#L138-L169
train
Cue/scales
src/greplin/scales/__init__.py
_Stats.__getStatContainer
def __getStatContainer(cls, context, parent=None): """Get the stat container for the given context under the given parent.""" container = parent if container is None: container = cls.stats if context is not None: context = str(context).lstrip('/') for key in context.split('/'): ...
python
def __getStatContainer(cls, context, parent=None): """Get the stat container for the given context under the given parent.""" container = parent if container is None: container = cls.stats if context is not None: context = str(context).lstrip('/') for key in context.split('/'): ...
[ "def", "__getStatContainer", "(", "cls", ",", "context", ",", "parent", "=", "None", ")", ":", "container", "=", "parent", "if", "container", "is", "None", ":", "container", "=", "cls", ".", "stats", "if", "context", "is", "not", "None", ":", "context", ...
Get the stat container for the given context under the given parent.
[ "Get", "the", "stat", "container", "for", "the", "given", "context", "under", "the", "given", "parent", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/__init__.py#L173-L183
train
Cue/scales
src/greplin/scales/__init__.py
_Stats.getStat
def getStat(cls, obj, name): """Gets the stat for the given object with the given name, or None if no such stat exists.""" objClass = type(obj) for theClass in objClass.__mro__: if theClass == object: break for value in theClass.__dict__.values(): if isinstance(value, Stat) and v...
python
def getStat(cls, obj, name): """Gets the stat for the given object with the given name, or None if no such stat exists.""" objClass = type(obj) for theClass in objClass.__mro__: if theClass == object: break for value in theClass.__dict__.values(): if isinstance(value, Stat) and v...
[ "def", "getStat", "(", "cls", ",", "obj", ",", "name", ")", ":", "objClass", "=", "type", "(", "obj", ")", "for", "theClass", "in", "objClass", ".", "__mro__", ":", "if", "theClass", "==", "object", ":", "break", "for", "value", "in", "theClass", "."...
Gets the stat for the given object with the given name, or None if no such stat exists.
[ "Gets", "the", "stat", "for", "the", "given", "object", "with", "the", "given", "name", "or", "None", "if", "no", "such", "stat", "exists", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/__init__.py#L193-L201
train
Cue/scales
src/greplin/scales/__init__.py
_Stats.getAggregator
def getAggregator(cls, instanceId, name): """Gets the aggregate stat for the given stat.""" parent = cls.parentMap.get(instanceId) while parent: stat = cls.getStat(parent, name) if stat: return stat, parent parent = cls.parentMap.get(statsId(parent))
python
def getAggregator(cls, instanceId, name): """Gets the aggregate stat for the given stat.""" parent = cls.parentMap.get(instanceId) while parent: stat = cls.getStat(parent, name) if stat: return stat, parent parent = cls.parentMap.get(statsId(parent))
[ "def", "getAggregator", "(", "cls", ",", "instanceId", ",", "name", ")", ":", "parent", "=", "cls", ".", "parentMap", ".", "get", "(", "instanceId", ")", "while", "parent", ":", "stat", "=", "cls", ".", "getStat", "(", "parent", ",", "name", ")", "if...
Gets the aggregate stat for the given stat.
[ "Gets", "the", "aggregate", "stat", "for", "the", "given", "stat", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/__init__.py#L205-L212
train
Cue/scales
src/greplin/scales/__init__.py
Stat._aggregate
def _aggregate(self, instanceId, container, value, subKey = None): """Performs stat aggregation.""" # Get the aggregator. if instanceId not in self._aggregators: self._aggregators[instanceId] = _Stats.getAggregator(instanceId, self.__name) aggregator = self._aggregators[instanceId] # If we a...
python
def _aggregate(self, instanceId, container, value, subKey = None): """Performs stat aggregation.""" # Get the aggregator. if instanceId not in self._aggregators: self._aggregators[instanceId] = _Stats.getAggregator(instanceId, self.__name) aggregator = self._aggregators[instanceId] # If we a...
[ "def", "_aggregate", "(", "self", ",", "instanceId", ",", "container", ",", "value", ",", "subKey", "=", "None", ")", ":", "if", "instanceId", "not", "in", "self", ".", "_aggregators", ":", "self", ".", "_aggregators", "[", "instanceId", "]", "=", "_Stat...
Performs stat aggregation.
[ "Performs", "stat", "aggregation", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/__init__.py#L254-L269
train
Cue/scales
src/greplin/scales/__init__.py
Stat.updateItem
def updateItem(self, instance, subKey, value): """Updates a child value. Must be called before the update has actually occurred.""" instanceId = statsId(instance) container = _Stats.getContainerForObject(instanceId) self._aggregate(instanceId, container, value, subKey)
python
def updateItem(self, instance, subKey, value): """Updates a child value. Must be called before the update has actually occurred.""" instanceId = statsId(instance) container = _Stats.getContainerForObject(instanceId) self._aggregate(instanceId, container, value, subKey)
[ "def", "updateItem", "(", "self", ",", "instance", ",", "subKey", ",", "value", ")", ":", "instanceId", "=", "statsId", "(", "instance", ")", "container", "=", "_Stats", ".", "getContainerForObject", "(", "instanceId", ")", "self", ".", "_aggregate", "(", ...
Updates a child value. Must be called before the update has actually occurred.
[ "Updates", "a", "child", "value", ".", "Must", "be", "called", "before", "the", "update", "has", "actually", "occurred", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/__init__.py#L283-L288
train
Cue/scales
src/greplin/scales/__init__.py
StateTimeStatDict.incr
def incr(self, item, value): """Increment a key by the given amount.""" if item in self: old = UserDict.__getitem__(self, item) else: old = 0.0 self[item] = old + value
python
def incr(self, item, value): """Increment a key by the given amount.""" if item in self: old = UserDict.__getitem__(self, item) else: old = 0.0 self[item] = old + value
[ "def", "incr", "(", "self", ",", "item", ",", "value", ")", ":", "if", "item", "in", "self", ":", "old", "=", "UserDict", ".", "__getitem__", "(", "self", ",", "item", ")", "else", ":", "old", "=", "0.0", "self", "[", "item", "]", "=", "old", "...
Increment a key by the given amount.
[ "Increment", "a", "key", "by", "the", "given", "amount", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/__init__.py#L617-L623
train
Cue/scales
src/greplin/scales/aggregation.py
Aggregation.addSource
def addSource(self, source, data): """Adds the given source's stats.""" self._aggregate(source, self._aggregators, data, self._result)
python
def addSource(self, source, data): """Adds the given source's stats.""" self._aggregate(source, self._aggregators, data, self._result)
[ "def", "addSource", "(", "self", ",", "source", ",", "data", ")", ":", "self", ".", "_aggregate", "(", "source", ",", "self", ".", "_aggregators", ",", "data", ",", "self", ".", "_result", ")" ]
Adds the given source's stats.
[ "Adds", "the", "given", "source", "s", "stats", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/aggregation.py#L332-L334
train
Cue/scales
src/greplin/scales/aggregation.py
Aggregation.addJsonDirectory
def addJsonDirectory(self, directory, test=None): """Adds data from json files in the given directory.""" for filename in os.listdir(directory): try: fullPath = os.path.join(directory, filename) if not test or test(filename, fullPath): with open(fullPath) as f: jsonD...
python
def addJsonDirectory(self, directory, test=None): """Adds data from json files in the given directory.""" for filename in os.listdir(directory): try: fullPath = os.path.join(directory, filename) if not test or test(filename, fullPath): with open(fullPath) as f: jsonD...
[ "def", "addJsonDirectory", "(", "self", ",", "directory", ",", "test", "=", "None", ")", ":", "for", "filename", "in", "os", ".", "listdir", "(", "directory", ")", ":", "try", ":", "fullPath", "=", "os", ".", "path", ".", "join", "(", "directory", ",...
Adds data from json files in the given directory.
[ "Adds", "data", "from", "json", "files", "in", "the", "given", "directory", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/aggregation.py#L337-L350
train
Cue/scales
src/greplin/scales/samplestats.py
Sampler.mean
def mean(self): """Return the sample mean.""" if len(self) == 0: return float('NaN') arr = self.samples() return sum(arr) / float(len(arr))
python
def mean(self): """Return the sample mean.""" if len(self) == 0: return float('NaN') arr = self.samples() return sum(arr) / float(len(arr))
[ "def", "mean", "(", "self", ")", ":", "if", "len", "(", "self", ")", "==", "0", ":", "return", "float", "(", "'NaN'", ")", "arr", "=", "self", ".", "samples", "(", ")", "return", "sum", "(", "arr", ")", "/", "float", "(", "len", "(", "arr", "...
Return the sample mean.
[ "Return", "the", "sample", "mean", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/samplestats.py#L46-L51
train
Cue/scales
src/greplin/scales/samplestats.py
Sampler.stddev
def stddev(self): """Return the sample standard deviation.""" if len(self) < 2: return float('NaN') # The stupidest algorithm, but it works fine. try: arr = self.samples() mean = sum(arr) / len(arr) bigsum = 0.0 for x in arr: bigsum += (x - mean)**2 return sqr...
python
def stddev(self): """Return the sample standard deviation.""" if len(self) < 2: return float('NaN') # The stupidest algorithm, but it works fine. try: arr = self.samples() mean = sum(arr) / len(arr) bigsum = 0.0 for x in arr: bigsum += (x - mean)**2 return sqr...
[ "def", "stddev", "(", "self", ")", ":", "if", "len", "(", "self", ")", "<", "2", ":", "return", "float", "(", "'NaN'", ")", "try", ":", "arr", "=", "self", ".", "samples", "(", ")", "mean", "=", "sum", "(", "arr", ")", "/", "len", "(", "arr",...
Return the sample standard deviation.
[ "Return", "the", "sample", "standard", "deviation", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/samplestats.py#L55-L68
train
Cue/scales
src/greplin/scales/samplestats.py
ExponentiallyDecayingReservoir.clear
def clear(self): """ Clear the samples. """ self.__init__(size=self.size, alpha=self.alpha, clock=self.clock)
python
def clear(self): """ Clear the samples. """ self.__init__(size=self.size, alpha=self.alpha, clock=self.clock)
[ "def", "clear", "(", "self", ")", ":", "self", ".", "__init__", "(", "size", "=", "self", ".", "size", ",", "alpha", "=", "self", ".", "alpha", ",", "clock", "=", "self", ".", "clock", ")" ]
Clear the samples.
[ "Clear", "the", "samples", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/samplestats.py#L140-L142
train
Cue/scales
src/greplin/scales/samplestats.py
ExponentiallyDecayingReservoir.update
def update(self, value): """ Adds an old value with a fixed timestamp to the reservoir. @param value the value to be added """ super(ExponentiallyDecayingReservoir, self).update(value) timestamp = self.clock.time() self.__rescaleIfNeeded() priority = self.__weight(timestamp - s...
python
def update(self, value): """ Adds an old value with a fixed timestamp to the reservoir. @param value the value to be added """ super(ExponentiallyDecayingReservoir, self).update(value) timestamp = self.clock.time() self.__rescaleIfNeeded() priority = self.__weight(timestamp - s...
[ "def", "update", "(", "self", ",", "value", ")", ":", "super", "(", "ExponentiallyDecayingReservoir", ",", "self", ")", ".", "update", "(", "value", ")", "timestamp", "=", "self", ".", "clock", ".", "time", "(", ")", "self", ".", "__rescaleIfNeeded", "("...
Adds an old value with a fixed timestamp to the reservoir. @param value the value to be added
[ "Adds", "an", "old", "value", "with", "a", "fixed", "timestamp", "to", "the", "reservoir", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/samplestats.py#L144-L167
train
Cue/scales
src/greplin/scales/samplestats.py
UniformSample.clear
def clear(self): """Clear the sample.""" for i in range(len(self.sample)): self.sample[i] = 0.0 self.count = 0
python
def clear(self): """Clear the sample.""" for i in range(len(self.sample)): self.sample[i] = 0.0 self.count = 0
[ "def", "clear", "(", "self", ")", ":", "for", "i", "in", "range", "(", "len", "(", "self", ".", "sample", ")", ")", ":", "self", ".", "sample", "[", "i", "]", "=", "0.0", "self", ".", "count", "=", "0" ]
Clear the sample.
[ "Clear", "the", "sample", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/samplestats.py#L212-L216
train
Cue/scales
src/greplin/scales/samplestats.py
UniformSample.update
def update(self, value): """Add a value to the sample.""" super(UniformSample, self).update(value) self.count += 1 c = self.count if c < len(self.sample): self.sample[c-1] = value else: r = random.randint(0, c) if r < len(self.sample): self.sample[r] = value
python
def update(self, value): """Add a value to the sample.""" super(UniformSample, self).update(value) self.count += 1 c = self.count if c < len(self.sample): self.sample[c-1] = value else: r = random.randint(0, c) if r < len(self.sample): self.sample[r] = value
[ "def", "update", "(", "self", ",", "value", ")", ":", "super", "(", "UniformSample", ",", "self", ")", ".", "update", "(", "value", ")", "self", ".", "count", "+=", "1", "c", "=", "self", ".", "count", "if", "c", "<", "len", "(", "self", ".", "...
Add a value to the sample.
[ "Add", "a", "value", "to", "the", "sample", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/samplestats.py#L222-L233
train
Cue/scales
src/greplin/scales/graphite.py
GraphitePusher._forbidden
def _forbidden(self, path, value): """Is a stat forbidden? Goes through the rules to find one that applies. Chronologically newer rules are higher-precedence than older ones. If no rule applies, the stat is forbidden by default.""" if path[0] == '/': path = path[1:] for rule in reversed(self.r...
python
def _forbidden(self, path, value): """Is a stat forbidden? Goes through the rules to find one that applies. Chronologically newer rules are higher-precedence than older ones. If no rule applies, the stat is forbidden by default.""" if path[0] == '/': path = path[1:] for rule in reversed(self.r...
[ "def", "_forbidden", "(", "self", ",", "path", ",", "value", ")", ":", "if", "path", "[", "0", "]", "==", "'/'", ":", "path", "=", "path", "[", "1", ":", "]", "for", "rule", "in", "reversed", "(", "self", ".", "rules", ")", ":", "if", "isinstan...
Is a stat forbidden? Goes through the rules to find one that applies. Chronologically newer rules are higher-precedence than older ones. If no rule applies, the stat is forbidden by default.
[ "Is", "a", "stat", "forbidden?", "Goes", "through", "the", "rules", "to", "find", "one", "that", "applies", ".", "Chronologically", "newer", "rules", "are", "higher", "-", "precedence", "than", "older", "ones", ".", "If", "no", "rule", "applies", "the", "s...
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/graphite.py#L55-L67
train
Cue/scales
src/greplin/scales/graphite.py
GraphitePusher._pruned
def _pruned(self, path): """Is a stat tree node pruned? Goes through the list of prune rules to find one that applies. Chronologically newer rules are higher-precedence than older ones. If no rule applies, the stat is not pruned by default.""" if path[0] == '/': path = path[1:] for rule ...
python
def _pruned(self, path): """Is a stat tree node pruned? Goes through the list of prune rules to find one that applies. Chronologically newer rules are higher-precedence than older ones. If no rule applies, the stat is not pruned by default.""" if path[0] == '/': path = path[1:] for rule ...
[ "def", "_pruned", "(", "self", ",", "path", ")", ":", "if", "path", "[", "0", "]", "==", "'/'", ":", "path", "=", "path", "[", "1", ":", "]", "for", "rule", "in", "reversed", "(", "self", ".", "pruneRules", ")", ":", "if", "isinstance", "(", "r...
Is a stat tree node pruned? Goes through the list of prune rules to find one that applies. Chronologically newer rules are higher-precedence than older ones. If no rule applies, the stat is not pruned by default.
[ "Is", "a", "stat", "tree", "node", "pruned?", "Goes", "through", "the", "list", "of", "prune", "rules", "to", "find", "one", "that", "applies", ".", "Chronologically", "newer", "rules", "are", "higher", "-", "precedence", "than", "older", "ones", ".", "If"...
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/graphite.py#L70-L83
train
Cue/scales
src/greplin/scales/graphite.py
GraphitePusher.push
def push(self, statsDict=None, prefix=None, path=None): """Push stat values out to Graphite.""" if statsDict is None: statsDict = scales.getStats() prefix = prefix or self.prefix path = path or '/' for name, value in list(statsDict.items()): name = str(name) subpath = os.path.join...
python
def push(self, statsDict=None, prefix=None, path=None): """Push stat values out to Graphite.""" if statsDict is None: statsDict = scales.getStats() prefix = prefix or self.prefix path = path or '/' for name, value in list(statsDict.items()): name = str(name) subpath = os.path.join...
[ "def", "push", "(", "self", ",", "statsDict", "=", "None", ",", "prefix", "=", "None", ",", "path", "=", "None", ")", ":", "if", "statsDict", "is", "None", ":", "statsDict", "=", "scales", ".", "getStats", "(", ")", "prefix", "=", "prefix", "or", "...
Push stat values out to Graphite.
[ "Push", "stat", "values", "out", "to", "Graphite", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/graphite.py#L86-L118
train
Cue/scales
src/greplin/scales/graphite.py
GraphitePeriodicPusher.run
def run(self): """Loop forever, pushing out stats.""" self.graphite.start() while True: log.debug('Graphite pusher is sleeping for %d seconds', self.period) time.sleep(self.period) log.debug('Pushing stats to Graphite') try: self.push() log.debug('Done pushing stats t...
python
def run(self): """Loop forever, pushing out stats.""" self.graphite.start() while True: log.debug('Graphite pusher is sleeping for %d seconds', self.period) time.sleep(self.period) log.debug('Pushing stats to Graphite') try: self.push() log.debug('Done pushing stats t...
[ "def", "run", "(", "self", ")", ":", "self", ".", "graphite", ".", "start", "(", ")", "while", "True", ":", "log", ".", "debug", "(", "'Graphite pusher is sleeping for %d seconds'", ",", "self", ".", "period", ")", "time", ".", "sleep", "(", "self", ".",...
Loop forever, pushing out stats.
[ "Loop", "forever", "pushing", "out", "stats", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/graphite.py#L163-L175
train
Cue/scales
src/greplin/scales/loop.py
installStatsLoop
def installStatsLoop(statsFile, statsDelay): """Installs an interval loop that dumps stats to a file.""" def dumpStats(): """Actual stats dump function.""" scales.dumpStatsTo(statsFile) reactor.callLater(statsDelay, dumpStats) def startStats(): """Starts the stats dump in "statsDelay" seconds.""...
python
def installStatsLoop(statsFile, statsDelay): """Installs an interval loop that dumps stats to a file.""" def dumpStats(): """Actual stats dump function.""" scales.dumpStatsTo(statsFile) reactor.callLater(statsDelay, dumpStats) def startStats(): """Starts the stats dump in "statsDelay" seconds.""...
[ "def", "installStatsLoop", "(", "statsFile", ",", "statsDelay", ")", ":", "def", "dumpStats", "(", ")", ":", "scales", ".", "dumpStatsTo", "(", "statsFile", ")", "reactor", ".", "callLater", "(", "statsDelay", ",", "dumpStats", ")", "def", "startStats", "(",...
Installs an interval loop that dumps stats to a file.
[ "Installs", "an", "interval", "loop", "that", "dumps", "stats", "to", "a", "file", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/loop.py#L22-L34
train
Cue/scales
src/greplin/scales/formats.py
runQuery
def runQuery(statDict, query): """Filters for the given query.""" parts = [x.strip() for x in OPERATOR.split(query)] assert len(parts) in (1, 3) queryKey = parts[0] result = {} for key, value in six.iteritems(statDict): if key == queryKey: if len(parts) == 3: op = OPERATORS[parts[1]] ...
python
def runQuery(statDict, query): """Filters for the given query.""" parts = [x.strip() for x in OPERATOR.split(query)] assert len(parts) in (1, 3) queryKey = parts[0] result = {} for key, value in six.iteritems(statDict): if key == queryKey: if len(parts) == 3: op = OPERATORS[parts[1]] ...
[ "def", "runQuery", "(", "statDict", ",", "query", ")", ":", "parts", "=", "[", "x", ".", "strip", "(", ")", "for", "x", "in", "OPERATOR", ".", "split", "(", "query", ")", "]", "assert", "len", "(", "parts", ")", "in", "(", "1", ",", "3", ")", ...
Filters for the given query.
[ "Filters", "for", "the", "given", "query", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/formats.py#L38-L60
train
Cue/scales
src/greplin/scales/formats.py
htmlHeader
def htmlHeader(output, path, serverName, query = None): """Writes an HTML header.""" if path and path != '/': output.write('<title>%s - Status: %s</title>' % (serverName, path)) else: output.write('<title>%s - Status</title>' % serverName) output.write(''' <style> body,td { font-family: monospace } .lev...
python
def htmlHeader(output, path, serverName, query = None): """Writes an HTML header.""" if path and path != '/': output.write('<title>%s - Status: %s</title>' % (serverName, path)) else: output.write('<title>%s - Status</title>' % serverName) output.write(''' <style> body,td { font-family: monospace } .lev...
[ "def", "htmlHeader", "(", "output", ",", "path", ",", "serverName", ",", "query", "=", "None", ")", ":", "if", "path", "and", "path", "!=", "'/'", ":", "output", ".", "write", "(", "'<title>%s - Status: %s</title>'", "%", "(", "serverName", ",", "path", ...
Writes an HTML header.
[ "Writes", "an", "HTML", "header", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/formats.py#L63-L88
train
Cue/scales
src/greplin/scales/formats.py
htmlFormat
def htmlFormat(output, pathParts = (), statDict = None, query = None): """Formats as HTML, writing to the given object.""" statDict = statDict or scales.getStats() if query: statDict = runQuery(statDict, query) _htmlRenderDict(pathParts, statDict, output)
python
def htmlFormat(output, pathParts = (), statDict = None, query = None): """Formats as HTML, writing to the given object.""" statDict = statDict or scales.getStats() if query: statDict = runQuery(statDict, query) _htmlRenderDict(pathParts, statDict, output)
[ "def", "htmlFormat", "(", "output", ",", "pathParts", "=", "(", ")", ",", "statDict", "=", "None", ",", "query", "=", "None", ")", ":", "statDict", "=", "statDict", "or", "scales", ".", "getStats", "(", ")", "if", "query", ":", "statDict", "=", "runQ...
Formats as HTML, writing to the given object.
[ "Formats", "as", "HTML", "writing", "to", "the", "given", "object", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/formats.py#L91-L96
train
Cue/scales
src/greplin/scales/formats.py
_htmlRenderDict
def _htmlRenderDict(pathParts, statDict, output): """Render a dictionary as a table - recursing as necessary.""" keys = list(statDict.keys()) keys.sort() links = [] output.write('<div class="level">') for key in keys: keyStr = cgi.escape(_utf8str(key)) value = statDict[key] if hasattr(value, '...
python
def _htmlRenderDict(pathParts, statDict, output): """Render a dictionary as a table - recursing as necessary.""" keys = list(statDict.keys()) keys.sort() links = [] output.write('<div class="level">') for key in keys: keyStr = cgi.escape(_utf8str(key)) value = statDict[key] if hasattr(value, '...
[ "def", "_htmlRenderDict", "(", "pathParts", ",", "statDict", ",", "output", ")", ":", "keys", "=", "list", "(", "statDict", ".", "keys", "(", ")", ")", "keys", ".", "sort", "(", ")", "links", "=", "[", "]", "output", ".", "write", "(", "'<div class=\...
Render a dictionary as a table - recursing as necessary.
[ "Render", "a", "dictionary", "as", "a", "table", "-", "recursing", "as", "necessary", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/formats.py#L99-L128
train
Cue/scales
src/greplin/scales/formats.py
jsonFormat
def jsonFormat(output, statDict = None, query = None, pretty = False): """Formats as JSON, writing to the given object.""" statDict = statDict or scales.getStats() if query: statDict = runQuery(statDict, query) indent = 2 if pretty else None # At first, assume that strings are in UTF-8. If this fails -- i...
python
def jsonFormat(output, statDict = None, query = None, pretty = False): """Formats as JSON, writing to the given object.""" statDict = statDict or scales.getStats() if query: statDict = runQuery(statDict, query) indent = 2 if pretty else None # At first, assume that strings are in UTF-8. If this fails -- i...
[ "def", "jsonFormat", "(", "output", ",", "statDict", "=", "None", ",", "query", "=", "None", ",", "pretty", "=", "False", ")", ":", "statDict", "=", "statDict", "or", "scales", ".", "getStats", "(", ")", "if", "query", ":", "statDict", "=", "runQuery",...
Formats as JSON, writing to the given object.
[ "Formats", "as", "JSON", "writing", "to", "the", "given", "object", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/formats.py#L143-L158
train
Cue/scales
src/greplin/scales/timer.py
RepeatTimer
def RepeatTimer(interval, function, iterations=0, *args, **kwargs): """Repeating timer. Returns a thread id.""" def __repeat_timer(interval, function, iterations, args, kwargs): """Inner function, run in background thread.""" count = 0 while iterations <= 0 or count < iterations: sleep(interval) ...
python
def RepeatTimer(interval, function, iterations=0, *args, **kwargs): """Repeating timer. Returns a thread id.""" def __repeat_timer(interval, function, iterations, args, kwargs): """Inner function, run in background thread.""" count = 0 while iterations <= 0 or count < iterations: sleep(interval) ...
[ "def", "RepeatTimer", "(", "interval", ",", "function", ",", "iterations", "=", "0", ",", "*", "args", ",", "**", "kwargs", ")", ":", "def", "__repeat_timer", "(", "interval", ",", "function", ",", "iterations", ",", "args", ",", "kwargs", ")", ":", "c...
Repeating timer. Returns a thread id.
[ "Repeating", "timer", ".", "Returns", "a", "thread", "id", "." ]
0aced26eb050ceb98ee9d5d6cdca8db448666986
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/timer.py#L39-L50
train
arthurk/django-disqus
disqus/templatetags/disqus_tags.py
get_config
def get_config(context): """ Return the formatted javascript for any disqus config variables. """ conf_vars = ['disqus_developer', 'disqus_identifier', 'disqus_url', 'disqus_title', 'disqus_category_id' ] js = '\t...
python
def get_config(context): """ Return the formatted javascript for any disqus config variables. """ conf_vars = ['disqus_developer', 'disqus_identifier', 'disqus_url', 'disqus_title', 'disqus_category_id' ] js = '\t...
[ "def", "get_config", "(", "context", ")", ":", "conf_vars", "=", "[", "'disqus_developer'", ",", "'disqus_identifier'", ",", "'disqus_url'", ",", "'disqus_title'", ",", "'disqus_category_id'", "]", "js", "=", "'\\tvar {} = \"{}\";'", "output", "=", "[", "js", ".",...
Return the formatted javascript for any disqus config variables.
[ "Return", "the", "formatted", "javascript", "for", "any", "disqus", "config", "variables", "." ]
0db52c240906c6663189c0a7aca9979a0db004d1
https://github.com/arthurk/django-disqus/blob/0db52c240906c6663189c0a7aca9979a0db004d1/disqus/templatetags/disqus_tags.py#L45-L62
train
arthurk/django-disqus
disqus/templatetags/disqus_tags.py
disqus_show_comments
def disqus_show_comments(context, shortname=''): """ Return the HTML code to display DISQUS comments. """ shortname = getattr(settings, 'DISQUS_WEBSITE_SHORTNAME', shortname) return { 'shortname': shortname, 'config': get_config(context), }
python
def disqus_show_comments(context, shortname=''): """ Return the HTML code to display DISQUS comments. """ shortname = getattr(settings, 'DISQUS_WEBSITE_SHORTNAME', shortname) return { 'shortname': shortname, 'config': get_config(context), }
[ "def", "disqus_show_comments", "(", "context", ",", "shortname", "=", "''", ")", ":", "shortname", "=", "getattr", "(", "settings", ",", "'DISQUS_WEBSITE_SHORTNAME'", ",", "shortname", ")", "return", "{", "'shortname'", ":", "shortname", ",", "'config'", ":", ...
Return the HTML code to display DISQUS comments.
[ "Return", "the", "HTML", "code", "to", "display", "DISQUS", "comments", "." ]
0db52c240906c6663189c0a7aca9979a0db004d1
https://github.com/arthurk/django-disqus/blob/0db52c240906c6663189c0a7aca9979a0db004d1/disqus/templatetags/disqus_tags.py#L158-L167
train
arthurk/django-disqus
disqus/wxr_feed.py
WxrFeedType.add_item
def add_item(self, title, link, description, author_email=None, author_name=None, author_link=None, pubdate=None, comments=None, unique_id=None, enclosure=None, categories=(), item_copyright=None, ttl=None, **kwargs): """ Adds an item to the feed. All args are expected to be Pyth...
python
def add_item(self, title, link, description, author_email=None, author_name=None, author_link=None, pubdate=None, comments=None, unique_id=None, enclosure=None, categories=(), item_copyright=None, ttl=None, **kwargs): """ Adds an item to the feed. All args are expected to be Pyth...
[ "def", "add_item", "(", "self", ",", "title", ",", "link", ",", "description", ",", "author_email", "=", "None", ",", "author_name", "=", "None", ",", "author_link", "=", "None", ",", "pubdate", "=", "None", ",", "comments", "=", "None", ",", "unique_id"...
Adds an item to the feed. All args are expected to be Python Unicode objects except pubdate, which is a datetime.datetime object, and enclosure, which is an instance of the Enclosure class.
[ "Adds", "an", "item", "to", "the", "feed", ".", "All", "args", "are", "expected", "to", "be", "Python", "Unicode", "objects", "except", "pubdate", "which", "is", "a", "datetime", ".", "datetime", "object", "and", "enclosure", "which", "is", "an", "instance...
0db52c240906c6663189c0a7aca9979a0db004d1
https://github.com/arthurk/django-disqus/blob/0db52c240906c6663189c0a7aca9979a0db004d1/disqus/wxr_feed.py#L31-L62
train
arthurk/django-disqus
disqus/__init__.py
call
def call(method, data, post=False): """ Calls `method` from the DISQUS API with data either in POST or GET. Returns deserialized JSON response. """ url = "%s%s" % ('http://disqus.com/api/', method) if post: # POST request url += "/" data = urlencode(data) else: ...
python
def call(method, data, post=False): """ Calls `method` from the DISQUS API with data either in POST or GET. Returns deserialized JSON response. """ url = "%s%s" % ('http://disqus.com/api/', method) if post: # POST request url += "/" data = urlencode(data) else: ...
[ "def", "call", "(", "method", ",", "data", ",", "post", "=", "False", ")", ":", "url", "=", "\"%s%s\"", "%", "(", "'http://disqus.com/api/'", ",", "method", ")", "if", "post", ":", "url", "+=", "\"/\"", "data", "=", "urlencode", "(", "data", ")", "el...
Calls `method` from the DISQUS API with data either in POST or GET. Returns deserialized JSON response.
[ "Calls", "method", "from", "the", "DISQUS", "API", "with", "data", "either", "in", "POST", "or", "GET", ".", "Returns", "deserialized", "JSON", "response", "." ]
0db52c240906c6663189c0a7aca9979a0db004d1
https://github.com/arthurk/django-disqus/blob/0db52c240906c6663189c0a7aca9979a0db004d1/disqus/__init__.py#L8-L25
train
arthurk/django-disqus
disqus/management/commands/disqus_export.py
Command._get_comments_to_export
def _get_comments_to_export(self, last_export_id=None): """Return comments which should be exported.""" qs = comments.get_model().objects.order_by('pk')\ .filter(is_public=True, is_removed=False) if last_export_id is not None: print("Resuming after comment %s" % str(l...
python
def _get_comments_to_export(self, last_export_id=None): """Return comments which should be exported.""" qs = comments.get_model().objects.order_by('pk')\ .filter(is_public=True, is_removed=False) if last_export_id is not None: print("Resuming after comment %s" % str(l...
[ "def", "_get_comments_to_export", "(", "self", ",", "last_export_id", "=", "None", ")", ":", "qs", "=", "comments", ".", "get_model", "(", ")", ".", "objects", ".", "order_by", "(", "'pk'", ")", ".", "filter", "(", "is_public", "=", "True", ",", "is_remo...
Return comments which should be exported.
[ "Return", "comments", "which", "should", "be", "exported", "." ]
0db52c240906c6663189c0a7aca9979a0db004d1
https://github.com/arthurk/django-disqus/blob/0db52c240906c6663189c0a7aca9979a0db004d1/disqus/management/commands/disqus_export.py#L32-L39
train
arthurk/django-disqus
disqus/management/commands/disqus_export.py
Command._get_last_state
def _get_last_state(self, state_file): """Checks the given path for the last exported comment's id""" state = None fp = open(state_file) try: state = int(fp.read()) print("Found previous state: %d" % (state,)) finally: fp.close() return...
python
def _get_last_state(self, state_file): """Checks the given path for the last exported comment's id""" state = None fp = open(state_file) try: state = int(fp.read()) print("Found previous state: %d" % (state,)) finally: fp.close() return...
[ "def", "_get_last_state", "(", "self", ",", "state_file", ")", ":", "state", "=", "None", "fp", "=", "open", "(", "state_file", ")", "try", ":", "state", "=", "int", "(", "fp", ".", "read", "(", ")", ")", "print", "(", "\"Found previous state: %d\"", "...
Checks the given path for the last exported comment's id
[ "Checks", "the", "given", "path", "for", "the", "last", "exported", "comment", "s", "id" ]
0db52c240906c6663189c0a7aca9979a0db004d1
https://github.com/arthurk/django-disqus/blob/0db52c240906c6663189c0a7aca9979a0db004d1/disqus/management/commands/disqus_export.py#L41-L50
train
arthurk/django-disqus
disqus/management/commands/disqus_export.py
Command._save_state
def _save_state(self, state_file, last_pk): """Saves the last_pk into the given state_file""" fp = open(state_file, 'w+') try: fp.write(str(last_pk)) finally: fp.close()
python
def _save_state(self, state_file, last_pk): """Saves the last_pk into the given state_file""" fp = open(state_file, 'w+') try: fp.write(str(last_pk)) finally: fp.close()
[ "def", "_save_state", "(", "self", ",", "state_file", ",", "last_pk", ")", ":", "fp", "=", "open", "(", "state_file", ",", "'w+'", ")", "try", ":", "fp", ".", "write", "(", "str", "(", "last_pk", ")", ")", "finally", ":", "fp", ".", "close", "(", ...
Saves the last_pk into the given state_file
[ "Saves", "the", "last_pk", "into", "the", "given", "state_file" ]
0db52c240906c6663189c0a7aca9979a0db004d1
https://github.com/arthurk/django-disqus/blob/0db52c240906c6663189c0a7aca9979a0db004d1/disqus/management/commands/disqus_export.py#L52-L58
train
arthurk/django-disqus
disqus/api.py
DisqusClient._get_request
def _get_request(self, request_url, request_method, **params): """ Return a Request object that has the GET parameters attached to the url or the POST data attached to the object. """ if request_method == 'GET': if params: request_url += '&%s' % urlenc...
python
def _get_request(self, request_url, request_method, **params): """ Return a Request object that has the GET parameters attached to the url or the POST data attached to the object. """ if request_method == 'GET': if params: request_url += '&%s' % urlenc...
[ "def", "_get_request", "(", "self", ",", "request_url", ",", "request_method", ",", "**", "params", ")", ":", "if", "request_method", "==", "'GET'", ":", "if", "params", ":", "request_url", "+=", "'&%s'", "%", "urlencode", "(", "params", ")", "request", "=...
Return a Request object that has the GET parameters attached to the url or the POST data attached to the object.
[ "Return", "a", "Request", "object", "that", "has", "the", "GET", "parameters", "attached", "to", "the", "url", "or", "the", "POST", "data", "attached", "to", "the", "object", "." ]
0db52c240906c6663189c0a7aca9979a0db004d1
https://github.com/arthurk/django-disqus/blob/0db52c240906c6663189c0a7aca9979a0db004d1/disqus/api.py#L65-L76
train
arthurk/django-disqus
disqus/api.py
DisqusClient.call
def call(self, method, **params): """ Call the DISQUS API and return the json response. URLError is raised when the request failed. DisqusException is raised when the query didn't succeed. """ url = self.api_url % method request = self._get_request(url, self.METHO...
python
def call(self, method, **params): """ Call the DISQUS API and return the json response. URLError is raised when the request failed. DisqusException is raised when the query didn't succeed. """ url = self.api_url % method request = self._get_request(url, self.METHO...
[ "def", "call", "(", "self", ",", "method", ",", "**", "params", ")", ":", "url", "=", "self", ".", "api_url", "%", "method", "request", "=", "self", ".", "_get_request", "(", "url", ",", "self", ".", "METHODS", "[", "method", "]", ",", "**", "param...
Call the DISQUS API and return the json response. URLError is raised when the request failed. DisqusException is raised when the query didn't succeed.
[ "Call", "the", "DISQUS", "API", "and", "return", "the", "json", "response", ".", "URLError", "is", "raised", "when", "the", "request", "failed", ".", "DisqusException", "is", "raised", "when", "the", "query", "didn", "t", "succeed", "." ]
0db52c240906c6663189c0a7aca9979a0db004d1
https://github.com/arthurk/django-disqus/blob/0db52c240906c6663189c0a7aca9979a0db004d1/disqus/api.py#L78-L94
train
lavr/flask-emails
flask_emails/message.py
init_app
def init_app(app): """ 'Initialize' flask application. It creates EmailsConfig object and saves it in app.extensions. You don't have to call this method directly. :param app: Flask application object :return: Just created :meth:`~EmailsConfig` object """ config = EmailsConfig(app) ...
python
def init_app(app): """ 'Initialize' flask application. It creates EmailsConfig object and saves it in app.extensions. You don't have to call this method directly. :param app: Flask application object :return: Just created :meth:`~EmailsConfig` object """ config = EmailsConfig(app) ...
[ "def", "init_app", "(", "app", ")", ":", "config", "=", "EmailsConfig", "(", "app", ")", "app", ".", "extensions", "=", "getattr", "(", "app", ",", "'extensions'", ",", "{", "}", ")", "app", ".", "extensions", "[", "'emails'", "]", "=", "config", "re...
'Initialize' flask application. It creates EmailsConfig object and saves it in app.extensions. You don't have to call this method directly. :param app: Flask application object :return: Just created :meth:`~EmailsConfig` object
[ "Initialize", "flask", "application", ".", "It", "creates", "EmailsConfig", "object", "and", "saves", "it", "in", "app", ".", "extensions", "." ]
a1a47108ce7d109fe6c32b6f967445e62f7e5ef6
https://github.com/lavr/flask-emails/blob/a1a47108ce7d109fe6c32b6f967445e62f7e5ef6/flask_emails/message.py#L9-L23
train
lavr/flask-emails
flask_emails/message.py
Message.send
def send(self, smtp=None, **kw): """ Sends message. :param smtp: When set, parameters from this dictionary overwrite options from config. See `emails.Message.send` for more information. :param kwargs: Parameters for `emails.Message.send` :return: Response ...
python
def send(self, smtp=None, **kw): """ Sends message. :param smtp: When set, parameters from this dictionary overwrite options from config. See `emails.Message.send` for more information. :param kwargs: Parameters for `emails.Message.send` :return: Response ...
[ "def", "send", "(", "self", ",", "smtp", "=", "None", ",", "**", "kw", ")", ":", "smtp_options", "=", "{", "}", "smtp_options", ".", "update", "(", "self", ".", "config", ".", "smtp_options", ")", "if", "smtp", ":", "smtp_options", ".", "update", "("...
Sends message. :param smtp: When set, parameters from this dictionary overwrite options from config. See `emails.Message.send` for more information. :param kwargs: Parameters for `emails.Message.send` :return: Response objects from emails backend. For def...
[ "Sends", "message", "." ]
a1a47108ce7d109fe6c32b6f967445e62f7e5ef6
https://github.com/lavr/flask-emails/blob/a1a47108ce7d109fe6c32b6f967445e62f7e5ef6/flask_emails/message.py#L47-L63
train
lavr/flask-emails
flask_emails/config.py
EmailsConfig.options
def options(self): """ Reads all EMAIL_ options and set default values. """ config = self._config o = {} o.update(self._default_smtp_options) o.update(self._default_message_options) o.update(self._default_backend_options) o.update(get_namespace(con...
python
def options(self): """ Reads all EMAIL_ options and set default values. """ config = self._config o = {} o.update(self._default_smtp_options) o.update(self._default_message_options) o.update(self._default_backend_options) o.update(get_namespace(con...
[ "def", "options", "(", "self", ")", ":", "config", "=", "self", ".", "_config", "o", "=", "{", "}", "o", ".", "update", "(", "self", ".", "_default_smtp_options", ")", "o", ".", "update", "(", "self", ".", "_default_message_options", ")", "o", ".", "...
Reads all EMAIL_ options and set default values.
[ "Reads", "all", "EMAIL_", "options", "and", "set", "default", "values", "." ]
a1a47108ce7d109fe6c32b6f967445e62f7e5ef6
https://github.com/lavr/flask-emails/blob/a1a47108ce7d109fe6c32b6f967445e62f7e5ef6/flask_emails/config.py#L109-L121
train
lavr/flask-emails
flask_emails/config.py
EmailsConfig.smtp_options
def smtp_options(self): """ Convert config namespace to emails.backend.SMTPBackend namespace Returns dict for SMTPFactory """ o = {} options = self.options for key in self._default_smtp_options: if key in options: o[key] = options[key] ...
python
def smtp_options(self): """ Convert config namespace to emails.backend.SMTPBackend namespace Returns dict for SMTPFactory """ o = {} options = self.options for key in self._default_smtp_options: if key in options: o[key] = options[key] ...
[ "def", "smtp_options", "(", "self", ")", ":", "o", "=", "{", "}", "options", "=", "self", ".", "options", "for", "key", "in", "self", ".", "_default_smtp_options", ":", "if", "key", "in", "options", ":", "o", "[", "key", "]", "=", "options", "[", "...
Convert config namespace to emails.backend.SMTPBackend namespace Returns dict for SMTPFactory
[ "Convert", "config", "namespace", "to", "emails", ".", "backend", ".", "SMTPBackend", "namespace", "Returns", "dict", "for", "SMTPFactory" ]
a1a47108ce7d109fe6c32b6f967445e62f7e5ef6
https://github.com/lavr/flask-emails/blob/a1a47108ce7d109fe6c32b6f967445e62f7e5ef6/flask_emails/config.py#L124-L144
train
lavr/flask-emails
flask_emails/config.py
EmailsConfig.message_options
def message_options(self): """ Convert config namespace to emails.Message namespace """ o = {} options = self.options for key in self._default_message_options: if key in options: o[key] = options[key] return o
python
def message_options(self): """ Convert config namespace to emails.Message namespace """ o = {} options = self.options for key in self._default_message_options: if key in options: o[key] = options[key] return o
[ "def", "message_options", "(", "self", ")", ":", "o", "=", "{", "}", "options", "=", "self", ".", "options", "for", "key", "in", "self", ".", "_default_message_options", ":", "if", "key", "in", "options", ":", "o", "[", "key", "]", "=", "options", "[...
Convert config namespace to emails.Message namespace
[ "Convert", "config", "namespace", "to", "emails", ".", "Message", "namespace" ]
a1a47108ce7d109fe6c32b6f967445e62f7e5ef6
https://github.com/lavr/flask-emails/blob/a1a47108ce7d109fe6c32b6f967445e62f7e5ef6/flask_emails/config.py#L147-L156
train
acroz/pylivy
livy/session.py
LivySession.start
def start(self) -> None: """Create the remote Spark session and wait for it to be ready.""" session = self.client.create_session( self.kind, self.proxy_user, self.jars, self.py_files, self.files, self.driver_memory, sel...
python
def start(self) -> None: """Create the remote Spark session and wait for it to be ready.""" session = self.client.create_session( self.kind, self.proxy_user, self.jars, self.py_files, self.files, self.driver_memory, sel...
[ "def", "start", "(", "self", ")", "->", "None", ":", "session", "=", "self", ".", "client", ".", "create_session", "(", "self", ".", "kind", ",", "self", ".", "proxy_user", ",", "self", ".", "jars", ",", "self", ".", "py_files", ",", "self", ".", "...
Create the remote Spark session and wait for it to be ready.
[ "Create", "the", "remote", "Spark", "session", "and", "wait", "for", "it", "to", "be", "ready", "." ]
14fc65e19434c51ec959c92acb0925b87a6e3569
https://github.com/acroz/pylivy/blob/14fc65e19434c51ec959c92acb0925b87a6e3569/livy/session.py#L165-L190
train
acroz/pylivy
livy/session.py
LivySession.state
def state(self) -> SessionState: """The state of the managed Spark session.""" if self.session_id is None: raise ValueError("session not yet started") session = self.client.get_session(self.session_id) if session is None: raise ValueError("session not found - it m...
python
def state(self) -> SessionState: """The state of the managed Spark session.""" if self.session_id is None: raise ValueError("session not yet started") session = self.client.get_session(self.session_id) if session is None: raise ValueError("session not found - it m...
[ "def", "state", "(", "self", ")", "->", "SessionState", ":", "if", "self", ".", "session_id", "is", "None", ":", "raise", "ValueError", "(", "\"session not yet started\"", ")", "session", "=", "self", ".", "client", ".", "get_session", "(", "self", ".", "s...
The state of the managed Spark session.
[ "The", "state", "of", "the", "managed", "Spark", "session", "." ]
14fc65e19434c51ec959c92acb0925b87a6e3569
https://github.com/acroz/pylivy/blob/14fc65e19434c51ec959c92acb0925b87a6e3569/livy/session.py#L193-L200
train
acroz/pylivy
livy/session.py
LivySession.close
def close(self) -> None: """Kill the managed Spark session.""" if self.session_id is not None: self.client.delete_session(self.session_id) self.client.close()
python
def close(self) -> None: """Kill the managed Spark session.""" if self.session_id is not None: self.client.delete_session(self.session_id) self.client.close()
[ "def", "close", "(", "self", ")", "->", "None", ":", "if", "self", ".", "session_id", "is", "not", "None", ":", "self", ".", "client", ".", "delete_session", "(", "self", ".", "session_id", ")", "self", ".", "client", ".", "close", "(", ")" ]
Kill the managed Spark session.
[ "Kill", "the", "managed", "Spark", "session", "." ]
14fc65e19434c51ec959c92acb0925b87a6e3569
https://github.com/acroz/pylivy/blob/14fc65e19434c51ec959c92acb0925b87a6e3569/livy/session.py#L202-L206
train
acroz/pylivy
livy/session.py
LivySession.run
def run(self, code: str) -> Output: """Run some code in the managed Spark session. :param code: The code to run. """ output = self._execute(code) if self.echo and output.text: print(output.text) if self.check: output.raise_for_status() ret...
python
def run(self, code: str) -> Output: """Run some code in the managed Spark session. :param code: The code to run. """ output = self._execute(code) if self.echo and output.text: print(output.text) if self.check: output.raise_for_status() ret...
[ "def", "run", "(", "self", ",", "code", ":", "str", ")", "->", "Output", ":", "output", "=", "self", ".", "_execute", "(", "code", ")", "if", "self", ".", "echo", "and", "output", ".", "text", ":", "print", "(", "output", ".", "text", ")", "if", ...
Run some code in the managed Spark session. :param code: The code to run.
[ "Run", "some", "code", "in", "the", "managed", "Spark", "session", "." ]
14fc65e19434c51ec959c92acb0925b87a6e3569
https://github.com/acroz/pylivy/blob/14fc65e19434c51ec959c92acb0925b87a6e3569/livy/session.py#L208-L218
train
acroz/pylivy
livy/session.py
LivySession.read
def read(self, dataframe_name: str) -> pandas.DataFrame: """Evaluate and retrieve a Spark dataframe in the managed session. :param dataframe_name: The name of the Spark dataframe to read. """ code = serialise_dataframe_code(dataframe_name, self.kind) output = self._execute(code)...
python
def read(self, dataframe_name: str) -> pandas.DataFrame: """Evaluate and retrieve a Spark dataframe in the managed session. :param dataframe_name: The name of the Spark dataframe to read. """ code = serialise_dataframe_code(dataframe_name, self.kind) output = self._execute(code)...
[ "def", "read", "(", "self", ",", "dataframe_name", ":", "str", ")", "->", "pandas", ".", "DataFrame", ":", "code", "=", "serialise_dataframe_code", "(", "dataframe_name", ",", "self", ".", "kind", ")", "output", "=", "self", ".", "_execute", "(", "code", ...
Evaluate and retrieve a Spark dataframe in the managed session. :param dataframe_name: The name of the Spark dataframe to read.
[ "Evaluate", "and", "retrieve", "a", "Spark", "dataframe", "in", "the", "managed", "session", "." ]
14fc65e19434c51ec959c92acb0925b87a6e3569
https://github.com/acroz/pylivy/blob/14fc65e19434c51ec959c92acb0925b87a6e3569/livy/session.py#L220-L230
train
acroz/pylivy
livy/session.py
LivySession.read_sql
def read_sql(self, code: str) -> pandas.DataFrame: """Evaluate a Spark SQL satatement and retrieve the result. :param code: The Spark SQL statement to evaluate. """ if self.kind != SessionKind.SQL: raise ValueError("not a SQL session") output = self._execute(code) ...
python
def read_sql(self, code: str) -> pandas.DataFrame: """Evaluate a Spark SQL satatement and retrieve the result. :param code: The Spark SQL statement to evaluate. """ if self.kind != SessionKind.SQL: raise ValueError("not a SQL session") output = self._execute(code) ...
[ "def", "read_sql", "(", "self", ",", "code", ":", "str", ")", "->", "pandas", ".", "DataFrame", ":", "if", "self", ".", "kind", "!=", "SessionKind", ".", "SQL", ":", "raise", "ValueError", "(", "\"not a SQL session\"", ")", "output", "=", "self", ".", ...
Evaluate a Spark SQL satatement and retrieve the result. :param code: The Spark SQL statement to evaluate.
[ "Evaluate", "a", "Spark", "SQL", "satatement", "and", "retrieve", "the", "result", "." ]
14fc65e19434c51ec959c92acb0925b87a6e3569
https://github.com/acroz/pylivy/blob/14fc65e19434c51ec959c92acb0925b87a6e3569/livy/session.py#L232-L243
train
acroz/pylivy
livy/client.py
LivyClient.server_version
def server_version(self) -> Version: """Get the version of Livy running on the server.""" if self._server_version_cache is None: data = self._client.get("/version") self._server_version_cache = Version(data["version"]) return self._server_version_cache
python
def server_version(self) -> Version: """Get the version of Livy running on the server.""" if self._server_version_cache is None: data = self._client.get("/version") self._server_version_cache = Version(data["version"]) return self._server_version_cache
[ "def", "server_version", "(", "self", ")", "->", "Version", ":", "if", "self", ".", "_server_version_cache", "is", "None", ":", "data", "=", "self", ".", "_client", ".", "get", "(", "\"/version\"", ")", "self", ".", "_server_version_cache", "=", "Version", ...
Get the version of Livy running on the server.
[ "Get", "the", "version", "of", "Livy", "running", "on", "the", "server", "." ]
14fc65e19434c51ec959c92acb0925b87a6e3569
https://github.com/acroz/pylivy/blob/14fc65e19434c51ec959c92acb0925b87a6e3569/livy/client.py#L78-L83
train
acroz/pylivy
livy/client.py
LivyClient.list_sessions
def list_sessions(self) -> List[Session]: """List all the active sessions in Livy.""" data = self._client.get("/sessions") return [Session.from_json(item) for item in data["sessions"]]
python
def list_sessions(self) -> List[Session]: """List all the active sessions in Livy.""" data = self._client.get("/sessions") return [Session.from_json(item) for item in data["sessions"]]
[ "def", "list_sessions", "(", "self", ")", "->", "List", "[", "Session", "]", ":", "data", "=", "self", ".", "_client", ".", "get", "(", "\"/sessions\"", ")", "return", "[", "Session", ".", "from_json", "(", "item", ")", "for", "item", "in", "data", "...
List all the active sessions in Livy.
[ "List", "all", "the", "active", "sessions", "in", "Livy", "." ]
14fc65e19434c51ec959c92acb0925b87a6e3569
https://github.com/acroz/pylivy/blob/14fc65e19434c51ec959c92acb0925b87a6e3569/livy/client.py#L94-L97
train
acroz/pylivy
livy/client.py
LivyClient.create_session
def create_session( self, kind: SessionKind, proxy_user: str = None, jars: List[str] = None, py_files: List[str] = None, files: List[str] = None, driver_memory: str = None, driver_cores: int = None, executor_memory: str = None, executor_cor...
python
def create_session( self, kind: SessionKind, proxy_user: str = None, jars: List[str] = None, py_files: List[str] = None, files: List[str] = None, driver_memory: str = None, driver_cores: int = None, executor_memory: str = None, executor_cor...
[ "def", "create_session", "(", "self", ",", "kind", ":", "SessionKind", ",", "proxy_user", ":", "str", "=", "None", ",", "jars", ":", "List", "[", "str", "]", "=", "None", ",", "py_files", ":", "List", "[", "str", "]", "=", "None", ",", "files", ":"...
Create a new session in Livy. The py_files, files, jars and archives arguments are lists of URLs, e.g. ["s3://bucket/object", "hdfs://path/to/file", ...] and must be reachable by the Spark driver process. If the provided URL has no scheme, it's considered to be relative to the default ...
[ "Create", "a", "new", "session", "in", "Livy", "." ]
14fc65e19434c51ec959c92acb0925b87a6e3569
https://github.com/acroz/pylivy/blob/14fc65e19434c51ec959c92acb0925b87a6e3569/livy/client.py#L99-L195
train
acroz/pylivy
livy/client.py
LivyClient.list_statements
def list_statements(self, session_id: int) -> List[Statement]: """Get all the statements in a session. :param session_id: The ID of the session. """ response = self._client.get(f"/sessions/{session_id}/statements") return [ Statement.from_json(session_id, data) ...
python
def list_statements(self, session_id: int) -> List[Statement]: """Get all the statements in a session. :param session_id: The ID of the session. """ response = self._client.get(f"/sessions/{session_id}/statements") return [ Statement.from_json(session_id, data) ...
[ "def", "list_statements", "(", "self", ",", "session_id", ":", "int", ")", "->", "List", "[", "Statement", "]", ":", "response", "=", "self", ".", "_client", ".", "get", "(", "f\"/sessions/{session_id}/statements\"", ")", "return", "[", "Statement", ".", "fr...
Get all the statements in a session. :param session_id: The ID of the session.
[ "Get", "all", "the", "statements", "in", "a", "session", "." ]
14fc65e19434c51ec959c92acb0925b87a6e3569
https://github.com/acroz/pylivy/blob/14fc65e19434c51ec959c92acb0925b87a6e3569/livy/client.py#L218-L227
train
acroz/pylivy
livy/client.py
LivyClient.create_statement
def create_statement( self, session_id: int, code: str, kind: StatementKind = None ) -> Statement: """Run a statement in a session. :param session_id: The ID of the session. :param code: The code to execute. :param kind: The kind of code to execute. """ data...
python
def create_statement( self, session_id: int, code: str, kind: StatementKind = None ) -> Statement: """Run a statement in a session. :param session_id: The ID of the session. :param code: The code to execute. :param kind: The kind of code to execute. """ data...
[ "def", "create_statement", "(", "self", ",", "session_id", ":", "int", ",", "code", ":", "str", ",", "kind", ":", "StatementKind", "=", "None", ")", "->", "Statement", ":", "data", "=", "{", "\"code\"", ":", "code", "}", "if", "kind", "is", "not", "N...
Run a statement in a session. :param session_id: The ID of the session. :param code: The code to execute. :param kind: The kind of code to execute.
[ "Run", "a", "statement", "in", "a", "session", "." ]
14fc65e19434c51ec959c92acb0925b87a6e3569
https://github.com/acroz/pylivy/blob/14fc65e19434c51ec959c92acb0925b87a6e3569/livy/client.py#L229-L249
train
acroz/pylivy
livy/client.py
LivyClient.get_statement
def get_statement(self, session_id: int, statement_id: int) -> Statement: """Get information about a statement in a session. :param session_id: The ID of the session. :param statement_id: The ID of the statement. """ response = self._client.get( f"/sessions/{session_...
python
def get_statement(self, session_id: int, statement_id: int) -> Statement: """Get information about a statement in a session. :param session_id: The ID of the session. :param statement_id: The ID of the statement. """ response = self._client.get( f"/sessions/{session_...
[ "def", "get_statement", "(", "self", ",", "session_id", ":", "int", ",", "statement_id", ":", "int", ")", "->", "Statement", ":", "response", "=", "self", ".", "_client", ".", "get", "(", "f\"/sessions/{session_id}/statements/{statement_id}\"", ")", "return", "S...
Get information about a statement in a session. :param session_id: The ID of the session. :param statement_id: The ID of the statement.
[ "Get", "information", "about", "a", "statement", "in", "a", "session", "." ]
14fc65e19434c51ec959c92acb0925b87a6e3569
https://github.com/acroz/pylivy/blob/14fc65e19434c51ec959c92acb0925b87a6e3569/livy/client.py#L251-L260
train
xflr6/concepts
concepts/visualize.py
lattice
def lattice(lattice, filename, directory, render, view, **kwargs): """Return graphviz source for visualizing the lattice graph.""" dot = graphviz.Digraph( name=lattice.__class__.__name__, comment=repr(lattice), filename=filename, directory=directory, node_attr=dict(shape=...
python
def lattice(lattice, filename, directory, render, view, **kwargs): """Return graphviz source for visualizing the lattice graph.""" dot = graphviz.Digraph( name=lattice.__class__.__name__, comment=repr(lattice), filename=filename, directory=directory, node_attr=dict(shape=...
[ "def", "lattice", "(", "lattice", ",", "filename", ",", "directory", ",", "render", ",", "view", ",", "**", "kwargs", ")", ":", "dot", "=", "graphviz", ".", "Digraph", "(", "name", "=", "lattice", ".", "__class__", ".", "__name__", ",", "comment", "=",...
Return graphviz source for visualizing the lattice graph.
[ "Return", "graphviz", "source", "for", "visualizing", "the", "lattice", "graph", "." ]
2801b27b05fa02cccee7d549451810ffcbf5c942
https://github.com/xflr6/concepts/blob/2801b27b05fa02cccee7d549451810ffcbf5c942/concepts/visualize.py#L15-L50
train
xflr6/concepts
concepts/formats.py
Format.load
def load(cls, filename, encoding): """Load and parse serialized objects, properties, bools from file.""" if encoding is None: encoding = cls.encoding with io.open(filename, 'r', encoding=encoding) as fd: source = fd.read() if cls.normalize_newlines: ...
python
def load(cls, filename, encoding): """Load and parse serialized objects, properties, bools from file.""" if encoding is None: encoding = cls.encoding with io.open(filename, 'r', encoding=encoding) as fd: source = fd.read() if cls.normalize_newlines: ...
[ "def", "load", "(", "cls", ",", "filename", ",", "encoding", ")", ":", "if", "encoding", "is", "None", ":", "encoding", "=", "cls", ".", "encoding", "with", "io", ".", "open", "(", "filename", ",", "'r'", ",", "encoding", "=", "encoding", ")", "as", ...
Load and parse serialized objects, properties, bools from file.
[ "Load", "and", "parse", "serialized", "objects", "properties", "bools", "from", "file", "." ]
2801b27b05fa02cccee7d549451810ffcbf5c942
https://github.com/xflr6/concepts/blob/2801b27b05fa02cccee7d549451810ffcbf5c942/concepts/formats.py#L67-L77
train
xflr6/concepts
concepts/formats.py
Format.dump
def dump(cls, filename, objects, properties, bools, encoding): """Write serialized objects, properties, bools to file.""" if encoding is None: encoding = cls.encoding source = cls.dumps(objects, properties, bools) if PY2: source = unicode(source) with io...
python
def dump(cls, filename, objects, properties, bools, encoding): """Write serialized objects, properties, bools to file.""" if encoding is None: encoding = cls.encoding source = cls.dumps(objects, properties, bools) if PY2: source = unicode(source) with io...
[ "def", "dump", "(", "cls", ",", "filename", ",", "objects", ",", "properties", ",", "bools", ",", "encoding", ")", ":", "if", "encoding", "is", "None", ":", "encoding", "=", "cls", ".", "encoding", "source", "=", "cls", ".", "dumps", "(", "objects", ...
Write serialized objects, properties, bools to file.
[ "Write", "serialized", "objects", "properties", "bools", "to", "file", "." ]
2801b27b05fa02cccee7d549451810ffcbf5c942
https://github.com/xflr6/concepts/blob/2801b27b05fa02cccee7d549451810ffcbf5c942/concepts/formats.py#L80-L90
train