partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
freshroastsr700.set_state_transition_func
THIS FUNCTION MUST BE CALLED BEFORE CALLING freshroastsr700.auto_connect(). Set, or re-set, the state transition function callback. The supplied function will be called from a separate thread within freshroastsr700, triggered by a separate, internal child process. This function ...
freshroastsr700/__init__.py
def set_state_transition_func(self, func): """THIS FUNCTION MUST BE CALLED BEFORE CALLING freshroastsr700.auto_connect(). Set, or re-set, the state transition function callback. The supplied function will be called from a separate thread within freshroastsr700, triggered by a se...
def set_state_transition_func(self, func): """THIS FUNCTION MUST BE CALLED BEFORE CALLING freshroastsr700.auto_connect(). Set, or re-set, the state transition function callback. The supplied function will be called from a separate thread within freshroastsr700, triggered by a se...
[ "THIS", "FUNCTION", "MUST", "BE", "CALLED", "BEFORE", "CALLING", "freshroastsr700", ".", "auto_connect", "()", "." ]
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/__init__.py#L391-L417
[ "def", "set_state_transition_func", "(", "self", ",", "func", ")", ":", "if", "self", ".", "_connected", ".", "value", ":", "logging", ".", "error", "(", "\"freshroastsr700.set_state_transition_func must be \"", "\"called before freshroastsr700.auto_connect().\"", "\" Not r...
49cf4961444c0f56d051d5ac5088ace480b54f02
train
freshroastsr700.update_data_run
This is the thread that listens to an event from the comm process to execute the update_data_func callback in the context of the main process.
freshroastsr700/__init__.py
def update_data_run(self, event_to_wait_on): """This is the thread that listens to an event from the comm process to execute the update_data_func callback in the context of the main process. """ # with the daemon=Turue setting, this thread should # quit 'automati...
def update_data_run(self, event_to_wait_on): """This is the thread that listens to an event from the comm process to execute the update_data_func callback in the context of the main process. """ # with the daemon=Turue setting, this thread should # quit 'automati...
[ "This", "is", "the", "thread", "that", "listens", "to", "an", "event", "from", "the", "comm", "process", "to", "execute", "the", "update_data_func", "callback", "in", "the", "context", "of", "the", "main", "process", "." ]
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/__init__.py#L419-L430
[ "def", "update_data_run", "(", "self", ",", "event_to_wait_on", ")", ":", "# with the daemon=Turue setting, this thread should", "# quit 'automatically'", "while", "event_to_wait_on", ".", "wait", "(", ")", ":", "event_to_wait_on", ".", "clear", "(", ")", "if", "self", ...
49cf4961444c0f56d051d5ac5088ace480b54f02
train
freshroastsr700.state_transition_run
This is the thread that listens to an event from the timer process to execute the state_transition_func callback in the context of the main process.
freshroastsr700/__init__.py
def state_transition_run(self, event_to_wait_on): """This is the thread that listens to an event from the timer process to execute the state_transition_func callback in the context of the main process. """ # with the daemon=Turue setting, this thread should # qui...
def state_transition_run(self, event_to_wait_on): """This is the thread that listens to an event from the timer process to execute the state_transition_func callback in the context of the main process. """ # with the daemon=Turue setting, this thread should # qui...
[ "This", "is", "the", "thread", "that", "listens", "to", "an", "event", "from", "the", "timer", "process", "to", "execute", "the", "state_transition_func", "callback", "in", "the", "context", "of", "the", "main", "process", "." ]
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/__init__.py#L432-L443
[ "def", "state_transition_run", "(", "self", ",", "event_to_wait_on", ")", ":", "# with the daemon=Turue setting, this thread should", "# quit 'automatically'", "while", "event_to_wait_on", ".", "wait", "(", ")", ":", "event_to_wait_on", ".", "clear", "(", ")", "if", "se...
49cf4961444c0f56d051d5ac5088ace480b54f02
train
freshroastsr700._connect
Do not call this directly - call auto_connect() or connect(), which will call _connect() for you. Connects to the roaster and creates communication thread. Raises a RoasterLokkupError exception if the hardware is not found.
freshroastsr700/__init__.py
def _connect(self): """Do not call this directly - call auto_connect() or connect(), which will call _connect() for you. Connects to the roaster and creates communication thread. Raises a RoasterLokkupError exception if the hardware is not found. """ # the following call...
def _connect(self): """Do not call this directly - call auto_connect() or connect(), which will call _connect() for you. Connects to the roaster and creates communication thread. Raises a RoasterLokkupError exception if the hardware is not found. """ # the following call...
[ "Do", "not", "call", "this", "directly", "-", "call", "auto_connect", "()", "or", "connect", "()", "which", "will", "call", "_connect", "()", "for", "you", "." ]
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/__init__.py#L445-L483
[ "def", "_connect", "(", "self", ")", ":", "# the following call raises a RoasterLookupException when the device", "# is not found. It is", "port", "=", "utils", ".", "find_device", "(", "'1A86:5523'", ")", "# on some systems, after the device port is added to the device list,", "# ...
49cf4961444c0f56d051d5ac5088ace480b54f02
train
freshroastsr700._initialize
Sends the initialization packet to the roaster.
freshroastsr700/__init__.py
def _initialize(self): """Sends the initialization packet to the roaster.""" self._header.value = b'\xAA\x55' self._current_state.value = b'\x00\x00' s = self._generate_packet() self._ser.write(s) self._header.value = b'\xAA\xAA' self._current_state.value = b'\x02...
def _initialize(self): """Sends the initialization packet to the roaster.""" self._header.value = b'\xAA\x55' self._current_state.value = b'\x00\x00' s = self._generate_packet() self._ser.write(s) self._header.value = b'\xAA\xAA' self._current_state.value = b'\x02...
[ "Sends", "the", "initialization", "packet", "to", "the", "roaster", "." ]
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/__init__.py#L485-L494
[ "def", "_initialize", "(", "self", ")", ":", "self", ".", "_header", ".", "value", "=", "b'\\xAA\\x55'", "self", ".", "_current_state", ".", "value", "=", "b'\\x00\\x00'", "s", "=", "self", ".", "_generate_packet", "(", ")", "self", ".", "_ser", ".", "wr...
49cf4961444c0f56d051d5ac5088ace480b54f02
train
freshroastsr700.connect
Attempt to connect to hardware immediately. Will not retry. Check freshroastsr700.connected or freshroastsr700.connect_state to verify result. Raises: freshroastsr700.exeptions.RoasterLookupError No hardware connected to the computer.
freshroastsr700/__init__.py
def connect(self): """Attempt to connect to hardware immediately. Will not retry. Check freshroastsr700.connected or freshroastsr700.connect_state to verify result. Raises: freshroastsr700.exeptions.RoasterLookupError No hardware connected to the computer. ...
def connect(self): """Attempt to connect to hardware immediately. Will not retry. Check freshroastsr700.connected or freshroastsr700.connect_state to verify result. Raises: freshroastsr700.exeptions.RoasterLookupError No hardware connected to the computer. ...
[ "Attempt", "to", "connect", "to", "hardware", "immediately", ".", "Will", "not", "retry", ".", "Check", "freshroastsr700", ".", "connected", "or", "freshroastsr700", ".", "connect_state", "to", "verify", "result", ".", "Raises", ":", "freshroastsr700", ".", "exe...
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/__init__.py#L539-L552
[ "def", "connect", "(", "self", ")", ":", "self", ".", "_start_connect", "(", "self", ".", "CA_SINGLE_SHOT", ")", "while", "(", "self", ".", "_connect_state", ".", "value", "==", "self", ".", "CS_ATTEMPTING_CONNECT", "or", "self", ".", "_connect_state", ".", ...
49cf4961444c0f56d051d5ac5088ace480b54f02
train
freshroastsr700._start_connect
Starts the connection process, as called (internally) from the user context, either from auto_connect() or connect(). Never call this from the _comm() process context.
freshroastsr700/__init__.py
def _start_connect(self, connect_type): """Starts the connection process, as called (internally) from the user context, either from auto_connect() or connect(). Never call this from the _comm() process context. """ if self._connect_state.value != self.CS_NOT_CONNECTED: ...
def _start_connect(self, connect_type): """Starts the connection process, as called (internally) from the user context, either from auto_connect() or connect(). Never call this from the _comm() process context. """ if self._connect_state.value != self.CS_NOT_CONNECTED: ...
[ "Starts", "the", "connection", "process", "as", "called", "(", "internally", ")", "from", "the", "user", "context", "either", "from", "auto_connect", "()", "or", "connect", "()", ".", "Never", "call", "this", "from", "the", "_comm", "()", "process", "context...
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/__init__.py#L559-L588
[ "def", "_start_connect", "(", "self", ",", "connect_type", ")", ":", "if", "self", ".", "_connect_state", ".", "value", "!=", "self", ".", "CS_NOT_CONNECTED", ":", "# already done or in process, assume success", "return", "self", ".", "_connected", ".", "value", "...
49cf4961444c0f56d051d5ac5088ace480b54f02
train
freshroastsr700._auto_connect
Attempts to connect to the roaster every quarter of a second.
freshroastsr700/__init__.py
def _auto_connect(self): """Attempts to connect to the roaster every quarter of a second.""" while not self._teardown.value: try: self._connect() return True except exceptions.RoasterLookupError: time.sleep(.25) return False
def _auto_connect(self): """Attempts to connect to the roaster every quarter of a second.""" while not self._teardown.value: try: self._connect() return True except exceptions.RoasterLookupError: time.sleep(.25) return False
[ "Attempts", "to", "connect", "to", "the", "roaster", "every", "quarter", "of", "a", "second", "." ]
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/__init__.py#L590-L598
[ "def", "_auto_connect", "(", "self", ")", ":", "while", "not", "self", ".", "_teardown", ".", "value", ":", "try", ":", "self", ".", "_connect", "(", ")", "return", "True", "except", "exceptions", ".", "RoasterLookupError", ":", "time", ".", "sleep", "("...
49cf4961444c0f56d051d5ac5088ace480b54f02
train
freshroastsr700._comm
Do not call this directly - call auto_connect(), which will spawn comm() for you. This is the main communications loop to the roaster. whenever a valid packet is received from the device, if an update_data_event is available, it will be signalled. Args: thermostat (...
freshroastsr700/__init__.py
def _comm(self, thermostat=False, kp=0.06, ki=0.0075, kd=0.01, heater_segments=8, ext_sw_heater_drive=False, update_data_event=None): """Do not call this directly - call auto_connect(), which will spawn comm() for you. This is the main communications lo...
def _comm(self, thermostat=False, kp=0.06, ki=0.0075, kd=0.01, heater_segments=8, ext_sw_heater_drive=False, update_data_event=None): """Do not call this directly - call auto_connect(), which will spawn comm() for you. This is the main communications lo...
[ "Do", "not", "call", "this", "directly", "-", "call", "auto_connect", "()", "which", "will", "spawn", "comm", "()", "for", "you", "." ]
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/__init__.py#L616-L814
[ "def", "_comm", "(", "self", ",", "thermostat", "=", "False", ",", "kp", "=", "0.06", ",", "ki", "=", "0.0075", ",", "kd", "=", "0.01", ",", "heater_segments", "=", "8", ",", "ext_sw_heater_drive", "=", "False", ",", "update_data_event", "=", "None", "...
49cf4961444c0f56d051d5ac5088ace480b54f02
train
freshroastsr700._timer
Timer loop used to keep track of the time while roasting or cooling. If the time remaining reaches zero, the roaster will call the supplied state transistion function or the roaster will be set to the idle state.
freshroastsr700/__init__.py
def _timer(self, state_transition_event=None): """Timer loop used to keep track of the time while roasting or cooling. If the time remaining reaches zero, the roaster will call the supplied state transistion function or the roaster will be set to the idle state.""" while not self...
def _timer(self, state_transition_event=None): """Timer loop used to keep track of the time while roasting or cooling. If the time remaining reaches zero, the roaster will call the supplied state transistion function or the roaster will be set to the idle state.""" while not self...
[ "Timer", "loop", "used", "to", "keep", "track", "of", "the", "time", "while", "roasting", "or", "cooling", ".", "If", "the", "time", "remaining", "reaches", "zero", "the", "roaster", "will", "call", "the", "supplied", "state", "transistion", "function", "or"...
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/__init__.py#L889-L907
[ "def", "_timer", "(", "self", ",", "state_transition_event", "=", "None", ")", ":", "while", "not", "self", ".", "_teardown", ".", "value", ":", "state", "=", "self", ".", "get_roaster_state", "(", ")", "if", "(", "state", "==", "'roasting'", "or", "stat...
49cf4961444c0f56d051d5ac5088ace480b54f02
train
freshroastsr700.get_roaster_state
Returns a string based upon the current state of the roaster. Will raise an exception if the state is unknown. Returns: 'idle' if idle, 'sleeping' if sleeping, 'cooling' if cooling, 'roasting' if roasting, 'connecting' if in hardware connectio...
freshroastsr700/__init__.py
def get_roaster_state(self): """Returns a string based upon the current state of the roaster. Will raise an exception if the state is unknown. Returns: 'idle' if idle, 'sleeping' if sleeping, 'cooling' if cooling, 'roasting' if roasting, ...
def get_roaster_state(self): """Returns a string based upon the current state of the roaster. Will raise an exception if the state is unknown. Returns: 'idle' if idle, 'sleeping' if sleeping, 'cooling' if cooling, 'roasting' if roasting, ...
[ "Returns", "a", "string", "based", "upon", "the", "current", "state", "of", "the", "roaster", ".", "Will", "raise", "an", "exception", "if", "the", "state", "is", "unknown", "." ]
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/__init__.py#L909-L934
[ "def", "get_roaster_state", "(", "self", ")", ":", "value", "=", "self", ".", "_current_state", ".", "value", "if", "(", "value", "==", "b'\\x02\\x01'", ")", ":", "return", "'idle'", "elif", "(", "value", "==", "b'\\x04\\x04'", ")", ":", "return", "'coolin...
49cf4961444c0f56d051d5ac5088ace480b54f02
train
freshroastsr700._generate_packet
Generates a packet based upon the current class variables. Note that current temperature is not sent, as the original application sent zeros to the roaster for the current temperature.
freshroastsr700/__init__.py
def _generate_packet(self): """Generates a packet based upon the current class variables. Note that current temperature is not sent, as the original application sent zeros to the roaster for the current temperature.""" roaster_time = utils.seconds_to_float(self._time_remaining.value) ...
def _generate_packet(self): """Generates a packet based upon the current class variables. Note that current temperature is not sent, as the original application sent zeros to the roaster for the current temperature.""" roaster_time = utils.seconds_to_float(self._time_remaining.value) ...
[ "Generates", "a", "packet", "based", "upon", "the", "current", "class", "variables", ".", "Note", "that", "current", "temperature", "is", "not", "sent", "as", "the", "original", "application", "sent", "zeros", "to", "the", "roaster", "for", "the", "current", ...
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/__init__.py#L936-L952
[ "def", "_generate_packet", "(", "self", ")", ":", "roaster_time", "=", "utils", ".", "seconds_to_float", "(", "self", ".", "_time_remaining", ".", "value", ")", "packet", "=", "(", "self", ".", "_header", ".", "value", "+", "self", ".", "_temp_unit", ".", ...
49cf4961444c0f56d051d5ac5088ace480b54f02
train
heat_controller.heat_level
Set the desired output level. Must be between 0 and number_of_segments inclusive.
freshroastsr700/__init__.py
def heat_level(self, value): """Set the desired output level. Must be between 0 and number_of_segments inclusive.""" if value < 0: self._heat_level = 0 elif round(value) > self._num_segments: self._heat_level = self._num_segments else: self._he...
def heat_level(self, value): """Set the desired output level. Must be between 0 and number_of_segments inclusive.""" if value < 0: self._heat_level = 0 elif round(value) > self._num_segments: self._heat_level = self._num_segments else: self._he...
[ "Set", "the", "desired", "output", "level", ".", "Must", "be", "between", "0", "and", "number_of_segments", "inclusive", "." ]
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/__init__.py#L1061-L1069
[ "def", "heat_level", "(", "self", ",", "value", ")", ":", "if", "value", "<", "0", ":", "self", ".", "_heat_level", "=", "0", "elif", "round", "(", "value", ")", ">", "self", ".", "_num_segments", ":", "self", ".", "_heat_level", "=", "self", ".", ...
49cf4961444c0f56d051d5ac5088ace480b54f02
train
heat_controller.generate_bangbang_output
Generates the latest on or off pulse in the string of on (True) or off (False) pulses according to the desired heat_level setting. Successive calls to this function will return the next value in the on/off array series. Call this at control loop rate to obtain th...
freshroastsr700/__init__.py
def generate_bangbang_output(self): """Generates the latest on or off pulse in the string of on (True) or off (False) pulses according to the desired heat_level setting. Successive calls to this function will return the next value in the on/off array series. Call th...
def generate_bangbang_output(self): """Generates the latest on or off pulse in the string of on (True) or off (False) pulses according to the desired heat_level setting. Successive calls to this function will return the next value in the on/off array series. Call th...
[ "Generates", "the", "latest", "on", "or", "off", "pulse", "in", "the", "string", "of", "on", "(", "True", ")", "or", "off", "(", "False", ")", "pulses", "according", "to", "the", "desired", "heat_level", "setting", ".", "Successive", "calls", "to", "this...
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/__init__.py#L1071-L1092
[ "def", "generate_bangbang_output", "(", "self", ")", ":", "if", "self", ".", "_current_index", ">=", "self", ".", "_num_segments", ":", "# we're due to switch over to the next", "# commanded heat_level", "self", ".", "_heat_level_now", "=", "self", ".", "_heat_level", ...
49cf4961444c0f56d051d5ac5088ace480b54f02
train
Roaster.update_data
This is a method that will be called every time a packet is opened from the roaster.
examples/pid_tune_aid.py
def update_data(self): """This is a method that will be called every time a packet is opened from the roaster.""" time_elapsed = datetime.datetime.now() - self.start_time crntTemp = self.roaster.current_temp targetTemp = self.roaster.target_temp heaterLevel = self.roaster...
def update_data(self): """This is a method that will be called every time a packet is opened from the roaster.""" time_elapsed = datetime.datetime.now() - self.start_time crntTemp = self.roaster.current_temp targetTemp = self.roaster.target_temp heaterLevel = self.roaster...
[ "This", "is", "a", "method", "that", "will", "be", "called", "every", "time", "a", "packet", "is", "opened", "from", "the", "roaster", "." ]
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/examples/pid_tune_aid.py#L122-L134
[ "def", "update_data", "(", "self", ")", ":", "time_elapsed", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "-", "self", ".", "start_time", "crntTemp", "=", "self", ".", "roaster", ".", "current_temp", "targetTemp", "=", "self", ".", "roaster", ...
49cf4961444c0f56d051d5ac5088ace480b54f02
train
Roaster.next_state
This is a method that will be called when the time remaining ends. The current state can be: roasting, cooling, idle, sleeping, connecting, or unkown.
examples/pid_tune_aid.py
def next_state(self): """This is a method that will be called when the time remaining ends. The current state can be: roasting, cooling, idle, sleeping, connecting, or unkown.""" self.active_recipe_item += 1 if self.active_recipe_item >= len(self.recipe): # we're done...
def next_state(self): """This is a method that will be called when the time remaining ends. The current state can be: roasting, cooling, idle, sleeping, connecting, or unkown.""" self.active_recipe_item += 1 if self.active_recipe_item >= len(self.recipe): # we're done...
[ "This", "is", "a", "method", "that", "will", "be", "called", "when", "the", "time", "remaining", "ends", ".", "The", "current", "state", "can", "be", ":", "roasting", "cooling", "idle", "sleeping", "connecting", "or", "unkown", "." ]
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/examples/pid_tune_aid.py#L136-L169
[ "def", "next_state", "(", "self", ")", ":", "self", ".", "active_recipe_item", "+=", "1", "if", "self", ".", "active_recipe_item", ">=", "len", "(", "self", ".", "recipe", ")", ":", "# we're done!", "return", "# show state step on screen", "print", "(", "\"---...
49cf4961444c0f56d051d5ac5088ace480b54f02
train
DNSBLResult.process_results
Process results by providers
pydnsbl/checker.py
def process_results(self): """ Process results by providers """ for result in self._results: provider = result.provider self.providers.append(provider) if result.error: self.failed_providers.append(provider) continue if not ...
def process_results(self): """ Process results by providers """ for result in self._results: provider = result.provider self.providers.append(provider) if result.error: self.failed_providers.append(provider) continue if not ...
[ "Process", "results", "by", "providers" ]
dmippolitov/pydnsbl
python
https://github.com/dmippolitov/pydnsbl/blob/76c460f1118213d66498ddafde2053d8de4ccbdb/pydnsbl/checker.py#L39-L54
[ "def", "process_results", "(", "self", ")", ":", "for", "result", "in", "self", ".", "_results", ":", "provider", "=", "result", ".", "provider", "self", ".", "providers", ".", "append", "(", "provider", ")", "if", "result", ".", "error", ":", "self", ...
76c460f1118213d66498ddafde2053d8de4ccbdb
train
DNSBLChecker.dnsbl_request
Make lookup to dnsbl provider Parameters: * addr (string) - ip address to check * provider (string) - dnsbl provider Returns: * DNSBLResponse object Raises: * ValueError
pydnsbl/checker.py
async def dnsbl_request(self, addr, provider): """ Make lookup to dnsbl provider Parameters: * addr (string) - ip address to check * provider (string) - dnsbl provider Returns: * DNSBLResponse object Raises: * ValueError "...
async def dnsbl_request(self, addr, provider): """ Make lookup to dnsbl provider Parameters: * addr (string) - ip address to check * provider (string) - dnsbl provider Returns: * DNSBLResponse object Raises: * ValueError "...
[ "Make", "lookup", "to", "dnsbl", "provider", "Parameters", ":", "*", "addr", "(", "string", ")", "-", "ip", "address", "to", "check", "*", "provider", "(", "string", ")", "-", "dnsbl", "provider" ]
dmippolitov/pydnsbl
python
https://github.com/dmippolitov/pydnsbl/blob/76c460f1118213d66498ddafde2053d8de4ccbdb/pydnsbl/checker.py#L92-L120
[ "async", "def", "dnsbl_request", "(", "self", ",", "addr", ",", "provider", ")", ":", "response", "=", "None", "error", "=", "None", "try", ":", "socket", ".", "inet_aton", "(", "addr", ")", "except", "socket", ".", "error", ":", "raise", "ValueError", ...
76c460f1118213d66498ddafde2053d8de4ccbdb
train
DNSBLChecker._check_ip
Async check ip with dnsbl providers. Parameters: * addr - ip address to check Returns: * DNSBLResult object
pydnsbl/checker.py
async def _check_ip(self, addr): """ Async check ip with dnsbl providers. Parameters: * addr - ip address to check Returns: * DNSBLResult object """ tasks = [] for provider in self.providers: tasks.append(self.dnsbl_request(ad...
async def _check_ip(self, addr): """ Async check ip with dnsbl providers. Parameters: * addr - ip address to check Returns: * DNSBLResult object """ tasks = [] for provider in self.providers: tasks.append(self.dnsbl_request(ad...
[ "Async", "check", "ip", "with", "dnsbl", "providers", ".", "Parameters", ":", "*", "addr", "-", "ip", "address", "to", "check" ]
dmippolitov/pydnsbl
python
https://github.com/dmippolitov/pydnsbl/blob/76c460f1118213d66498ddafde2053d8de4ccbdb/pydnsbl/checker.py#L122-L136
[ "async", "def", "_check_ip", "(", "self", ",", "addr", ")", ":", "tasks", "=", "[", "]", "for", "provider", "in", "self", ".", "providers", ":", "tasks", ".", "append", "(", "self", ".", "dnsbl_request", "(", "addr", ",", "provider", ")", ")", "resul...
76c460f1118213d66498ddafde2053d8de4ccbdb
train
DNSBLChecker.check_ips
sync check multiple ips
pydnsbl/checker.py
def check_ips(self, addrs): """ sync check multiple ips """ tasks = [] for addr in addrs: tasks.append(self._check_ip(addr)) return self._loop.run_until_complete(asyncio.gather(*tasks))
def check_ips(self, addrs): """ sync check multiple ips """ tasks = [] for addr in addrs: tasks.append(self._check_ip(addr)) return self._loop.run_until_complete(asyncio.gather(*tasks))
[ "sync", "check", "multiple", "ips" ]
dmippolitov/pydnsbl
python
https://github.com/dmippolitov/pydnsbl/blob/76c460f1118213d66498ddafde2053d8de4ccbdb/pydnsbl/checker.py#L150-L157
[ "def", "check_ips", "(", "self", ",", "addrs", ")", ":", "tasks", "=", "[", "]", "for", "addr", "in", "addrs", ":", "tasks", ".", "append", "(", "self", ".", "_check_ip", "(", "addr", ")", ")", "return", "self", ".", "_loop", ".", "run_until_complete...
76c460f1118213d66498ddafde2053d8de4ccbdb
train
frange
A generator that will generate a range of floats.
freshroastsr700/utils.py
def frange(start, stop, step, precision): """A generator that will generate a range of floats.""" value = start while round(value, precision) < stop: yield round(value, precision) value += step
def frange(start, stop, step, precision): """A generator that will generate a range of floats.""" value = start while round(value, precision) < stop: yield round(value, precision) value += step
[ "A", "generator", "that", "will", "generate", "a", "range", "of", "floats", "." ]
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/utils.py#L11-L16
[ "def", "frange", "(", "start", ",", "stop", ",", "step", ",", "precision", ")", ":", "value", "=", "start", "while", "round", "(", "value", ",", "precision", ")", "<", "stop", ":", "yield", "round", "(", "value", ",", "precision", ")", "value", "+=",...
49cf4961444c0f56d051d5ac5088ace480b54f02
train
find_device
Finds a connected device with the given VID:PID. Returns the serial port url.
freshroastsr700/utils.py
def find_device(vidpid): """Finds a connected device with the given VID:PID. Returns the serial port url.""" for port in list_ports.comports(): if re.search(vidpid, port[2], flags=re.IGNORECASE): return port[0] raise exceptions.RoasterLookupError
def find_device(vidpid): """Finds a connected device with the given VID:PID. Returns the serial port url.""" for port in list_ports.comports(): if re.search(vidpid, port[2], flags=re.IGNORECASE): return port[0] raise exceptions.RoasterLookupError
[ "Finds", "a", "connected", "device", "with", "the", "given", "VID", ":", "PID", ".", "Returns", "the", "serial", "port", "url", "." ]
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/utils.py#L19-L26
[ "def", "find_device", "(", "vidpid", ")", ":", "for", "port", "in", "list_ports", ".", "comports", "(", ")", ":", "if", "re", ".", "search", "(", "vidpid", ",", "port", "[", "2", "]", ",", "flags", "=", "re", ".", "IGNORECASE", ")", ":", "return", ...
49cf4961444c0f56d051d5ac5088ace480b54f02
train
PID.update
Calculate PID output value for given reference input and feedback.
freshroastsr700/pid.py
def update(self, currentTemp, targetTemp): """Calculate PID output value for given reference input and feedback.""" # in this implementation, ki includes the dt multiplier term, # and kd includes the dt divisor term. This is typical practice in # industry. self.targetTemp = targ...
def update(self, currentTemp, targetTemp): """Calculate PID output value for given reference input and feedback.""" # in this implementation, ki includes the dt multiplier term, # and kd includes the dt divisor term. This is typical practice in # industry. self.targetTemp = targ...
[ "Calculate", "PID", "output", "value", "for", "given", "reference", "input", "and", "feedback", "." ]
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/pid.py#L28-L59
[ "def", "update", "(", "self", ",", "currentTemp", ",", "targetTemp", ")", ":", "# in this implementation, ki includes the dt multiplier term,", "# and kd includes the dt divisor term. This is typical practice in", "# industry.", "self", ".", "targetTemp", "=", "targetTemp", "sel...
49cf4961444c0f56d051d5ac5088ace480b54f02
train
PID.setPoint
Initilize the setpoint of PID.
freshroastsr700/pid.py
def setPoint(self, targetTemp): """Initilize the setpoint of PID.""" self.targetTemp = targetTemp self.Integrator = 0 self.Derivator = 0
def setPoint(self, targetTemp): """Initilize the setpoint of PID.""" self.targetTemp = targetTemp self.Integrator = 0 self.Derivator = 0
[ "Initilize", "the", "setpoint", "of", "PID", "." ]
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/pid.py#L61-L65
[ "def", "setPoint", "(", "self", ",", "targetTemp", ")", ":", "self", ".", "targetTemp", "=", "targetTemp", "self", ".", "Integrator", "=", "0", "self", ".", "Derivator", "=", "0" ]
49cf4961444c0f56d051d5ac5088ace480b54f02
train
Roaster.next_state
This is a method that will be called when the time remaining ends. The current state can be: roasting, cooling, idle, sleeping, connecting, or unkown.
examples/advanced.py
def next_state(self): """This is a method that will be called when the time remaining ends. The current state can be: roasting, cooling, idle, sleeping, connecting, or unkown.""" if(self.roaster.get_roaster_state() == 'roasting'): self.roaster.time_remaining = 20 ...
def next_state(self): """This is a method that will be called when the time remaining ends. The current state can be: roasting, cooling, idle, sleeping, connecting, or unkown.""" if(self.roaster.get_roaster_state() == 'roasting'): self.roaster.time_remaining = 20 ...
[ "This", "is", "a", "method", "that", "will", "be", "called", "when", "the", "time", "remaining", "ends", ".", "The", "current", "state", "can", "be", ":", "roasting", "cooling", "idle", "sleeping", "connecting", "or", "unkown", "." ]
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/examples/advanced.py#L21-L29
[ "def", "next_state", "(", "self", ")", ":", "if", "(", "self", ".", "roaster", ".", "get_roaster_state", "(", ")", "==", "'roasting'", ")", ":", "self", ".", "roaster", ".", "time_remaining", "=", "20", "self", ".", "roaster", ".", "cool", "(", ")", ...
49cf4961444c0f56d051d5ac5088ace480b54f02
train
Random.load_nouns
Load dict from file for random words. :param str file: filename
random_words/random_words.py
def load_nouns(self, file): """ Load dict from file for random words. :param str file: filename """ with open(os.path.join(main_dir, file + '.dat'), 'r') as f: self.nouns = json.load(f)
def load_nouns(self, file): """ Load dict from file for random words. :param str file: filename """ with open(os.path.join(main_dir, file + '.dat'), 'r') as f: self.nouns = json.load(f)
[ "Load", "dict", "from", "file", "for", "random", "words", "." ]
tomislater/RandomWords
python
https://github.com/tomislater/RandomWords/blob/601aa48732d3c389f4c17ba0ed98ffe0e4821d78/random_words/random_words.py#L30-L37
[ "def", "load_nouns", "(", "self", ",", "file", ")", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "main_dir", ",", "file", "+", "'.dat'", ")", ",", "'r'", ")", "as", "f", ":", "self", ".", "nouns", "=", "json", ".", "load", "("...
601aa48732d3c389f4c17ba0ed98ffe0e4821d78
train
Random.load_dmails
Load list from file for random mails :param str file: filename
random_words/random_words.py
def load_dmails(self, file): """ Load list from file for random mails :param str file: filename """ with open(os.path.join(main_dir, file + '.dat'), 'r') as f: self.dmails = frozenset(json.load(f))
def load_dmails(self, file): """ Load list from file for random mails :param str file: filename """ with open(os.path.join(main_dir, file + '.dat'), 'r') as f: self.dmails = frozenset(json.load(f))
[ "Load", "list", "from", "file", "for", "random", "mails" ]
tomislater/RandomWords
python
https://github.com/tomislater/RandomWords/blob/601aa48732d3c389f4c17ba0ed98ffe0e4821d78/random_words/random_words.py#L39-L46
[ "def", "load_dmails", "(", "self", ",", "file", ")", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "main_dir", ",", "file", "+", "'.dat'", ")", ",", "'r'", ")", "as", "f", ":", "self", ".", "dmails", "=", "frozenset", "(", "json"...
601aa48732d3c389f4c17ba0ed98ffe0e4821d78
train
Random.load_nicknames
Load dict from file for random nicknames. :param str file: filename
random_words/random_words.py
def load_nicknames(self, file): """ Load dict from file for random nicknames. :param str file: filename """ with open(os.path.join(main_dir, file + '.dat'), 'r') as f: self.nicknames = json.load(f)
def load_nicknames(self, file): """ Load dict from file for random nicknames. :param str file: filename """ with open(os.path.join(main_dir, file + '.dat'), 'r') as f: self.nicknames = json.load(f)
[ "Load", "dict", "from", "file", "for", "random", "nicknames", "." ]
tomislater/RandomWords
python
https://github.com/tomislater/RandomWords/blob/601aa48732d3c389f4c17ba0ed98ffe0e4821d78/random_words/random_words.py#L48-L55
[ "def", "load_nicknames", "(", "self", ",", "file", ")", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "main_dir", ",", "file", "+", "'.dat'", ")", ",", "'r'", ")", "as", "f", ":", "self", ".", "nicknames", "=", "json", ".", "load...
601aa48732d3c389f4c17ba0ed98ffe0e4821d78
train
RandomWords.random_words
Returns list of random words. :param str letter: letter :param int count: how much words :rtype: list :returns: list of random words :raises: ValueError
random_words/random_words.py
def random_words(self, letter=None, count=1): """ Returns list of random words. :param str letter: letter :param int count: how much words :rtype: list :returns: list of random words :raises: ValueError """ self.check_count(count) words =...
def random_words(self, letter=None, count=1): """ Returns list of random words. :param str letter: letter :param int count: how much words :rtype: list :returns: list of random words :raises: ValueError """ self.check_count(count) words =...
[ "Returns", "list", "of", "random", "words", "." ]
tomislater/RandomWords
python
https://github.com/tomislater/RandomWords/blob/601aa48732d3c389f4c17ba0ed98ffe0e4821d78/random_words/random_words.py#L88-L129
[ "def", "random_words", "(", "self", ",", "letter", "=", "None", ",", "count", "=", "1", ")", ":", "self", ".", "check_count", "(", "count", ")", "words", "=", "[", "]", "if", "letter", "is", "None", ":", "all_words", "=", "list", "(", "chain", ".",...
601aa48732d3c389f4c17ba0ed98ffe0e4821d78
train
RandomNicknames.random_nicks
Return list of random nicks. :param str letter: letter :param str gender: ``'f'`` for female, ``'m'`` for male and None for both :param int count: how much nicks :rtype: list :returns: list of random nicks :raises: ValueError
random_words/random_words.py
def random_nicks(self, letter=None, gender='u', count=1): """ Return list of random nicks. :param str letter: letter :param str gender: ``'f'`` for female, ``'m'`` for male and None for both :param int count: how much nicks :rtype: list :returns: list of random n...
def random_nicks(self, letter=None, gender='u', count=1): """ Return list of random nicks. :param str letter: letter :param str gender: ``'f'`` for female, ``'m'`` for male and None for both :param int count: how much nicks :rtype: list :returns: list of random n...
[ "Return", "list", "of", "random", "nicks", "." ]
tomislater/RandomWords
python
https://github.com/tomislater/RandomWords/blob/601aa48732d3c389f4c17ba0ed98ffe0e4821d78/random_words/random_words.py#L153-L199
[ "def", "random_nicks", "(", "self", ",", "letter", "=", "None", ",", "gender", "=", "'u'", ",", "count", "=", "1", ")", ":", "self", ".", "check_count", "(", "count", ")", "nicks", "=", "[", "]", "if", "gender", "not", "in", "(", "'f'", ",", "'m'...
601aa48732d3c389f4c17ba0ed98ffe0e4821d78
train
RandomEmails.randomMails
Return random e-mails. :rtype: list :returns: list of random e-mails
random_words/random_words.py
def randomMails(self, count=1): """ Return random e-mails. :rtype: list :returns: list of random e-mails """ self.check_count(count) random_nicks = self.rn.random_nicks(count=count) random_domains = sample(self.dmails, count) return [ ...
def randomMails(self, count=1): """ Return random e-mails. :rtype: list :returns: list of random e-mails """ self.check_count(count) random_nicks = self.rn.random_nicks(count=count) random_domains = sample(self.dmails, count) return [ ...
[ "Return", "random", "e", "-", "mails", "." ]
tomislater/RandomWords
python
https://github.com/tomislater/RandomWords/blob/601aa48732d3c389f4c17ba0ed98ffe0e4821d78/random_words/random_words.py#L218-L233
[ "def", "randomMails", "(", "self", ",", "count", "=", "1", ")", ":", "self", ".", "check_count", "(", "count", ")", "random_nicks", "=", "self", ".", "rn", ".", "random_nicks", "(", "count", "=", "count", ")", "random_domains", "=", "sample", "(", "sel...
601aa48732d3c389f4c17ba0ed98ffe0e4821d78
train
LoremIpsum.get_sentences_list
Return sentences in list. :param int sentences: how many sentences :returns: list of strings with sentence :rtype: list
random_words/lorem_ipsum.py
def get_sentences_list(self, sentences=1): """ Return sentences in list. :param int sentences: how many sentences :returns: list of strings with sentence :rtype: list """ if sentences < 1: raise ValueError('Param "sentences" must be greater than 0.') ...
def get_sentences_list(self, sentences=1): """ Return sentences in list. :param int sentences: how many sentences :returns: list of strings with sentence :rtype: list """ if sentences < 1: raise ValueError('Param "sentences" must be greater than 0.') ...
[ "Return", "sentences", "in", "list", "." ]
tomislater/RandomWords
python
https://github.com/tomislater/RandomWords/blob/601aa48732d3c389f4c17ba0ed98ffe0e4821d78/random_words/lorem_ipsum.py#L27-L49
[ "def", "get_sentences_list", "(", "self", ",", "sentences", "=", "1", ")", ":", "if", "sentences", "<", "1", ":", "raise", "ValueError", "(", "'Param \"sentences\" must be greater than 0.'", ")", "sentences_list", "=", "[", "]", "while", "sentences", ":", "num_r...
601aa48732d3c389f4c17ba0ed98ffe0e4821d78
train
LoremIpsum.make_sentence
Return a sentence from list of words. :param list list_words: list of words :returns: sentence :rtype: str
random_words/lorem_ipsum.py
def make_sentence(list_words): """ Return a sentence from list of words. :param list list_words: list of words :returns: sentence :rtype: str """ lw_len = len(list_words) if lw_len > 6: list_words.insert(lw_len // 2 + random.choice(range(-2, ...
def make_sentence(list_words): """ Return a sentence from list of words. :param list list_words: list of words :returns: sentence :rtype: str """ lw_len = len(list_words) if lw_len > 6: list_words.insert(lw_len // 2 + random.choice(range(-2, ...
[ "Return", "a", "sentence", "from", "list", "of", "words", "." ]
tomislater/RandomWords
python
https://github.com/tomislater/RandomWords/blob/601aa48732d3c389f4c17ba0ed98ffe0e4821d78/random_words/lorem_ipsum.py#L62-L77
[ "def", "make_sentence", "(", "list_words", ")", ":", "lw_len", "=", "len", "(", "list_words", ")", "if", "lw_len", ">", "6", ":", "list_words", ".", "insert", "(", "lw_len", "//", "2", "+", "random", ".", "choice", "(", "range", "(", "-", "2", ",", ...
601aa48732d3c389f4c17ba0ed98ffe0e4821d78
train
_discover_cover_image
Find the cover image path in the OPF file. Returns a tuple: (image content in base64, file extension)
epub_meta/collector.py
def _discover_cover_image(zf, opf_xmldoc, opf_filepath): ''' Find the cover image path in the OPF file. Returns a tuple: (image content in base64, file extension) ''' content = None filepath = None extension = None # Strategies to discover the cover-image path: # e.g.: <meta name="...
def _discover_cover_image(zf, opf_xmldoc, opf_filepath): ''' Find the cover image path in the OPF file. Returns a tuple: (image content in base64, file extension) ''' content = None filepath = None extension = None # Strategies to discover the cover-image path: # e.g.: <meta name="...
[ "Find", "the", "cover", "image", "path", "in", "the", "OPF", "file", ".", "Returns", "a", "tuple", ":", "(", "image", "content", "in", "base64", "file", "extension", ")" ]
paulocheque/epub-meta
python
https://github.com/paulocheque/epub-meta/blob/3f0efb9f29a286b1a6896ad05422b23f10e10164/epub_meta/collector.py#L183-L215
[ "def", "_discover_cover_image", "(", "zf", ",", "opf_xmldoc", ",", "opf_filepath", ")", ":", "content", "=", "None", "filepath", "=", "None", "extension", "=", "None", "# Strategies to discover the cover-image path:", "# e.g.: <meta name=\"cover\" content=\"cover\"/>", "tag...
3f0efb9f29a286b1a6896ad05422b23f10e10164
train
_discover_toc
Returns a list of objects: {title: str, src: str, level: int, index: int}
epub_meta/collector.py
def _discover_toc(zf, opf_xmldoc, opf_filepath): ''' Returns a list of objects: {title: str, src: str, level: int, index: int} ''' toc = None # ePub 3.x tag = find_tag(opf_xmldoc, 'item', 'properties', 'nav') if tag and 'href' in tag.attributes.keys(): filepath = unquote(tag.attribu...
def _discover_toc(zf, opf_xmldoc, opf_filepath): ''' Returns a list of objects: {title: str, src: str, level: int, index: int} ''' toc = None # ePub 3.x tag = find_tag(opf_xmldoc, 'item', 'properties', 'nav') if tag and 'href' in tag.attributes.keys(): filepath = unquote(tag.attribu...
[ "Returns", "a", "list", "of", "objects", ":", "{", "title", ":", "str", "src", ":", "str", "level", ":", "int", "index", ":", "int", "}" ]
paulocheque/epub-meta
python
https://github.com/paulocheque/epub-meta/blob/3f0efb9f29a286b1a6896ad05422b23f10e10164/epub_meta/collector.py#L218-L332
[ "def", "_discover_toc", "(", "zf", ",", "opf_xmldoc", ",", "opf_filepath", ")", ":", "toc", "=", "None", "# ePub 3.x", "tag", "=", "find_tag", "(", "opf_xmldoc", ",", "'item'", ",", "'properties'", ",", "'nav'", ")", "if", "tag", "and", "'href'", "in", "...
3f0efb9f29a286b1a6896ad05422b23f10e10164
train
get_epub_metadata
References: http://idpf.org/epub/201 and http://idpf.org/epub/301 1. Parse META-INF/container.xml file and find the .OPF file path. 2. In the .OPF file, find the metadata
epub_meta/collector.py
def get_epub_metadata(filepath, read_cover_image=True, read_toc=True): ''' References: http://idpf.org/epub/201 and http://idpf.org/epub/301 1. Parse META-INF/container.xml file and find the .OPF file path. 2. In the .OPF file, find the metadata ''' if not zipfile.is_zipfile(filepath): r...
def get_epub_metadata(filepath, read_cover_image=True, read_toc=True): ''' References: http://idpf.org/epub/201 and http://idpf.org/epub/301 1. Parse META-INF/container.xml file and find the .OPF file path. 2. In the .OPF file, find the metadata ''' if not zipfile.is_zipfile(filepath): r...
[ "References", ":", "http", ":", "//", "idpf", ".", "org", "/", "epub", "/", "201", "and", "http", ":", "//", "idpf", ".", "org", "/", "epub", "/", "301", "1", ".", "Parse", "META", "-", "INF", "/", "container", ".", "xml", "file", "and", "find", ...
paulocheque/epub-meta
python
https://github.com/paulocheque/epub-meta/blob/3f0efb9f29a286b1a6896ad05422b23f10e10164/epub_meta/collector.py#L335-L395
[ "def", "get_epub_metadata", "(", "filepath", ",", "read_cover_image", "=", "True", ",", "read_toc", "=", "True", ")", ":", "if", "not", "zipfile", ".", "is_zipfile", "(", "filepath", ")", ":", "raise", "EPubException", "(", "'Unknown file'", ")", "# print('Rea...
3f0efb9f29a286b1a6896ad05422b23f10e10164
train
get_epub_opf_xml
Returns the file.OPF contents of the ePub file
epub_meta/collector.py
def get_epub_opf_xml(filepath): ''' Returns the file.OPF contents of the ePub file ''' if not zipfile.is_zipfile(filepath): raise EPubException('Unknown file') # print('Reading ePub file: {}'.format(filepath)) zf = zipfile.ZipFile(filepath, 'r', compression=zipfile.ZIP_DEFLATED, allowZi...
def get_epub_opf_xml(filepath): ''' Returns the file.OPF contents of the ePub file ''' if not zipfile.is_zipfile(filepath): raise EPubException('Unknown file') # print('Reading ePub file: {}'.format(filepath)) zf = zipfile.ZipFile(filepath, 'r', compression=zipfile.ZIP_DEFLATED, allowZi...
[ "Returns", "the", "file", ".", "OPF", "contents", "of", "the", "ePub", "file" ]
paulocheque/epub-meta
python
https://github.com/paulocheque/epub-meta/blob/3f0efb9f29a286b1a6896ad05422b23f10e10164/epub_meta/collector.py#L398-L411
[ "def", "get_epub_opf_xml", "(", "filepath", ")", ":", "if", "not", "zipfile", ".", "is_zipfile", "(", "filepath", ")", ":", "raise", "EPubException", "(", "'Unknown file'", ")", "# print('Reading ePub file: {}'.format(filepath))", "zf", "=", "zipfile", ".", "ZipFile...
3f0efb9f29a286b1a6896ad05422b23f10e10164
train
Petrovich.firstname
u""" Склонение имени :param value: Значение для склонения :param case: Падеж для склонения (значение из класса Case) :param gender: Грамматический род
petrovich/main.py
def firstname(self, value, case, gender=None): u""" Склонение имени :param value: Значение для склонения :param case: Падеж для склонения (значение из класса Case) :param gender: Грамматический род """ if not value: raise ValueError('Firstname cannot ...
def firstname(self, value, case, gender=None): u""" Склонение имени :param value: Значение для склонения :param case: Падеж для склонения (значение из класса Case) :param gender: Грамматический род """ if not value: raise ValueError('Firstname cannot ...
[ "u", "Склонение", "имени" ]
damirazo/Petrovich
python
https://github.com/damirazo/Petrovich/blob/b587158896a87d21ad6520d8e2e570d71e4338b4/petrovich/main.py#L43-L54
[ "def", "firstname", "(", "self", ",", "value", ",", "case", ",", "gender", "=", "None", ")", ":", "if", "not", "value", ":", "raise", "ValueError", "(", "'Firstname cannot be empty.'", ")", "return", "self", ".", "__inflect", "(", "value", ",", "case", "...
b587158896a87d21ad6520d8e2e570d71e4338b4
train
Petrovich.lastname
u""" Склонение фамилии :param value: Значение для склонения :param case: Падеж для склонения (значение из класса Case) :param gender: Грамматический род
petrovich/main.py
def lastname(self, value, case, gender=None): u""" Склонение фамилии :param value: Значение для склонения :param case: Падеж для склонения (значение из класса Case) :param gender: Грамматический род """ if not value: raise ValueError('Lastname cannot ...
def lastname(self, value, case, gender=None): u""" Склонение фамилии :param value: Значение для склонения :param case: Падеж для склонения (значение из класса Case) :param gender: Грамматический род """ if not value: raise ValueError('Lastname cannot ...
[ "u", "Склонение", "фамилии" ]
damirazo/Petrovich
python
https://github.com/damirazo/Petrovich/blob/b587158896a87d21ad6520d8e2e570d71e4338b4/petrovich/main.py#L56-L67
[ "def", "lastname", "(", "self", ",", "value", ",", "case", ",", "gender", "=", "None", ")", ":", "if", "not", "value", ":", "raise", "ValueError", "(", "'Lastname cannot be empty.'", ")", "return", "self", ".", "__inflect", "(", "value", ",", "case", ","...
b587158896a87d21ad6520d8e2e570d71e4338b4
train
Petrovich.middlename
u""" Склонение отчества :param value: Значение для склонения :param case: Падеж для склонения (значение из класса Case) :param gender: Грамматический род
petrovich/main.py
def middlename(self, value, case, gender=None): u""" Склонение отчества :param value: Значение для склонения :param case: Падеж для склонения (значение из класса Case) :param gender: Грамматический род """ if not value: raise ValueError('Middlename ca...
def middlename(self, value, case, gender=None): u""" Склонение отчества :param value: Значение для склонения :param case: Падеж для склонения (значение из класса Case) :param gender: Грамматический род """ if not value: raise ValueError('Middlename ca...
[ "u", "Склонение", "отчества" ]
damirazo/Petrovich
python
https://github.com/damirazo/Petrovich/blob/b587158896a87d21ad6520d8e2e570d71e4338b4/petrovich/main.py#L69-L80
[ "def", "middlename", "(", "self", ",", "value", ",", "case", ",", "gender", "=", "None", ")", ":", "if", "not", "value", ":", "raise", "ValueError", "(", "'Middlename cannot be empty.'", ")", "return", "self", ".", "__inflect", "(", "value", ",", "case", ...
b587158896a87d21ad6520d8e2e570d71e4338b4
train
Petrovich.__split_name
u""" Разделяет имя на сегменты по разделителям в self.separators :param name: имя :return: разделённое имя вместе с разделителями
petrovich/main.py
def __split_name(self, name): u""" Разделяет имя на сегменты по разделителям в self.separators :param name: имя :return: разделённое имя вместе с разделителями """ def gen(name, separators): if len(separators) == 0: yield name else:...
def __split_name(self, name): u""" Разделяет имя на сегменты по разделителям в self.separators :param name: имя :return: разделённое имя вместе с разделителями """ def gen(name, separators): if len(separators) == 0: yield name else:...
[ "u", "Разделяет", "имя", "на", "сегменты", "по", "разделителям", "в", "self", ".", "separators", ":", "param", "name", ":", "имя", ":", "return", ":", "разделённое", "имя", "вместе", "с", "разделителями" ]
damirazo/Petrovich
python
https://github.com/damirazo/Petrovich/blob/b587158896a87d21ad6520d8e2e570d71e4338b4/petrovich/main.py#L82-L100
[ "def", "__split_name", "(", "self", ",", "name", ")", ":", "def", "gen", "(", "name", ",", "separators", ")", ":", "if", "len", "(", "separators", ")", "==", "0", ":", "yield", "name", "else", ":", "segments", "=", "name", ".", "split", "(", "separ...
b587158896a87d21ad6520d8e2e570d71e4338b4
train
expand
Expand a reference expression to individual spans. Also works on space-separated ID lists, although a sequence of space characters will be considered a delimiter. >>> expand('a1') 'a1' >>> expand('a1[3:5]') 'a1[3:5]' >>> expand('a1[3:5+6:7]') 'a1[3:5]+a1[6:7]' >>> expand('a1 a2 a3'...
xigt/ref.py
def expand(expression): """ Expand a reference expression to individual spans. Also works on space-separated ID lists, although a sequence of space characters will be considered a delimiter. >>> expand('a1') 'a1' >>> expand('a1[3:5]') 'a1[3:5]' >>> expand('a1[3:5+6:7]') 'a1[3:5]...
def expand(expression): """ Expand a reference expression to individual spans. Also works on space-separated ID lists, although a sequence of space characters will be considered a delimiter. >>> expand('a1') 'a1' >>> expand('a1[3:5]') 'a1[3:5]' >>> expand('a1[3:5+6:7]') 'a1[3:5]...
[ "Expand", "a", "reference", "expression", "to", "individual", "spans", ".", "Also", "works", "on", "space", "-", "separated", "ID", "lists", "although", "a", "sequence", "of", "space", "characters", "will", "be", "considered", "a", "delimiter", "." ]
xigt/xigt
python
https://github.com/xigt/xigt/blob/3736fbb6d26887181de57bd189cbd731cec91289/xigt/ref.py#L36-L62
[ "def", "expand", "(", "expression", ")", ":", "tokens", "=", "[", "]", "for", "(", "pre", ",", "_id", ",", "_range", ")", "in", "robust_ref_re", ".", "findall", "(", "expression", ")", ":", "if", "not", "_range", ":", "tokens", ".", "append", "(", ...
3736fbb6d26887181de57bd189cbd731cec91289
train
compress
Compress a reference expression to group spans on the same id. Also works on space-separated ID lists, although a sequence of space characters will be considered a delimiter. >>> compress('a1') 'a1' >>> compress('a1[3:5]') 'a1[3:5]' >>> compress('a1[3:5+6:7]') 'a1[3:5+6:7]' >>> comp...
xigt/ref.py
def compress(expression): """ Compress a reference expression to group spans on the same id. Also works on space-separated ID lists, although a sequence of space characters will be considered a delimiter. >>> compress('a1') 'a1' >>> compress('a1[3:5]') 'a1[3:5]' >>> compress('a1[3:5...
def compress(expression): """ Compress a reference expression to group spans on the same id. Also works on space-separated ID lists, although a sequence of space characters will be considered a delimiter. >>> compress('a1') 'a1' >>> compress('a1[3:5]') 'a1[3:5]' >>> compress('a1[3:5...
[ "Compress", "a", "reference", "expression", "to", "group", "spans", "on", "the", "same", "id", ".", "Also", "works", "on", "space", "-", "separated", "ID", "lists", "although", "a", "sequence", "of", "space", "characters", "will", "be", "considered", "a", ...
xigt/xigt
python
https://github.com/xigt/xigt/blob/3736fbb6d26887181de57bd189cbd731cec91289/xigt/ref.py#L65-L101
[ "def", "compress", "(", "expression", ")", ":", "tokens", "=", "[", "]", "selection", "=", "[", "]", "last_id", "=", "None", "for", "(", "pre", ",", "_id", ",", "_range", ")", "in", "robust_ref_re", ".", "findall", "(", "expression", ")", ":", "if", ...
3736fbb6d26887181de57bd189cbd731cec91289
train
selections
Split the expression into individual selection expressions. The delimiters will be kept as separate items if keep_delimters=True. Also works on space-separated ID lists, although a sequence of space characters will be considered a delimiter. >>> selections('a1') ['a1'] >>> selections('a1[3:5]')...
xigt/ref.py
def selections(expression, keep_delimiters=True): """ Split the expression into individual selection expressions. The delimiters will be kept as separate items if keep_delimters=True. Also works on space-separated ID lists, although a sequence of space characters will be considered a delimiter. ...
def selections(expression, keep_delimiters=True): """ Split the expression into individual selection expressions. The delimiters will be kept as separate items if keep_delimters=True. Also works on space-separated ID lists, although a sequence of space characters will be considered a delimiter. ...
[ "Split", "the", "expression", "into", "individual", "selection", "expressions", ".", "The", "delimiters", "will", "be", "kept", "as", "separate", "items", "if", "keep_delimters", "=", "True", ".", "Also", "works", "on", "space", "-", "separated", "ID", "lists"...
xigt/xigt
python
https://github.com/xigt/xigt/blob/3736fbb6d26887181de57bd189cbd731cec91289/xigt/ref.py#L104-L134
[ "def", "selections", "(", "expression", ",", "keep_delimiters", "=", "True", ")", ":", "tokens", "=", "[", "]", "for", "(", "pre", ",", "_id", ",", "_range", ")", "in", "robust_ref_re", ".", "findall", "(", "expression", ")", ":", "if", "keep_delimiters"...
3736fbb6d26887181de57bd189cbd731cec91289
train
resolve
Return the string that is the resolution of the alignment expression `expression`, which selects ids from `container`.
xigt/ref.py
def resolve(container, expression): """ Return the string that is the resolution of the alignment expression `expression`, which selects ids from `container`. """ itemgetter = getattr(container, 'get_item', container.get) tokens = [] expression = expression.strip() for sel_delim, _id, _r...
def resolve(container, expression): """ Return the string that is the resolution of the alignment expression `expression`, which selects ids from `container`. """ itemgetter = getattr(container, 'get_item', container.get) tokens = [] expression = expression.strip() for sel_delim, _id, _r...
[ "Return", "the", "string", "that", "is", "the", "resolution", "of", "the", "alignment", "expression", "expression", "which", "selects", "ids", "from", "container", "." ]
xigt/xigt
python
https://github.com/xigt/xigt/blob/3736fbb6d26887181de57bd189cbd731cec91289/xigt/ref.py#L181-L210
[ "def", "resolve", "(", "container", ",", "expression", ")", ":", "itemgetter", "=", "getattr", "(", "container", ",", "'get_item'", ",", "container", ".", "get", ")", "tokens", "=", "[", "]", "expression", "=", "expression", ".", "strip", "(", ")", "for"...
3736fbb6d26887181de57bd189cbd731cec91289
train
referents
Return a list of ids denoting objects (tiers or items) in `igt` that are referred by the object denoted by `id` using a reference attribute in `refattrs`. If `refattrs` is None, then consider all known reference attributes for the type of object denoted by _id_. In other words, if 'b1' refers to 'a1' us...
xigt/ref.py
def referents(igt, id, refattrs=None): """ Return a list of ids denoting objects (tiers or items) in `igt` that are referred by the object denoted by `id` using a reference attribute in `refattrs`. If `refattrs` is None, then consider all known reference attributes for the type of object denoted by ...
def referents(igt, id, refattrs=None): """ Return a list of ids denoting objects (tiers or items) in `igt` that are referred by the object denoted by `id` using a reference attribute in `refattrs`. If `refattrs` is None, then consider all known reference attributes for the type of object denoted by ...
[ "Return", "a", "list", "of", "ids", "denoting", "objects", "(", "tiers", "or", "items", ")", "in", "igt", "that", "are", "referred", "by", "the", "object", "denoted", "by", "id", "using", "a", "reference", "attribute", "in", "refattrs", ".", "If", "refat...
xigt/xigt
python
https://github.com/xigt/xigt/blob/3736fbb6d26887181de57bd189cbd731cec91289/xigt/ref.py#L213-L227
[ "def", "referents", "(", "igt", ",", "id", ",", "refattrs", "=", "None", ")", ":", "obj", "=", "igt", ".", "get_any", "(", "id", ")", "if", "obj", "is", "None", ":", "raise", "XigtLookupError", "(", "id", ")", "if", "refattrs", "is", "None", ":", ...
3736fbb6d26887181de57bd189cbd731cec91289
train
referrers
Return a list of ids denoting objects (tiers or items) in `igt` that refer to the given `id`. In other words, if 'b1' refers to 'a1', then `referrers(igt, 'a1')` returns `['b1']`.
xigt/ref.py
def referrers(igt, id, refattrs=None): """ Return a list of ids denoting objects (tiers or items) in `igt` that refer to the given `id`. In other words, if 'b1' refers to 'a1', then `referrers(igt, 'a1')` returns `['b1']`. """ if refattrs is None: result = {} else: result = {...
def referrers(igt, id, refattrs=None): """ Return a list of ids denoting objects (tiers or items) in `igt` that refer to the given `id`. In other words, if 'b1' refers to 'a1', then `referrers(igt, 'a1')` returns `['b1']`. """ if refattrs is None: result = {} else: result = {...
[ "Return", "a", "list", "of", "ids", "denoting", "objects", "(", "tiers", "or", "items", ")", "in", "igt", "that", "refer", "to", "the", "given", "id", ".", "In", "other", "words", "if", "b1", "refers", "to", "a1", "then", "referrers", "(", "igt", "a1...
xigt/xigt
python
https://github.com/xigt/xigt/blob/3736fbb6d26887181de57bd189cbd731cec91289/xigt/ref.py#L230-L265
[ "def", "referrers", "(", "igt", ",", "id", ",", "refattrs", "=", "None", ")", ":", "if", "refattrs", "is", "None", ":", "result", "=", "{", "}", "else", ":", "result", "=", "{", "ra", ":", "[", "]", "for", "ra", "in", "refattrs", "}", "# if the i...
3736fbb6d26887181de57bd189cbd731cec91289
train
ancestors
>>> for anc in query.ancestors(igt.get_item('g1'), refattrs=(ALIGNMENT, SEGMENTATION)): ... print(anc) (<Tier object (id: g type: glosses) at ...>, 'alignment', <Tier object (id: m type: morphemes) at ...>, [<Item object (id: m1) at ...>]) (<Tier object (id: m type: morphemes) at ...>, 'segmentation', <...
xigt/query.py
def ancestors(obj, refattrs=(ALIGNMENT, SEGMENTATION)): """ >>> for anc in query.ancestors(igt.get_item('g1'), refattrs=(ALIGNMENT, SEGMENTATION)): ... print(anc) (<Tier object (id: g type: glosses) at ...>, 'alignment', <Tier object (id: m type: morphemes) at ...>, [<Item object (id: m1) at ...>]) ...
def ancestors(obj, refattrs=(ALIGNMENT, SEGMENTATION)): """ >>> for anc in query.ancestors(igt.get_item('g1'), refattrs=(ALIGNMENT, SEGMENTATION)): ... print(anc) (<Tier object (id: g type: glosses) at ...>, 'alignment', <Tier object (id: m type: morphemes) at ...>, [<Item object (id: m1) at ...>]) ...
[ ">>>", "for", "anc", "in", "query", ".", "ancestors", "(", "igt", ".", "get_item", "(", "g1", ")", "refattrs", "=", "(", "ALIGNMENT", "SEGMENTATION", "))", ":", "...", "print", "(", "anc", ")", "(", "<Tier", "object", "(", "id", ":", "g", "type", "...
xigt/xigt
python
https://github.com/xigt/xigt/blob/3736fbb6d26887181de57bd189cbd731cec91289/xigt/query.py#L13-L46
[ "def", "ancestors", "(", "obj", ",", "refattrs", "=", "(", "ALIGNMENT", ",", "SEGMENTATION", ")", ")", ":", "if", "hasattr", "(", "obj", ",", "'tier'", ")", ":", "tier", "=", "obj", ".", "tier", "items", "=", "[", "obj", "]", "else", ":", "tier", ...
3736fbb6d26887181de57bd189cbd731cec91289
train
descendants
>>> for des in query.descendants(igt.get_item('p1'), refattrs=(SEGMENTATION, ALIGNMENT)): ... print(des) (<Tier object (id: p type: phrases) at ...>, 'segmentation', <Tier object (id: w type: words) at ...>, [<Item object (id: w1) at ...>]) (<Tier object (id: p type: phrases) at ...>, 'alignment', <Tier...
xigt/query.py
def descendants(obj, refattrs=(SEGMENTATION, ALIGNMENT), follow='first'): """ >>> for des in query.descendants(igt.get_item('p1'), refattrs=(SEGMENTATION, ALIGNMENT)): ... print(des) (<Tier object (id: p type: phrases) at ...>, 'segmentation', <Tier object (id: w type: words) at ...>, [<Item object ...
def descendants(obj, refattrs=(SEGMENTATION, ALIGNMENT), follow='first'): """ >>> for des in query.descendants(igt.get_item('p1'), refattrs=(SEGMENTATION, ALIGNMENT)): ... print(des) (<Tier object (id: p type: phrases) at ...>, 'segmentation', <Tier object (id: w type: words) at ...>, [<Item object ...
[ ">>>", "for", "des", "in", "query", ".", "descendants", "(", "igt", ".", "get_item", "(", "p1", ")", "refattrs", "=", "(", "SEGMENTATION", "ALIGNMENT", "))", ":", "...", "print", "(", "des", ")", "(", "<Tier", "object", "(", "id", ":", "p", "type", ...
xigt/xigt
python
https://github.com/xigt/xigt/blob/3736fbb6d26887181de57bd189cbd731cec91289/xigt/query.py#L49-L93
[ "def", "descendants", "(", "obj", ",", "refattrs", "=", "(", "SEGMENTATION", ",", "ALIGNMENT", ")", ",", "follow", "=", "'first'", ")", ":", "if", "hasattr", "(", "obj", ",", "'tier'", ")", ":", "tier", "=", "obj", ".", "tier", "items", "=", "[", "...
3736fbb6d26887181de57bd189cbd731cec91289
train
default_decode
Decode a XigtCorpus element.
xigt/codecs/xigtxml.py
def default_decode(events, mode='full'): """Decode a XigtCorpus element.""" event, elem = next(events) root = elem # store root for later instantiation while (event, elem.tag) not in [('start', 'igt'), ('end', 'xigt-corpus')]: event, elem = next(events) igts = None if event == 'start' a...
def default_decode(events, mode='full'): """Decode a XigtCorpus element.""" event, elem = next(events) root = elem # store root for later instantiation while (event, elem.tag) not in [('start', 'igt'), ('end', 'xigt-corpus')]: event, elem = next(events) igts = None if event == 'start' a...
[ "Decode", "a", "XigtCorpus", "element", "." ]
xigt/xigt
python
https://github.com/xigt/xigt/blob/3736fbb6d26887181de57bd189cbd731cec91289/xigt/codecs/xigtxml.py#L212-L227
[ "def", "default_decode", "(", "events", ",", "mode", "=", "'full'", ")", ":", "event", ",", "elem", "=", "next", "(", "events", ")", "root", "=", "elem", "# store root for later instantiation", "while", "(", "event", ",", "elem", ".", "tag", ")", "not", ...
3736fbb6d26887181de57bd189cbd731cec91289
train
_get_file_content
Return a tuple, each value being a line of the source file. Remove empty lines and comments (lines starting with a '#').
siggen/siglists_utils.py
def _get_file_content(source): """Return a tuple, each value being a line of the source file. Remove empty lines and comments (lines starting with a '#'). """ filepath = os.path.join('siglists', source + '.txt') lines = [] with resource_stream(__name__, filepath) as f: for i, line in ...
def _get_file_content(source): """Return a tuple, each value being a line of the source file. Remove empty lines and comments (lines starting with a '#'). """ filepath = os.path.join('siglists', source + '.txt') lines = [] with resource_stream(__name__, filepath) as f: for i, line in ...
[ "Return", "a", "tuple", "each", "value", "being", "a", "line", "of", "the", "source", "file", "." ]
willkg/socorro-siggen
python
https://github.com/willkg/socorro-siggen/blob/db7e3233e665a458a961c48da22e93a69b1d08d6/siggen/siglists_utils.py#L30-L61
[ "def", "_get_file_content", "(", "source", ")", ":", "filepath", "=", "os", ".", "path", ".", "join", "(", "'siglists'", ",", "source", "+", "'.txt'", ")", "lines", "=", "[", "]", "with", "resource_stream", "(", "__name__", ",", "filepath", ")", "as", ...
db7e3233e665a458a961c48da22e93a69b1d08d6
train
_get_rar_version
Check quickly whether file is rar archive.
thomas/processors/rar.py
def _get_rar_version(xfile): """Check quickly whether file is rar archive. """ buf = xfile.read(len(RAR5_ID)) if buf.startswith(RAR_ID): return 3 elif buf.startswith(RAR5_ID): xfile.read(1) return 5 return 0
def _get_rar_version(xfile): """Check quickly whether file is rar archive. """ buf = xfile.read(len(RAR5_ID)) if buf.startswith(RAR_ID): return 3 elif buf.startswith(RAR5_ID): xfile.read(1) return 5 return 0
[ "Check", "quickly", "whether", "file", "is", "rar", "archive", "." ]
JohnDoee/thomas
python
https://github.com/JohnDoee/thomas/blob/51916dd110098b189a1c2fbcb71794fd9ec94832/thomas/processors/rar.py#L155-L164
[ "def", "_get_rar_version", "(", "xfile", ")", ":", "buf", "=", "xfile", ".", "read", "(", "len", "(", "RAR5_ID", ")", ")", "if", "buf", ".", "startswith", "(", "RAR_ID", ")", ":", "return", "3", "elif", "buf", ".", "startswith", "(", "RAR5_ID", ")", ...
51916dd110098b189a1c2fbcb71794fd9ec94832
train
VirtualDirectReader._open_next
Proceed to next volume.
thomas/processors/rar.py
def _open_next(self): """Proceed to next volume.""" # is the file split over archives? if (self._cur.flags & rarfile.RAR_FILE_SPLIT_AFTER) == 0: return False if self._fd: self._fd.close() self._fd = None # open next part self._volfil...
def _open_next(self): """Proceed to next volume.""" # is the file split over archives? if (self._cur.flags & rarfile.RAR_FILE_SPLIT_AFTER) == 0: return False if self._fd: self._fd.close() self._fd = None # open next part self._volfil...
[ "Proceed", "to", "next", "volume", "." ]
JohnDoee/thomas
python
https://github.com/JohnDoee/thomas/blob/51916dd110098b189a1c2fbcb71794fd9ec94832/thomas/processors/rar.py#L168-L200
[ "def", "_open_next", "(", "self", ")", ":", "# is the file split over archives?", "if", "(", "self", ".", "_cur", ".", "flags", "&", "rarfile", ".", "RAR_FILE_SPLIT_AFTER", ")", "==", "0", ":", "return", "False", "if", "self", ".", "_fd", ":", "self", ".",...
51916dd110098b189a1c2fbcb71794fd9ec94832
train
VirtualDirectReader._check
Do not check final CRC.
thomas/processors/rar.py
def _check(self): # TODO: fix? """Do not check final CRC.""" if self._returncode: rarfile.check_returncode(self, '') if self._remain != 0: raise rarfile.BadRarFile("Failed the read enough data")
def _check(self): # TODO: fix? """Do not check final CRC.""" if self._returncode: rarfile.check_returncode(self, '') if self._remain != 0: raise rarfile.BadRarFile("Failed the read enough data")
[ "Do", "not", "check", "final", "CRC", "." ]
JohnDoee/thomas
python
https://github.com/JohnDoee/thomas/blob/51916dd110098b189a1c2fbcb71794fd9ec94832/thomas/processors/rar.py#L202-L207
[ "def", "_check", "(", "self", ")", ":", "# TODO: fix?", "if", "self", ".", "_returncode", ":", "rarfile", ".", "check_returncode", "(", "self", ",", "''", ")", "if", "self", ".", "_remain", "!=", "0", ":", "raise", "rarfile", ".", "BadRarFile", "(", "\...
51916dd110098b189a1c2fbcb71794fd9ec94832
train
_normalize
rescales a numpy array, so that min is 0 and max is 255
pyparadigm/extras.py
def _normalize(mat: np.ndarray): """rescales a numpy array, so that min is 0 and max is 255""" return ((mat - mat.min()) * (255 / mat.max())).astype(np.uint8)
def _normalize(mat: np.ndarray): """rescales a numpy array, so that min is 0 and max is 255""" return ((mat - mat.min()) * (255 / mat.max())).astype(np.uint8)
[ "rescales", "a", "numpy", "array", "so", "that", "min", "is", "0", "and", "max", "is", "255" ]
KnorrFG/pyparadigm
python
https://github.com/KnorrFG/pyparadigm/blob/69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3/pyparadigm/extras.py#L15-L17
[ "def", "_normalize", "(", "mat", ":", "np", ".", "ndarray", ")", ":", "return", "(", "(", "mat", "-", "mat", ".", "min", "(", ")", ")", "*", "(", "255", "/", "mat", ".", "max", "(", ")", ")", ")", ".", "astype", "(", "np", ".", "uint8", ")"...
69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3
train
to_24bit_gray
returns a matrix that contains RGB channels, and colors scaled from 0 to 255
pyparadigm/extras.py
def to_24bit_gray(mat: np.ndarray): """returns a matrix that contains RGB channels, and colors scaled from 0 to 255""" return np.repeat(np.expand_dims(_normalize(mat), axis=2), 3, axis=2)
def to_24bit_gray(mat: np.ndarray): """returns a matrix that contains RGB channels, and colors scaled from 0 to 255""" return np.repeat(np.expand_dims(_normalize(mat), axis=2), 3, axis=2)
[ "returns", "a", "matrix", "that", "contains", "RGB", "channels", "and", "colors", "scaled", "from", "0", "to", "255" ]
KnorrFG/pyparadigm
python
https://github.com/KnorrFG/pyparadigm/blob/69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3/pyparadigm/extras.py#L20-L23
[ "def", "to_24bit_gray", "(", "mat", ":", "np", ".", "ndarray", ")", ":", "return", "np", ".", "repeat", "(", "np", ".", "expand_dims", "(", "_normalize", "(", "mat", ")", ",", "axis", "=", "2", ")", ",", "3", ",", "axis", "=", "2", ")" ]
69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3
train
apply_color_map
returns an RGB matrix scaled by a matplotlib color map
pyparadigm/extras.py
def apply_color_map(name: str, mat: np.ndarray = None): """returns an RGB matrix scaled by a matplotlib color map""" def apply_map(mat): return (cm.get_cmap(name)(_normalize(mat))[:, :, :3] * 255).astype(np.uint8) return apply_map if mat is None else apply_map(mat)
def apply_color_map(name: str, mat: np.ndarray = None): """returns an RGB matrix scaled by a matplotlib color map""" def apply_map(mat): return (cm.get_cmap(name)(_normalize(mat))[:, :, :3] * 255).astype(np.uint8) return apply_map if mat is None else apply_map(mat)
[ "returns", "an", "RGB", "matrix", "scaled", "by", "a", "matplotlib", "color", "map" ]
KnorrFG/pyparadigm
python
https://github.com/KnorrFG/pyparadigm/blob/69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3/pyparadigm/extras.py#L26-L31
[ "def", "apply_color_map", "(", "name", ":", "str", ",", "mat", ":", "np", ".", "ndarray", "=", "None", ")", ":", "def", "apply_map", "(", "mat", ")", ":", "return", "(", "cm", ".", "get_cmap", "(", "name", ")", "(", "_normalize", "(", "mat", ")", ...
69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3
train
mat_to_surface
Can be used to create a pygame.Surface from a 2d numpy array. By default a grey image with scaled colors is returned, but using the transformer argument any transformation can be used. :param mat: the matrix to create the surface of. :type mat: np.ndarray :param transformer: function that transfo...
pyparadigm/extras.py
def mat_to_surface(mat: np.ndarray, transformer=to_24bit_gray): """Can be used to create a pygame.Surface from a 2d numpy array. By default a grey image with scaled colors is returned, but using the transformer argument any transformation can be used. :param mat: the matrix to create the surface of. ...
def mat_to_surface(mat: np.ndarray, transformer=to_24bit_gray): """Can be used to create a pygame.Surface from a 2d numpy array. By default a grey image with scaled colors is returned, but using the transformer argument any transformation can be used. :param mat: the matrix to create the surface of. ...
[ "Can", "be", "used", "to", "create", "a", "pygame", ".", "Surface", "from", "a", "2d", "numpy", "array", "." ]
KnorrFG/pyparadigm
python
https://github.com/KnorrFG/pyparadigm/blob/69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3/pyparadigm/extras.py#L34-L49
[ "def", "mat_to_surface", "(", "mat", ":", "np", ".", "ndarray", ",", "transformer", "=", "to_24bit_gray", ")", ":", "return", "pygame", ".", "pixelcopy", ".", "make_surface", "(", "transformer", "(", "mat", ".", "transpose", "(", ")", ")", "if", "transform...
69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3
train
random_id
Creates a random id with the given length and charset. ## Parameters * length the number of characters in the id * charset what character set to use (a list of characters) * first_charset what character set for the first character * sep='' what character to insert be...
bl/id.py
def random_id(length=16, charset=alphanum_chars, first_charset=alpha_chars, sep='', group=0): """Creates a random id with the given length and charset. ## Parameters * length the number of characters in the id * charset what character set to use (a list of characters) * first_c...
def random_id(length=16, charset=alphanum_chars, first_charset=alpha_chars, sep='', group=0): """Creates a random id with the given length and charset. ## Parameters * length the number of characters in the id * charset what character set to use (a list of characters) * first_c...
[ "Creates", "a", "random", "id", "with", "the", "given", "length", "and", "charset", ".", "##", "Parameters", "*", "length", "the", "number", "of", "characters", "in", "the", "id", "*", "charset", "what", "character", "set", "to", "use", "(", "a", "list",...
BlackEarth/bl
python
https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/id.py#L60-L82
[ "def", "random_id", "(", "length", "=", "16", ",", "charset", "=", "alphanum_chars", ",", "first_charset", "=", "alpha_chars", ",", "sep", "=", "''", ",", "group", "=", "0", ")", ":", "t", "=", "[", "]", "first_chars", "=", "list", "(", "set", "(", ...
edf6f37dac718987260b90ad0e7f7fe084a7c1a3
train
merge_dict
Merge any number of dictionaries
pagarme/common/util.py
def merge_dict(data, *args): """Merge any number of dictionaries """ results = {} for current in (data,) + args: results.update(current) return results
def merge_dict(data, *args): """Merge any number of dictionaries """ results = {} for current in (data,) + args: results.update(current) return results
[ "Merge", "any", "number", "of", "dictionaries" ]
michaeltcoelho/pagarme.py
python
https://github.com/michaeltcoelho/pagarme.py/blob/469fdd6e61e7c24a9eaf23d474d25316c3b5450b/pagarme/common/util.py#L5-L11
[ "def", "merge_dict", "(", "data", ",", "*", "args", ")", ":", "results", "=", "{", "}", "for", "current", "in", "(", "data", ",", ")", "+", "args", ":", "results", ".", "update", "(", "current", ")", "return", "results" ]
469fdd6e61e7c24a9eaf23d474d25316c3b5450b
train
make_url
Joins individual URL strings together, and returns a single string.
pagarme/common/util.py
def make_url(url, *paths): """Joins individual URL strings together, and returns a single string. """ for path in paths: url = re.sub(r'/?$', re.sub(r'^/?', '/', path), url) return url
def make_url(url, *paths): """Joins individual URL strings together, and returns a single string. """ for path in paths: url = re.sub(r'/?$', re.sub(r'^/?', '/', path), url) return url
[ "Joins", "individual", "URL", "strings", "together", "and", "returns", "a", "single", "string", "." ]
michaeltcoelho/pagarme.py
python
https://github.com/michaeltcoelho/pagarme.py/blob/469fdd6e61e7c24a9eaf23d474d25316c3b5450b/pagarme/common/util.py#L14-L19
[ "def", "make_url", "(", "url", ",", "*", "paths", ")", ":", "for", "path", "in", "paths", ":", "url", "=", "re", ".", "sub", "(", "r'/?$'", ",", "re", ".", "sub", "(", "r'^/?'", ",", "'/'", ",", "path", ")", ",", "url", ")", "return", "url" ]
469fdd6e61e7c24a9eaf23d474d25316c3b5450b
train
Email.aggregate_result
aggregate result
monitoring_agent/outputs/email.py
def aggregate_result(self, return_code, output, service_description='', specific_servers=None): ''' aggregate result ''' if specific_servers == None: specific_servers = self.servers else: specific_servers = set(self.servers).intersection(specific_servers) ...
def aggregate_result(self, return_code, output, service_description='', specific_servers=None): ''' aggregate result ''' if specific_servers == None: specific_servers = self.servers else: specific_servers = set(self.servers).intersection(specific_servers) ...
[ "aggregate", "result" ]
Eyepea/tanto
python
https://github.com/Eyepea/tanto/blob/ad8fd32e0fd3b7bc3dee5dabb984a2567ae46fe9/monitoring_agent/outputs/email.py#L35-L51
[ "def", "aggregate_result", "(", "self", ",", "return_code", ",", "output", ",", "service_description", "=", "''", ",", "specific_servers", "=", "None", ")", ":", "if", "specific_servers", "==", "None", ":", "specific_servers", "=", "self", ".", "servers", "els...
ad8fd32e0fd3b7bc3dee5dabb984a2567ae46fe9
train
Email.send_results
send results
monitoring_agent/outputs/email.py
def send_results(self): ''' send results ''' for server in self.servers: if self.servers[server]['results']: if len(self.servers[server]['results']) == 1: msg = MIMEText('') msg['Subject'] = '[%(custom_fqdn)s] [%(servic...
def send_results(self): ''' send results ''' for server in self.servers: if self.servers[server]['results']: if len(self.servers[server]['results']) == 1: msg = MIMEText('') msg['Subject'] = '[%(custom_fqdn)s] [%(servic...
[ "send", "results" ]
Eyepea/tanto
python
https://github.com/Eyepea/tanto/blob/ad8fd32e0fd3b7bc3dee5dabb984a2567ae46fe9/monitoring_agent/outputs/email.py#L53-L86
[ "def", "send_results", "(", "self", ")", ":", "for", "server", "in", "self", ".", "servers", ":", "if", "self", ".", "servers", "[", "server", "]", "[", "'results'", "]", ":", "if", "len", "(", "self", ".", "servers", "[", "server", "]", "[", "'res...
ad8fd32e0fd3b7bc3dee5dabb984a2567ae46fe9
train
main
MAIN
example.py
def main(): """MAIN""" config = { "api": { "services": [ { "name": "my_api", "testkey": "testval", }, ], "calls": { "hello_world": { "delay": 5, ...
def main(): """MAIN""" config = { "api": { "services": [ { "name": "my_api", "testkey": "testval", }, ], "calls": { "hello_world": { "delay": 5, ...
[ "MAIN" ]
RobotStudio/bors
python
https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/example.py#L104-L132
[ "def", "main", "(", ")", ":", "config", "=", "{", "\"api\"", ":", "{", "\"services\"", ":", "[", "{", "\"name\"", ":", "\"my_api\"", ",", "\"testkey\"", ":", "\"testval\"", ",", "}", ",", "]", ",", "\"calls\"", ":", "{", "\"hello_world\"", ":", "{", ...
38bf338fc6905d90819faa56bd832140116720f0
train
RequestSchema.make_request
Parse the outgoing schema
example.py
def make_request(self, data): """Parse the outgoing schema""" sch = MockItemSchema() return Request(**{ "callname": self.context.get("callname"), "payload": sch.dump(data), })
def make_request(self, data): """Parse the outgoing schema""" sch = MockItemSchema() return Request(**{ "callname": self.context.get("callname"), "payload": sch.dump(data), })
[ "Parse", "the", "outgoing", "schema" ]
RobotStudio/bors
python
https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/example.py#L58-L64
[ "def", "make_request", "(", "self", ",", "data", ")", ":", "sch", "=", "MockItemSchema", "(", ")", "return", "Request", "(", "*", "*", "{", "\"callname\"", ":", "self", ".", "context", ".", "get", "(", "\"callname\"", ")", ",", "\"payload\"", ":", "sch...
38bf338fc6905d90819faa56bd832140116720f0
train
ResponseSchema.populate_data
Parse the outgoing schema
example.py
def populate_data(self, data): """Parse the outgoing schema""" sch = MockItemSchema() return Result(**{ "callname": self.context.get("callname"), "result": sch.dump(data), })
def populate_data(self, data): """Parse the outgoing schema""" sch = MockItemSchema() return Result(**{ "callname": self.context.get("callname"), "result": sch.dump(data), })
[ "Parse", "the", "outgoing", "schema" ]
RobotStudio/bors
python
https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/example.py#L74-L80
[ "def", "populate_data", "(", "self", ",", "data", ")", ":", "sch", "=", "MockItemSchema", "(", ")", "return", "Result", "(", "*", "*", "{", "\"callname\"", ":", "self", ".", "context", ".", "get", "(", "\"callname\"", ")", ",", "\"result\"", ":", "sch"...
38bf338fc6905d90819faa56bd832140116720f0
train
Handler.key_press
returns a handler that can be used with EventListener.listen() and returns when a key in keys is pressed
pyparadigm/eventlistener.py
def key_press(keys): """returns a handler that can be used with EventListener.listen() and returns when a key in keys is pressed""" return lambda e: e.key if e.type == pygame.KEYDOWN \ and e.key in keys else EventConsumerInfo.DONT_CARE
def key_press(keys): """returns a handler that can be used with EventListener.listen() and returns when a key in keys is pressed""" return lambda e: e.key if e.type == pygame.KEYDOWN \ and e.key in keys else EventConsumerInfo.DONT_CARE
[ "returns", "a", "handler", "that", "can", "be", "used", "with", "EventListener", ".", "listen", "()", "and", "returns", "when", "a", "key", "in", "keys", "is", "pressed" ]
KnorrFG/pyparadigm
python
https://github.com/KnorrFG/pyparadigm/blob/69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3/pyparadigm/eventlistener.py#L70-L74
[ "def", "key_press", "(", "keys", ")", ":", "return", "lambda", "e", ":", "e", ".", "key", "if", "e", ".", "type", "==", "pygame", ".", "KEYDOWN", "and", "e", ".", "key", "in", "keys", "else", "EventConsumerInfo", ".", "DONT_CARE" ]
69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3
train
Handler.unicode_char
returns a handler that listens for unicode characters
pyparadigm/eventlistener.py
def unicode_char(ignored_chars=None): """returns a handler that listens for unicode characters""" return lambda e: e.unicode if e.type == pygame.KEYDOWN \ and ((ignored_chars is None) or (e.unicode not in ignored_chars))\ else EventConsumerInfo.DONT_CARE
def unicode_char(ignored_chars=None): """returns a handler that listens for unicode characters""" return lambda e: e.unicode if e.type == pygame.KEYDOWN \ and ((ignored_chars is None) or (e.unicode not in ignored_chars))\ else EventConsumerInfo.DONT_CARE
[ "returns", "a", "handler", "that", "listens", "for", "unicode", "characters" ]
KnorrFG/pyparadigm
python
https://github.com/KnorrFG/pyparadigm/blob/69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3/pyparadigm/eventlistener.py#L77-L82
[ "def", "unicode_char", "(", "ignored_chars", "=", "None", ")", ":", "return", "lambda", "e", ":", "e", ".", "unicode", "if", "e", ".", "type", "==", "pygame", ".", "KEYDOWN", "and", "(", "(", "ignored_chars", "is", "None", ")", "or", "(", "e", ".", ...
69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3
train
EventListener.mouse_area
Adds a new MouseProxy for the given group to the EventListener.mouse_proxies dict if it is not in there yet, and returns the (new) MouseProxy. In listen() all entries in the current group of mouse_proxies are used.
pyparadigm/eventlistener.py
def mouse_area(self, handler, group=0, ident=None): """Adds a new MouseProxy for the given group to the EventListener.mouse_proxies dict if it is not in there yet, and returns the (new) MouseProxy. In listen() all entries in the current group of mouse_proxies are used.""" key = ...
def mouse_area(self, handler, group=0, ident=None): """Adds a new MouseProxy for the given group to the EventListener.mouse_proxies dict if it is not in there yet, and returns the (new) MouseProxy. In listen() all entries in the current group of mouse_proxies are used.""" key = ...
[ "Adds", "a", "new", "MouseProxy", "for", "the", "given", "group", "to", "the", "EventListener", ".", "mouse_proxies", "dict", "if", "it", "is", "not", "in", "there", "yet", "and", "returns", "the", "(", "new", ")", "MouseProxy", ".", "In", "listen", "()"...
KnorrFG/pyparadigm
python
https://github.com/KnorrFG/pyparadigm/blob/69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3/pyparadigm/eventlistener.py#L167-L175
[ "def", "mouse_area", "(", "self", ",", "handler", ",", "group", "=", "0", ",", "ident", "=", "None", ")", ":", "key", "=", "ident", "or", "id", "(", "handler", ")", "if", "key", "not", "in", "self", ".", "mouse_proxies", "[", "group", "]", ":", "...
69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3
train
EventListener.listen
When listen() is called all queued pygame.Events will be passed to all registered listeners. There are two ways to register a listener: 1. as a permanent listener, that is always executed for every event. These are registered by passing the handler-functions during construction 2. ...
pyparadigm/eventlistener.py
def listen(self, *temporary_handlers): """When listen() is called all queued pygame.Events will be passed to all registered listeners. There are two ways to register a listener: 1. as a permanent listener, that is always executed for every event. These are registered by passing the ...
def listen(self, *temporary_handlers): """When listen() is called all queued pygame.Events will be passed to all registered listeners. There are two ways to register a listener: 1. as a permanent listener, that is always executed for every event. These are registered by passing the ...
[ "When", "listen", "()", "is", "called", "all", "queued", "pygame", ".", "Events", "will", "be", "passed", "to", "all", "registered", "listeners", ".", "There", "are", "two", "ways", "to", "register", "a", "listener", ":" ]
KnorrFG/pyparadigm
python
https://github.com/KnorrFG/pyparadigm/blob/69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3/pyparadigm/eventlistener.py#L183-L225
[ "def", "listen", "(", "self", ",", "*", "temporary_handlers", ")", ":", "funcs", "=", "tuple", "(", "itt", ".", "chain", "(", "self", ".", "permanent_handlers", ",", "(", "proxy", ".", "listener", "for", "proxy", "in", "self", ".", "mouse_proxies", "[", ...
69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3
train
EventListener.listen_until_return
Calls listen repeatedly until listen returns something else than None. Then returns listen's result. If timeout is not zero listen_until_return stops after timeout seconds and returns None.
pyparadigm/eventlistener.py
def listen_until_return(self, *temporary_handlers, timeout=0): """Calls listen repeatedly until listen returns something else than None. Then returns listen's result. If timeout is not zero listen_until_return stops after timeout seconds and returns None.""" start = time.time() w...
def listen_until_return(self, *temporary_handlers, timeout=0): """Calls listen repeatedly until listen returns something else than None. Then returns listen's result. If timeout is not zero listen_until_return stops after timeout seconds and returns None.""" start = time.time() w...
[ "Calls", "listen", "repeatedly", "until", "listen", "returns", "something", "else", "than", "None", ".", "Then", "returns", "listen", "s", "result", ".", "If", "timeout", "is", "not", "zero", "listen_until_return", "stops", "after", "timeout", "seconds", "and", ...
KnorrFG/pyparadigm
python
https://github.com/KnorrFG/pyparadigm/blob/69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3/pyparadigm/eventlistener.py#L227-L235
[ "def", "listen_until_return", "(", "self", ",", "*", "temporary_handlers", ",", "timeout", "=", "0", ")", ":", "start", "=", "time", ".", "time", "(", ")", "while", "timeout", "==", "0", "or", "time", ".", "time", "(", ")", "-", "start", "<", "timeou...
69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3
train
EventListener.wait_for_n_keypresses
Waits till one key was pressed n times. :param key: the key to be pressed as defined by pygame. E.g. pygame.K_LEFT for the left arrow key :type key: int :param n: number of repetitions till the function returns :type n: int
pyparadigm/eventlistener.py
def wait_for_n_keypresses(self, key, n=1): """Waits till one key was pressed n times. :param key: the key to be pressed as defined by pygame. E.g. pygame.K_LEFT for the left arrow key :type key: int :param n: number of repetitions till the function returns :type n: i...
def wait_for_n_keypresses(self, key, n=1): """Waits till one key was pressed n times. :param key: the key to be pressed as defined by pygame. E.g. pygame.K_LEFT for the left arrow key :type key: int :param n: number of repetitions till the function returns :type n: i...
[ "Waits", "till", "one", "key", "was", "pressed", "n", "times", "." ]
KnorrFG/pyparadigm
python
https://github.com/KnorrFG/pyparadigm/blob/69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3/pyparadigm/eventlistener.py#L237-L255
[ "def", "wait_for_n_keypresses", "(", "self", ",", "key", ",", "n", "=", "1", ")", ":", "my_const", "=", "\"key_consumed\"", "counter", "=", "0", "def", "keypress_listener", "(", "e", ")", ":", "return", "my_const", "if", "e", ".", "type", "==", "pygame",...
69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3
train
EventListener.wait_for_keys
Waits until one of the specified keys was pressed, and returns which key was pressed. :param keys: iterable of integers of pygame-keycodes, or simply multiple keys passed via multiple arguments :type keys: iterable :param timeout: number of seconds to wait till the functio...
pyparadigm/eventlistener.py
def wait_for_keys(self, *keys, timeout=0): """Waits until one of the specified keys was pressed, and returns which key was pressed. :param keys: iterable of integers of pygame-keycodes, or simply multiple keys passed via multiple arguments :type keys: iterable :par...
def wait_for_keys(self, *keys, timeout=0): """Waits until one of the specified keys was pressed, and returns which key was pressed. :param keys: iterable of integers of pygame-keycodes, or simply multiple keys passed via multiple arguments :type keys: iterable :par...
[ "Waits", "until", "one", "of", "the", "specified", "keys", "was", "pressed", "and", "returns", "which", "key", "was", "pressed", "." ]
KnorrFG/pyparadigm
python
https://github.com/KnorrFG/pyparadigm/blob/69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3/pyparadigm/eventlistener.py#L257-L273
[ "def", "wait_for_keys", "(", "self", ",", "*", "keys", ",", "timeout", "=", "0", ")", ":", "if", "len", "(", "keys", ")", "==", "1", "and", "_is_iterable", "(", "keys", "[", "0", "]", ")", ":", "keys", "=", "keys", "[", "0", "]", "return", "sel...
69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3
train
EventListener.wait_for_keys_modified
The same as wait_for_keys, but returns a frozen_set which contains the pressed key, and the modifier keys. :param modifiers_to_check: iterable of modifiers for which the function will check whether they are pressed :type modifiers: Iterable[int]
pyparadigm/eventlistener.py
def wait_for_keys_modified(self, *keys, modifiers_to_check=_mod_keys, timeout=0): """The same as wait_for_keys, but returns a frozen_set which contains the pressed key, and the modifier keys. :param modifiers_to_check: iterable of modifiers for which the function...
def wait_for_keys_modified(self, *keys, modifiers_to_check=_mod_keys, timeout=0): """The same as wait_for_keys, but returns a frozen_set which contains the pressed key, and the modifier keys. :param modifiers_to_check: iterable of modifiers for which the function...
[ "The", "same", "as", "wait_for_keys", "but", "returns", "a", "frozen_set", "which", "contains", "the", "pressed", "key", "and", "the", "modifier", "keys", "." ]
KnorrFG/pyparadigm
python
https://github.com/KnorrFG/pyparadigm/blob/69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3/pyparadigm/eventlistener.py#L275-L288
[ "def", "wait_for_keys_modified", "(", "self", ",", "*", "keys", ",", "modifiers_to_check", "=", "_mod_keys", ",", "timeout", "=", "0", ")", ":", "set_mods", "=", "pygame", ".", "key", ".", "get_mods", "(", ")", "return", "frozenset", ".", "union", "(", "...
69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3
train
EventListener.wait_for_unicode_char
Returns a str that contains the single character that was pressed. This already respects modifier keys and keyboard layouts. If timeout is not none and no key is pressed within the specified timeout, None is returned. If a key is ingnored_chars it will be ignored. As argument for irgnore...
pyparadigm/eventlistener.py
def wait_for_unicode_char(self, ignored_chars=None, timeout=0): """Returns a str that contains the single character that was pressed. This already respects modifier keys and keyboard layouts. If timeout is not none and no key is pressed within the specified timeout, None is returned. If ...
def wait_for_unicode_char(self, ignored_chars=None, timeout=0): """Returns a str that contains the single character that was pressed. This already respects modifier keys and keyboard layouts. If timeout is not none and no key is pressed within the specified timeout, None is returned. If ...
[ "Returns", "a", "str", "that", "contains", "the", "single", "character", "that", "was", "pressed", ".", "This", "already", "respects", "modifier", "keys", "and", "keyboard", "layouts", ".", "If", "timeout", "is", "not", "none", "and", "no", "key", "is", "p...
KnorrFG/pyparadigm
python
https://github.com/KnorrFG/pyparadigm/blob/69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3/pyparadigm/eventlistener.py#L295-L303
[ "def", "wait_for_unicode_char", "(", "self", ",", "ignored_chars", "=", "None", ",", "timeout", "=", "0", ")", ":", "return", "self", ".", "listen_until_return", "(", "Handler", ".", "unicode_char", "(", "ignored_chars", ")", ",", "timeout", "=", "timeout", ...
69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3
train
RarStreamer._find_all_first_files
Does not support the full range of ways rar can split as it'd require reading the file to ensure you are using the correct way.
thomas/streamers/rar.py
def _find_all_first_files(self, item): """ Does not support the full range of ways rar can split as it'd require reading the file to ensure you are using the correct way. """ for listed_item in item.list(): new_style = re.findall(r'(?i)\.part(\d+)\.rar^', list...
def _find_all_first_files(self, item): """ Does not support the full range of ways rar can split as it'd require reading the file to ensure you are using the correct way. """ for listed_item in item.list(): new_style = re.findall(r'(?i)\.part(\d+)\.rar^', list...
[ "Does", "not", "support", "the", "full", "range", "of", "ways", "rar", "can", "split", "as", "it", "d", "require", "reading", "the", "file", "to", "ensure", "you", "are", "using", "the", "correct", "way", "." ]
JohnDoee/thomas
python
https://github.com/JohnDoee/thomas/blob/51916dd110098b189a1c2fbcb71794fd9ec94832/thomas/streamers/rar.py#L15-L27
[ "def", "_find_all_first_files", "(", "self", ",", "item", ")", ":", "for", "listed_item", "in", "item", ".", "list", "(", ")", ":", "new_style", "=", "re", ".", "findall", "(", "r'(?i)\\.part(\\d+)\\.rar^'", ",", "listed_item", ".", "id", ")", "if", "new_s...
51916dd110098b189a1c2fbcb71794fd9ec94832
train
find_datafile
find all matching data files in search_path search_path: path of directories to load from codecs: allow to override from list of installed returns array of tuples (codec_object, filename)
facsimile/codec.py
def find_datafile(name, search_path, codecs=get_codecs()): """ find all matching data files in search_path search_path: path of directories to load from codecs: allow to override from list of installed returns array of tuples (codec_object, filename) """ return munge.find_datafile(name, sear...
def find_datafile(name, search_path, codecs=get_codecs()): """ find all matching data files in search_path search_path: path of directories to load from codecs: allow to override from list of installed returns array of tuples (codec_object, filename) """ return munge.find_datafile(name, sear...
[ "find", "all", "matching", "data", "files", "in", "search_path", "search_path", ":", "path", "of", "directories", "to", "load", "from", "codecs", ":", "allow", "to", "override", "from", "list", "of", "installed", "returns", "array", "of", "tuples", "(", "cod...
20c/facsimile
python
https://github.com/20c/facsimile/blob/570e28568475d5be1b1a2c95b8e941fbfbc167eb/facsimile/codec.py#L14-L21
[ "def", "find_datafile", "(", "name", ",", "search_path", ",", "codecs", "=", "get_codecs", "(", ")", ")", ":", "return", "munge", ".", "find_datafile", "(", "name", ",", "search_path", ",", "codecs", ")" ]
570e28568475d5be1b1a2c95b8e941fbfbc167eb
train
load_datafile
find datafile and load them from codec TODO only does the first one kwargs: default = if passed will return that on failure instead of throwing
facsimile/codec.py
def load_datafile(name, search_path, codecs=get_codecs(), **kwargs): """ find datafile and load them from codec TODO only does the first one kwargs: default = if passed will return that on failure instead of throwing """ return munge.load_datafile(name, search_path, codecs, **kwargs)
def load_datafile(name, search_path, codecs=get_codecs(), **kwargs): """ find datafile and load them from codec TODO only does the first one kwargs: default = if passed will return that on failure instead of throwing """ return munge.load_datafile(name, search_path, codecs, **kwargs)
[ "find", "datafile", "and", "load", "them", "from", "codec", "TODO", "only", "does", "the", "first", "one", "kwargs", ":", "default", "=", "if", "passed", "will", "return", "that", "on", "failure", "instead", "of", "throwing" ]
20c/facsimile
python
https://github.com/20c/facsimile/blob/570e28568475d5be1b1a2c95b8e941fbfbc167eb/facsimile/codec.py#L23-L30
[ "def", "load_datafile", "(", "name", ",", "search_path", ",", "codecs", "=", "get_codecs", "(", ")", ",", "*", "*", "kwargs", ")", ":", "return", "munge", ".", "load_datafile", "(", "name", ",", "search_path", ",", "codecs", ",", "*", "*", "kwargs", ")...
570e28568475d5be1b1a2c95b8e941fbfbc167eb
train
BirdsiteSkeleton.cred_init
Initialize what requires credentials/secret files. :param secrets_dir: dir to expect credentials in and store logs/history in. :param log: logger to use for log output. :param bot_name: name of this bot, used for various kinds of labelling. :returns: none.
botskeleton/outputs/output_birdsite.py
def cred_init( self, *, secrets_dir: str, log: Logger, bot_name: str, ) -> None: """ Initialize what requires credentials/secret files. :param secrets_dir: dir to expect credentials in and store logs/history in. :param log:...
def cred_init( self, *, secrets_dir: str, log: Logger, bot_name: str, ) -> None: """ Initialize what requires credentials/secret files. :param secrets_dir: dir to expect credentials in and store logs/history in. :param log:...
[ "Initialize", "what", "requires", "credentials", "/", "secret", "files", "." ]
alixnovosi/botskeleton
python
https://github.com/alixnovosi/botskeleton/blob/55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9/botskeleton/outputs/output_birdsite.py#L23-L69
[ "def", "cred_init", "(", "self", ",", "*", ",", "secrets_dir", ":", "str", ",", "log", ":", "Logger", ",", "bot_name", ":", "str", ",", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "secrets_dir", "=", "secrets_dir", ",", "log", ...
55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9
train
BirdsiteSkeleton.send
Send birdsite message. :param text: text to send in post. :returns: list of output records, each corresponding to either a single post, or an error.
botskeleton/outputs/output_birdsite.py
def send( self, *, text: str, ) -> List[OutputRecord]: """ Send birdsite message. :param text: text to send in post. :returns: list of output records, each corresponding to either a single post, or an error. """ ...
def send( self, *, text: str, ) -> List[OutputRecord]: """ Send birdsite message. :param text: text to send in post. :returns: list of output records, each corresponding to either a single post, or an error. """ ...
[ "Send", "birdsite", "message", "." ]
alixnovosi/botskeleton
python
https://github.com/alixnovosi/botskeleton/blob/55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9/botskeleton/outputs/output_birdsite.py#L71-L93
[ "def", "send", "(", "self", ",", "*", ",", "text", ":", "str", ",", ")", "->", "List", "[", "OutputRecord", "]", ":", "try", ":", "status", "=", "self", ".", "api", ".", "update_status", "(", "text", ")", "self", ".", "ldebug", "(", "f\"Status obje...
55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9
train
BirdsiteSkeleton.send_with_media
Upload media to birdsite, and send status and media, and captions if present. :param text: tweet text. :param files: list of files to upload with post. :param captions: list of captions to include as alt-text with files. :returns: list of output records, each...
botskeleton/outputs/output_birdsite.py
def send_with_media( self, *, text: str, files: List[str], captions: List[str]=[] ) -> List[OutputRecord]: """ Upload media to birdsite, and send status and media, and captions if present. :param text: tweet text. ...
def send_with_media( self, *, text: str, files: List[str], captions: List[str]=[] ) -> List[OutputRecord]: """ Upload media to birdsite, and send status and media, and captions if present. :param text: tweet text. ...
[ "Upload", "media", "to", "birdsite", "and", "send", "status", "and", "media", "and", "captions", "if", "present", "." ]
alixnovosi/botskeleton
python
https://github.com/alixnovosi/botskeleton/blob/55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9/botskeleton/outputs/output_birdsite.py#L95-L144
[ "def", "send_with_media", "(", "self", ",", "*", ",", "text", ":", "str", ",", "files", ":", "List", "[", "str", "]", ",", "captions", ":", "List", "[", "str", "]", "=", "[", "]", ")", "->", "List", "[", "OutputRecord", "]", ":", "# upload media", ...
55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9
train
BirdsiteSkeleton.perform_batch_reply
Performs batch reply on target account. Looks up the recent messages of the target user, applies the callback, and replies with what the callback generates. :param callback: a callback taking a message id, message contents, and optional extra keys, ...
botskeleton/outputs/output_birdsite.py
def perform_batch_reply( self, *, callback: Callable[..., str], lookback_limit: int, target_handle: str, ) -> List[OutputRecord]: """ Performs batch reply on target account. Looks up the recent messages of the target user, a...
def perform_batch_reply( self, *, callback: Callable[..., str], lookback_limit: int, target_handle: str, ) -> List[OutputRecord]: """ Performs batch reply on target account. Looks up the recent messages of the target user, a...
[ "Performs", "batch", "reply", "on", "target", "account", ".", "Looks", "up", "the", "recent", "messages", "of", "the", "target", "user", "applies", "the", "callback", "and", "replies", "with", "what", "the", "callback", "generates", "." ]
alixnovosi/botskeleton
python
https://github.com/alixnovosi/botskeleton/blob/55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9/botskeleton/outputs/output_birdsite.py#L146-L223
[ "def", "perform_batch_reply", "(", "self", ",", "*", ",", "callback", ":", "Callable", "[", "...", ",", "str", "]", ",", "lookback_limit", ":", "int", ",", "target_handle", ":", "str", ",", ")", "->", "List", "[", "OutputRecord", "]", ":", "self", ".",...
55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9
train
BirdsiteSkeleton.send_dm_sos
Send DM to owner if something happens. :param message: message to send to owner. :returns: None.
botskeleton/outputs/output_birdsite.py
def send_dm_sos(self, message: str) -> None: """ Send DM to owner if something happens. :param message: message to send to owner. :returns: None. """ if self.owner_handle: try: # twitter changed the DM API and tweepy (as of 2019-03-08) ...
def send_dm_sos(self, message: str) -> None: """ Send DM to owner if something happens. :param message: message to send to owner. :returns: None. """ if self.owner_handle: try: # twitter changed the DM API and tweepy (as of 2019-03-08) ...
[ "Send", "DM", "to", "owner", "if", "something", "happens", "." ]
alixnovosi/botskeleton
python
https://github.com/alixnovosi/botskeleton/blob/55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9/botskeleton/outputs/output_birdsite.py#L226-L260
[ "def", "send_dm_sos", "(", "self", ",", "message", ":", "str", ")", "->", "None", ":", "if", "self", ".", "owner_handle", ":", "try", ":", "# twitter changed the DM API and tweepy (as of 2019-03-08)", "# has not adapted.", "# fixing with", "# https://github.com/tweepy/twe...
55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9
train
BirdsiteSkeleton.handle_error
Handle error while trying to do something. :param message: message to send in DM regarding error. :param e: tweepy error object. :returns: OutputRecord containing an error.
botskeleton/outputs/output_birdsite.py
def handle_error( self, *, message: str, error: tweepy.TweepError, ) -> OutputRecord: """ Handle error while trying to do something. :param message: message to send in DM regarding error. :param e: tweepy error object. :returns...
def handle_error( self, *, message: str, error: tweepy.TweepError, ) -> OutputRecord: """ Handle error while trying to do something. :param message: message to send in DM regarding error. :param e: tweepy error object. :returns...
[ "Handle", "error", "while", "trying", "to", "do", "something", "." ]
alixnovosi/botskeleton
python
https://github.com/alixnovosi/botskeleton/blob/55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9/botskeleton/outputs/output_birdsite.py#L262-L288
[ "def", "handle_error", "(", "self", ",", "*", ",", "message", ":", "str", ",", "error", ":", "tweepy", ".", "TweepError", ",", ")", "->", "OutputRecord", ":", "self", ".", "lerror", "(", "f\"Got an error! {error}\"", ")", "# Handle errors if we know how.", "tr...
55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9
train
BirdsiteSkeleton._handle_caption_upload
Handle uploading all captions. :param media_ids: media ids of uploads to attach captions to. :param captions: captions to be attached to those media ids. :returns: None.
botskeleton/outputs/output_birdsite.py
def _handle_caption_upload( self, *, media_ids: List[str], captions: Optional[List[str]], ) -> None: """ Handle uploading all captions. :param media_ids: media ids of uploads to attach captions to. :param captions: captions to be attac...
def _handle_caption_upload( self, *, media_ids: List[str], captions: Optional[List[str]], ) -> None: """ Handle uploading all captions. :param media_ids: media ids of uploads to attach captions to. :param captions: captions to be attac...
[ "Handle", "uploading", "all", "captions", "." ]
alixnovosi/botskeleton
python
https://github.com/alixnovosi/botskeleton/blob/55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9/botskeleton/outputs/output_birdsite.py#L298-L319
[ "def", "_handle_caption_upload", "(", "self", ",", "*", ",", "media_ids", ":", "List", "[", "str", "]", ",", "captions", ":", "Optional", "[", "List", "[", "str", "]", "]", ",", ")", "->", "None", ":", "if", "captions", "is", "None", ":", "captions",...
55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9
train
BirdsiteSkeleton._send_direct_message_new
:reference: https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/new-event.html
botskeleton/outputs/output_birdsite.py
def _send_direct_message_new(self, messageobject: Dict[str, Dict]) -> Any: """ :reference: https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/new-event.html """ headers, post_data = _buildmessageobject(messageobject) newdm_path = "/direct_me...
def _send_direct_message_new(self, messageobject: Dict[str, Dict]) -> Any: """ :reference: https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/new-event.html """ headers, post_data = _buildmessageobject(messageobject) newdm_path = "/direct_me...
[ ":", "reference", ":", "https", ":", "//", "developer", ".", "twitter", ".", "com", "/", "en", "/", "docs", "/", "direct", "-", "messages", "/", "sending", "-", "and", "-", "receiving", "/", "api", "-", "reference", "/", "new", "-", "event", ".", "...
alixnovosi/botskeleton
python
https://github.com/alixnovosi/botskeleton/blob/55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9/botskeleton/outputs/output_birdsite.py#L343-L355
[ "def", "_send_direct_message_new", "(", "self", ",", "messageobject", ":", "Dict", "[", "str", ",", "Dict", "]", ")", "->", "Any", ":", "headers", ",", "post_data", "=", "_buildmessageobject", "(", "messageobject", ")", "newdm_path", "=", "\"/direct_messages/eve...
55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9
train
main
Takes crash data via stdin and generates a Socorro signature
siggen/cmd_signify.py
def main(): """Takes crash data via stdin and generates a Socorro signature""" parser = argparse.ArgumentParser(description=DESCRIPTION) parser.add_argument( '-v', '--verbose', help='increase output verbosity', action='store_true' ) args = parser.parse_args() generator = SignatureGenera...
def main(): """Takes crash data via stdin and generates a Socorro signature""" parser = argparse.ArgumentParser(description=DESCRIPTION) parser.add_argument( '-v', '--verbose', help='increase output verbosity', action='store_true' ) args = parser.parse_args() generator = SignatureGenera...
[ "Takes", "crash", "data", "via", "stdin", "and", "generates", "a", "Socorro", "signature" ]
willkg/socorro-siggen
python
https://github.com/willkg/socorro-siggen/blob/db7e3233e665a458a961c48da22e93a69b1d08d6/siggen/cmd_signify.py#L19-L33
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "DESCRIPTION", ")", "parser", ".", "add_argument", "(", "'-v'", ",", "'--verbose'", ",", "help", "=", "'increase output verbosity'", ",", "action", "=", ...
db7e3233e665a458a961c48da22e93a69b1d08d6
train
Base.add_config
Update internel configuration dict with config and recheck
facsimile/base.py
def add_config(self, config): """ Update internel configuration dict with config and recheck """ for attr in self.__fixed_attrs: if attr in config: raise Exception("cannot set '%s' outside of init", attr) # pre checkout stages = config.get('s...
def add_config(self, config): """ Update internel configuration dict with config and recheck """ for attr in self.__fixed_attrs: if attr in config: raise Exception("cannot set '%s' outside of init", attr) # pre checkout stages = config.get('s...
[ "Update", "internel", "configuration", "dict", "with", "config", "and", "recheck" ]
20c/facsimile
python
https://github.com/20c/facsimile/blob/570e28568475d5be1b1a2c95b8e941fbfbc167eb/facsimile/base.py#L234-L292
[ "def", "add_config", "(", "self", ",", "config", ")", ":", "for", "attr", "in", "self", ".", "__fixed_attrs", ":", "if", "attr", "in", "config", ":", "raise", "Exception", "(", "\"cannot set '%s' outside of init\"", ",", "attr", ")", "# pre checkout", "stages"...
570e28568475d5be1b1a2c95b8e941fbfbc167eb
train
Base.check_config
called after config was modified to sanity check raises on error
facsimile/base.py
def check_config(self): """ called after config was modified to sanity check raises on error """ # sanity checks - no config access past here if not getattr(self, 'stages', None): raise NotImplementedError("member variable 'stages' must be defined") #...
def check_config(self): """ called after config was modified to sanity check raises on error """ # sanity checks - no config access past here if not getattr(self, 'stages', None): raise NotImplementedError("member variable 'stages' must be defined") #...
[ "called", "after", "config", "was", "modified", "to", "sanity", "check", "raises", "on", "error" ]
20c/facsimile
python
https://github.com/20c/facsimile/blob/570e28568475d5be1b1a2c95b8e941fbfbc167eb/facsimile/base.py#L294-L376
[ "def", "check_config", "(", "self", ")", ":", "# sanity checks - no config access past here", "if", "not", "getattr", "(", "self", ",", "'stages'", ",", "None", ")", ":", "raise", "NotImplementedError", "(", "\"member variable 'stages' must be defined\"", ")", "# start ...
570e28568475d5be1b1a2c95b8e941fbfbc167eb
train
Base.check_definition
called after Defintion was loaded to sanity check raises on error
facsimile/base.py
def check_definition(self): """ called after Defintion was loaded to sanity check raises on error """ if not self.write_codec: self.__write_codec = self.defined.data_ext # TODO need to add back a class scope target limited for subprojects with sub target sets...
def check_definition(self): """ called after Defintion was loaded to sanity check raises on error """ if not self.write_codec: self.__write_codec = self.defined.data_ext # TODO need to add back a class scope target limited for subprojects with sub target sets...
[ "called", "after", "Defintion", "was", "loaded", "to", "sanity", "check", "raises", "on", "error" ]
20c/facsimile
python
https://github.com/20c/facsimile/blob/570e28568475d5be1b1a2c95b8e941fbfbc167eb/facsimile/base.py#L378-L394
[ "def", "check_definition", "(", "self", ")", ":", "if", "not", "self", ".", "write_codec", ":", "self", ".", "__write_codec", "=", "self", ".", "defined", ".", "data_ext", "# TODO need to add back a class scope target limited for subprojects with sub target sets", "target...
570e28568475d5be1b1a2c95b8e941fbfbc167eb
train
Base.find_datafile
find all matching data files in search_path returns array of tuples (codec_object, filename)
facsimile/base.py
def find_datafile(self, name, search_path=None): """ find all matching data files in search_path returns array of tuples (codec_object, filename) """ if not search_path: search_path = self.define_dir return codec.find_datafile(name, search_path)
def find_datafile(self, name, search_path=None): """ find all matching data files in search_path returns array of tuples (codec_object, filename) """ if not search_path: search_path = self.define_dir return codec.find_datafile(name, search_path)
[ "find", "all", "matching", "data", "files", "in", "search_path", "returns", "array", "of", "tuples", "(", "codec_object", "filename", ")" ]
20c/facsimile
python
https://github.com/20c/facsimile/blob/570e28568475d5be1b1a2c95b8e941fbfbc167eb/facsimile/base.py#L457-L465
[ "def", "find_datafile", "(", "self", ",", "name", ",", "search_path", "=", "None", ")", ":", "if", "not", "search_path", ":", "search_path", "=", "self", ".", "define_dir", "return", "codec", ".", "find_datafile", "(", "name", ",", "search_path", ")" ]
570e28568475d5be1b1a2c95b8e941fbfbc167eb
train
Base.load_datafile
find datafile and load them from codec
facsimile/base.py
def load_datafile(self, name, search_path=None, **kwargs): """ find datafile and load them from codec """ if not search_path: search_path = self.define_dir self.debug_msg('loading datafile %s from %s' % (name, str(search_path))) return codec.load_datafile(nam...
def load_datafile(self, name, search_path=None, **kwargs): """ find datafile and load them from codec """ if not search_path: search_path = self.define_dir self.debug_msg('loading datafile %s from %s' % (name, str(search_path))) return codec.load_datafile(nam...
[ "find", "datafile", "and", "load", "them", "from", "codec" ]
20c/facsimile
python
https://github.com/20c/facsimile/blob/570e28568475d5be1b1a2c95b8e941fbfbc167eb/facsimile/base.py#L467-L475
[ "def", "load_datafile", "(", "self", ",", "name", ",", "search_path", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "search_path", ":", "search_path", "=", "self", ".", "define_dir", "self", ".", "debug_msg", "(", "'loading datafile %s from %s...
570e28568475d5be1b1a2c95b8e941fbfbc167eb
train
Base.run
run all configured stages
facsimile/base.py
def run(self): """ run all configured stages """ self.sanity_check() # TODO - check for devel # if not self.version: # raise Exception("no version") # XXX check attr exist if not self.release_environment: raise Exception("no instance name") time_start = t...
def run(self): """ run all configured stages """ self.sanity_check() # TODO - check for devel # if not self.version: # raise Exception("no version") # XXX check attr exist if not self.release_environment: raise Exception("no instance name") time_start = t...
[ "run", "all", "configured", "stages" ]
20c/facsimile
python
https://github.com/20c/facsimile/blob/570e28568475d5be1b1a2c95b8e941fbfbc167eb/facsimile/base.py#L695-L753
[ "def", "run", "(", "self", ")", ":", "self", ".", "sanity_check", "(", ")", "# TODO - check for devel", "# if not self.version:", "# raise Exception(\"no version\")", "# XXX check attr exist", "if", "not", "self", ".", "release_environment", ":", "raise", ...
570e28568475d5be1b1a2c95b8e941fbfbc167eb
train
timestamp
Return POSIX timestamp as float. >>> timestamp(datetime.datetime.now()) > 1494638812 True >>> timestamp(datetime.datetime.now()) % 1 > 0 True
backports/datetime_timestamp/__init__.py
def timestamp(dt): """ Return POSIX timestamp as float. >>> timestamp(datetime.datetime.now()) > 1494638812 True >>> timestamp(datetime.datetime.now()) % 1 > 0 True """ if dt.tzinfo is None: return time.mktime(( dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, -1, -1, -1)) + dt.microsecond...
def timestamp(dt): """ Return POSIX timestamp as float. >>> timestamp(datetime.datetime.now()) > 1494638812 True >>> timestamp(datetime.datetime.now()) % 1 > 0 True """ if dt.tzinfo is None: return time.mktime(( dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, -1, -1, -1)) + dt.microsecond...
[ "Return", "POSIX", "timestamp", "as", "float", "." ]
jaraco/backports.datetime_timestamp
python
https://github.com/jaraco/backports.datetime_timestamp/blob/914d3f75b3f8818b8dd4ac1863698917be2354ca/backports/datetime_timestamp/__init__.py#L24-L40
[ "def", "timestamp", "(", "dt", ")", ":", "if", "dt", ".", "tzinfo", "is", "None", ":", "return", "time", ".", "mktime", "(", "(", "dt", ".", "year", ",", "dt", ".", "month", ",", "dt", ".", "day", ",", "dt", ".", "hour", ",", "dt", ".", "minu...
914d3f75b3f8818b8dd4ac1863698917be2354ca
train
rate_limited
Rate limit a function.
botskeleton/botskeleton.py
def rate_limited(max_per_hour: int, *args: Any) -> Callable[..., Any]: """Rate limit a function.""" return util.rate_limited(max_per_hour, *args)
def rate_limited(max_per_hour: int, *args: Any) -> Callable[..., Any]: """Rate limit a function.""" return util.rate_limited(max_per_hour, *args)
[ "Rate", "limit", "a", "function", "." ]
alixnovosi/botskeleton
python
https://github.com/alixnovosi/botskeleton/blob/55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9/botskeleton/botskeleton.py#L492-L494
[ "def", "rate_limited", "(", "max_per_hour", ":", "int", ",", "*", "args", ":", "Any", ")", "->", "Callable", "[", "...", ",", "Any", "]", ":", "return", "util", ".", "rate_limited", "(", "max_per_hour", ",", "*", "args", ")" ]
55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9
train
_repair
Repair a corrupted IterationRecord with a specific known issue.
botskeleton/botskeleton.py
def _repair(record: Dict[str, Any]) -> Dict[str, Any]: """Repair a corrupted IterationRecord with a specific known issue.""" output_records = record.get("output_records") if record.get("_type", None) == "IterationRecord" and output_records is not None: birdsite_record = output_records.get("birdsite"...
def _repair(record: Dict[str, Any]) -> Dict[str, Any]: """Repair a corrupted IterationRecord with a specific known issue.""" output_records = record.get("output_records") if record.get("_type", None) == "IterationRecord" and output_records is not None: birdsite_record = output_records.get("birdsite"...
[ "Repair", "a", "corrupted", "IterationRecord", "with", "a", "specific", "known", "issue", "." ]
alixnovosi/botskeleton
python
https://github.com/alixnovosi/botskeleton/blob/55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9/botskeleton/botskeleton.py#L510-L554
[ "def", "_repair", "(", "record", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "output_records", "=", "record", ".", "get", "(", "\"output_records\"", ")", "if", "record", ".", "get", "(", "\"_type\"",...
55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9
train
IterationRecord.from_dict
Get object back from dict.
botskeleton/botskeleton.py
def from_dict(cls, obj_dict: Dict[str, Any]) -> "IterationRecord": """Get object back from dict.""" obj = cls() for key, item in obj_dict.items(): obj.__dict__[key] = item return obj
def from_dict(cls, obj_dict: Dict[str, Any]) -> "IterationRecord": """Get object back from dict.""" obj = cls() for key, item in obj_dict.items(): obj.__dict__[key] = item return obj
[ "Get", "object", "back", "from", "dict", "." ]
alixnovosi/botskeleton
python
https://github.com/alixnovosi/botskeleton/blob/55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9/botskeleton/botskeleton.py#L48-L54
[ "def", "from_dict", "(", "cls", ",", "obj_dict", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "\"IterationRecord\"", ":", "obj", "=", "cls", "(", ")", "for", "key", ",", "item", "in", "obj_dict", ".", "items", "(", ")", ":", "obj", ".", "...
55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9
train
BotSkeleton.send
Post text-only to all outputs. :param args: positional arguments. expected: text to send as message in post. keyword text argument is preferred over this. :param text: text to send as message in post. :returns: new record of iteration
botskeleton/botskeleton.py
def send( self, *args: str, text: str=None, ) -> IterationRecord: """ Post text-only to all outputs. :param args: positional arguments. expected: text to send as message in post. keyword text argument is preferred over this. ...
def send( self, *args: str, text: str=None, ) -> IterationRecord: """ Post text-only to all outputs. :param args: positional arguments. expected: text to send as message in post. keyword text argument is preferred over this. ...
[ "Post", "text", "-", "only", "to", "all", "outputs", "." ]
alixnovosi/botskeleton
python
https://github.com/alixnovosi/botskeleton/blob/55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9/botskeleton/botskeleton.py#L102-L140
[ "def", "send", "(", "self", ",", "*", "args", ":", "str", ",", "text", ":", "str", "=", "None", ",", ")", "->", "IterationRecord", ":", "if", "text", "is", "not", "None", ":", "final_text", "=", "text", "else", ":", "if", "len", "(", "args", ")",...
55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9
train
BotSkeleton.send_with_one_media
Post with one media item to all outputs. Provide filename so outputs can handle their own uploads. :param args: positional arguments. expected: text to send as message in post. file to be uploaded. caption to be paired with file. k...
botskeleton/botskeleton.py
def send_with_one_media( self, *args: str, text: str=None, file: str=None, caption: str=None, ) -> IterationRecord: """ Post with one media item to all outputs. Provide filename so outputs can handle their own uploads. :par...
def send_with_one_media( self, *args: str, text: str=None, file: str=None, caption: str=None, ) -> IterationRecord: """ Post with one media item to all outputs. Provide filename so outputs can handle their own uploads. :par...
[ "Post", "with", "one", "media", "item", "to", "all", "outputs", ".", "Provide", "filename", "so", "outputs", "can", "handle", "their", "own", "uploads", "." ]
alixnovosi/botskeleton
python
https://github.com/alixnovosi/botskeleton/blob/55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9/botskeleton/botskeleton.py#L142-L208
[ "def", "send_with_one_media", "(", "self", ",", "*", "args", ":", "str", ",", "text", ":", "str", "=", "None", ",", "file", ":", "str", "=", "None", ",", "caption", ":", "str", "=", "None", ",", ")", "->", "IterationRecord", ":", "final_text", "=", ...
55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9
train
BotSkeleton.send_with_many_media
Post with several media. Provide filenames so outputs can handle their own uploads. :param args: positional arguments. expected: text to send as message in post. files to be uploaded. captions to be paired with files. keyword argum...
botskeleton/botskeleton.py
def send_with_many_media( self, *args: str, text: str=None, files: List[str]=None, captions: List[str]=[], ) -> IterationRecord: """ Post with several media. Provide filenames so outputs can handle their own uploads. :param...
def send_with_many_media( self, *args: str, text: str=None, files: List[str]=None, captions: List[str]=[], ) -> IterationRecord: """ Post with several media. Provide filenames so outputs can handle their own uploads. :param...
[ "Post", "with", "several", "media", ".", "Provide", "filenames", "so", "outputs", "can", "handle", "their", "own", "uploads", "." ]
alixnovosi/botskeleton
python
https://github.com/alixnovosi/botskeleton/blob/55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9/botskeleton/botskeleton.py#L210-L269
[ "def", "send_with_many_media", "(", "self", ",", "*", "args", ":", "str", ",", "text", ":", "str", "=", "None", ",", "files", ":", "List", "[", "str", "]", "=", "None", ",", "captions", ":", "List", "[", "str", "]", "=", "[", "]", ",", ")", "->...
55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9