repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
jmbeach/KEP.py
src/keppy/simulator_device.py
SimulatorDevice.process_string
def process_string(self, tag): """Process string type tags""" tag.set_address(self.string_register.current_address) if self.is_sixteen_bit: # each string address needs 1 byte = 1/2 an address self.string_register.move_to_next_address(1) return # each s...
python
def process_string(self, tag): """Process string type tags""" tag.set_address(self.string_register.current_address) if self.is_sixteen_bit: # each string address needs 1 byte = 1/2 an address self.string_register.move_to_next_address(1) return # each s...
[ "def", "process_string", "(", "self", ",", "tag", ")", ":", "tag", ".", "set_address", "(", "self", ".", "string_register", ".", "current_address", ")", "if", "self", ".", "is_sixteen_bit", ":", "# each string address needs 1 byte = 1/2 an address", "self", ".", "...
Process string type tags
[ "Process", "string", "type", "tags" ]
68cda64ab649640a486534867c81274c41e39446
https://github.com/jmbeach/KEP.py/blob/68cda64ab649640a486534867c81274c41e39446/src/keppy/simulator_device.py#L166-L174
train
Process string type tags
tjcsl/cslbot
cslbot/commands/microwave.py
cmd
def cmd(send, msg, args): """Microwaves something. Syntax: {command} <level> <target> """ nick = args['nick'] channel = args['target'] if args['target'] != 'private' else args['config']['core']['channel'] levels = { 1: 'Whirr...', 2: 'Vrrm...', 3: 'Zzzzhhhh...', ...
python
def cmd(send, msg, args): """Microwaves something. Syntax: {command} <level> <target> """ nick = args['nick'] channel = args['target'] if args['target'] != 'private' else args['config']['core']['channel'] levels = { 1: 'Whirr...', 2: 'Vrrm...', 3: 'Zzzzhhhh...', ...
[ "def", "cmd", "(", "send", ",", "msg", ",", "args", ")", ":", "nick", "=", "args", "[", "'nick'", "]", "channel", "=", "args", "[", "'target'", "]", "if", "args", "[", "'target'", "]", "!=", "'private'", "else", "args", "[", "'config'", "]", "[", ...
Microwaves something. Syntax: {command} <level> <target>
[ "Microwaves", "something", "." ]
aebe07be47141f61d7c180706bddfb707f19b2b5
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/microwave.py#L25-L83
train
Microwaves something.
fabaff/python-opensensemap-api
example.py
main
async def main(): """Sample code to retrieve the data from an OpenSenseMap station.""" async with aiohttp.ClientSession() as session: station = OpenSenseMap(SENSOR_ID, loop, session) # Print details about the given station await station.get_data() print("Name:", station.name) ...
python
async def main(): """Sample code to retrieve the data from an OpenSenseMap station.""" async with aiohttp.ClientSession() as session: station = OpenSenseMap(SENSOR_ID, loop, session) # Print details about the given station await station.get_data() print("Name:", station.name) ...
[ "async", "def", "main", "(", ")", ":", "async", "with", "aiohttp", ".", "ClientSession", "(", ")", "as", "session", ":", "station", "=", "OpenSenseMap", "(", "SENSOR_ID", ",", "loop", ",", "session", ")", "# Print details about the given station", "await", "st...
Sample code to retrieve the data from an OpenSenseMap station.
[ "Sample", "code", "to", "retrieve", "the", "data", "from", "an", "OpenSenseMap", "station", "." ]
3c4f5473c514185087aae5d766ab4d5736ec1f30
https://github.com/fabaff/python-opensensemap-api/blob/3c4f5473c514185087aae5d766ab4d5736ec1f30/example.py#L11-L26
train
Sample code to retrieve the data from an OpenSenseMap station.
adamheins/r12
r12/shell.py
ShellStyle.theme
def theme(self, text): ''' Theme style. ''' return self.theme_color + self.BRIGHT + text + self.RESET
python
def theme(self, text): ''' Theme style. ''' return self.theme_color + self.BRIGHT + text + self.RESET
[ "def", "theme", "(", "self", ",", "text", ")", ":", "return", "self", ".", "theme_color", "+", "self", ".", "BRIGHT", "+", "text", "+", "self", ".", "RESET" ]
Theme style.
[ "Theme", "style", "." ]
ff78178332140930bf46a94a0b15ee082bb92491
https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/shell.py#L33-L35
train
Theme style.
adamheins/r12
r12/shell.py
ShellStyle._label_desc
def _label_desc(self, label, desc, label_color=''): ''' Generic styler for a line consisting of a label and description. ''' return self.BRIGHT + label_color + label + self.RESET + desc
python
def _label_desc(self, label, desc, label_color=''): ''' Generic styler for a line consisting of a label and description. ''' return self.BRIGHT + label_color + label + self.RESET + desc
[ "def", "_label_desc", "(", "self", ",", "label", ",", "desc", ",", "label_color", "=", "''", ")", ":", "return", "self", ".", "BRIGHT", "+", "label_color", "+", "label", "+", "self", ".", "RESET", "+", "desc" ]
Generic styler for a line consisting of a label and description.
[ "Generic", "styler", "for", "a", "line", "consisting", "of", "a", "label", "and", "description", "." ]
ff78178332140930bf46a94a0b15ee082bb92491
https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/shell.py#L38-L40
train
Generic styler for a line consisting of a label and description.
adamheins/r12
r12/shell.py
ShellStyle.error
def error(self, cmd, desc=''): ''' Style for an error message. ''' return self._label_desc(cmd, desc, self.error_color)
python
def error(self, cmd, desc=''): ''' Style for an error message. ''' return self._label_desc(cmd, desc, self.error_color)
[ "def", "error", "(", "self", ",", "cmd", ",", "desc", "=", "''", ")", ":", "return", "self", ".", "_label_desc", "(", "cmd", ",", "desc", ",", "self", ".", "error_color", ")" ]
Style for an error message.
[ "Style", "for", "an", "error", "message", "." ]
ff78178332140930bf46a94a0b15ee082bb92491
https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/shell.py#L48-L50
train
Style for an error message.
adamheins/r12
r12/shell.py
ShellStyle.warn
def warn(self, cmd, desc=''): ''' Style for warning message. ''' return self._label_desc(cmd, desc, self.warn_color)
python
def warn(self, cmd, desc=''): ''' Style for warning message. ''' return self._label_desc(cmd, desc, self.warn_color)
[ "def", "warn", "(", "self", ",", "cmd", ",", "desc", "=", "''", ")", ":", "return", "self", ".", "_label_desc", "(", "cmd", ",", "desc", ",", "self", ".", "warn_color", ")" ]
Style for warning message.
[ "Style", "for", "warning", "message", "." ]
ff78178332140930bf46a94a0b15ee082bb92491
https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/shell.py#L53-L55
train
Style for warning message.
adamheins/r12
r12/shell.py
ShellStyle.success
def success(self, cmd, desc=''): ''' Style for a success message. ''' return self._label_desc(cmd, desc, self.success_color)
python
def success(self, cmd, desc=''): ''' Style for a success message. ''' return self._label_desc(cmd, desc, self.success_color)
[ "def", "success", "(", "self", ",", "cmd", ",", "desc", "=", "''", ")", ":", "return", "self", ".", "_label_desc", "(", "cmd", ",", "desc", ",", "self", ".", "success_color", ")" ]
Style for a success message.
[ "Style", "for", "a", "success", "message", "." ]
ff78178332140930bf46a94a0b15ee082bb92491
https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/shell.py#L58-L60
train
Style for a success message.
adamheins/r12
r12/shell.py
ArmShell.cmdloop
def cmdloop(self, intro=None): ''' Override the command loop to handle Ctrl-C. ''' self.preloop() # Set up completion with readline. if self.use_rawinput and self.completekey: try: import readline self.old_completer = readline.get_completer() ...
python
def cmdloop(self, intro=None): ''' Override the command loop to handle Ctrl-C. ''' self.preloop() # Set up completion with readline. if self.use_rawinput and self.completekey: try: import readline self.old_completer = readline.get_completer() ...
[ "def", "cmdloop", "(", "self", ",", "intro", "=", "None", ")", ":", "self", ".", "preloop", "(", ")", "# Set up completion with readline.", "if", "self", ".", "use_rawinput", "and", "self", ".", "completekey", ":", "try", ":", "import", "readline", "self", ...
Override the command loop to handle Ctrl-C.
[ "Override", "the", "command", "loop", "to", "handle", "Ctrl", "-", "C", "." ]
ff78178332140930bf46a94a0b15ee082bb92491
https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/shell.py#L95-L147
train
Override the command loop to handle Ctrl - C.
adamheins/r12
r12/shell.py
ArmShell.do_exit
def do_exit(self, arg): ''' Exit the shell. ''' if self.arm.is_connected(): self.arm.disconnect() print('Bye!') return True
python
def do_exit(self, arg): ''' Exit the shell. ''' if self.arm.is_connected(): self.arm.disconnect() print('Bye!') return True
[ "def", "do_exit", "(", "self", ",", "arg", ")", ":", "if", "self", ".", "arm", ".", "is_connected", "(", ")", ":", "self", ".", "arm", ".", "disconnect", "(", ")", "print", "(", "'Bye!'", ")", "return", "True" ]
Exit the shell.
[ "Exit", "the", "shell", "." ]
ff78178332140930bf46a94a0b15ee082bb92491
https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/shell.py#L150-L155
train
Exit the shell.
adamheins/r12
r12/shell.py
ArmShell.do_ctrlc
def do_ctrlc(self, arg): ''' Ctrl-C sends a STOP command to the arm. ''' print('STOP') if self.arm.is_connected(): self.arm.write('STOP')
python
def do_ctrlc(self, arg): ''' Ctrl-C sends a STOP command to the arm. ''' print('STOP') if self.arm.is_connected(): self.arm.write('STOP')
[ "def", "do_ctrlc", "(", "self", ",", "arg", ")", ":", "print", "(", "'STOP'", ")", "if", "self", ".", "arm", ".", "is_connected", "(", ")", ":", "self", ".", "arm", ".", "write", "(", "'STOP'", ")" ]
Ctrl-C sends a STOP command to the arm.
[ "Ctrl", "-", "C", "sends", "a", "STOP", "command", "to", "the", "arm", "." ]
ff78178332140930bf46a94a0b15ee082bb92491
https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/shell.py#L158-L162
train
Ctrl - C sends a STOP command to the arm.
adamheins/r12
r12/shell.py
ArmShell.do_status
def do_status(self, arg): ''' Print information about the arm. ''' info = self.arm.get_info() max_len = len(max(info.keys(), key=len)) print(self.style.theme('\nArm Status')) for key, value in info.items(): print(self.style.help(key.ljust(max_len + 2), str(value))) ...
python
def do_status(self, arg): ''' Print information about the arm. ''' info = self.arm.get_info() max_len = len(max(info.keys(), key=len)) print(self.style.theme('\nArm Status')) for key, value in info.items(): print(self.style.help(key.ljust(max_len + 2), str(value))) ...
[ "def", "do_status", "(", "self", ",", "arg", ")", ":", "info", "=", "self", ".", "arm", ".", "get_info", "(", ")", "max_len", "=", "len", "(", "max", "(", "info", ".", "keys", "(", ")", ",", "key", "=", "len", ")", ")", "print", "(", "self", ...
Print information about the arm.
[ "Print", "information", "about", "the", "arm", "." ]
ff78178332140930bf46a94a0b15ee082bb92491
https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/shell.py#L180-L188
train
Print information about the arm.
adamheins/r12
r12/shell.py
ArmShell.do_connect
def do_connect(self, arg): ''' Connect to the arm. ''' if self.arm.is_connected(): print(self.style.error('Error: ', 'Arm is already connected.')) else: try: port = self.arm.connect() print(self.style.success('Success: ', ...
python
def do_connect(self, arg): ''' Connect to the arm. ''' if self.arm.is_connected(): print(self.style.error('Error: ', 'Arm is already connected.')) else: try: port = self.arm.connect() print(self.style.success('Success: ', ...
[ "def", "do_connect", "(", "self", ",", "arg", ")", ":", "if", "self", ".", "arm", ".", "is_connected", "(", ")", ":", "print", "(", "self", ".", "style", ".", "error", "(", "'Error: '", ",", "'Arm is already connected.'", ")", ")", "else", ":", "try", ...
Connect to the arm.
[ "Connect", "to", "the", "arm", "." ]
ff78178332140930bf46a94a0b15ee082bb92491
https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/shell.py#L191-L201
train
Connect to the arm.
adamheins/r12
r12/shell.py
ArmShell.do_disconnect
def do_disconnect(self, arg): ''' Disconnect from the arm. ''' if not self.arm.is_connected(): print(self.style.error('Error: ', 'Arm is already disconnected.')) else: self.arm.disconnect() print(self.style.success('Success: ', 'Disconnected.'))
python
def do_disconnect(self, arg): ''' Disconnect from the arm. ''' if not self.arm.is_connected(): print(self.style.error('Error: ', 'Arm is already disconnected.')) else: self.arm.disconnect() print(self.style.success('Success: ', 'Disconnected.'))
[ "def", "do_disconnect", "(", "self", ",", "arg", ")", ":", "if", "not", "self", ".", "arm", ".", "is_connected", "(", ")", ":", "print", "(", "self", ".", "style", ".", "error", "(", "'Error: '", ",", "'Arm is already disconnected.'", ")", ")", "else", ...
Disconnect from the arm.
[ "Disconnect", "from", "the", "arm", "." ]
ff78178332140930bf46a94a0b15ee082bb92491
https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/shell.py#L204-L210
train
Disconnect from the arm.
adamheins/r12
r12/shell.py
ArmShell.do_run
def do_run(self, arg): ''' Load and run an external FORTH script. ''' if not self.arm.is_connected(): print(self.style.error('Error: ', 'Arm is not connected.')) return # Load the script. try: with open(arg) as f: lines = [line.strip()...
python
def do_run(self, arg): ''' Load and run an external FORTH script. ''' if not self.arm.is_connected(): print(self.style.error('Error: ', 'Arm is not connected.')) return # Load the script. try: with open(arg) as f: lines = [line.strip()...
[ "def", "do_run", "(", "self", ",", "arg", ")", ":", "if", "not", "self", ".", "arm", ".", "is_connected", "(", ")", ":", "print", "(", "self", ".", "style", ".", "error", "(", "'Error: '", ",", "'Arm is not connected.'", ")", ")", "return", "# Load the...
Load and run an external FORTH script.
[ "Load", "and", "run", "an", "external", "FORTH", "script", "." ]
ff78178332140930bf46a94a0b15ee082bb92491
https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/shell.py#L213-L235
train
Load and run an external FORTH script.
adamheins/r12
r12/shell.py
ArmShell.do_dump
def do_dump(self, arg): ''' Output all bytes waiting in output queue. ''' if not self.arm.is_connected(): print(self.style.error('Error: ', 'Arm is not connected.')) return print(self.arm.dump())
python
def do_dump(self, arg): ''' Output all bytes waiting in output queue. ''' if not self.arm.is_connected(): print(self.style.error('Error: ', 'Arm is not connected.')) return print(self.arm.dump())
[ "def", "do_dump", "(", "self", ",", "arg", ")", ":", "if", "not", "self", ".", "arm", ".", "is_connected", "(", ")", ":", "print", "(", "self", ".", "style", ".", "error", "(", "'Error: '", ",", "'Arm is not connected.'", ")", ")", "return", "print", ...
Output all bytes waiting in output queue.
[ "Output", "all", "bytes", "waiting", "in", "output", "queue", "." ]
ff78178332140930bf46a94a0b15ee082bb92491
https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/shell.py#L238-L243
train
Dump all bytes waiting in output queue.
adamheins/r12
r12/shell.py
ArmShell.complete_run
def complete_run(self, text, line, b, e): ''' Autocomplete file names with .forth ending. ''' # Don't break on path separators. text = line.split()[-1] # Try to find files with a forth file ending, .fs. forth_files = glob.glob(text + '*.fs') # Failing that, just try and...
python
def complete_run(self, text, line, b, e): ''' Autocomplete file names with .forth ending. ''' # Don't break on path separators. text = line.split()[-1] # Try to find files with a forth file ending, .fs. forth_files = glob.glob(text + '*.fs') # Failing that, just try and...
[ "def", "complete_run", "(", "self", ",", "text", ",", "line", ",", "b", ",", "e", ")", ":", "# Don't break on path separators.", "text", "=", "line", ".", "split", "(", ")", "[", "-", "1", "]", "# Try to find files with a forth file ending, .fs.", "forth_files",...
Autocomplete file names with .forth ending.
[ "Autocomplete", "file", "names", "with", ".", "forth", "ending", "." ]
ff78178332140930bf46a94a0b15ee082bb92491
https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/shell.py#L251-L264
train
Autocomplete file names with. forth ending.
adamheins/r12
r12/shell.py
ArmShell.default
def default(self, line): ''' Commands with no do_* method fall to here. ''' # Commands that fall through to this method are interpreted as FORTH, # and must be in upper case. if not line.isupper(): print(self.style.error('Error: ', 'Unrecognized command.')) return...
python
def default(self, line): ''' Commands with no do_* method fall to here. ''' # Commands that fall through to this method are interpreted as FORTH, # and must be in upper case. if not line.isupper(): print(self.style.error('Error: ', 'Unrecognized command.')) return...
[ "def", "default", "(", "self", ",", "line", ")", ":", "# Commands that fall through to this method are interpreted as FORTH,", "# and must be in upper case.", "if", "not", "line", ".", "isupper", "(", ")", ":", "print", "(", "self", ".", "style", ".", "error", "(", ...
Commands with no do_* method fall to here.
[ "Commands", "with", "no", "do_", "*", "method", "fall", "to", "here", "." ]
ff78178332140930bf46a94a0b15ee082bb92491
https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/shell.py#L272-L294
train
This method is used to set the default command for a specific class.
adamheins/r12
r12/shell.py
ArmShell.get_names
def get_names(self): ''' Get names for autocompletion. ''' # Overridden to support autocompletion for the ROBOFORTH commands. return (['do_' + x for x in self.commands['shell']] + ['do_' + x for x in self.commands['forth']])
python
def get_names(self): ''' Get names for autocompletion. ''' # Overridden to support autocompletion for the ROBOFORTH commands. return (['do_' + x for x in self.commands['shell']] + ['do_' + x for x in self.commands['forth']])
[ "def", "get_names", "(", "self", ")", ":", "# Overridden to support autocompletion for the ROBOFORTH commands.", "return", "(", "[", "'do_'", "+", "x", "for", "x", "in", "self", ".", "commands", "[", "'shell'", "]", "]", "+", "[", "'do_'", "+", "x", "for", "...
Get names for autocompletion.
[ "Get", "names", "for", "autocompletion", "." ]
ff78178332140930bf46a94a0b15ee082bb92491
https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/shell.py#L297-L301
train
Get names for autocompletion.
adamheins/r12
r12/shell.py
ArmShell.parse_help_text
def parse_help_text(self, file_path): ''' Load of list of commands and descriptions from a file. ''' with open(file_path) as f: lines = f.readlines() # Parse commands and descriptions, which are separated by a multi-space # (any sequence of two or more space characters in a ...
python
def parse_help_text(self, file_path): ''' Load of list of commands and descriptions from a file. ''' with open(file_path) as f: lines = f.readlines() # Parse commands and descriptions, which are separated by a multi-space # (any sequence of two or more space characters in a ...
[ "def", "parse_help_text", "(", "self", ",", "file_path", ")", ":", "with", "open", "(", "file_path", ")", "as", "f", ":", "lines", "=", "f", ".", "readlines", "(", ")", "# Parse commands and descriptions, which are separated by a multi-space", "# (any sequence of two ...
Load of list of commands and descriptions from a file.
[ "Load", "of", "list", "of", "commands", "and", "descriptions", "from", "a", "file", "." ]
ff78178332140930bf46a94a0b15ee082bb92491
https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/shell.py#L304-L333
train
Load the list of commands and descriptions from a file.
adamheins/r12
r12/shell.py
ArmShell.load_forth_commands
def load_forth_commands(self, help_dir): ''' Load completion list for ROBOFORTH commands. ''' try: help_file_path = os.path.join(help_dir, 'roboforth.txt') commands, help_text = self.parse_help_text(help_file_path) except IOError: print(self.style.warn('Warnin...
python
def load_forth_commands(self, help_dir): ''' Load completion list for ROBOFORTH commands. ''' try: help_file_path = os.path.join(help_dir, 'roboforth.txt') commands, help_text = self.parse_help_text(help_file_path) except IOError: print(self.style.warn('Warnin...
[ "def", "load_forth_commands", "(", "self", ",", "help_dir", ")", ":", "try", ":", "help_file_path", "=", "os", ".", "path", ".", "join", "(", "help_dir", ",", "'roboforth.txt'", ")", "commands", ",", "help_text", "=", "self", ".", "parse_help_text", "(", "...
Load completion list for ROBOFORTH commands.
[ "Load", "completion", "list", "for", "ROBOFORTH", "commands", "." ]
ff78178332140930bf46a94a0b15ee082bb92491
https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/shell.py#L336-L347
train
Load completion list for ROBOFORTH commands.
adamheins/r12
r12/shell.py
ArmShell.preloop
def preloop(self): ''' Executed before the command loop starts. ''' script_dir = os.path.dirname(os.path.realpath(__file__)) help_dir = os.path.join(script_dir, HELP_DIR_NAME) self.load_forth_commands(help_dir) self.load_shell_commands(help_dir)
python
def preloop(self): ''' Executed before the command loop starts. ''' script_dir = os.path.dirname(os.path.realpath(__file__)) help_dir = os.path.join(script_dir, HELP_DIR_NAME) self.load_forth_commands(help_dir) self.load_shell_commands(help_dir)
[ "def", "preloop", "(", "self", ")", ":", "script_dir", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "realpath", "(", "__file__", ")", ")", "help_dir", "=", "os", ".", "path", ".", "join", "(", "script_dir", ",", "HELP_DIR_NAME...
Executed before the command loop starts.
[ "Executed", "before", "the", "command", "loop", "starts", "." ]
ff78178332140930bf46a94a0b15ee082bb92491
https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/shell.py#L363-L368
train
Executes before the command loop starts.
tjcsl/cslbot
cslbot/commands/bc.py
cmd
def cmd(send, msg, args): """Evaluates mathmatical expressions. Syntax: {command} <expression> """ if not msg: send("Calculate what?") return cursor = args['db'] scores = get_scores(cursor) for word in msg.split(): if word in scores: msg = msg.replace(wo...
python
def cmd(send, msg, args): """Evaluates mathmatical expressions. Syntax: {command} <expression> """ if not msg: send("Calculate what?") return cursor = args['db'] scores = get_scores(cursor) for word in msg.split(): if word in scores: msg = msg.replace(wo...
[ "def", "cmd", "(", "send", ",", "msg", ",", "args", ")", ":", "if", "not", "msg", ":", "send", "(", "\"Calculate what?\"", ")", "return", "cursor", "=", "args", "[", "'db'", "]", "scores", "=", "get_scores", "(", "cursor", ")", "for", "word", "in", ...
Evaluates mathmatical expressions. Syntax: {command} <expression>
[ "Evaluates", "mathmatical", "expressions", "." ]
aebe07be47141f61d7c180706bddfb707f19b2b5
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/bc.py#L30-L56
train
Evaluates mathmatical expressions.
The-Politico/politico-civic-election-night
electionnight/management/commands/methods/bootstrap/legislative_office.py
LegislativeOffice.bootstrap_legislative_office
def bootstrap_legislative_office(self, election): """ For legislative offices, create page content for the legislative Body the Office belongs to AND the state-level Division. E.g., for a Texas U.S. Senate seat, create page content for: - U.S. Senate page - Texas...
python
def bootstrap_legislative_office(self, election): """ For legislative offices, create page content for the legislative Body the Office belongs to AND the state-level Division. E.g., for a Texas U.S. Senate seat, create page content for: - U.S. Senate page - Texas...
[ "def", "bootstrap_legislative_office", "(", "self", ",", "election", ")", ":", "body", "=", "election", ".", "race", ".", "office", ".", "body", "body_division", "=", "election", ".", "race", ".", "office", ".", "body", ".", "jurisdiction", ".", "division", ...
For legislative offices, create page content for the legislative Body the Office belongs to AND the state-level Division. E.g., for a Texas U.S. Senate seat, create page content for: - U.S. Senate page - Texas state page
[ "For", "legislative", "offices", "create", "page", "content", "for", "the", "legislative", "Body", "the", "Office", "belongs", "to", "AND", "the", "state", "-", "level", "Division", "." ]
a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6
https://github.com/The-Politico/politico-civic-election-night/blob/a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6/electionnight/management/commands/methods/bootstrap/legislative_office.py#L40-L94
train
Create page content for the legislative office.
mardix/Juice
juice/ext.py
_Mailer.send
def send(self, to, subject=None, body=None, reply_to=None, template=None, **kwargs): """ To send email :param to: the recipients, list or string :param subject: the subject :param body: the body :param reply_to: reply_to :param template: template, will use the tem...
python
def send(self, to, subject=None, body=None, reply_to=None, template=None, **kwargs): """ To send email :param to: the recipients, list or string :param subject: the subject :param body: the body :param reply_to: reply_to :param template: template, will use the tem...
[ "def", "send", "(", "self", ",", "to", ",", "subject", "=", "None", ",", "body", "=", "None", ",", "reply_to", "=", "None", ",", "template", "=", "None", ",", "*", "*", "kwargs", ")", ":", "sender", "=", "self", ".", "config", ".", "get", "(", ...
To send email :param to: the recipients, list or string :param subject: the subject :param body: the body :param reply_to: reply_to :param template: template, will use the templates instead :param kwargs: context args :return: bool - True if everything is ok
[ "To", "send", "email", ":", "param", "to", ":", "the", "recipients", "list", "or", "string", ":", "param", "subject", ":", "the", "subject", ":", "param", "body", ":", "the", "body", ":", "param", "reply_to", ":", "reply_to", ":", "param", "template", ...
7afa8d4238868235dfcdae82272bd77958dd416a
https://github.com/mardix/Juice/blob/7afa8d4238868235dfcdae82272bd77958dd416a/juice/ext.py#L243-L293
train
Send an email to the specified recipients list or string.
acutesoftware/virtual-AI-simulator
vais/world_generator.py
main
def main(): """ generates a random world, sets terrain and runs agents in it TODO - need to change pieces in multiple places (see worlds.py, cls_grid, world_generator) (takes about 5 minutes to make 500x400 grid with 8% blockages) """ width = 20 # grid width height = 10 #...
python
def main(): """ generates a random world, sets terrain and runs agents in it TODO - need to change pieces in multiple places (see worlds.py, cls_grid, world_generator) (takes about 5 minutes to make 500x400 grid with 8% blockages) """ width = 20 # grid width height = 10 #...
[ "def", "main", "(", ")", ":", "width", "=", "20", "# grid width ", "height", "=", "10", "# grid height", "iterations", "=", "20", "# how many simulations to run", "num_agents", "=", "6", "# number of agents to enter the world", "w", "=", "build_world", "(", "height"...
generates a random world, sets terrain and runs agents in it TODO - need to change pieces in multiple places (see worlds.py, cls_grid, world_generator) (takes about 5 minutes to make 500x400 grid with 8% blockages)
[ "generates", "a", "random", "world", "sets", "terrain", "and", "runs", "agents", "in", "it", "TODO", "-", "need", "to", "change", "pieces", "in", "multiple", "places", "(", "see", "worlds", ".", "py", "cls_grid", "world_generator", ")", "(", "takes", "abou...
57de679a5b1a58c38fefe6aea58af1f3a7e79c58
https://github.com/acutesoftware/virtual-AI-simulator/blob/57de679a5b1a58c38fefe6aea58af1f3a7e79c58/vais/world_generator.py#L15-L31
train
creates a random world sets terrain and runs agents in it
tjcsl/cslbot
cslbot/commands/xkcd.py
cmd
def cmd(send, msg, args): """Gets a xkcd comic. Syntax: {command} [num|latest|term] """ latest = get_latest() if not msg: msg = randrange(1, latest) elif msg == 'latest': msg = latest elif msg.isdigit(): msg = int(msg) if msg > latest or msg < 1: ...
python
def cmd(send, msg, args): """Gets a xkcd comic. Syntax: {command} [num|latest|term] """ latest = get_latest() if not msg: msg = randrange(1, latest) elif msg == 'latest': msg = latest elif msg.isdigit(): msg = int(msg) if msg > latest or msg < 1: ...
[ "def", "cmd", "(", "send", ",", "msg", ",", "args", ")", ":", "latest", "=", "get_latest", "(", ")", "if", "not", "msg", ":", "msg", "=", "randrange", "(", "1", ",", "latest", ")", "elif", "msg", "==", "'latest'", ":", "msg", "=", "latest", "elif...
Gets a xkcd comic. Syntax: {command} [num|latest|term]
[ "Gets", "a", "xkcd", "comic", "." ]
aebe07be47141f61d7c180706bddfb707f19b2b5
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/xkcd.py#L41-L63
train
Gets a xkcd comic.
louib/confirm
confirm/generator.py
generate_config_parser
def generate_config_parser(config, include_all=False): """ Generates a config parser from a configuration dictionary. The dictionary contains the merged informations of the schema and, optionally, of a source configuration file. Values of the source configuration file will be stored in the *value* ...
python
def generate_config_parser(config, include_all=False): """ Generates a config parser from a configuration dictionary. The dictionary contains the merged informations of the schema and, optionally, of a source configuration file. Values of the source configuration file will be stored in the *value* ...
[ "def", "generate_config_parser", "(", "config", ",", "include_all", "=", "False", ")", ":", "# The allow_no_value allows us to output commented lines.", "config_parser", "=", "SafeConfigParser", "(", "allow_no_value", "=", "True", ")", "for", "section_name", ",", "option_...
Generates a config parser from a configuration dictionary. The dictionary contains the merged informations of the schema and, optionally, of a source configuration file. Values of the source configuration file will be stored in the *value* field of an option.
[ "Generates", "a", "config", "parser", "from", "a", "configuration", "dictionary", "." ]
0acd1eccda6cd71c69d2ae33166a16a257685811
https://github.com/louib/confirm/blob/0acd1eccda6cd71c69d2ae33166a16a257685811/confirm/generator.py#L24-L55
train
Generates a config parser from a configuration dictionary.
louib/confirm
confirm/generator.py
generate_documentation
def generate_documentation(schema): """ Generates reStructuredText documentation from a Confirm file. :param schema: Dictionary representing the Confirm schema. :returns: String representing the reStructuredText documentation. """ documentation_title = "Configuration documentation" docume...
python
def generate_documentation(schema): """ Generates reStructuredText documentation from a Confirm file. :param schema: Dictionary representing the Confirm schema. :returns: String representing the reStructuredText documentation. """ documentation_title = "Configuration documentation" docume...
[ "def", "generate_documentation", "(", "schema", ")", ":", "documentation_title", "=", "\"Configuration documentation\"", "documentation", "=", "documentation_title", "+", "\"\\n\"", "documentation", "+=", "\"=\"", "*", "len", "(", "documentation_title", ")", "+", "'\\n'...
Generates reStructuredText documentation from a Confirm file. :param schema: Dictionary representing the Confirm schema. :returns: String representing the reStructuredText documentation.
[ "Generates", "reStructuredText", "documentation", "from", "a", "Confirm", "file", "." ]
0acd1eccda6cd71c69d2ae33166a16a257685811
https://github.com/louib/confirm/blob/0acd1eccda6cd71c69d2ae33166a16a257685811/confirm/generator.py#L73-L123
train
Generates the reStructuredText documentation from a Confirm file.
louib/confirm
confirm/generator.py
append_existing_values
def append_existing_values(schema, config): """ Adds the values of the existing config to the config dictionary. """ for section_name in config: for option_name in config[section_name]: option_value = config[section_name][option_name] # Note that we must preserve existi...
python
def append_existing_values(schema, config): """ Adds the values of the existing config to the config dictionary. """ for section_name in config: for option_name in config[section_name]: option_value = config[section_name][option_name] # Note that we must preserve existi...
[ "def", "append_existing_values", "(", "schema", ",", "config", ")", ":", "for", "section_name", "in", "config", ":", "for", "option_name", "in", "config", "[", "section_name", "]", ":", "option_value", "=", "config", "[", "section_name", "]", "[", "option_name...
Adds the values of the existing config to the config dictionary.
[ "Adds", "the", "values", "of", "the", "existing", "config", "to", "the", "config", "dictionary", "." ]
0acd1eccda6cd71c69d2ae33166a16a257685811
https://github.com/louib/confirm/blob/0acd1eccda6cd71c69d2ae33166a16a257685811/confirm/generator.py#L126-L139
train
Adds the values of the existing config to the schema.
louib/confirm
confirm/generator.py
generate_schema_file
def generate_schema_file(config_file): """ Generates a basic confirm schema file from a configuration file. """ config = utils.load_config_from_ini_file(config_file) schema = {} for section_name in config: for option_name in config[section_name]: schema.setdefault(section_n...
python
def generate_schema_file(config_file): """ Generates a basic confirm schema file from a configuration file. """ config = utils.load_config_from_ini_file(config_file) schema = {} for section_name in config: for option_name in config[section_name]: schema.setdefault(section_n...
[ "def", "generate_schema_file", "(", "config_file", ")", ":", "config", "=", "utils", ".", "load_config_from_ini_file", "(", "config_file", ")", "schema", "=", "{", "}", "for", "section_name", "in", "config", ":", "for", "option_name", "in", "config", "[", "sec...
Generates a basic confirm schema file from a configuration file.
[ "Generates", "a", "basic", "confirm", "schema", "file", "from", "a", "configuration", "file", "." ]
0acd1eccda6cd71c69d2ae33166a16a257685811
https://github.com/louib/confirm/blob/0acd1eccda6cd71c69d2ae33166a16a257685811/confirm/generator.py#L142-L155
train
Generates a basic confirm schema file from a configuration file.
rraadd88/rohan
rohan/dandage/io_sets.py
rankwithlist
def rankwithlist(l,lwith,test=False): """ rank l wrt lwith """ if not (isinstance(l,list) and isinstance(lwith,list)): l,lwith=list(l),list(lwith) from scipy.stats import rankdata if test: print(l,lwith) print(rankdata(l),rankdata(lwith)) print(rankdata(l+lwith)) ...
python
def rankwithlist(l,lwith,test=False): """ rank l wrt lwith """ if not (isinstance(l,list) and isinstance(lwith,list)): l,lwith=list(l),list(lwith) from scipy.stats import rankdata if test: print(l,lwith) print(rankdata(l),rankdata(lwith)) print(rankdata(l+lwith)) ...
[ "def", "rankwithlist", "(", "l", ",", "lwith", ",", "test", "=", "False", ")", ":", "if", "not", "(", "isinstance", "(", "l", ",", "list", ")", "and", "isinstance", "(", "lwith", ",", "list", ")", ")", ":", "l", ",", "lwith", "=", "list", "(", ...
rank l wrt lwith
[ "rank", "l", "wrt", "lwith" ]
b0643a3582a2fffc0165ace69fb80880d92bfb10
https://github.com/rraadd88/rohan/blob/b0643a3582a2fffc0165ace69fb80880d92bfb10/rohan/dandage/io_sets.py#L38-L49
train
rank l wrt lwith
mardix/Juice
juice/app-skel/juicy.py
setup_admin_user_publisher
def setup_admin_user_publisher(): """ Setup Juice User and Publisher Admin :return: """ # ==== Setup User Admin === # admin_email = conf.APPLICATION_ADMIN_EMAIL if not admin_email: print("ERROR: APPLICATION_ADMIN_EMAIL is empty") exit() password = utils.generate_random...
python
def setup_admin_user_publisher(): """ Setup Juice User and Publisher Admin :return: """ # ==== Setup User Admin === # admin_email = conf.APPLICATION_ADMIN_EMAIL if not admin_email: print("ERROR: APPLICATION_ADMIN_EMAIL is empty") exit() password = utils.generate_random...
[ "def", "setup_admin_user_publisher", "(", ")", ":", "# ==== Setup User Admin === #", "admin_email", "=", "conf", ".", "APPLICATION_ADMIN_EMAIL", "if", "not", "admin_email", ":", "print", "(", "\"ERROR: APPLICATION_ADMIN_EMAIL is empty\"", ")", "exit", "(", ")", "password"...
Setup Juice User and Publisher Admin :return:
[ "Setup", "Juice", "User", "and", "Publisher", "Admin", ":", "return", ":" ]
7afa8d4238868235dfcdae82272bd77958dd416a
https://github.com/mardix/Juice/blob/7afa8d4238868235dfcdae82272bd77958dd416a/juice/app-skel/juicy.py#L85-L130
train
Setup Juice User and Publisher Admin
brandjon/simplestruct
simplestruct/type.py
TypeChecker.normalize_kind
def normalize_kind(self, kindlike): """Make a kind out of a possible shorthand. If the given argument is a sequence of types or a singular type, it becomes a kind that accepts exactly those types. If the given argument is None, it becomes a type that accepts anything. """ ...
python
def normalize_kind(self, kindlike): """Make a kind out of a possible shorthand. If the given argument is a sequence of types or a singular type, it becomes a kind that accepts exactly those types. If the given argument is None, it becomes a type that accepts anything. """ ...
[ "def", "normalize_kind", "(", "self", ",", "kindlike", ")", ":", "if", "kindlike", "is", "None", ":", "return", "(", "object", ",", ")", "elif", "isinstance", "(", "kindlike", ",", "type", ")", ":", "return", "(", "kindlike", ",", ")", "else", ":", "...
Make a kind out of a possible shorthand. If the given argument is a sequence of types or a singular type, it becomes a kind that accepts exactly those types. If the given argument is None, it becomes a type that accepts anything.
[ "Make", "a", "kind", "out", "of", "a", "possible", "shorthand", ".", "If", "the", "given", "argument", "is", "a", "sequence", "of", "types", "or", "a", "singular", "type", "it", "becomes", "a", "kind", "that", "accepts", "exactly", "those", "types", ".",...
f2bba77278838b5904fd72b35741da162f337c37
https://github.com/brandjon/simplestruct/blob/f2bba77278838b5904fd72b35741da162f337c37/simplestruct/type.py#L31-L42
train
Make a kind out of a possible shorthand.
brandjon/simplestruct
simplestruct/type.py
TypeChecker.str_kind
def str_kind(self, kind): """Get a string describing a kind.""" if len(kind) == 0: return 'Nothing' elif len(kind) == 1: return kind[0].__name__ elif len(kind) == 2: return kind[0].__name__ + ' or ' + kind[1].__name__ else: return '...
python
def str_kind(self, kind): """Get a string describing a kind.""" if len(kind) == 0: return 'Nothing' elif len(kind) == 1: return kind[0].__name__ elif len(kind) == 2: return kind[0].__name__ + ' or ' + kind[1].__name__ else: return '...
[ "def", "str_kind", "(", "self", ",", "kind", ")", ":", "if", "len", "(", "kind", ")", "==", "0", ":", "return", "'Nothing'", "elif", "len", "(", "kind", ")", "==", "1", ":", "return", "kind", "[", "0", "]", ".", "__name__", "elif", "len", "(", ...
Get a string describing a kind.
[ "Get", "a", "string", "describing", "a", "kind", "." ]
f2bba77278838b5904fd72b35741da162f337c37
https://github.com/brandjon/simplestruct/blob/f2bba77278838b5904fd72b35741da162f337c37/simplestruct/type.py#L44-L53
train
Get a string describing a kind.
brandjon/simplestruct
simplestruct/type.py
TypeChecker.checktype
def checktype(self, val, kind, **kargs): """Raise TypeError if val does not satisfy kind.""" if not isinstance(val, kind): raise TypeError('Expected {}; got {}'.format( self.str_kind(kind), self.str_valtype(val)))
python
def checktype(self, val, kind, **kargs): """Raise TypeError if val does not satisfy kind.""" if not isinstance(val, kind): raise TypeError('Expected {}; got {}'.format( self.str_kind(kind), self.str_valtype(val)))
[ "def", "checktype", "(", "self", ",", "val", ",", "kind", ",", "*", "*", "kargs", ")", ":", "if", "not", "isinstance", "(", "val", ",", "kind", ")", ":", "raise", "TypeError", "(", "'Expected {}; got {}'", ".", "format", "(", "self", ".", "str_kind", ...
Raise TypeError if val does not satisfy kind.
[ "Raise", "TypeError", "if", "val", "does", "not", "satisfy", "kind", "." ]
f2bba77278838b5904fd72b35741da162f337c37
https://github.com/brandjon/simplestruct/blob/f2bba77278838b5904fd72b35741da162f337c37/simplestruct/type.py#L55-L59
train
Raise TypeError if val does not satisfy kind.
brandjon/simplestruct
simplestruct/type.py
TypeChecker.checktype_seq
def checktype_seq(self, seq, kind, *, unique=False, **kargs): """Raise TypeError if seq is not a sequence of elements satisfying kind. Optionally require elements to be unique. As a special case, a string is considered to be an atomic value rather than a sequence of single-chara...
python
def checktype_seq(self, seq, kind, *, unique=False, **kargs): """Raise TypeError if seq is not a sequence of elements satisfying kind. Optionally require elements to be unique. As a special case, a string is considered to be an atomic value rather than a sequence of single-chara...
[ "def", "checktype_seq", "(", "self", ",", "seq", ",", "kind", ",", "*", ",", "unique", "=", "False", ",", "*", "*", "kargs", ")", ":", "exp", "=", "self", ".", "str_kind", "(", "kind", ")", "# Make sure we have a sequence.", "try", ":", "iterator", "="...
Raise TypeError if seq is not a sequence of elements satisfying kind. Optionally require elements to be unique. As a special case, a string is considered to be an atomic value rather than a sequence of single-character strings. (Thus, checktype_seq('foo', str) will fail.)
[ "Raise", "TypeError", "if", "seq", "is", "not", "a", "sequence", "of", "elements", "satisfying", "kind", ".", "Optionally", "require", "elements", "to", "be", "unique", ".", "As", "a", "special", "case", "a", "string", "is", "considered", "to", "be", "an",...
f2bba77278838b5904fd72b35741da162f337c37
https://github.com/brandjon/simplestruct/blob/f2bba77278838b5904fd72b35741da162f337c37/simplestruct/type.py#L61-L106
train
Raise TypeError if seq is not a sequence of elements satisfying the given kind.
jeffh/describe
describe/mock/expectations.py
Expectation.raises
def raises(cls, sender, attrname, error, args=ANYTHING, kwargs=ANYTHING): "An alternative constructor which raises the given error" def raise_error(): raise error return cls(sender, attrname, returns=Invoke(raise_error), args=ANYTHING, kwargs=ANYTHING)
python
def raises(cls, sender, attrname, error, args=ANYTHING, kwargs=ANYTHING): "An alternative constructor which raises the given error" def raise_error(): raise error return cls(sender, attrname, returns=Invoke(raise_error), args=ANYTHING, kwargs=ANYTHING)
[ "def", "raises", "(", "cls", ",", "sender", ",", "attrname", ",", "error", ",", "args", "=", "ANYTHING", ",", "kwargs", "=", "ANYTHING", ")", ":", "def", "raise_error", "(", ")", ":", "raise", "error", "return", "cls", "(", "sender", ",", "attrname", ...
An alternative constructor which raises the given error
[ "An", "alternative", "constructor", "which", "raises", "the", "given", "error" ]
6a33ffecc3340b57e60bc8a7095521882ff9a156
https://github.com/jeffh/describe/blob/6a33ffecc3340b57e60bc8a7095521882ff9a156/describe/mock/expectations.py#L24-L28
train
An alternative constructor which raises the given error
jeffh/describe
describe/mock/expectations.py
ExpectationBuilder.and_raises
def and_raises(self, *errors): "Expects an error or more to be raised from the given expectation." for error in errors: self.__expect(Expectation.raises, error)
python
def and_raises(self, *errors): "Expects an error or more to be raised from the given expectation." for error in errors: self.__expect(Expectation.raises, error)
[ "def", "and_raises", "(", "self", ",", "*", "errors", ")", ":", "for", "error", "in", "errors", ":", "self", ".", "__expect", "(", "Expectation", ".", "raises", ",", "error", ")" ]
Expects an error or more to be raised from the given expectation.
[ "Expects", "an", "error", "or", "more", "to", "be", "raised", "from", "the", "given", "expectation", "." ]
6a33ffecc3340b57e60bc8a7095521882ff9a156
https://github.com/jeffh/describe/blob/6a33ffecc3340b57e60bc8a7095521882ff9a156/describe/mock/expectations.py#L204-L207
train
Expects an error or more to be raised from the given expectation.
jeffh/describe
describe/mock/expectations.py
ExpectationBuilder.and_calls
def and_calls(self, *funcs): """Expects the return value from one or more functions to be raised from the given expectation. """ for fn in funcs: self.__expect(Expectation, Invoke(fn))
python
def and_calls(self, *funcs): """Expects the return value from one or more functions to be raised from the given expectation. """ for fn in funcs: self.__expect(Expectation, Invoke(fn))
[ "def", "and_calls", "(", "self", ",", "*", "funcs", ")", ":", "for", "fn", "in", "funcs", ":", "self", ".", "__expect", "(", "Expectation", ",", "Invoke", "(", "fn", ")", ")" ]
Expects the return value from one or more functions to be raised from the given expectation.
[ "Expects", "the", "return", "value", "from", "one", "or", "more", "functions", "to", "be", "raised", "from", "the", "given", "expectation", "." ]
6a33ffecc3340b57e60bc8a7095521882ff9a156
https://github.com/jeffh/describe/blob/6a33ffecc3340b57e60bc8a7095521882ff9a156/describe/mock/expectations.py#L214-L219
train
Expects the return value from one or more functions to be raised from the given expectation.
jeffh/describe
describe/mock/expectations.py
ExpectationBuilder.and_yields
def and_yields(self, *values): """Expects the return value of the expectation to be a generator of the given values """ def generator(): for value in values: yield value self.__expect(Expectation, Invoke(generator))
python
def and_yields(self, *values): """Expects the return value of the expectation to be a generator of the given values """ def generator(): for value in values: yield value self.__expect(Expectation, Invoke(generator))
[ "def", "and_yields", "(", "self", ",", "*", "values", ")", ":", "def", "generator", "(", ")", ":", "for", "value", "in", "values", ":", "yield", "value", "self", ".", "__expect", "(", "Expectation", ",", "Invoke", "(", "generator", ")", ")" ]
Expects the return value of the expectation to be a generator of the given values
[ "Expects", "the", "return", "value", "of", "the", "expectation", "to", "be", "a", "generator", "of", "the", "given", "values" ]
6a33ffecc3340b57e60bc8a7095521882ff9a156
https://github.com/jeffh/describe/blob/6a33ffecc3340b57e60bc8a7095521882ff9a156/describe/mock/expectations.py#L221-L228
train
Expects the return value of the expectation to be a generator of the given values
jeffh/describe
describe/mock/expectations.py
ExpectationBuilderFactory.attribute_invoked
def attribute_invoked(self, sender, name, args, kwargs): "Handles the creation of ExpectationBuilder when an attribute is invoked." return ExpectationBuilder(self.sender, self.delegate, self.add_invocation, self.add_expectations, '__call__')(*args, **kwargs)
python
def attribute_invoked(self, sender, name, args, kwargs): "Handles the creation of ExpectationBuilder when an attribute is invoked." return ExpectationBuilder(self.sender, self.delegate, self.add_invocation, self.add_expectations, '__call__')(*args, **kwargs)
[ "def", "attribute_invoked", "(", "self", ",", "sender", ",", "name", ",", "args", ",", "kwargs", ")", ":", "return", "ExpectationBuilder", "(", "self", ".", "sender", ",", "self", ".", "delegate", ",", "self", ".", "add_invocation", ",", "self", ".", "ad...
Handles the creation of ExpectationBuilder when an attribute is invoked.
[ "Handles", "the", "creation", "of", "ExpectationBuilder", "when", "an", "attribute", "is", "invoked", "." ]
6a33ffecc3340b57e60bc8a7095521882ff9a156
https://github.com/jeffh/describe/blob/6a33ffecc3340b57e60bc8a7095521882ff9a156/describe/mock/expectations.py#L257-L259
train
Handles the creation of ExpectationBuilder when an attribute is invoked.
jeffh/describe
describe/mock/expectations.py
ExpectationBuilderFactory.attribute_read
def attribute_read(self, sender, name): "Handles the creation of ExpectationBuilder when an attribute is read." return ExpectationBuilder(self.sender, self.delegate, self.add_invocation, self.add_expectations, name)
python
def attribute_read(self, sender, name): "Handles the creation of ExpectationBuilder when an attribute is read." return ExpectationBuilder(self.sender, self.delegate, self.add_invocation, self.add_expectations, name)
[ "def", "attribute_read", "(", "self", ",", "sender", ",", "name", ")", ":", "return", "ExpectationBuilder", "(", "self", ".", "sender", ",", "self", ".", "delegate", ",", "self", ".", "add_invocation", ",", "self", ".", "add_expectations", ",", "name", ")"...
Handles the creation of ExpectationBuilder when an attribute is read.
[ "Handles", "the", "creation", "of", "ExpectationBuilder", "when", "an", "attribute", "is", "read", "." ]
6a33ffecc3340b57e60bc8a7095521882ff9a156
https://github.com/jeffh/describe/blob/6a33ffecc3340b57e60bc8a7095521882ff9a156/describe/mock/expectations.py#L261-L263
train
Handles the creation of ExpectationBuilder when an attribute is read.
jeffh/describe
describe/mock/expectations.py
ExpectationBuilderFactory.key_read
def key_read(self, sender, name): "Handles the creation of ExpectationBuilder when a dictionary item access." return ExpectationBuilder(self.sender, self.delegate, self.add_invocation, self.add_expectations, '__getitem__')(name)
python
def key_read(self, sender, name): "Handles the creation of ExpectationBuilder when a dictionary item access." return ExpectationBuilder(self.sender, self.delegate, self.add_invocation, self.add_expectations, '__getitem__')(name)
[ "def", "key_read", "(", "self", ",", "sender", ",", "name", ")", ":", "return", "ExpectationBuilder", "(", "self", ".", "sender", ",", "self", ".", "delegate", ",", "self", ".", "add_invocation", ",", "self", ".", "add_expectations", ",", "'__getitem__'", ...
Handles the creation of ExpectationBuilder when a dictionary item access.
[ "Handles", "the", "creation", "of", "ExpectationBuilder", "when", "a", "dictionary", "item", "access", "." ]
6a33ffecc3340b57e60bc8a7095521882ff9a156
https://github.com/jeffh/describe/blob/6a33ffecc3340b57e60bc8a7095521882ff9a156/describe/mock/expectations.py#L265-L267
train
Handles the creation of ExpectationBuilder when a dictionary item access.
ataylor32/django-friendly-tag-loader
src/friendlytagloader/templatetags/friendly_loader.py
friendly_load
def friendly_load(parser, token): """ Tries to load a custom template tag set. Non existing tag libraries are ignored. This means that, if used in conjunction with ``if_has_tag``, you can try to load the comments template tag library to enable comments even if the comments framework is not inst...
python
def friendly_load(parser, token): """ Tries to load a custom template tag set. Non existing tag libraries are ignored. This means that, if used in conjunction with ``if_has_tag``, you can try to load the comments template tag library to enable comments even if the comments framework is not inst...
[ "def", "friendly_load", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "contents", ".", "split", "(", ")", "if", "len", "(", "bits", ")", ">=", "4", "and", "bits", "[", "-", "2", "]", "==", "\"from\"", ":", "# from syntax is used; ...
Tries to load a custom template tag set. Non existing tag libraries are ignored. This means that, if used in conjunction with ``if_has_tag``, you can try to load the comments template tag library to enable comments even if the comments framework is not installed. For example:: {% load fri...
[ "Tries", "to", "load", "a", "custom", "template", "tag", "set", ".", "Non", "existing", "tag", "libraries", "are", "ignored", "." ]
fe6037dbb1a4a97a64b57d0f2212ad77b832057a
https://github.com/ataylor32/django-friendly-tag-loader/blob/fe6037dbb1a4a97a64b57d0f2212ad77b832057a/src/friendlytagloader/templatetags/friendly_loader.py#L19-L59
train
A friendly load of a custom template tag set.
ataylor32/django-friendly-tag-loader
src/friendlytagloader/templatetags/friendly_loader.py
do_if_has_tag
def do_if_has_tag(parser, token, negate=False): """ The logic for both ``{% if_has_tag %}`` and ``{% if not_has_tag %}``. Checks if all the given tags exist (or not exist if ``negate`` is ``True``) and then only parses the branch that will not error due to non-existing tags. This means that th...
python
def do_if_has_tag(parser, token, negate=False): """ The logic for both ``{% if_has_tag %}`` and ``{% if not_has_tag %}``. Checks if all the given tags exist (or not exist if ``negate`` is ``True``) and then only parses the branch that will not error due to non-existing tags. This means that th...
[ "def", "do_if_has_tag", "(", "parser", ",", "token", ",", "negate", "=", "False", ")", ":", "bits", "=", "list", "(", "token", ".", "split_contents", "(", ")", ")", "if", "len", "(", "bits", ")", "<", "2", ":", "raise", "TemplateSyntaxError", "(", "\...
The logic for both ``{% if_has_tag %}`` and ``{% if not_has_tag %}``. Checks if all the given tags exist (or not exist if ``negate`` is ``True``) and then only parses the branch that will not error due to non-existing tags. This means that the following is essentially the same as a ``{% comment %}...
[ "The", "logic", "for", "both", "{", "%", "if_has_tag", "%", "}", "and", "{", "%", "if", "not_has_tag", "%", "}", "." ]
fe6037dbb1a4a97a64b57d0f2212ad77b832057a
https://github.com/ataylor32/django-friendly-tag-loader/blob/fe6037dbb1a4a97a64b57d0f2212ad77b832057a/src/friendlytagloader/templatetags/friendly_loader.py#L62-L111
train
Checks if all the given tags exist and if not exists returns a new branch that is not error due to existing tags.
jlesquembre/autopilot
src/autopilot/ui.py
CursesManager.off
def off(self): """Turn off curses""" self.win.keypad(0) curses.nocbreak() curses.echo() try: curses.curs_set(1) except: pass curses.endwin()
python
def off(self): """Turn off curses""" self.win.keypad(0) curses.nocbreak() curses.echo() try: curses.curs_set(1) except: pass curses.endwin()
[ "def", "off", "(", "self", ")", ":", "self", ".", "win", ".", "keypad", "(", "0", ")", "curses", ".", "nocbreak", "(", ")", "curses", ".", "echo", "(", ")", "try", ":", "curses", ".", "curs_set", "(", "1", ")", "except", ":", "pass", "curses", ...
Turn off curses
[ "Turn", "off", "curses" ]
ca5f36269ba0173bd29c39db6971dac57a58513d
https://github.com/jlesquembre/autopilot/blob/ca5f36269ba0173bd29c39db6971dac57a58513d/src/autopilot/ui.py#L36-L45
train
Turn off curses
acutesoftware/virtual-AI-simulator
vais/simulator.py
Simulator._verify_agents
def _verify_agents(self): """ verify agents passed to simulator by: 1. checking for unique names 2. TODO - other checks if needed """ #print('verifying...') nmes = [] for agt_num, a in enumerate(self.agents): #print('agent#', agt_num, 'is type'...
python
def _verify_agents(self): """ verify agents passed to simulator by: 1. checking for unique names 2. TODO - other checks if needed """ #print('verifying...') nmes = [] for agt_num, a in enumerate(self.agents): #print('agent#', agt_num, 'is type'...
[ "def", "_verify_agents", "(", "self", ")", ":", "#print('verifying...')", "nmes", "=", "[", "]", "for", "agt_num", ",", "a", "in", "enumerate", "(", "self", ".", "agents", ")", ":", "#print('agent#', agt_num, 'is type', type(a))", "nmes", ".", "append", "(", "...
verify agents passed to simulator by: 1. checking for unique names 2. TODO - other checks if needed
[ "verify", "agents", "passed", "to", "simulator", "by", ":", "1", ".", "checking", "for", "unique", "names", "2", ".", "TODO", "-", "other", "checks", "if", "needed" ]
57de679a5b1a58c38fefe6aea58af1f3a7e79c58
https://github.com/acutesoftware/virtual-AI-simulator/blob/57de679a5b1a58c38fefe6aea58af1f3a7e79c58/vais/simulator.py#L41-L55
train
verify that the list of agents passed to the simulator are unique
acutesoftware/virtual-AI-simulator
vais/simulator.py
Simulator.command
def command(self, cmd, agent, src='admin', password=''): """ takes a command from a source 'src' and if access is allowed (future implementation) then execute the command on the 'agent' """ print(src, 'says ' + cmd['type'] + ' agent', agent.name, '', cmd['direction'],'...
python
def command(self, cmd, agent, src='admin', password=''): """ takes a command from a source 'src' and if access is allowed (future implementation) then execute the command on the 'agent' """ print(src, 'says ' + cmd['type'] + ' agent', agent.name, '', cmd['direction'],'...
[ "def", "command", "(", "self", ",", "cmd", ",", "agent", ",", "src", "=", "'admin'", ",", "password", "=", "''", ")", ":", "print", "(", "src", ",", "'says '", "+", "cmd", "[", "'type'", "]", "+", "' agent'", ",", "agent", ".", "name", ",", "''",...
takes a command from a source 'src' and if access is allowed (future implementation) then execute the command on the 'agent'
[ "takes", "a", "command", "from", "a", "source", "src", "and", "if", "access", "is", "allowed", "(", "future", "implementation", ")", "then", "execute", "the", "command", "on", "the", "agent" ]
57de679a5b1a58c38fefe6aea58af1f3a7e79c58
https://github.com/acutesoftware/virtual-AI-simulator/blob/57de679a5b1a58c38fefe6aea58af1f3a7e79c58/vais/simulator.py#L93-L105
train
Execute a command on an agent
acutesoftware/virtual-AI-simulator
vais/simulator.py
Simulator._move_agent
def _move_agent(self, agent, direction, wrap_allowed=True): """ moves agent 'agent' in 'direction' """ x,y = agent.coords['x'], agent.coords['y'] print('moving agent ', agent.name, 'to x,y=', direction, 'wrap_allowed = ', wrap_allowed) agent.coords['x'] = x + direction[0]...
python
def _move_agent(self, agent, direction, wrap_allowed=True): """ moves agent 'agent' in 'direction' """ x,y = agent.coords['x'], agent.coords['y'] print('moving agent ', agent.name, 'to x,y=', direction, 'wrap_allowed = ', wrap_allowed) agent.coords['x'] = x + direction[0]...
[ "def", "_move_agent", "(", "self", ",", "agent", ",", "direction", ",", "wrap_allowed", "=", "True", ")", ":", "x", ",", "y", "=", "agent", ".", "coords", "[", "'x'", "]", ",", "agent", ".", "coords", "[", "'y'", "]", "print", "(", "'moving agent '",...
moves agent 'agent' in 'direction'
[ "moves", "agent", "agent", "in", "direction" ]
57de679a5b1a58c38fefe6aea58af1f3a7e79c58
https://github.com/acutesoftware/virtual-AI-simulator/blob/57de679a5b1a58c38fefe6aea58af1f3a7e79c58/vais/simulator.py#L107-L114
train
move agent in direction
tjcsl/cslbot
cslbot/commands/metar.py
cmd
def cmd(send, msg, args): """Gets the weather. Syntax: {command} <station> [station2...] """ parser = arguments.ArgParser(args['config']) parser.add_argument('stations', nargs='*') try: cmdargs = parser.parse_args(msg) except arguments.ArgumentException as e: send(str(e)) ...
python
def cmd(send, msg, args): """Gets the weather. Syntax: {command} <station> [station2...] """ parser = arguments.ArgParser(args['config']) parser.add_argument('stations', nargs='*') try: cmdargs = parser.parse_args(msg) except arguments.ArgumentException as e: send(str(e)) ...
[ "def", "cmd", "(", "send", ",", "msg", ",", "args", ")", ":", "parser", "=", "arguments", ".", "ArgParser", "(", "args", "[", "'config'", "]", ")", "parser", ".", "add_argument", "(", "'stations'", ",", "nargs", "=", "'*'", ")", "try", ":", "cmdargs"...
Gets the weather. Syntax: {command} <station> [station2...]
[ "Gets", "the", "weather", "." ]
aebe07be47141f61d7c180706bddfb707f19b2b5
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/metar.py#L27-L65
train
Gets the weather.
Xion/taipan
taipan/functional/functions.py
attr_func
def attr_func(*attrs, **kwargs): """Creates an "attribute function" for given attribute name(s). Resulting function will retrieve attributes with given names, in order, from the object that has been passed to it. For example, ``attr_func('a', 'b')(foo)`` yields the same as ``foo.a.b`` :param attrs...
python
def attr_func(*attrs, **kwargs): """Creates an "attribute function" for given attribute name(s). Resulting function will retrieve attributes with given names, in order, from the object that has been passed to it. For example, ``attr_func('a', 'b')(foo)`` yields the same as ``foo.a.b`` :param attrs...
[ "def", "attr_func", "(", "*", "attrs", ",", "*", "*", "kwargs", ")", ":", "ensure_argcount", "(", "attrs", ",", "min_", "=", "1", ")", "ensure_keyword_args", "(", "kwargs", ",", "optional", "=", "(", "'default'", ",", ")", ")", "# preprocess argument list:...
Creates an "attribute function" for given attribute name(s). Resulting function will retrieve attributes with given names, in order, from the object that has been passed to it. For example, ``attr_func('a', 'b')(foo)`` yields the same as ``foo.a.b`` :param attrs: Attribute names :param default: Op...
[ "Creates", "an", "attribute", "function", "for", "given", "attribute", "name", "(", "s", ")", "." ]
f333f0287c8bd0915182c7d5308e5f05ef0cca78
https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/functional/functions.py#L83-L131
train
Creates an attribute function that returns the value of the attribute with given names in order and the object that has been passed to it.
Xion/taipan
taipan/functional/functions.py
key_func
def key_func(*keys, **kwargs): """Creates a "key function" based on given keys. Resulting function will perform lookup using specified keys, in order, on the object passed to it as an argument. For example, ``key_func('a', 'b')(foo)`` is equivalent to ``foo['a']['b']``. :param keys: Lookup keys ...
python
def key_func(*keys, **kwargs): """Creates a "key function" based on given keys. Resulting function will perform lookup using specified keys, in order, on the object passed to it as an argument. For example, ``key_func('a', 'b')(foo)`` is equivalent to ``foo['a']['b']``. :param keys: Lookup keys ...
[ "def", "key_func", "(", "*", "keys", ",", "*", "*", "kwargs", ")", ":", "ensure_argcount", "(", "keys", ",", "min_", "=", "1", ")", "ensure_keyword_args", "(", "kwargs", ",", "optional", "=", "(", "'default'", ",", ")", ")", "keys", "=", "list", "(",...
Creates a "key function" based on given keys. Resulting function will perform lookup using specified keys, in order, on the object passed to it as an argument. For example, ``key_func('a', 'b')(foo)`` is equivalent to ``foo['a']['b']``. :param keys: Lookup keys :param default: Optional keyword arg...
[ "Creates", "a", "key", "function", "based", "on", "given", "keys", "." ]
f333f0287c8bd0915182c7d5308e5f05ef0cca78
https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/functional/functions.py#L134-L170
train
Creates a key function based on given keys.
Xion/taipan
taipan/functional/functions.py
dotcall
def dotcall(name, *args, **kwargs): """Creates a function that accepts an object and invokes a member function (a "method") on it. The object can be a class instance, a class, a type, or even a module. :param name: Name of member function to invoke The rest of positional and keyword arguments will...
python
def dotcall(name, *args, **kwargs): """Creates a function that accepts an object and invokes a member function (a "method") on it. The object can be a class instance, a class, a type, or even a module. :param name: Name of member function to invoke The rest of positional and keyword arguments will...
[ "def", "dotcall", "(", "name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "ensure_string", "(", "name", ")", "get_member_func", "=", "attr_func", "(", "name", ")", "def", "call", "(", "obj", ")", ":", "member_func", "=", "ensure_callable", "(...
Creates a function that accepts an object and invokes a member function (a "method") on it. The object can be a class instance, a class, a type, or even a module. :param name: Name of member function to invoke The rest of positional and keyword arguments will be passed to the member function as it...
[ "Creates", "a", "function", "that", "accepts", "an", "object", "and", "invokes", "a", "member", "function", "(", "a", "method", ")", "on", "it", ".", "The", "object", "can", "be", "a", "class", "instance", "a", "class", "a", "type", "or", "even", "a", ...
f333f0287c8bd0915182c7d5308e5f05ef0cca78
https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/functional/functions.py#L177-L201
train
Creates a function that accepts an object and invokes a member functionon it.
adamziel/python_translate
python_translate/utils.py
find_files
def find_files(path, patterns): """ Returns all files from a given path that matches the pattern or list of patterns @type path: str @param path: A path to traverse @typ patterns: str|list @param patterns: A pattern or a list of patterns to match @rtype: list[str]: @return: A list...
python
def find_files(path, patterns): """ Returns all files from a given path that matches the pattern or list of patterns @type path: str @param path: A path to traverse @typ patterns: str|list @param patterns: A pattern or a list of patterns to match @rtype: list[str]: @return: A list...
[ "def", "find_files", "(", "path", ",", "patterns", ")", ":", "if", "not", "isinstance", "(", "patterns", ",", "(", "list", ",", "tuple", ")", ")", ":", "patterns", "=", "[", "patterns", "]", "matches", "=", "[", "]", "for", "root", ",", "dirnames", ...
Returns all files from a given path that matches the pattern or list of patterns @type path: str @param path: A path to traverse @typ patterns: str|list @param patterns: A pattern or a list of patterns to match @rtype: list[str]: @return: A list of matched files
[ "Returns", "all", "files", "from", "a", "given", "path", "that", "matches", "the", "pattern", "or", "list", "of", "patterns" ]
0aee83f434bd2d1b95767bcd63adb7ac7036c7df
https://github.com/adamziel/python_translate/blob/0aee83f434bd2d1b95767bcd63adb7ac7036c7df/python_translate/utils.py#L18-L40
train
Returns all files from a given path that matches the pattern or list of patterns
adamziel/python_translate
python_translate/utils.py
recursive_update
def recursive_update(_dict, _update): """ Same as dict.update, but updates also nested dicts instead of overriding then @type _dict: A @param _dict: dict to apply update to @type _update: A @param _update: dict to pick update data from @return: """ for k, v in _update.items():...
python
def recursive_update(_dict, _update): """ Same as dict.update, but updates also nested dicts instead of overriding then @type _dict: A @param _dict: dict to apply update to @type _update: A @param _update: dict to pick update data from @return: """ for k, v in _update.items():...
[ "def", "recursive_update", "(", "_dict", ",", "_update", ")", ":", "for", "k", ",", "v", "in", "_update", ".", "items", "(", ")", ":", "if", "isinstance", "(", "v", ",", "collections", ".", "Mapping", ")", ":", "r", "=", "recursive_update", "(", "_di...
Same as dict.update, but updates also nested dicts instead of overriding then @type _dict: A @param _dict: dict to apply update to @type _update: A @param _update: dict to pick update data from @return:
[ "Same", "as", "dict", ".", "update", "but", "updates", "also", "nested", "dicts", "instead", "of", "overriding", "then" ]
0aee83f434bd2d1b95767bcd63adb7ac7036c7df
https://github.com/adamziel/python_translate/blob/0aee83f434bd2d1b95767bcd63adb7ac7036c7df/python_translate/utils.py#L43-L62
train
Same as dict. update but updates also nested dicts instead of overriding then
adamziel/python_translate
python_translate/utils.py
CaseInsensitiveDict.lower_items
def lower_items(self): """Like iteritems(), but with all lowercase keys.""" return ( (lowerkey, keyval[1]) for (lowerkey, keyval) in list(self._store.items()) )
python
def lower_items(self): """Like iteritems(), but with all lowercase keys.""" return ( (lowerkey, keyval[1]) for (lowerkey, keyval) in list(self._store.items()) )
[ "def", "lower_items", "(", "self", ")", ":", "return", "(", "(", "lowerkey", ",", "keyval", "[", "1", "]", ")", "for", "(", "lowerkey", ",", "keyval", ")", "in", "list", "(", "self", ".", "_store", ".", "items", "(", ")", ")", ")" ]
Like iteritems(), but with all lowercase keys.
[ "Like", "iteritems", "()", "but", "with", "all", "lowercase", "keys", "." ]
0aee83f434bd2d1b95767bcd63adb7ac7036c7df
https://github.com/adamziel/python_translate/blob/0aee83f434bd2d1b95767bcd63adb7ac7036c7df/python_translate/utils.py#L129-L135
train
Like iteritems but with all lowercase keys.
UMIACS/qav
qav/validators.py
Validator.validate
def validate(self, value): '''The most basic validation''' if not self.blank and value == '': self.error_message = 'Can not be empty. Please provide a value.' return False self._choice = value return True
python
def validate(self, value): '''The most basic validation''' if not self.blank and value == '': self.error_message = 'Can not be empty. Please provide a value.' return False self._choice = value return True
[ "def", "validate", "(", "self", ",", "value", ")", ":", "if", "not", "self", ".", "blank", "and", "value", "==", "''", ":", "self", ".", "error_message", "=", "'Can not be empty. Please provide a value.'", "return", "False", "self", ".", "_choice", "=", "va...
The most basic validation
[ "The", "most", "basic", "validation" ]
f92108855f9fcbe3ccea5fc6f683bd90a6e18e1b
https://github.com/UMIACS/qav/blob/f92108855f9fcbe3ccea5fc6f683bd90a6e18e1b/qav/validators.py#L42-L48
train
The most basic validation
UMIACS/qav
qav/validators.py
DomainNameValidator.validate
def validate(self, value): """Attempts a forward lookup via the socket library and if successful will try to do a reverse lookup to verify DNS is returning both lookups. """ if '.' not in value: self.error_message = '%s is not a fully qualified domain name.' ...
python
def validate(self, value): """Attempts a forward lookup via the socket library and if successful will try to do a reverse lookup to verify DNS is returning both lookups. """ if '.' not in value: self.error_message = '%s is not a fully qualified domain name.' ...
[ "def", "validate", "(", "self", ",", "value", ")", ":", "if", "'.'", "not", "in", "value", ":", "self", ".", "error_message", "=", "'%s is not a fully qualified domain name.'", "%", "value", "return", "False", "try", ":", "ipaddress", "=", "socket", ".", "ge...
Attempts a forward lookup via the socket library and if successful will try to do a reverse lookup to verify DNS is returning both lookups.
[ "Attempts", "a", "forward", "lookup", "via", "the", "socket", "library", "and", "if", "successful", "will", "try", "to", "do", "a", "reverse", "lookup", "to", "verify", "DNS", "is", "returning", "both", "lookups", "." ]
f92108855f9fcbe3ccea5fc6f683bd90a6e18e1b
https://github.com/UMIACS/qav/blob/f92108855f9fcbe3ccea5fc6f683bd90a6e18e1b/qav/validators.py#L125-L147
train
Attempts a forward lookup via the socket library and if it fails it will try to do a reverse lookup via the socket library and if it fails it will return False otherwise it will return True
UMIACS/qav
qav/validators.py
IPAddressValidator.validate
def validate(self, value): """Return a boolean if the value is valid""" try: self._choice = IPAddress(value) return True except (ValueError, AddrFormatError): self.error_message = '%s is not a valid IP address.' % value return False
python
def validate(self, value): """Return a boolean if the value is valid""" try: self._choice = IPAddress(value) return True except (ValueError, AddrFormatError): self.error_message = '%s is not a valid IP address.' % value return False
[ "def", "validate", "(", "self", ",", "value", ")", ":", "try", ":", "self", ".", "_choice", "=", "IPAddress", "(", "value", ")", "return", "True", "except", "(", "ValueError", ",", "AddrFormatError", ")", ":", "self", ".", "error_message", "=", "'%s is n...
Return a boolean if the value is valid
[ "Return", "a", "boolean", "if", "the", "value", "is", "valid" ]
f92108855f9fcbe3ccea5fc6f683bd90a6e18e1b
https://github.com/UMIACS/qav/blob/f92108855f9fcbe3ccea5fc6f683bd90a6e18e1b/qav/validators.py#L165-L172
train
Return a boolean indicating if the value is valid.
UMIACS/qav
qav/validators.py
IPNetmaskValidator.validate
def validate(self, value): """Return a boolean if the value is a valid netmask.""" try: self._choice = IPAddress(value) except (ValueError, AddrFormatError): self.error_message = '%s is not a valid IP address.' % value return False if self._choice.is_n...
python
def validate(self, value): """Return a boolean if the value is a valid netmask.""" try: self._choice = IPAddress(value) except (ValueError, AddrFormatError): self.error_message = '%s is not a valid IP address.' % value return False if self._choice.is_n...
[ "def", "validate", "(", "self", ",", "value", ")", ":", "try", ":", "self", ".", "_choice", "=", "IPAddress", "(", "value", ")", "except", "(", "ValueError", ",", "AddrFormatError", ")", ":", "self", ".", "error_message", "=", "'%s is not a valid IP address....
Return a boolean if the value is a valid netmask.
[ "Return", "a", "boolean", "if", "the", "value", "is", "a", "valid", "netmask", "." ]
f92108855f9fcbe3ccea5fc6f683bd90a6e18e1b
https://github.com/UMIACS/qav/blob/f92108855f9fcbe3ccea5fc6f683bd90a6e18e1b/qav/validators.py#L177-L188
train
Return a boolean if the value is a valid netmask.
UMIACS/qav
qav/validators.py
URIValidator.validate
def validate(self, value): '''Return a boolean indicating if the value is a valid URI''' if self.blank and value == '': return True if URIValidator.uri_regex.match(value): self._choice = value return True else: self.error_message = '%s is n...
python
def validate(self, value): '''Return a boolean indicating if the value is a valid URI''' if self.blank and value == '': return True if URIValidator.uri_regex.match(value): self._choice = value return True else: self.error_message = '%s is n...
[ "def", "validate", "(", "self", ",", "value", ")", ":", "if", "self", ".", "blank", "and", "value", "==", "''", ":", "return", "True", "if", "URIValidator", ".", "uri_regex", ".", "match", "(", "value", ")", ":", "self", ".", "_choice", "=", "value",...
Return a boolean indicating if the value is a valid URI
[ "Return", "a", "boolean", "indicating", "if", "the", "value", "is", "a", "valid", "URI" ]
f92108855f9fcbe3ccea5fc6f683bd90a6e18e1b
https://github.com/UMIACS/qav/blob/f92108855f9fcbe3ccea5fc6f683bd90a6e18e1b/qav/validators.py#L203-L212
train
Return a boolean indicating if the value is a valid URI
UMIACS/qav
qav/validators.py
HashValidator.validate
def validate(self, value): """Return a boolean if the choice is a number in the enumeration""" if value in list(self.choices.keys()): self._choice = value return True try: self._choice = list(self.choices.keys())[int(value)] return True exc...
python
def validate(self, value): """Return a boolean if the choice is a number in the enumeration""" if value in list(self.choices.keys()): self._choice = value return True try: self._choice = list(self.choices.keys())[int(value)] return True exc...
[ "def", "validate", "(", "self", ",", "value", ")", ":", "if", "value", "in", "list", "(", "self", ".", "choices", ".", "keys", "(", ")", ")", ":", "self", ".", "_choice", "=", "value", "return", "True", "try", ":", "self", ".", "_choice", "=", "l...
Return a boolean if the choice is a number in the enumeration
[ "Return", "a", "boolean", "if", "the", "choice", "is", "a", "number", "in", "the", "enumeration" ]
f92108855f9fcbe3ccea5fc6f683bd90a6e18e1b
https://github.com/UMIACS/qav/blob/f92108855f9fcbe3ccea5fc6f683bd90a6e18e1b/qav/validators.py#L354-L364
train
Return a boolean if the choice is a number in the enumeration
UMIACS/qav
qav/validators.py
IntegerValidator.validate
def validate(self, value): """ Return True if the choice is an integer; False otherwise. If the value was cast successfully to an int, set the choice that will make its way into the answers dict to the cast int value, not the string representation. """ try: ...
python
def validate(self, value): """ Return True if the choice is an integer; False otherwise. If the value was cast successfully to an int, set the choice that will make its way into the answers dict to the cast int value, not the string representation. """ try: ...
[ "def", "validate", "(", "self", ",", "value", ")", ":", "try", ":", "int_value", "=", "int", "(", "value", ")", "self", ".", "_choice", "=", "int_value", "return", "True", "except", "ValueError", ":", "self", ".", "error_message", "=", "'%s is not a valid ...
Return True if the choice is an integer; False otherwise. If the value was cast successfully to an int, set the choice that will make its way into the answers dict to the cast int value, not the string representation.
[ "Return", "True", "if", "the", "choice", "is", "an", "integer", ";", "False", "otherwise", "." ]
f92108855f9fcbe3ccea5fc6f683bd90a6e18e1b
https://github.com/UMIACS/qav/blob/f92108855f9fcbe3ccea5fc6f683bd90a6e18e1b/qav/validators.py#L369-L383
train
Validate the choice of the cateate entry.
acutesoftware/virtual-AI-simulator
vais/build_internet.py
main
def main(): """ generates a virtual internet, sets pages and runs web_users on it """ e = mod_env.Internet('VAIS - Load testing', 'Simulation of several websites') e.create(800) print(e) #Create some users to browse the web and load test website print(npc.web_users.params)
python
def main(): """ generates a virtual internet, sets pages and runs web_users on it """ e = mod_env.Internet('VAIS - Load testing', 'Simulation of several websites') e.create(800) print(e) #Create some users to browse the web and load test website print(npc.web_users.params)
[ "def", "main", "(", ")", ":", "e", "=", "mod_env", ".", "Internet", "(", "'VAIS - Load testing'", ",", "'Simulation of several websites'", ")", "e", ".", "create", "(", "800", ")", "print", "(", "e", ")", "#Create some users to browse the web and load test website",...
generates a virtual internet, sets pages and runs web_users on it
[ "generates", "a", "virtual", "internet", "sets", "pages", "and", "runs", "web_users", "on", "it" ]
57de679a5b1a58c38fefe6aea58af1f3a7e79c58
https://github.com/acutesoftware/virtual-AI-simulator/blob/57de679a5b1a58c38fefe6aea58af1f3a7e79c58/vais/build_internet.py#L12-L21
train
Generate a virtual internet sets pages runs web_users on it
Aplopio/django_rip
rip/schema/base_field.py
BaseField.validate
def validate(self, request, value): """ This is not for business validation This should be only used for type validation Hence the only input is the value of the field :param value: :return: """ if self.required and value == DEFAULT_FIELD_VALUE: ...
python
def validate(self, request, value): """ This is not for business validation This should be only used for type validation Hence the only input is the value of the field :param value: :return: """ if self.required and value == DEFAULT_FIELD_VALUE: ...
[ "def", "validate", "(", "self", ",", "request", ",", "value", ")", ":", "if", "self", ".", "required", "and", "value", "==", "DEFAULT_FIELD_VALUE", ":", "return", "ValidationResult", "(", "is_success", "=", "False", ",", "reason", "=", "'This field is required...
This is not for business validation This should be only used for type validation Hence the only input is the value of the field :param value: :return:
[ "This", "is", "not", "for", "business", "validation", "This", "should", "be", "only", "used", "for", "type", "validation", "Hence", "the", "only", "input", "is", "the", "value", "of", "the", "field", ":", "param", "value", ":", ":", "return", ":" ]
6b03962ccb778c1a95950a3803e5170c7a2392df
https://github.com/Aplopio/django_rip/blob/6b03962ccb778c1a95950a3803e5170c7a2392df/rip/schema/base_field.py#L28-L42
train
This method is used to validate the value of the field
mardix/Juice
juice/cli.py
create_project
def create_project(project_name, skel="basic"): """ Create the project """ project_dir = get_project_dir_path(project_name) app_tpl = pkg_resources.resource_string(__name__, '%s/app.py' % (SKELETON_DIR)) propel_tpl = pkg_resources.resource_string(__name__, '%s/propel.yml' % (SKELETON_DIR)) c...
python
def create_project(project_name, skel="basic"): """ Create the project """ project_dir = get_project_dir_path(project_name) app_tpl = pkg_resources.resource_string(__name__, '%s/app.py' % (SKELETON_DIR)) propel_tpl = pkg_resources.resource_string(__name__, '%s/propel.yml' % (SKELETON_DIR)) c...
[ "def", "create_project", "(", "project_name", ",", "skel", "=", "\"basic\"", ")", ":", "project_dir", "=", "get_project_dir_path", "(", "project_name", ")", "app_tpl", "=", "pkg_resources", ".", "resource_string", "(", "__name__", ",", "'%s/app.py'", "%", "(", "...
Create the project
[ "Create", "the", "project" ]
7afa8d4238868235dfcdae82272bd77958dd416a
https://github.com/mardix/Juice/blob/7afa8d4238868235dfcdae82272bd77958dd416a/juice/cli.py#L54-L96
train
Create a new project
mardix/Juice
juice/cli.py
get_deploy_hosts_list
def get_deploy_hosts_list(cwd, key=None, file="propel.yml"): """ Returns the remote hosts in propel :param cwd: :param key: :param file: :return: list """ config = propel_deploy_config(cwd=cwd, file=file)["hosts"] return config[key] if key else [v for k, l in config.items() for v in ...
python
def get_deploy_hosts_list(cwd, key=None, file="propel.yml"): """ Returns the remote hosts in propel :param cwd: :param key: :param file: :return: list """ config = propel_deploy_config(cwd=cwd, file=file)["hosts"] return config[key] if key else [v for k, l in config.items() for v in ...
[ "def", "get_deploy_hosts_list", "(", "cwd", ",", "key", "=", "None", ",", "file", "=", "\"propel.yml\"", ")", ":", "config", "=", "propel_deploy_config", "(", "cwd", "=", "cwd", ",", "file", "=", "file", ")", "[", "\"hosts\"", "]", "return", "config", "[...
Returns the remote hosts in propel :param cwd: :param key: :param file: :return: list
[ "Returns", "the", "remote", "hosts", "in", "propel", ":", "param", "cwd", ":", ":", "param", "key", ":", ":", "param", "file", ":", ":", "return", ":", "list" ]
7afa8d4238868235dfcdae82272bd77958dd416a
https://github.com/mardix/Juice/blob/7afa8d4238868235dfcdae82272bd77958dd416a/juice/cli.py#L107-L116
train
Returns the remote hosts in a non - remote container
mardix/Juice
juice/cli.py
get_deploy_assets2s3_list
def get_deploy_assets2s3_list(cwd, file="propel.yml"): """ Return the list of all the assets2s3 repo to publish when deploying :param cwd: :param file: :return: list """ conf = propel_deploy_config(cwd=cwd, file=file) return conf["assets2s3"] if "assets2s3" in conf else []
python
def get_deploy_assets2s3_list(cwd, file="propel.yml"): """ Return the list of all the assets2s3 repo to publish when deploying :param cwd: :param file: :return: list """ conf = propel_deploy_config(cwd=cwd, file=file) return conf["assets2s3"] if "assets2s3" in conf else []
[ "def", "get_deploy_assets2s3_list", "(", "cwd", ",", "file", "=", "\"propel.yml\"", ")", ":", "conf", "=", "propel_deploy_config", "(", "cwd", "=", "cwd", ",", "file", "=", "file", ")", "return", "conf", "[", "\"assets2s3\"", "]", "if", "\"assets2s3\"", "in"...
Return the list of all the assets2s3 repo to publish when deploying :param cwd: :param file: :return: list
[ "Return", "the", "list", "of", "all", "the", "assets2s3", "repo", "to", "publish", "when", "deploying", ":", "param", "cwd", ":", ":", "param", "file", ":", ":", "return", ":", "list" ]
7afa8d4238868235dfcdae82272bd77958dd416a
https://github.com/mardix/Juice/blob/7afa8d4238868235dfcdae82272bd77958dd416a/juice/cli.py#L119-L127
train
Get the list of all the assets2s3 repo to publish when deploying
mardix/Juice
juice/cli.py
git_push_to_master
def git_push_to_master(cwd, hosts, name="all"): """ To push to master :param cwd: :param hosts: :param force: :return: """ with sh.pushd(cwd): name = "juicy_deploy_%s" % name if sh.git("status", "--porcelain").strip(): raise Exception("Repository is UNCLEAN. ...
python
def git_push_to_master(cwd, hosts, name="all"): """ To push to master :param cwd: :param hosts: :param force: :return: """ with sh.pushd(cwd): name = "juicy_deploy_%s" % name if sh.git("status", "--porcelain").strip(): raise Exception("Repository is UNCLEAN. ...
[ "def", "git_push_to_master", "(", "cwd", ",", "hosts", ",", "name", "=", "\"all\"", ")", ":", "with", "sh", ".", "pushd", "(", "cwd", ")", ":", "name", "=", "\"juicy_deploy_%s\"", "%", "name", "if", "sh", ".", "git", "(", "\"status\"", ",", "\"--porcel...
To push to master :param cwd: :param hosts: :param force: :return:
[ "To", "push", "to", "master", ":", "param", "cwd", ":", ":", "param", "hosts", ":", ":", "param", "force", ":", ":", "return", ":" ]
7afa8d4238868235dfcdae82272bd77958dd416a
https://github.com/mardix/Juice/blob/7afa8d4238868235dfcdae82272bd77958dd416a/juice/cli.py#L130-L152
train
Pushes the current node to master
mardix/Juice
juice/cli.py
create
def create(project, skel): """ Create a new Project in the current directory """ app = project_name(project) header("Create New Project ...") print("- Project: %s " % app) create_project(app, skel) print("") print("----- That's Juicy! ----") print("") print("- Your new project [ ...
python
def create(project, skel): """ Create a new Project in the current directory """ app = project_name(project) header("Create New Project ...") print("- Project: %s " % app) create_project(app, skel) print("") print("----- That's Juicy! ----") print("") print("- Your new project [ ...
[ "def", "create", "(", "project", ",", "skel", ")", ":", "app", "=", "project_name", "(", "project", ")", "header", "(", "\"Create New Project ...\"", ")", "print", "(", "\"- Project: %s \"", "%", "app", ")", "create_project", "(", "app", ",", "skel", ")", ...
Create a new Project in the current directory
[ "Create", "a", "new", "Project", "in", "the", "current", "directory" ]
7afa8d4238868235dfcdae82272bd77958dd416a
https://github.com/mardix/Juice/blob/7afa8d4238868235dfcdae82272bd77958dd416a/juice/cli.py#L226-L246
train
Create a new project in the current directory
mardix/Juice
juice/cli.py
serve
def serve(project, port, no_watch): """ Serve application in development mode """ header("Serving application in development mode ... ") print("- Project: %s " % project) print("") print("- Port: %s" % port) print("") module = import_module(project, True) extra_files = [] if not n...
python
def serve(project, port, no_watch): """ Serve application in development mode """ header("Serving application in development mode ... ") print("- Project: %s " % project) print("") print("- Port: %s" % port) print("") module = import_module(project, True) extra_files = [] if not n...
[ "def", "serve", "(", "project", ",", "port", ",", "no_watch", ")", ":", "header", "(", "\"Serving application in development mode ... \"", ")", "print", "(", "\"- Project: %s \"", "%", "project", ")", "print", "(", "\"\"", ")", "print", "(", "\"- Port: %s\"", "%...
Serve application in development mode
[ "Serve", "application", "in", "development", "mode" ]
7afa8d4238868235dfcdae82272bd77958dd416a
https://github.com/mardix/Juice/blob/7afa8d4238868235dfcdae82272bd77958dd416a/juice/cli.py#L273-L298
train
Serve application in development mode
mardix/Juice
juice/cli.py
deploy
def deploy(remote, assets_to_s3): """ To DEPLOY your application """ header("Deploying...") if assets_to_s3: for mod in get_deploy_assets2s3_list(CWD): _assets2s3(mod) remote_name = remote or "ALL" print("Pushing application's content to remote: %s " % remote_name) hosts =...
python
def deploy(remote, assets_to_s3): """ To DEPLOY your application """ header("Deploying...") if assets_to_s3: for mod in get_deploy_assets2s3_list(CWD): _assets2s3(mod) remote_name = remote or "ALL" print("Pushing application's content to remote: %s " % remote_name) hosts =...
[ "def", "deploy", "(", "remote", ",", "assets_to_s3", ")", ":", "header", "(", "\"Deploying...\"", ")", "if", "assets_to_s3", ":", "for", "mod", "in", "get_deploy_assets2s3_list", "(", "CWD", ")", ":", "_assets2s3", "(", "mod", ")", "remote_name", "=", "remot...
To DEPLOY your application
[ "To", "DEPLOY", "your", "application" ]
7afa8d4238868235dfcdae82272bd77958dd416a
https://github.com/mardix/Juice/blob/7afa8d4238868235dfcdae82272bd77958dd416a/juice/cli.py#L305-L318
train
Deploy the application to the remote
mardix/Juice
juice/cli.py
cmd
def cmd(): """ Help to run the command line :return: """ if os.path.isfile(os.path.join(os.path.join(CWD, "juicy.py"))): import_module("juicy") else: print("ERROR: Missing <<'juicy.py'>> @ %s" % CWD) cli()
python
def cmd(): """ Help to run the command line :return: """ if os.path.isfile(os.path.join(os.path.join(CWD, "juicy.py"))): import_module("juicy") else: print("ERROR: Missing <<'juicy.py'>> @ %s" % CWD) cli()
[ "def", "cmd", "(", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "join", "(", "CWD", ",", "\"juicy.py\"", ")", ")", ")", ":", "import_module", "(", "\"juicy\"", ")", "else", ...
Help to run the command line :return:
[ "Help", "to", "run", "the", "command", "line", ":", "return", ":" ]
7afa8d4238868235dfcdae82272bd77958dd416a
https://github.com/mardix/Juice/blob/7afa8d4238868235dfcdae82272bd77958dd416a/juice/cli.py#L323-L333
train
Help to run the command line
drericstrong/pyedna
pyedna/calc_config.py
CalcConfig.write_relationships
def write_relationships(self, file_name, flat=True): """ This module will output the eDNA tags which are used inside each calculation. If flat=True, data will be written flat, like: ADE1CA01, ADE1PI01, ADE1PI02 If flat=False, data will be written in the non-flat way...
python
def write_relationships(self, file_name, flat=True): """ This module will output the eDNA tags which are used inside each calculation. If flat=True, data will be written flat, like: ADE1CA01, ADE1PI01, ADE1PI02 If flat=False, data will be written in the non-flat way...
[ "def", "write_relationships", "(", "self", ",", "file_name", ",", "flat", "=", "True", ")", ":", "with", "open", "(", "file_name", ",", "'w'", ")", "as", "writer", ":", "if", "flat", ":", "self", ".", "_write_relationships_flat", "(", "writer", ")", "els...
This module will output the eDNA tags which are used inside each calculation. If flat=True, data will be written flat, like: ADE1CA01, ADE1PI01, ADE1PI02 If flat=False, data will be written in the non-flat way, like: ADE1CA01, ADE1PI01 ADE1CA01, ADE1PI02 ...
[ "This", "module", "will", "output", "the", "eDNA", "tags", "which", "are", "used", "inside", "each", "calculation", "." ]
b8f8f52def4f26bb4f3a993ce3400769518385f6
https://github.com/drericstrong/pyedna/blob/b8f8f52def4f26bb4f3a993ce3400769518385f6/pyedna/calc_config.py#L87-L107
train
This module will output the eDNA relationships of the eDNA tags which are used inside each ArcGIS calculation.
tjcsl/cslbot
cslbot/commands/timeout.py
cmd
def cmd(send, msg, args): """Quiets a user, then unquiets them after the specified period of time. Syntax: {command} <timespec> <nickname> timespec is in the format: <number><unit>, where unit is s, m, h, or d. """ nickregex = args['config']['core']['nickregex'] setmode = args['handler'].conne...
python
def cmd(send, msg, args): """Quiets a user, then unquiets them after the specified period of time. Syntax: {command} <timespec> <nickname> timespec is in the format: <number><unit>, where unit is s, m, h, or d. """ nickregex = args['config']['core']['nickregex'] setmode = args['handler'].conne...
[ "def", "cmd", "(", "send", ",", "msg", ",", "args", ")", ":", "nickregex", "=", "args", "[", "'config'", "]", "[", "'core'", "]", "[", "'nickregex'", "]", "setmode", "=", "args", "[", "'handler'", "]", ".", "connection", ".", "mode", "channel", "=", ...
Quiets a user, then unquiets them after the specified period of time. Syntax: {command} <timespec> <nickname> timespec is in the format: <number><unit>, where unit is s, m, h, or d.
[ "Quiets", "a", "user", "then", "unquiets", "them", "after", "the", "specified", "period", "of", "time", "." ]
aebe07be47141f61d7c180706bddfb707f19b2b5
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/timeout.py#L25-L61
train
Quiets a user then unquiets them after the specified period of time.
textbook/atmdb
atmdb/client.py
TMDbClient._update_config
async def _update_config(self): """Update configuration data if required. Notes: Per `the documentation`_, this updates the API configuration data *"every few days"*. .. _the documentation: http://docs.themoviedb.apiary.io/#reference/configuration """ ...
python
async def _update_config(self): """Update configuration data if required. Notes: Per `the documentation`_, this updates the API configuration data *"every few days"*. .. _the documentation: http://docs.themoviedb.apiary.io/#reference/configuration """ ...
[ "async", "def", "_update_config", "(", "self", ")", ":", "if", "self", ".", "config", "[", "'data'", "]", "is", "None", "or", "self", ".", "config_expired", ":", "data", "=", "await", "self", ".", "get_data", "(", "self", ".", "url_builder", "(", "'con...
Update configuration data if required. Notes: Per `the documentation`_, this updates the API configuration data *"every few days"*. .. _the documentation: http://docs.themoviedb.apiary.io/#reference/configuration
[ "Update", "configuration", "data", "if", "required", "." ]
cab14547d2e777a1e26c2560266365c484855789
https://github.com/textbook/atmdb/blob/cab14547d2e777a1e26c2560266365c484855789/atmdb/client.py#L44-L57
train
Update the configuration data if required.
textbook/atmdb
atmdb/client.py
TMDbClient.get_data
async def get_data(self, url): """Get data from the TMDb API via :py:func:`aiohttp.get`. Notes: Updates configuration (if required) on successful requests. Arguments: url (:py:class:`str`): The endpoint URL and params. Returns: :py:class:`dict`: The parse...
python
async def get_data(self, url): """Get data from the TMDb API via :py:func:`aiohttp.get`. Notes: Updates configuration (if required) on successful requests. Arguments: url (:py:class:`str`): The endpoint URL and params. Returns: :py:class:`dict`: The parse...
[ "async", "def", "get_data", "(", "self", ",", "url", ")", ":", "logger", ".", "debug", "(", "'making request to %r'", ",", "url", ")", "with", "aiohttp", ".", "ClientSession", "(", ")", "as", "session", ":", "async", "with", "session", ".", "get", "(", ...
Get data from the TMDb API via :py:func:`aiohttp.get`. Notes: Updates configuration (if required) on successful requests. Arguments: url (:py:class:`str`): The endpoint URL and params. Returns: :py:class:`dict`: The parsed JSON result.
[ "Get", "data", "from", "the", "TMDb", "API", "via", ":", "py", ":", "func", ":", "aiohttp", ".", "get", "." ]
cab14547d2e777a1e26c2560266365c484855789
https://github.com/textbook/atmdb/blob/cab14547d2e777a1e26c2560266365c484855789/atmdb/client.py#L59-L94
train
Get data from the TMDb API via aiohttp. get.
textbook/atmdb
atmdb/client.py
TMDbClient.find_movie
async def find_movie(self, query): """Retrieve movie data by search query. Arguments: query (:py:class:`str`): Query to search for. Returns: :py:class:`list`: Possible matches. """ params = OrderedDict([ ('query', query), ('include_adult', False...
python
async def find_movie(self, query): """Retrieve movie data by search query. Arguments: query (:py:class:`str`): Query to search for. Returns: :py:class:`list`: Possible matches. """ params = OrderedDict([ ('query', query), ('include_adult', False...
[ "async", "def", "find_movie", "(", "self", ",", "query", ")", ":", "params", "=", "OrderedDict", "(", "[", "(", "'query'", ",", "query", ")", ",", "(", "'include_adult'", ",", "False", ")", ",", "]", ")", "url", "=", "self", ".", "url_builder", "(", ...
Retrieve movie data by search query. Arguments: query (:py:class:`str`): Query to search for. Returns: :py:class:`list`: Possible matches.
[ "Retrieve", "movie", "data", "by", "search", "query", "." ]
cab14547d2e777a1e26c2560266365c484855789
https://github.com/textbook/atmdb/blob/cab14547d2e777a1e26c2560266365c484855789/atmdb/client.py#L96-L116
train
Retrieve movie data by search query.
textbook/atmdb
atmdb/client.py
TMDbClient.find_person
async def find_person(self, query): """Retrieve person data by search query. Arguments: query (:py:class:`str`): Query to search for. Returns: :py:class:`list`: Possible matches. """ url = self.url_builder( 'search/person', dict(), ...
python
async def find_person(self, query): """Retrieve person data by search query. Arguments: query (:py:class:`str`): Query to search for. Returns: :py:class:`list`: Possible matches. """ url = self.url_builder( 'search/person', dict(), ...
[ "async", "def", "find_person", "(", "self", ",", "query", ")", ":", "url", "=", "self", ".", "url_builder", "(", "'search/person'", ",", "dict", "(", ")", ",", "url_params", "=", "OrderedDict", "(", "[", "(", "'query'", ",", "query", ")", ",", "(", "...
Retrieve person data by search query. Arguments: query (:py:class:`str`): Query to search for. Returns: :py:class:`list`: Possible matches.
[ "Retrieve", "person", "data", "by", "search", "query", "." ]
cab14547d2e777a1e26c2560266365c484855789
https://github.com/textbook/atmdb/blob/cab14547d2e777a1e26c2560266365c484855789/atmdb/client.py#L118-L141
train
Retrieve person data by search query.
textbook/atmdb
atmdb/client.py
TMDbClient.get_movie
async def get_movie(self, id_): """Retrieve movie data by ID. Arguments: id_ (:py:class:`int`): The movie's TMDb ID. Returns: :py:class:`~.Movie`: The requested movie. """ url = self.url_builder( 'movie/{movie_id}', dict(movie_id=id_...
python
async def get_movie(self, id_): """Retrieve movie data by ID. Arguments: id_ (:py:class:`int`): The movie's TMDb ID. Returns: :py:class:`~.Movie`: The requested movie. """ url = self.url_builder( 'movie/{movie_id}', dict(movie_id=id_...
[ "async", "def", "get_movie", "(", "self", ",", "id_", ")", ":", "url", "=", "self", ".", "url_builder", "(", "'movie/{movie_id}'", ",", "dict", "(", "movie_id", "=", "id_", ")", ",", "url_params", "=", "OrderedDict", "(", "append_to_response", "=", "'credi...
Retrieve movie data by ID. Arguments: id_ (:py:class:`int`): The movie's TMDb ID. Returns: :py:class:`~.Movie`: The requested movie.
[ "Retrieve", "movie", "data", "by", "ID", "." ]
cab14547d2e777a1e26c2560266365c484855789
https://github.com/textbook/atmdb/blob/cab14547d2e777a1e26c2560266365c484855789/atmdb/client.py#L143-L161
train
Retrieve movie by ID.
textbook/atmdb
atmdb/client.py
TMDbClient.get_person
async def get_person(self, id_): """Retrieve person data by ID. Arguments: id_ (:py:class:`int`): The person's TMDb ID. Returns: :py:class:`~.Person`: The requested person. """ data = await self._get_person_json( id_, OrderedDict(app...
python
async def get_person(self, id_): """Retrieve person data by ID. Arguments: id_ (:py:class:`int`): The person's TMDb ID. Returns: :py:class:`~.Person`: The requested person. """ data = await self._get_person_json( id_, OrderedDict(app...
[ "async", "def", "get_person", "(", "self", ",", "id_", ")", ":", "data", "=", "await", "self", ".", "_get_person_json", "(", "id_", ",", "OrderedDict", "(", "append_to_response", "=", "'movie_credits'", ")", ")", "return", "Person", ".", "from_json", "(", ...
Retrieve person data by ID. Arguments: id_ (:py:class:`int`): The person's TMDb ID. Returns: :py:class:`~.Person`: The requested person.
[ "Retrieve", "person", "data", "by", "ID", "." ]
cab14547d2e777a1e26c2560266365c484855789
https://github.com/textbook/atmdb/blob/cab14547d2e777a1e26c2560266365c484855789/atmdb/client.py#L163-L177
train
Retrieve a person by ID.
textbook/atmdb
atmdb/client.py
TMDbClient._get_person_json
async def _get_person_json(self, id_, url_params=None): """Retrieve raw person JSON by ID. Arguments: id_ (:py:class:`int`): The person's TMDb ID. url_params (:py:class:`dict`): Any additional URL parameters. Returns: :py:class:`dict`: The JSON data. """ ...
python
async def _get_person_json(self, id_, url_params=None): """Retrieve raw person JSON by ID. Arguments: id_ (:py:class:`int`): The person's TMDb ID. url_params (:py:class:`dict`): Any additional URL parameters. Returns: :py:class:`dict`: The JSON data. """ ...
[ "async", "def", "_get_person_json", "(", "self", ",", "id_", ",", "url_params", "=", "None", ")", ":", "url", "=", "self", ".", "url_builder", "(", "'person/{person_id}'", ",", "dict", "(", "person_id", "=", "id_", ")", ",", "url_params", "=", "url_params"...
Retrieve raw person JSON by ID. Arguments: id_ (:py:class:`int`): The person's TMDb ID. url_params (:py:class:`dict`): Any additional URL parameters. Returns: :py:class:`dict`: The JSON data.
[ "Retrieve", "raw", "person", "JSON", "by", "ID", "." ]
cab14547d2e777a1e26c2560266365c484855789
https://github.com/textbook/atmdb/blob/cab14547d2e777a1e26c2560266365c484855789/atmdb/client.py#L179-L196
train
Retrieve raw person JSON by ID.
textbook/atmdb
atmdb/client.py
TMDbClient.get_random_popular_person
async def get_random_popular_person(self, limit=500): """Randomly select a popular person. Notes: Requires at least two API calls. May require three API calls if the randomly-selected index isn't within the first page of required data. Arguments: limit (...
python
async def get_random_popular_person(self, limit=500): """Randomly select a popular person. Notes: Requires at least two API calls. May require three API calls if the randomly-selected index isn't within the first page of required data. Arguments: limit (...
[ "async", "def", "get_random_popular_person", "(", "self", ",", "limit", "=", "500", ")", ":", "index", "=", "random", ".", "randrange", "(", "limit", ")", "data", "=", "await", "self", ".", "_get_popular_people_page", "(", ")", "if", "data", "is", "None", ...
Randomly select a popular person. Notes: Requires at least two API calls. May require three API calls if the randomly-selected index isn't within the first page of required data. Arguments: limit (:py:class:`int`, optional): How many of the most popu...
[ "Randomly", "select", "a", "popular", "person", "." ]
cab14547d2e777a1e26c2560266365c484855789
https://github.com/textbook/atmdb/blob/cab14547d2e777a1e26c2560266365c484855789/atmdb/client.py#L198-L228
train
Randomly select a popular person.
textbook/atmdb
atmdb/client.py
TMDbClient._get_popular_people_page
async def _get_popular_people_page(self, page=1): """Get a specific page of popular person data. Arguments: page (:py:class:`int`, optional): The page to get. Returns: :py:class:`dict`: The page data. """ return await self.get_data(self.url_builder( ...
python
async def _get_popular_people_page(self, page=1): """Get a specific page of popular person data. Arguments: page (:py:class:`int`, optional): The page to get. Returns: :py:class:`dict`: The page data. """ return await self.get_data(self.url_builder( ...
[ "async", "def", "_get_popular_people_page", "(", "self", ",", "page", "=", "1", ")", ":", "return", "await", "self", ".", "get_data", "(", "self", ".", "url_builder", "(", "'person/popular'", ",", "url_params", "=", "OrderedDict", "(", "page", "=", "page", ...
Get a specific page of popular person data. Arguments: page (:py:class:`int`, optional): The page to get. Returns: :py:class:`dict`: The page data.
[ "Get", "a", "specific", "page", "of", "popular", "person", "data", "." ]
cab14547d2e777a1e26c2560266365c484855789
https://github.com/textbook/atmdb/blob/cab14547d2e777a1e26c2560266365c484855789/atmdb/client.py#L230-L243
train
Get a specific page of popular person data.
textbook/atmdb
atmdb/client.py
TMDbClient._calculate_page_index
def _calculate_page_index(index, data): """Determine the location of a given index in paged data. Arguments: index (:py:class:`int`): The overall index. data: (:py:class:`dict`) The first page of data. Returns: :py:class:`tuple`: The location of that index, in the...
python
def _calculate_page_index(index, data): """Determine the location of a given index in paged data. Arguments: index (:py:class:`int`): The overall index. data: (:py:class:`dict`) The first page of data. Returns: :py:class:`tuple`: The location of that index, in the...
[ "def", "_calculate_page_index", "(", "index", ",", "data", ")", ":", "if", "index", ">", "data", "[", "'total_results'", "]", ":", "raise", "ValueError", "(", "'index not in paged data'", ")", "page_length", "=", "len", "(", "data", "[", "'results'", "]", ")...
Determine the location of a given index in paged data. Arguments: index (:py:class:`int`): The overall index. data: (:py:class:`dict`) The first page of data. Returns: :py:class:`tuple`: The location of that index, in the format ``(page, index_in_page)``.
[ "Determine", "the", "location", "of", "a", "given", "index", "in", "paged", "data", "." ]
cab14547d2e777a1e26c2560266365c484855789
https://github.com/textbook/atmdb/blob/cab14547d2e777a1e26c2560266365c484855789/atmdb/client.py#L246-L261
train
Determine the location of a given index in paged data.
tjcsl/cslbot
cslbot/commands/ipa.py
cmd
def cmd(send, msg, args): """Converts text into NATO form. Syntax: {command} <text> """ if not msg: send("NATO what?") return nato = gen_nato(msg) if len(nato) > 100: send("Your NATO is too long. Have you considered letters?") else: send(nato)
python
def cmd(send, msg, args): """Converts text into NATO form. Syntax: {command} <text> """ if not msg: send("NATO what?") return nato = gen_nato(msg) if len(nato) > 100: send("Your NATO is too long. Have you considered letters?") else: send(nato)
[ "def", "cmd", "(", "send", ",", "msg", ",", "args", ")", ":", "if", "not", "msg", ":", "send", "(", "\"NATO what?\"", ")", "return", "nato", "=", "gen_nato", "(", "msg", ")", "if", "len", "(", "nato", ")", ">", "100", ":", "send", "(", "\"Your NA...
Converts text into NATO form. Syntax: {command} <text>
[ "Converts", "text", "into", "NATO", "form", "." ]
aebe07be47141f61d7c180706bddfb707f19b2b5
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/ipa.py#L73-L86
train
Converts text into NATO form.
tjcsl/cslbot
cslbot/commands/time.py
cmd
def cmd(send, msg, _): """Tells the time. Syntax: {command} """ bold = '\x02' if not msg: msg = bold + "Date: " + bold + "%A, %m/%d/%Y" + bold + " Time: " + bold + "%H:%M:%S" send(time.strftime(msg))
python
def cmd(send, msg, _): """Tells the time. Syntax: {command} """ bold = '\x02' if not msg: msg = bold + "Date: " + bold + "%A, %m/%d/%Y" + bold + " Time: " + bold + "%H:%M:%S" send(time.strftime(msg))
[ "def", "cmd", "(", "send", ",", "msg", ",", "_", ")", ":", "bold", "=", "'\\x02'", "if", "not", "msg", ":", "msg", "=", "bold", "+", "\"Date: \"", "+", "bold", "+", "\"%A, %m/%d/%Y\"", "+", "bold", "+", "\" Time: \"", "+", "bold", "+", "\"%H:%M:%S\...
Tells the time. Syntax: {command}
[ "Tells", "the", "time", "." ]
aebe07be47141f61d7c180706bddfb707f19b2b5
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/time.py#L24-L33
train
Tells the time.
Aplopio/django_rip
rip/view/view_resource.py
ViewResource._setup_configuration
def _setup_configuration(self): """ All steps are accepted as classes. Instantiate them with the right configuration and set them in a local property. """ self.configuration = dict( schema_cls=self.schema_cls, allowed_actions=self.allowed_actions, ...
python
def _setup_configuration(self): """ All steps are accepted as classes. Instantiate them with the right configuration and set them in a local property. """ self.configuration = dict( schema_cls=self.schema_cls, allowed_actions=self.allowed_actions, ...
[ "def", "_setup_configuration", "(", "self", ")", ":", "self", ".", "configuration", "=", "dict", "(", "schema_cls", "=", "self", ".", "schema_cls", ",", "allowed_actions", "=", "self", ".", "allowed_actions", ",", "filter_by_fields", "=", "self", ".", "filter_...
All steps are accepted as classes. Instantiate them with the right configuration and set them in a local property.
[ "All", "steps", "are", "accepted", "as", "classes", ".", "Instantiate", "them", "with", "the", "right", "configuration", "and", "set", "them", "in", "a", "local", "property", "." ]
6b03962ccb778c1a95950a3803e5170c7a2392df
https://github.com/Aplopio/django_rip/blob/6b03962ccb778c1a95950a3803e5170c7a2392df/rip/view/view_resource.py#L61-L91
train
Setup the configuration for the current locale.
Aplopio/django_rip
rip/view/view_resource.py
ViewResource.read
def read(self, request): """ Implements HTTP GET :param request: rip.Request :return: rip.Response """ pipeline = view_pipeline_factory.read_pipeline( configuration=self.configuration) return pipeline(request=request)
python
def read(self, request): """ Implements HTTP GET :param request: rip.Request :return: rip.Response """ pipeline = view_pipeline_factory.read_pipeline( configuration=self.configuration) return pipeline(request=request)
[ "def", "read", "(", "self", ",", "request", ")", ":", "pipeline", "=", "view_pipeline_factory", ".", "read_pipeline", "(", "configuration", "=", "self", ".", "configuration", ")", "return", "pipeline", "(", "request", "=", "request", ")" ]
Implements HTTP GET :param request: rip.Request :return: rip.Response
[ "Implements", "HTTP", "GET", ":", "param", "request", ":", "rip", ".", "Request", ":", "return", ":", "rip", ".", "Response" ]
6b03962ccb778c1a95950a3803e5170c7a2392df
https://github.com/Aplopio/django_rip/blob/6b03962ccb778c1a95950a3803e5170c7a2392df/rip/view/view_resource.py#L119-L127
train
Implements HTTP GET
tjcsl/cslbot
cslbot/commands/highlight.py
cmd
def cmd(send, msg, args): """When a nick was last pinged. Syntax: {command} [--channel #channel] [nick] """ parser = arguments.ArgParser(args['config']) parser.add_argument('--channel', nargs='?', action=arguments.ChanParser) parser.add_argument('nick', nargs='?', action=arguments.NickParser, ...
python
def cmd(send, msg, args): """When a nick was last pinged. Syntax: {command} [--channel #channel] [nick] """ parser = arguments.ArgParser(args['config']) parser.add_argument('--channel', nargs='?', action=arguments.ChanParser) parser.add_argument('nick', nargs='?', action=arguments.NickParser, ...
[ "def", "cmd", "(", "send", ",", "msg", ",", "args", ")", ":", "parser", "=", "arguments", ".", "ArgParser", "(", "args", "[", "'config'", "]", ")", "parser", ".", "add_argument", "(", "'--channel'", ",", "nargs", "=", "'?'", ",", "action", "=", "argu...
When a nick was last pinged. Syntax: {command} [--channel #channel] [nick]
[ "When", "a", "nick", "was", "last", "pinged", "." ]
aebe07be47141f61d7c180706bddfb707f19b2b5
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/highlight.py#L24-L49
train
When a nick was last pinged.
tjcsl/cslbot
cslbot/helpers/backtrace.py
output_traceback
def output_traceback(ex): """Returns a tuple of a prettyprinted error message and string representation of the error.""" # Dump full traceback to console. output = "".join(traceback.format_exc()).strip() for line in output.split('\n'): logging.error(line) trace_obj = traceback.extract_tb(ex....
python
def output_traceback(ex): """Returns a tuple of a prettyprinted error message and string representation of the error.""" # Dump full traceback to console. output = "".join(traceback.format_exc()).strip() for line in output.split('\n'): logging.error(line) trace_obj = traceback.extract_tb(ex....
[ "def", "output_traceback", "(", "ex", ")", ":", "# Dump full traceback to console.", "output", "=", "\"\"", ".", "join", "(", "traceback", ".", "format_exc", "(", ")", ")", ".", "strip", "(", ")", "for", "line", "in", "output", ".", "split", "(", "'\\n'", ...
Returns a tuple of a prettyprinted error message and string representation of the error.
[ "Returns", "a", "tuple", "of", "a", "prettyprinted", "error", "message", "and", "string", "representation", "of", "the", "error", "." ]
aebe07be47141f61d7c180706bddfb707f19b2b5
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/helpers/backtrace.py#L28-L39
train
Returns a tuple of a prettyprinted error message and string representation of the error.
jlesquembre/autopilot
src/autopilot/main.py
new
def new(project_name): """Creates a new project""" try: locale.setlocale(locale.LC_ALL, '') except: print("Warning: Unable to set locale. Expect encoding problems.") config = utils.get_config() config['new_project']['project_name'] = project_name values = new_project_ui(confi...
python
def new(project_name): """Creates a new project""" try: locale.setlocale(locale.LC_ALL, '') except: print("Warning: Unable to set locale. Expect encoding problems.") config = utils.get_config() config['new_project']['project_name'] = project_name values = new_project_ui(confi...
[ "def", "new", "(", "project_name", ")", ":", "try", ":", "locale", ".", "setlocale", "(", "locale", ".", "LC_ALL", ",", "''", ")", "except", ":", "print", "(", "\"Warning: Unable to set locale. Expect encoding problems.\"", ")", "config", "=", "utils", ".", "...
Creates a new project
[ "Creates", "a", "new", "project" ]
ca5f36269ba0173bd29c39db6971dac57a58513d
https://github.com/jlesquembre/autopilot/blob/ca5f36269ba0173bd29c39db6971dac57a58513d/src/autopilot/main.py#L28-L46
train
Creates a new project
jlesquembre/autopilot
src/autopilot/main.py
release
def release(no_master, release_type): '''Releases a new version''' try: locale.setlocale(locale.LC_ALL, '') except: print("Warning: Unable to set locale. Expect encoding problems.") git.is_repo_clean(master=(not no_master)) config = utils.get_config() config.update(utils.get_...
python
def release(no_master, release_type): '''Releases a new version''' try: locale.setlocale(locale.LC_ALL, '') except: print("Warning: Unable to set locale. Expect encoding problems.") git.is_repo_clean(master=(not no_master)) config = utils.get_config() config.update(utils.get_...
[ "def", "release", "(", "no_master", ",", "release_type", ")", ":", "try", ":", "locale", ".", "setlocale", "(", "locale", ".", "LC_ALL", ",", "''", ")", "except", ":", "print", "(", "\"Warning: Unable to set locale. Expect encoding problems.\"", ")", "git", "."...
Releases a new version
[ "Releases", "a", "new", "version" ]
ca5f36269ba0173bd29c39db6971dac57a58513d
https://github.com/jlesquembre/autopilot/blob/ca5f36269ba0173bd29c39db6971dac57a58513d/src/autopilot/main.py#L55-L82
train
Releases a new version of the current project.
JIC-CSB/jicimagelib
jicimagelib/geometry.py
Point2D._set_types
def _set_types(self): """Make sure that x, y have consistent types and set dtype.""" # If we given something that is not an int or a float we raise # a RuntimeError as we do not want to have to guess if the given # input should be interpreted as an int or a float, for example the ...
python
def _set_types(self): """Make sure that x, y have consistent types and set dtype.""" # If we given something that is not an int or a float we raise # a RuntimeError as we do not want to have to guess if the given # input should be interpreted as an int or a float, for example the ...
[ "def", "_set_types", "(", "self", ")", ":", "# If we given something that is not an int or a float we raise", "# a RuntimeError as we do not want to have to guess if the given", "# input should be interpreted as an int or a float, for example the", "# interpretation of the string \"1\" vs the inte...
Make sure that x, y have consistent types and set dtype.
[ "Make", "sure", "that", "x", "y", "have", "consistent", "types", "and", "set", "dtype", "." ]
fbd67accb2e6d55969c6d4ed7e8b4bb4ab65cd44
https://github.com/JIC-CSB/jicimagelib/blob/fbd67accb2e6d55969c6d4ed7e8b4bb4ab65cd44/jicimagelib/geometry.py#L70-L87
train
Make sure that x y have consistent types and set dtype.
JIC-CSB/jicimagelib
jicimagelib/geometry.py
Point2D.magnitude
def magnitude(self): """Return the magnitude when treating the point as a vector.""" return math.sqrt( self.x * self.x + self.y * self.y )
python
def magnitude(self): """Return the magnitude when treating the point as a vector.""" return math.sqrt( self.x * self.x + self.y * self.y )
[ "def", "magnitude", "(", "self", ")", ":", "return", "math", ".", "sqrt", "(", "self", ".", "x", "*", "self", ".", "x", "+", "self", ".", "y", "*", "self", ".", "y", ")" ]
Return the magnitude when treating the point as a vector.
[ "Return", "the", "magnitude", "when", "treating", "the", "point", "as", "a", "vector", "." ]
fbd67accb2e6d55969c6d4ed7e8b4bb4ab65cd44
https://github.com/JIC-CSB/jicimagelib/blob/fbd67accb2e6d55969c6d4ed7e8b4bb4ab65cd44/jicimagelib/geometry.py#L95-L97
train
Return the magnitude when treating the point as a vector.
JIC-CSB/jicimagelib
jicimagelib/geometry.py
Point2D.unit_vector
def unit_vector(self): """Return the unit vector.""" return Point2D( self.x / self.magnitude, self.y / self.magnitude )
python
def unit_vector(self): """Return the unit vector.""" return Point2D( self.x / self.magnitude, self.y / self.magnitude )
[ "def", "unit_vector", "(", "self", ")", ":", "return", "Point2D", "(", "self", ".", "x", "/", "self", ".", "magnitude", ",", "self", ".", "y", "/", "self", ".", "magnitude", ")" ]
Return the unit vector.
[ "Return", "the", "unit", "vector", "." ]
fbd67accb2e6d55969c6d4ed7e8b4bb4ab65cd44
https://github.com/JIC-CSB/jicimagelib/blob/fbd67accb2e6d55969c6d4ed7e8b4bb4ab65cd44/jicimagelib/geometry.py#L100-L102
train
Return the unit vector.
JIC-CSB/jicimagelib
jicimagelib/geometry.py
Point2D.astype
def astype(self, dtype): """Return a point of the specified dtype.""" if dtype == "int": return Point2D( int( round(self.x, 0) ), int( round(self.y, 0) ) ) elif dtype == "float": return Point2D( float(self.x), float(self.y)) else: raise(RuntimeError("I...
python
def astype(self, dtype): """Return a point of the specified dtype.""" if dtype == "int": return Point2D( int( round(self.x, 0) ), int( round(self.y, 0) ) ) elif dtype == "float": return Point2D( float(self.x), float(self.y)) else: raise(RuntimeError("I...
[ "def", "astype", "(", "self", ",", "dtype", ")", ":", "if", "dtype", "==", "\"int\"", ":", "return", "Point2D", "(", "int", "(", "round", "(", "self", ".", "x", ",", "0", ")", ")", ",", "int", "(", "round", "(", "self", ".", "y", ",", "0", ")...
Return a point of the specified dtype.
[ "Return", "a", "point", "of", "the", "specified", "dtype", "." ]
fbd67accb2e6d55969c6d4ed7e8b4bb4ab65cd44
https://github.com/JIC-CSB/jicimagelib/blob/fbd67accb2e6d55969c6d4ed7e8b4bb4ab65cd44/jicimagelib/geometry.py#L148-L155
train
Return a point of the specified dtype.
kodethon/KoDrive
kodrive/syncthing_factory.py
SyncthingClient.free
def free(self, local_path): ''' Stop synchronization of local_path ''' # Process local ~~~ # 1. Syncthing config config = self.get_config() # Check whether folders are still connected to this device folder = st_util.find_folder_with_path(local_path, config) self.delete_...
python
def free(self, local_path): ''' Stop synchronization of local_path ''' # Process local ~~~ # 1. Syncthing config config = self.get_config() # Check whether folders are still connected to this device folder = st_util.find_folder_with_path(local_path, config) self.delete_...
[ "def", "free", "(", "self", ",", "local_path", ")", ":", "# Process local ~~~", "# 1. Syncthing config", "config", "=", "self", ".", "get_config", "(", ")", "# Check whether folders are still connected to this device ", "folder", "=", "st_util", ".", "find_folder_with_pat...
Stop synchronization of local_path
[ "Stop", "synchronization", "of", "local_path" ]
325fe5e5870b7d4eb121dcc7e93be64aa16e7988
https://github.com/kodethon/KoDrive/blob/325fe5e5870b7d4eb121dcc7e93be64aa16e7988/kodrive/syncthing_factory.py#L862-L941
train
Free the local path and all of its contents.
kodethon/KoDrive
kodrive/syncthing_factory.py
SyncthingClient.tag
def tag(self, path, name): ''' Change name associated with path ''' if not path[len(path) - 1] == '/': path += '/' config = self.get_config() folder = self.find_folder({ 'path' : path }, config) if not folder: raise custom_errors.FileNotInConfig(path) old_name...
python
def tag(self, path, name): ''' Change name associated with path ''' if not path[len(path) - 1] == '/': path += '/' config = self.get_config() folder = self.find_folder({ 'path' : path }, config) if not folder: raise custom_errors.FileNotInConfig(path) old_name...
[ "def", "tag", "(", "self", ",", "path", ",", "name", ")", ":", "if", "not", "path", "[", "len", "(", "path", ")", "-", "1", "]", "==", "'/'", ":", "path", "+=", "'/'", "config", "=", "self", ".", "get_config", "(", ")", "folder", "=", "self", ...
Change name associated with path
[ "Change", "name", "associated", "with", "path" ]
325fe5e5870b7d4eb121dcc7e93be64aa16e7988
https://github.com/kodethon/KoDrive/blob/325fe5e5870b7d4eb121dcc7e93be64aa16e7988/kodrive/syncthing_factory.py#L943-L969
train
Tag a file with the given name