partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
SFTPClone._match_modes
Match mod, utime and uid/gid with locals one.
sftpclone/sftpclone.py
def _match_modes(self, remote_path, l_st): """Match mod, utime and uid/gid with locals one.""" self.sftp.chmod(remote_path, S_IMODE(l_st.st_mode)) self.sftp.utime(remote_path, (l_st.st_atime, l_st.st_mtime)) if self.chown: self.sftp.chown(remote_path, l_st.st_uid, l_st.st_gi...
def _match_modes(self, remote_path, l_st): """Match mod, utime and uid/gid with locals one.""" self.sftp.chmod(remote_path, S_IMODE(l_st.st_mode)) self.sftp.utime(remote_path, (l_st.st_atime, l_st.st_mtime)) if self.chown: self.sftp.chown(remote_path, l_st.st_uid, l_st.st_gi...
[ "Match", "mod", "utime", "and", "uid", "/", "gid", "with", "locals", "one", "." ]
unbit/sftpclone
python
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L384-L390
[ "def", "_match_modes", "(", "self", ",", "remote_path", ",", "l_st", ")", ":", "self", ".", "sftp", ".", "chmod", "(", "remote_path", ",", "S_IMODE", "(", "l_st", ".", "st_mode", ")", ")", "self", ".", "sftp", ".", "utime", "(", "remote_path", ",", "...
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
train
SFTPClone.file_upload
Upload local_path to remote_path and set permission and mtime.
sftpclone/sftpclone.py
def file_upload(self, local_path, remote_path, l_st): """Upload local_path to remote_path and set permission and mtime.""" self.sftp.put(local_path, remote_path) self._match_modes(remote_path, l_st)
def file_upload(self, local_path, remote_path, l_st): """Upload local_path to remote_path and set permission and mtime.""" self.sftp.put(local_path, remote_path) self._match_modes(remote_path, l_st)
[ "Upload", "local_path", "to", "remote_path", "and", "set", "permission", "and", "mtime", "." ]
unbit/sftpclone
python
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L392-L395
[ "def", "file_upload", "(", "self", ",", "local_path", ",", "remote_path", ",", "l_st", ")", ":", "self", ".", "sftp", ".", "put", "(", "local_path", ",", "remote_path", ")", "self", ".", "_match_modes", "(", "remote_path", ",", "l_st", ")" ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
train
SFTPClone.remote_delete
Remove the remote directory node.
sftpclone/sftpclone.py
def remote_delete(self, remote_path, r_st): """Remove the remote directory node.""" # If it's a directory, then delete content and directory if S_ISDIR(r_st.st_mode): for item in self.sftp.listdir_attr(remote_path): full_path = path_join(remote_path, item.filename) ...
def remote_delete(self, remote_path, r_st): """Remove the remote directory node.""" # If it's a directory, then delete content and directory if S_ISDIR(r_st.st_mode): for item in self.sftp.listdir_attr(remote_path): full_path = path_join(remote_path, item.filename) ...
[ "Remove", "the", "remote", "directory", "node", "." ]
unbit/sftpclone
python
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L397-L413
[ "def", "remote_delete", "(", "self", ",", "remote_path", ",", "r_st", ")", ":", "# If it's a directory, then delete content and directory", "if", "S_ISDIR", "(", "r_st", ".", "st_mode", ")", ":", "for", "item", "in", "self", ".", "sftp", ".", "listdir_attr", "("...
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
train
SFTPClone.check_for_deletion
Traverse the entire remote_path tree. Find files/directories that need to be deleted, not being present in the local folder.
sftpclone/sftpclone.py
def check_for_deletion(self, relative_path=None): """Traverse the entire remote_path tree. Find files/directories that need to be deleted, not being present in the local folder. """ if not relative_path: relative_path = str() # root of shared directory tree ...
def check_for_deletion(self, relative_path=None): """Traverse the entire remote_path tree. Find files/directories that need to be deleted, not being present in the local folder. """ if not relative_path: relative_path = str() # root of shared directory tree ...
[ "Traverse", "the", "entire", "remote_path", "tree", "." ]
unbit/sftpclone
python
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L415-L445
[ "def", "check_for_deletion", "(", "self", ",", "relative_path", "=", "None", ")", ":", "if", "not", "relative_path", ":", "relative_path", "=", "str", "(", ")", "# root of shared directory tree", "remote_path", "=", "path_join", "(", "self", ".", "remote_path", ...
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
train
SFTPClone.create_update_symlink
Create a new link pointing to link_destination in remote_path position.
sftpclone/sftpclone.py
def create_update_symlink(self, link_destination, remote_path): """Create a new link pointing to link_destination in remote_path position.""" try: # if there's anything, delete it self.sftp.remove(remote_path) except IOError: # that's fine, nothing exists there! pass ...
def create_update_symlink(self, link_destination, remote_path): """Create a new link pointing to link_destination in remote_path position.""" try: # if there's anything, delete it self.sftp.remove(remote_path) except IOError: # that's fine, nothing exists there! pass ...
[ "Create", "a", "new", "link", "pointing", "to", "link_destination", "in", "remote_path", "position", "." ]
unbit/sftpclone
python
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L447-L460
[ "def", "create_update_symlink", "(", "self", ",", "link_destination", ",", "remote_path", ")", ":", "try", ":", "# if there's anything, delete it", "self", ".", "sftp", ".", "remove", "(", "remote_path", ")", "except", "IOError", ":", "# that's fine, nothing exists th...
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
train
SFTPClone.node_check_for_upload_create
Check if the given directory tree node has to be uploaded/created on the remote folder.
sftpclone/sftpclone.py
def node_check_for_upload_create(self, relative_path, f): """Check if the given directory tree node has to be uploaded/created on the remote folder.""" if not relative_path: # we're at the root of the shared directory tree relative_path = str() # the (absolute) local add...
def node_check_for_upload_create(self, relative_path, f): """Check if the given directory tree node has to be uploaded/created on the remote folder.""" if not relative_path: # we're at the root of the shared directory tree relative_path = str() # the (absolute) local add...
[ "Check", "if", "the", "given", "directory", "tree", "node", "has", "to", "be", "uploaded", "/", "created", "on", "the", "remote", "folder", "." ]
unbit/sftpclone
python
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L462-L583
[ "def", "node_check_for_upload_create", "(", "self", ",", "relative_path", ",", "f", ")", ":", "if", "not", "relative_path", ":", "# we're at the root of the shared directory tree", "relative_path", "=", "str", "(", ")", "# the (absolute) local address of f.", "local_path", ...
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
train
SFTPClone.check_for_upload_create
Traverse the relative_path tree and check for files that need to be uploaded/created. Relativity here refers to the shared directory tree.
sftpclone/sftpclone.py
def check_for_upload_create(self, relative_path=None): """Traverse the relative_path tree and check for files that need to be uploaded/created. Relativity here refers to the shared directory tree.""" for f in os.listdir( path_join( self.local_path, relative_path) if ...
def check_for_upload_create(self, relative_path=None): """Traverse the relative_path tree and check for files that need to be uploaded/created. Relativity here refers to the shared directory tree.""" for f in os.listdir( path_join( self.local_path, relative_path) if ...
[ "Traverse", "the", "relative_path", "tree", "and", "check", "for", "files", "that", "need", "to", "be", "uploaded", "/", "created", "." ]
unbit/sftpclone
python
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L585-L593
[ "def", "check_for_upload_create", "(", "self", ",", "relative_path", "=", "None", ")", ":", "for", "f", "in", "os", ".", "listdir", "(", "path_join", "(", "self", ".", "local_path", ",", "relative_path", ")", "if", "relative_path", "else", "self", ".", "lo...
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
train
SFTPClone.run
Run the sync. Confront the local and the remote directories and perform the needed changes.
sftpclone/sftpclone.py
def run(self): """Run the sync. Confront the local and the remote directories and perform the needed changes.""" # Check if remote path is present try: self.sftp.stat(self.remote_path) except FileNotFoundError as e: if self.create_remote_directory: ...
def run(self): """Run the sync. Confront the local and the remote directories and perform the needed changes.""" # Check if remote path is present try: self.sftp.stat(self.remote_path) except FileNotFoundError as e: if self.create_remote_directory: ...
[ "Run", "the", "sync", "." ]
unbit/sftpclone
python
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L595-L625
[ "def", "run", "(", "self", ")", ":", "# Check if remote path is present", "try", ":", "self", ".", "sftp", ".", "stat", "(", "self", ".", "remote_path", ")", "except", "FileNotFoundError", "as", "e", ":", "if", "self", ".", "create_remote_directory", ":", "s...
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
train
list_files
tree unix command replacement.
sftpclone/t/utils.py
def list_files(start_path): """tree unix command replacement.""" s = u'\n' for root, dirs, files in os.walk(start_path): level = root.replace(start_path, '').count(os.sep) indent = ' ' * 4 * level s += u'{}{}/\n'.format(indent, os.path.basename(root)) sub_indent = ' ' * 4 * (...
def list_files(start_path): """tree unix command replacement.""" s = u'\n' for root, dirs, files in os.walk(start_path): level = root.replace(start_path, '').count(os.sep) indent = ' ' * 4 * level s += u'{}{}/\n'.format(indent, os.path.basename(root)) sub_indent = ' ' * 4 * (...
[ "tree", "unix", "command", "replacement", "." ]
unbit/sftpclone
python
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/t/utils.py#L26-L36
[ "def", "list_files", "(", "start_path", ")", ":", "s", "=", "u'\\n'", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "start_path", ")", ":", "level", "=", "root", ".", "replace", "(", "start_path", ",", "''", ")", ".", "cou...
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
train
file_tree
Create a nested dictionary that represents the folder structure of `start_path`. Liberally adapted from http://code.activestate.com/recipes/577879-create-a-nested-dictionary-from-oswalk/
sftpclone/t/utils.py
def file_tree(start_path): """ Create a nested dictionary that represents the folder structure of `start_path`. Liberally adapted from http://code.activestate.com/recipes/577879-create-a-nested-dictionary-from-oswalk/ """ nested_dirs = {} root_dir = start_path.rstrip(os.sep) start = roo...
def file_tree(start_path): """ Create a nested dictionary that represents the folder structure of `start_path`. Liberally adapted from http://code.activestate.com/recipes/577879-create-a-nested-dictionary-from-oswalk/ """ nested_dirs = {} root_dir = start_path.rstrip(os.sep) start = roo...
[ "Create", "a", "nested", "dictionary", "that", "represents", "the", "folder", "structure", "of", "start_path", "." ]
unbit/sftpclone
python
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/t/utils.py#L39-L54
[ "def", "file_tree", "(", "start_path", ")", ":", "nested_dirs", "=", "{", "}", "root_dir", "=", "start_path", ".", "rstrip", "(", "os", ".", "sep", ")", "start", "=", "root_dir", ".", "rfind", "(", "os", ".", "sep", ")", "+", "1", "for", "path", ",...
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
train
capture_sys_output
Capture standard output and error.
sftpclone/t/utils.py
def capture_sys_output(): """Capture standard output and error.""" capture_out, capture_err = StringIO(), StringIO() current_out, current_err = sys.stdout, sys.stderr try: sys.stdout, sys.stderr = capture_out, capture_err yield capture_out, capture_err finally: sys.stdout, sy...
def capture_sys_output(): """Capture standard output and error.""" capture_out, capture_err = StringIO(), StringIO() current_out, current_err = sys.stdout, sys.stderr try: sys.stdout, sys.stderr = capture_out, capture_err yield capture_out, capture_err finally: sys.stdout, sy...
[ "Capture", "standard", "output", "and", "error", "." ]
unbit/sftpclone
python
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/t/utils.py#L58-L66
[ "def", "capture_sys_output", "(", ")", ":", "capture_out", ",", "capture_err", "=", "StringIO", "(", ")", ",", "StringIO", "(", ")", "current_out", ",", "current_err", "=", "sys", ".", "stdout", ",", "sys", ".", "stderr", "try", ":", "sys", ".", "stdout"...
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
train
suppress_logging
Suppress logging.
sftpclone/t/utils.py
def suppress_logging(log_level=logging.CRITICAL): """Suppress logging.""" logging.disable(log_level) yield logging.disable(logging.NOTSET)
def suppress_logging(log_level=logging.CRITICAL): """Suppress logging.""" logging.disable(log_level) yield logging.disable(logging.NOTSET)
[ "Suppress", "logging", "." ]
unbit/sftpclone
python
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/t/utils.py#L70-L74
[ "def", "suppress_logging", "(", "log_level", "=", "logging", ".", "CRITICAL", ")", ":", "logging", ".", "disable", "(", "log_level", ")", "yield", "logging", ".", "disable", "(", "logging", ".", "NOTSET", ")" ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
train
override_env_variables
Override user environmental variables with custom one.
sftpclone/t/utils.py
def override_env_variables(): """Override user environmental variables with custom one.""" env_vars = ("LOGNAME", "USER", "LNAME", "USERNAME") old = [os.environ[v] if v in os.environ else None for v in env_vars] for v in env_vars: os.environ[v] = "test" yield for i, v in enumerate(env_...
def override_env_variables(): """Override user environmental variables with custom one.""" env_vars = ("LOGNAME", "USER", "LNAME", "USERNAME") old = [os.environ[v] if v in os.environ else None for v in env_vars] for v in env_vars: os.environ[v] = "test" yield for i, v in enumerate(env_...
[ "Override", "user", "environmental", "variables", "with", "custom", "one", "." ]
unbit/sftpclone
python
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/t/utils.py#L78-L89
[ "def", "override_env_variables", "(", ")", ":", "env_vars", "=", "(", "\"LOGNAME\"", ",", "\"USER\"", ",", "\"LNAME\"", ",", "\"USERNAME\"", ")", "old", "=", "[", "os", ".", "environ", "[", "v", "]", "if", "v", "in", "os", ".", "environ", "else", "None...
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
train
override_ssh_auth_env
Override the `$SSH_AUTH_SOCK `env variable to mock the absence of an SSH agent.
sftpclone/t/utils.py
def override_ssh_auth_env(): """Override the `$SSH_AUTH_SOCK `env variable to mock the absence of an SSH agent.""" ssh_auth_sock = "SSH_AUTH_SOCK" old_ssh_auth_sock = os.environ.get(ssh_auth_sock) del os.environ[ssh_auth_sock] yield if old_ssh_auth_sock: os.environ[ssh_auth_sock] = ol...
def override_ssh_auth_env(): """Override the `$SSH_AUTH_SOCK `env variable to mock the absence of an SSH agent.""" ssh_auth_sock = "SSH_AUTH_SOCK" old_ssh_auth_sock = os.environ.get(ssh_auth_sock) del os.environ[ssh_auth_sock] yield if old_ssh_auth_sock: os.environ[ssh_auth_sock] = ol...
[ "Override", "the", "$SSH_AUTH_SOCK", "env", "variable", "to", "mock", "the", "absence", "of", "an", "SSH", "agent", "." ]
unbit/sftpclone
python
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/t/utils.py#L93-L103
[ "def", "override_ssh_auth_env", "(", ")", ":", "ssh_auth_sock", "=", "\"SSH_AUTH_SOCK\"", "old_ssh_auth_sock", "=", "os", ".", "environ", ".", "get", "(", "ssh_auth_sock", ")", "del", "os", ".", "environ", "[", "ssh_auth_sock", "]", "yield", "if", "old_ssh_auth_...
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
train
get_config
Get the configurations from .tldrrc and return it as a dict.
tldr/config.py
def get_config(): """Get the configurations from .tldrrc and return it as a dict.""" config_path = path.join( (os.environ.get('TLDR_CONFIG_DIR') or path.expanduser('~')), '.tldrrc') if not path.exists(config_path): sys.exit("Can't find config file at: {0}. You may use `tldr init` " ...
def get_config(): """Get the configurations from .tldrrc and return it as a dict.""" config_path = path.join( (os.environ.get('TLDR_CONFIG_DIR') or path.expanduser('~')), '.tldrrc') if not path.exists(config_path): sys.exit("Can't find config file at: {0}. You may use `tldr init` " ...
[ "Get", "the", "configurations", "from", ".", "tldrrc", "and", "return", "it", "as", "a", "dict", "." ]
lord63/tldr.py
python
https://github.com/lord63/tldr.py/blob/73cf9f86254691b2476910ea6a743b6d8bd04963/tldr/config.py#L14-L38
[ "def", "get_config", "(", ")", ":", "config_path", "=", "path", ".", "join", "(", "(", "os", ".", "environ", ".", "get", "(", "'TLDR_CONFIG_DIR'", ")", "or", "path", ".", "expanduser", "(", "'~'", ")", ")", ",", "'.tldrrc'", ")", "if", "not", "path",...
73cf9f86254691b2476910ea6a743b6d8bd04963
train
parse_man_page
Parse the man page and return the parsed lines.
tldr/cli.py
def parse_man_page(command, platform): """Parse the man page and return the parsed lines.""" page_path = find_page_location(command, platform) output_lines = parse_page(page_path) return output_lines
def parse_man_page(command, platform): """Parse the man page and return the parsed lines.""" page_path = find_page_location(command, platform) output_lines = parse_page(page_path) return output_lines
[ "Parse", "the", "man", "page", "and", "return", "the", "parsed", "lines", "." ]
lord63/tldr.py
python
https://github.com/lord63/tldr.py/blob/73cf9f86254691b2476910ea6a743b6d8bd04963/tldr/cli.py#L22-L26
[ "def", "parse_man_page", "(", "command", ",", "platform", ")", ":", "page_path", "=", "find_page_location", "(", "command", ",", "platform", ")", "output_lines", "=", "parse_page", "(", "page_path", ")", "return", "output_lines" ]
73cf9f86254691b2476910ea6a743b6d8bd04963
train
find_page_location
Find the command man page in the pages directory.
tldr/cli.py
def find_page_location(command, specified_platform): """Find the command man page in the pages directory.""" repo_directory = get_config()['repo_directory'] default_platform = get_config()['platform'] command_platform = ( specified_platform if specified_platform else default_platform) with ...
def find_page_location(command, specified_platform): """Find the command man page in the pages directory.""" repo_directory = get_config()['repo_directory'] default_platform = get_config()['platform'] command_platform = ( specified_platform if specified_platform else default_platform) with ...
[ "Find", "the", "command", "man", "page", "in", "the", "pages", "directory", "." ]
lord63/tldr.py
python
https://github.com/lord63/tldr.py/blob/73cf9f86254691b2476910ea6a743b6d8bd04963/tldr/cli.py#L29-L62
[ "def", "find_page_location", "(", "command", ",", "specified_platform", ")", ":", "repo_directory", "=", "get_config", "(", ")", "[", "'repo_directory'", "]", "default_platform", "=", "get_config", "(", ")", "[", "'platform'", "]", "command_platform", "=", "(", ...
73cf9f86254691b2476910ea6a743b6d8bd04963
train
find
Find the command usage.
tldr/cli.py
def find(command, on): """Find the command usage.""" output_lines = parse_man_page(command, on) click.echo(''.join(output_lines))
def find(command, on): """Find the command usage.""" output_lines = parse_man_page(command, on) click.echo(''.join(output_lines))
[ "Find", "the", "command", "usage", "." ]
lord63/tldr.py
python
https://github.com/lord63/tldr.py/blob/73cf9f86254691b2476910ea6a743b6d8bd04963/tldr/cli.py#L101-L104
[ "def", "find", "(", "command", ",", "on", ")", ":", "output_lines", "=", "parse_man_page", "(", "command", ",", "on", ")", "click", ".", "echo", "(", "''", ".", "join", "(", "output_lines", ")", ")" ]
73cf9f86254691b2476910ea6a743b6d8bd04963
train
update
Update to the latest pages.
tldr/cli.py
def update(): """Update to the latest pages.""" repo_directory = get_config()['repo_directory'] os.chdir(repo_directory) click.echo("Check for updates...") local = subprocess.check_output('git rev-parse master'.split()).strip() remote = subprocess.check_output( 'git ls-remote https://gi...
def update(): """Update to the latest pages.""" repo_directory = get_config()['repo_directory'] os.chdir(repo_directory) click.echo("Check for updates...") local = subprocess.check_output('git rev-parse master'.split()).strip() remote = subprocess.check_output( 'git ls-remote https://gi...
[ "Update", "to", "the", "latest", "pages", "." ]
lord63/tldr.py
python
https://github.com/lord63/tldr.py/blob/73cf9f86254691b2476910ea6a743b6d8bd04963/tldr/cli.py#L108-L125
[ "def", "update", "(", ")", ":", "repo_directory", "=", "get_config", "(", ")", "[", "'repo_directory'", "]", "os", ".", "chdir", "(", "repo_directory", ")", "click", ".", "echo", "(", "\"Check for updates...\"", ")", "local", "=", "subprocess", ".", "check_o...
73cf9f86254691b2476910ea6a743b6d8bd04963
train
init
Init config file.
tldr/cli.py
def init(): """Init config file.""" default_config_path = path.join( (os.environ.get('TLDR_CONFIG_DIR') or path.expanduser('~')), '.tldrrc') if path.exists(default_config_path): click.echo("There is already a config file exists, " "skip initializing it.") else:...
def init(): """Init config file.""" default_config_path = path.join( (os.environ.get('TLDR_CONFIG_DIR') or path.expanduser('~')), '.tldrrc') if path.exists(default_config_path): click.echo("There is already a config file exists, " "skip initializing it.") else:...
[ "Init", "config", "file", "." ]
lord63/tldr.py
python
https://github.com/lord63/tldr.py/blob/73cf9f86254691b2476910ea6a743b6d8bd04963/tldr/cli.py#L129-L161
[ "def", "init", "(", ")", ":", "default_config_path", "=", "path", ".", "join", "(", "(", "os", ".", "environ", ".", "get", "(", "'TLDR_CONFIG_DIR'", ")", "or", "path", ".", "expanduser", "(", "'~'", ")", ")", ",", "'.tldrrc'", ")", "if", "path", ".",...
73cf9f86254691b2476910ea6a743b6d8bd04963
train
locate
Locate the command's man page.
tldr/cli.py
def locate(command, on): """Locate the command's man page.""" location = find_page_location(command, on) click.echo(location)
def locate(command, on): """Locate the command's man page.""" location = find_page_location(command, on) click.echo(location)
[ "Locate", "the", "command", "s", "man", "page", "." ]
lord63/tldr.py
python
https://github.com/lord63/tldr.py/blob/73cf9f86254691b2476910ea6a743b6d8bd04963/tldr/cli.py#L175-L178
[ "def", "locate", "(", "command", ",", "on", ")", ":", "location", "=", "find_page_location", "(", "command", ",", "on", ")", "click", ".", "echo", "(", "location", ")" ]
73cf9f86254691b2476910ea6a743b6d8bd04963
train
TableClassType.relate
Produce a relationship between this mapped table and another one. This makes usage of SQLAlchemy's :func:`sqlalchemy.orm.relationship` construct.
cruzdb/sqlsoup.py
def relate(cls, propname, *args, **kwargs): """Produce a relationship between this mapped table and another one. This makes usage of SQLAlchemy's :func:`sqlalchemy.orm.relationship` construct. """ class_mapper(cls)._configure_property(propname, relation...
def relate(cls, propname, *args, **kwargs): """Produce a relationship between this mapped table and another one. This makes usage of SQLAlchemy's :func:`sqlalchemy.orm.relationship` construct. """ class_mapper(cls)._configure_property(propname, relation...
[ "Produce", "a", "relationship", "between", "this", "mapped", "table", "and", "another", "one", ".", "This", "makes", "usage", "of", "SQLAlchemy", "s", ":", "func", ":", "sqlalchemy", ".", "orm", ".", "relationship", "construct", "." ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/sqlsoup.py#L93-L101
[ "def", "relate", "(", "cls", ",", "propname", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "class_mapper", "(", "cls", ")", ".", "_configure_property", "(", "propname", ",", "relationship", "(", "*", "args", ",", "*", "*", "kwargs", ")", ")" ...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
SQLSoup.execute
Execute a SQL statement. The statement may be a string SQL string, an :func:`sqlalchemy.sql.expression.select` construct, or a :func:`sqlalchemy.sql.expression.text` construct.
cruzdb/sqlsoup.py
def execute(self, stmt, **params): """Execute a SQL statement. The statement may be a string SQL string, an :func:`sqlalchemy.sql.expression.select` construct, or a :func:`sqlalchemy.sql.expression.text` construct. """ return self.session.execute(sql.text(stmt...
def execute(self, stmt, **params): """Execute a SQL statement. The statement may be a string SQL string, an :func:`sqlalchemy.sql.expression.select` construct, or a :func:`sqlalchemy.sql.expression.text` construct. """ return self.session.execute(sql.text(stmt...
[ "Execute", "a", "SQL", "statement", "." ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/sqlsoup.py#L229-L238
[ "def", "execute", "(", "self", ",", "stmt", ",", "*", "*", "params", ")", ":", "return", "self", ".", "session", ".", "execute", "(", "sql", ".", "text", "(", "stmt", ",", "bind", "=", "self", ".", "bind", ")", ",", "*", "*", "params", ")" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
SQLSoup.map_to
Configure a mapping to the given attrname. This is the "master" method that can be used to create any configuration. :param attrname: String attribute name which will be established as an attribute on this :class:.`.SQLSoup` instance. :param base: a Python class wh...
cruzdb/sqlsoup.py
def map_to(self, attrname, tablename=None, selectable=None, schema=None, base=None, mapper_args=util.immutabledict()): """Configure a mapping to the given attrname. This is the "master" method that can be used to create any configuration. :param attrname: String a...
def map_to(self, attrname, tablename=None, selectable=None, schema=None, base=None, mapper_args=util.immutabledict()): """Configure a mapping to the given attrname. This is the "master" method that can be used to create any configuration. :param attrname: String a...
[ "Configure", "a", "mapping", "to", "the", "given", "attrname", "." ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/sqlsoup.py#L292-L373
[ "def", "map_to", "(", "self", ",", "attrname", ",", "tablename", "=", "None", ",", "selectable", "=", "None", ",", "schema", "=", "None", ",", "base", "=", "None", ",", "mapper_args", "=", "util", ".", "immutabledict", "(", ")", ")", ":", "if", "attr...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
SQLSoup.map
Map a selectable directly. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param selectable: an :func:`.expression.select` construct. :param base: a Python class which will be used as the base for the mapped class. If ``None``,...
cruzdb/sqlsoup.py
def map(self, selectable, base=None, **mapper_args): """Map a selectable directly. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param selectable: an :func:`.expression.select` construct. :param base: a Python class which will ...
def map(self, selectable, base=None, **mapper_args): """Map a selectable directly. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param selectable: an :func:`.expression.select` construct. :param base: a Python class which will ...
[ "Map", "a", "selectable", "directly", "." ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/sqlsoup.py#L376-L399
[ "def", "map", "(", "self", ",", "selectable", ",", "base", "=", "None", ",", "*", "*", "mapper_args", ")", ":", "return", "_class_for_table", "(", "self", ".", "session", ",", "self", ".", "engine", ",", "selectable", ",", "base", "or", "self", ".", ...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
SQLSoup.with_labels
Map a selectable directly, wrapping the selectable in a subquery with labels. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param selectable: an :func:`.expression.select` construct. :param base: a Python class which will be u...
cruzdb/sqlsoup.py
def with_labels(self, selectable, base=None, **mapper_args): """Map a selectable directly, wrapping the selectable in a subquery with labels. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param selectable: an :func:`.expressio...
def with_labels(self, selectable, base=None, **mapper_args): """Map a selectable directly, wrapping the selectable in a subquery with labels. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param selectable: an :func:`.expressio...
[ "Map", "a", "selectable", "directly", "wrapping", "the", "selectable", "in", "a", "subquery", "with", "labels", "." ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/sqlsoup.py#L401-L423
[ "def", "with_labels", "(", "self", ",", "selectable", ",", "base", "=", "None", ",", "*", "*", "mapper_args", ")", ":", "# TODO give meaningful aliases", "return", "self", ".", "map", "(", "expression", ".", "_clause_element_as_expr", "(", "selectable", ")", "...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
SQLSoup.join
Create an :func:`.expression.join` and map to it. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param left: a mapped class or table object. :param right: a mapped class or table object. :param onclause: optional "ON" clause con...
cruzdb/sqlsoup.py
def join(self, left, right, onclause=None, isouter=False, base=None, **mapper_args): """Create an :func:`.expression.join` and map to it. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param left: a mapped class or tabl...
def join(self, left, right, onclause=None, isouter=False, base=None, **mapper_args): """Create an :func:`.expression.join` and map to it. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param left: a mapped class or tabl...
[ "Create", "an", ":", "func", ":", ".", "expression", ".", "join", "and", "map", "to", "it", "." ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/sqlsoup.py#L425-L447
[ "def", "join", "(", "self", ",", "left", ",", "right", ",", "onclause", "=", "None", ",", "isouter", "=", "False", ",", "base", "=", "None", ",", "*", "*", "mapper_args", ")", ":", "j", "=", "join", "(", "left", ",", "right", ",", "onclause", "="...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
SQLSoup.entity
Return the named entity from this :class:`.SQLSoup`, or create if not present. For more generalized mapping, see :meth:`.map_to`.
cruzdb/sqlsoup.py
def entity(self, attr, schema=None): """Return the named entity from this :class:`.SQLSoup`, or create if not present. For more generalized mapping, see :meth:`.map_to`. """ try: return self._cache[attr] except KeyError, ke: return self.map_to(a...
def entity(self, attr, schema=None): """Return the named entity from this :class:`.SQLSoup`, or create if not present. For more generalized mapping, see :meth:`.map_to`. """ try: return self._cache[attr] except KeyError, ke: return self.map_to(a...
[ "Return", "the", "named", "entity", "from", "this", ":", "class", ":", ".", "SQLSoup", "or", "create", "if", "not", "present", "." ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/sqlsoup.py#L449-L459
[ "def", "entity", "(", "self", ",", "attr", ",", "schema", "=", "None", ")", ":", "try", ":", "return", "self", ".", "_cache", "[", "attr", "]", "except", "KeyError", ",", "ke", ":", "return", "self", ".", "map_to", "(", "attr", ",", "tablename", "=...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
distance
\ Distance between 2 features. The integer result is always positive or zero. If the features overlap or touch, it is zero. >>> from intersecter import Feature, distance >>> distance(Feature(1, 2), Feature(12, 13)) 10 >>> distance(Feature(1, 2), Feature(2, 3)) 0 >>> distance(Feature(1, 1...
cruzdb/intersecter.py
def distance(f1, f2): """\ Distance between 2 features. The integer result is always positive or zero. If the features overlap or touch, it is zero. >>> from intersecter import Feature, distance >>> distance(Feature(1, 2), Feature(12, 13)) 10 >>> distance(Feature(1, 2), Feature(2, 3)) 0 ...
def distance(f1, f2): """\ Distance between 2 features. The integer result is always positive or zero. If the features overlap or touch, it is zero. >>> from intersecter import Feature, distance >>> distance(Feature(1, 2), Feature(12, 13)) 10 >>> distance(Feature(1, 2), Feature(2, 3)) 0 ...
[ "\\", "Distance", "between", "2", "features", ".", "The", "integer", "result", "is", "always", "positive", "or", "zero", ".", "If", "the", "features", "overlap", "or", "touch", "it", "is", "zero", ".", ">>>", "from", "intersecter", "import", "Feature", "di...
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/intersecter.py#L269-L284
[ "def", "distance", "(", "f1", ",", "f2", ")", ":", "if", "f1", ".", "end", "<", "f2", ".", "start", ":", "return", "f2", ".", "start", "-", "f1", ".", "end", "if", "f2", ".", "end", "<", "f1", ".", "start", ":", "return", "f1", ".", "start", ...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
Intersecter.find
Return a object of all stored intervals intersecting between (start, end) inclusive.
cruzdb/intersecter.py
def find(self, start, end, chrom=None): """Return a object of all stored intervals intersecting between (start, end) inclusive.""" intervals = self.intervals[chrom] ilen = len(intervals) # NOTE: we only search for starts, since any feature that starts within max_len of # the quer...
def find(self, start, end, chrom=None): """Return a object of all stored intervals intersecting between (start, end) inclusive.""" intervals = self.intervals[chrom] ilen = len(intervals) # NOTE: we only search for starts, since any feature that starts within max_len of # the quer...
[ "Return", "a", "object", "of", "all", "stored", "intervals", "intersecting", "between", "(", "start", "end", ")", "inclusive", "." ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/intersecter.py#L147-L161
[ "def", "find", "(", "self", ",", "start", ",", "end", ",", "chrom", "=", "None", ")", ":", "intervals", "=", "self", ".", "intervals", "[", "chrom", "]", "ilen", "=", "len", "(", "intervals", ")", "# NOTE: we only search for starts, since any feature that star...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
Intersecter.left
return the nearest n features strictly to the left of a Feature f. Overlapping features are not considered as to the left. f: a Feature object n: the number of features to return
cruzdb/intersecter.py
def left(self, f, n=1): """return the nearest n features strictly to the left of a Feature f. Overlapping features are not considered as to the left. f: a Feature object n: the number of features to return """ intervals = self.intervals[f.chrom] if intervals == [...
def left(self, f, n=1): """return the nearest n features strictly to the left of a Feature f. Overlapping features are not considered as to the left. f: a Feature object n: the number of features to return """ intervals = self.intervals[f.chrom] if intervals == [...
[ "return", "the", "nearest", "n", "features", "strictly", "to", "the", "left", "of", "a", "Feature", "f", ".", "Overlapping", "features", "are", "not", "considered", "as", "to", "the", "left", "." ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/intersecter.py#L163-L192
[ "def", "left", "(", "self", ",", "f", ",", "n", "=", "1", ")", ":", "intervals", "=", "self", ".", "intervals", "[", "f", ".", "chrom", "]", "if", "intervals", "==", "[", "]", ":", "return", "[", "]", "iright", "=", "binsearch_left_start", "(", "...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
Intersecter.right
return the nearest n features strictly to the right of a Feature f. Overlapping features are not considered as to the right. f: a Feature object n: the number of features to return
cruzdb/intersecter.py
def right(self, f, n=1): """return the nearest n features strictly to the right of a Feature f. Overlapping features are not considered as to the right. f: a Feature object n: the number of features to return """ intervals = self.intervals[f.chrom] ilen = len(int...
def right(self, f, n=1): """return the nearest n features strictly to the right of a Feature f. Overlapping features are not considered as to the right. f: a Feature object n: the number of features to return """ intervals = self.intervals[f.chrom] ilen = len(int...
[ "return", "the", "nearest", "n", "features", "strictly", "to", "the", "right", "of", "a", "Feature", "f", ".", "Overlapping", "features", "are", "not", "considered", "as", "to", "the", "right", "." ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/intersecter.py#L194-L215
[ "def", "right", "(", "self", ",", "f", ",", "n", "=", "1", ")", ":", "intervals", "=", "self", ".", "intervals", "[", "f", ".", "chrom", "]", "ilen", "=", "len", "(", "intervals", ")", "iright", "=", "binsearch_right_end", "(", "intervals", ",", "f...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
Intersecter.upstream
find n upstream features where upstream is determined by the strand of the query Feature f Overlapping features are not considered. f: a Feature object n: the number of features to return
cruzdb/intersecter.py
def upstream(self, f, n=1): """find n upstream features where upstream is determined by the strand of the query Feature f Overlapping features are not considered. f: a Feature object n: the number of features to return """ if f.strand == -1: return se...
def upstream(self, f, n=1): """find n upstream features where upstream is determined by the strand of the query Feature f Overlapping features are not considered. f: a Feature object n: the number of features to return """ if f.strand == -1: return se...
[ "find", "n", "upstream", "features", "where", "upstream", "is", "determined", "by", "the", "strand", "of", "the", "query", "Feature", "f", "Overlapping", "features", "are", "not", "considered", "." ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/intersecter.py#L218-L228
[ "def", "upstream", "(", "self", ",", "f", ",", "n", "=", "1", ")", ":", "if", "f", ".", "strand", "==", "-", "1", ":", "return", "self", ".", "right", "(", "f", ",", "n", ")", "return", "self", ".", "left", "(", "f", ",", "n", ")" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
Intersecter.downstream
find n downstream features where downstream is determined by the strand of the query Feature f Overlapping features are not considered. f: a Feature object n: the number of features to return
cruzdb/intersecter.py
def downstream(self, f, n=1): """find n downstream features where downstream is determined by the strand of the query Feature f Overlapping features are not considered. f: a Feature object n: the number of features to return """ if f.strand == -1: ret...
def downstream(self, f, n=1): """find n downstream features where downstream is determined by the strand of the query Feature f Overlapping features are not considered. f: a Feature object n: the number of features to return """ if f.strand == -1: ret...
[ "find", "n", "downstream", "features", "where", "downstream", "is", "determined", "by", "the", "strand", "of", "the", "query", "Feature", "f", "Overlapping", "features", "are", "not", "considered", "." ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/intersecter.py#L231-L241
[ "def", "downstream", "(", "self", ",", "f", ",", "n", "=", "1", ")", ":", "if", "f", ".", "strand", "==", "-", "1", ":", "return", "self", ".", "left", "(", "f", ",", "n", ")", "return", "self", ".", "right", "(", "f", ",", "n", ")" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
Intersecter.knearest
return the n nearest neighbors to the given feature f: a Feature object k: the number of features to return
cruzdb/intersecter.py
def knearest(self, f_or_start, end=None, chrom=None, k=1): """return the n nearest neighbors to the given feature f: a Feature object k: the number of features to return """ if end is not None: f = Feature(f_or_start, end, chrom=chrom) else: f = ...
def knearest(self, f_or_start, end=None, chrom=None, k=1): """return the n nearest neighbors to the given feature f: a Feature object k: the number of features to return """ if end is not None: f = Feature(f_or_start, end, chrom=chrom) else: f = ...
[ "return", "the", "n", "nearest", "neighbors", "to", "the", "given", "feature", "f", ":", "a", "Feature", "object", "k", ":", "the", "number", "of", "features", "to", "return" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/intersecter.py#L243-L266
[ "def", "knearest", "(", "self", ",", "f_or_start", ",", "end", "=", "None", ",", "chrom", "=", "None", ",", "k", "=", "1", ")", ":", "if", "end", "is", "not", "None", ":", "f", "=", "Feature", "(", "f_or_start", ",", "end", ",", "chrom", "=", "...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
IntervalTree.find
find all elements between (or overlapping) start and end
scripts/interval_tree.py
def find(self, start, end): """find all elements between (or overlapping) start and end""" if self.intervals and not end < self.intervals[0].start: overlapping = [i for i in self.intervals if i.end >= start and i.start <= end] else:...
def find(self, start, end): """find all elements between (or overlapping) start and end""" if self.intervals and not end < self.intervals[0].start: overlapping = [i for i in self.intervals if i.end >= start and i.start <= end] else:...
[ "find", "all", "elements", "between", "(", "or", "overlapping", ")", "start", "and", "end" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/scripts/interval_tree.py#L77-L91
[ "def", "find", "(", "self", ",", "start", ",", "end", ")", ":", "if", "self", ".", "intervals", "and", "not", "end", "<", "self", ".", "intervals", "[", "0", "]", ".", "start", ":", "overlapping", "=", "[", "i", "for", "i", "in", "self", ".", "...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
sequence
return the sequence for a region using the UCSC DAS server. note the start is 1-based each feature will have it's own .sequence method which sends the correct start and end to this function. >>> sequence('hg18', 'chr2', 2223, 2230) 'caacttag'
cruzdb/sequence.py
def sequence(db, chrom, start, end): """ return the sequence for a region using the UCSC DAS server. note the start is 1-based each feature will have it's own .sequence method which sends the correct start and end to this function. >>> sequence('hg18', 'chr2', 2223, 2230) 'caacttag' """...
def sequence(db, chrom, start, end): """ return the sequence for a region using the UCSC DAS server. note the start is 1-based each feature will have it's own .sequence method which sends the correct start and end to this function. >>> sequence('hg18', 'chr2', 2223, 2230) 'caacttag' """...
[ "return", "the", "sequence", "for", "a", "region", "using", "the", "UCSC", "DAS", "server", ".", "note", "the", "start", "is", "1", "-", "based", "each", "feature", "will", "have", "it", "s", "own", ".", "sequence", "method", "which", "sends", "the", "...
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/sequence.py#L10-L23
[ "def", "sequence", "(", "db", ",", "chrom", ",", "start", ",", "end", ")", ":", "url", "=", "\"http://genome.ucsc.edu/cgi-bin/das/%s\"", "%", "db", "url", "+=", "\"/dna?segment=%s:%i,%i\"", "xml", "=", "U", ".", "urlopen", "(", "url", "%", "(", "chrom", ",...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
set_table
alter the table to work between different dialects
cruzdb/mirror.py
def set_table(genome, table, table_name, connection_string, metadata): """ alter the table to work between different dialects """ table = Table(table_name, genome._metadata, autoload=True, autoload_with=genome.bind, extend_existing=True) #print "\t".join([c.name for c in tab...
def set_table(genome, table, table_name, connection_string, metadata): """ alter the table to work between different dialects """ table = Table(table_name, genome._metadata, autoload=True, autoload_with=genome.bind, extend_existing=True) #print "\t".join([c.name for c in tab...
[ "alter", "the", "table", "to", "work", "between", "different", "dialects" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/mirror.py#L39-L80
[ "def", "set_table", "(", "genome", ",", "table", ",", "table_name", ",", "connection_string", ",", "metadata", ")", ":", "table", "=", "Table", "(", "table_name", ",", "genome", ".", "_metadata", ",", "autoload", "=", "True", ",", "autoload_with", "=", "ge...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
Genome.create_url
internal: create a dburl from a set of parameters or the defaults on this object
cruzdb/__init__.py
def create_url(self, db="", user="genome", host="genome-mysql.cse.ucsc.edu", password="", dialect="mysqldb"): """ internal: create a dburl from a set of parameters or the defaults on this object """ if os.path.exists(db): db = "sqlite:///" + db # Is t...
def create_url(self, db="", user="genome", host="genome-mysql.cse.ucsc.edu", password="", dialect="mysqldb"): """ internal: create a dburl from a set of parameters or the defaults on this object """ if os.path.exists(db): db = "sqlite:///" + db # Is t...
[ "internal", ":", "create", "a", "dburl", "from", "a", "set", "of", "parameters", "or", "the", "defaults", "on", "this", "object" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L69-L92
[ "def", "create_url", "(", "self", ",", "db", "=", "\"\"", ",", "user", "=", "\"genome\"", ",", "host", "=", "\"genome-mysql.cse.ucsc.edu\"", ",", "password", "=", "\"\"", ",", "dialect", "=", "\"mysqldb\"", ")", ":", "if", "os", ".", "path", ".", "exists...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
Genome.mirror
miror a set of `tables` from `dest_url` Returns a new Genome object Parameters ---------- tables : list an iterable of tables dest_url: str a dburl string, e.g. 'sqlite:///local.db'
cruzdb/__init__.py
def mirror(self, tables, dest_url): """ miror a set of `tables` from `dest_url` Returns a new Genome object Parameters ---------- tables : list an iterable of tables dest_url: str a dburl string, e.g. 'sqlite:///local.db' """ ...
def mirror(self, tables, dest_url): """ miror a set of `tables` from `dest_url` Returns a new Genome object Parameters ---------- tables : list an iterable of tables dest_url: str a dburl string, e.g. 'sqlite:///local.db' """ ...
[ "miror", "a", "set", "of", "tables", "from", "dest_url" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L94-L110
[ "def", "mirror", "(", "self", ",", "tables", ",", "dest_url", ")", ":", "from", "mirror", "import", "mirror", "return", "mirror", "(", "self", ",", "tables", ",", "dest_url", ")" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
Genome.dataframe
create a pandas dataframe from a table or query Parameters ---------- table : table a table in this database or a query limit: integer an integer limit on the query offset: integer an offset for the query
cruzdb/__init__.py
def dataframe(self, table): """ create a pandas dataframe from a table or query Parameters ---------- table : table a table in this database or a query limit: integer an integer limit on the query offset: integer an offset f...
def dataframe(self, table): """ create a pandas dataframe from a table or query Parameters ---------- table : table a table in this database or a query limit: integer an integer limit on the query offset: integer an offset f...
[ "create", "a", "pandas", "dataframe", "from", "a", "table", "or", "query" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L112-L140
[ "def", "dataframe", "(", "self", ",", "table", ")", ":", "from", "pandas", "import", "DataFrame", "if", "isinstance", "(", "table", ",", "six", ".", "string_types", ")", ":", "table", "=", "getattr", "(", "self", ",", "table", ")", "try", ":", "rec", ...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
Genome.load_file
use some of the machinery in pandas to load a file into a table Parameters ---------- fname : str filename or filehandle to load table : str table to load the file to sep : str CSV separator bins : bool add a "bin" colu...
cruzdb/__init__.py
def load_file(self, fname, table=None, sep="\t", bins=False, indexes=None): """ use some of the machinery in pandas to load a file into a table Parameters ---------- fname : str filename or filehandle to load table : str table to load the file t...
def load_file(self, fname, table=None, sep="\t", bins=False, indexes=None): """ use some of the machinery in pandas to load a file into a table Parameters ---------- fname : str filename or filehandle to load table : str table to load the file t...
[ "use", "some", "of", "the", "machinery", "in", "pandas", "to", "load", "a", "file", "into", "a", "table" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L146-L228
[ "def", "load_file", "(", "self", ",", "fname", ",", "table", "=", "None", ",", "sep", "=", "\"\\t\"", ",", "bins", "=", "False", ",", "indexes", "=", "None", ")", ":", "convs", "=", "{", "\"#chr\"", ":", "\"chrom\"", ",", "\"start\"", ":", "\"txStart...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
Genome.david_go
open a web-browser to the DAVID online enrichment tool Parameters ---------- refseq_list : list list of refseq names to check for enrichment annot : list iterable of DAVID annotations to check for enrichment
cruzdb/__init__.py
def david_go(refseq_list, annot=('SP_PIR_KEYWORDS', 'GOTERM_BP_FAT', 'GOTERM_CC_FAT', 'GOTERM_MF_FAT')): """ open a web-browser to the DAVID online enrichment tool Parameters ---------- refseq_list : list list of refseq names ...
def david_go(refseq_list, annot=('SP_PIR_KEYWORDS', 'GOTERM_BP_FAT', 'GOTERM_CC_FAT', 'GOTERM_MF_FAT')): """ open a web-browser to the DAVID online enrichment tool Parameters ---------- refseq_list : list list of refseq names ...
[ "open", "a", "web", "-", "browser", "to", "the", "DAVID", "online", "enrichment", "tool" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L231-L248
[ "def", "david_go", "(", "refseq_list", ",", "annot", "=", "(", "'SP_PIR_KEYWORDS'", ",", "'GOTERM_BP_FAT'", ",", "'GOTERM_CC_FAT'", ",", "'GOTERM_MF_FAT'", ")", ")", ":", "URL", "=", "\"http://david.abcc.ncifcrf.gov/api.jsp?type=REFSEQ_MRNA&ids=%s&tool=term2term&annot=\"", ...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
Genome.bin_query
perform an efficient spatial query using the bin column if available. The possible bins are calculated from the `start` and `end` sent to this function. Parameters ---------- table : str or table table to query chrom : str chromosome for the query...
cruzdb/__init__.py
def bin_query(self, table, chrom, start, end): """ perform an efficient spatial query using the bin column if available. The possible bins are calculated from the `start` and `end` sent to this function. Parameters ---------- table : str or table tabl...
def bin_query(self, table, chrom, start, end): """ perform an efficient spatial query using the bin column if available. The possible bins are calculated from the `start` and `end` sent to this function. Parameters ---------- table : str or table tabl...
[ "perform", "an", "efficient", "spatial", "query", "using", "the", "bin", "column", "if", "available", ".", "The", "possible", "bins", "are", "calculated", "from", "the", "start", "and", "end", "sent", "to", "this", "function", "." ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L250-L289
[ "def", "bin_query", "(", "self", ",", "table", ",", "chrom", ",", "start", ",", "end", ")", ":", "if", "isinstance", "(", "table", ",", "six", ".", "string_types", ")", ":", "table", "=", "getattr", "(", "self", ",", "table", ")", "try", ":", "tbl"...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
Genome.upstream
Return k-nearest upstream features Parameters ---------- table : str or table table against which to query chrom_or_feat : str or feat either a chromosome, e.g. 'chr3' or a feature with .chrom, .start, .end attributes start : int ...
cruzdb/__init__.py
def upstream(self, table, chrom_or_feat, start=None, end=None, k=1): """ Return k-nearest upstream features Parameters ---------- table : str or table table against which to query chrom_or_feat : str or feat either a chromosome, e.g. 'chr3' or a...
def upstream(self, table, chrom_or_feat, start=None, end=None, k=1): """ Return k-nearest upstream features Parameters ---------- table : str or table table against which to query chrom_or_feat : str or feat either a chromosome, e.g. 'chr3' or a...
[ "Return", "k", "-", "nearest", "upstream", "features" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L291-L321
[ "def", "upstream", "(", "self", ",", "table", ",", "chrom_or_feat", ",", "start", "=", "None", ",", "end", "=", "None", ",", "k", "=", "1", ")", ":", "res", "=", "self", ".", "knearest", "(", "table", ",", "chrom_or_feat", ",", "start", ",", "end",...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
Genome.knearest
Return k-nearest features Parameters ---------- table : str or table table against which to query chrom_or_feat : str or feat either a chromosome, e.g. 'chr3' or a feature with .chrom, .start, .end attributes start : int if `chr...
cruzdb/__init__.py
def knearest(self, table, chrom_or_feat, start=None, end=None, k=1, _direction=None): """ Return k-nearest features Parameters ---------- table : str or table table against which to query chrom_or_feat : str or feat either a chromoso...
def knearest(self, table, chrom_or_feat, start=None, end=None, k=1, _direction=None): """ Return k-nearest features Parameters ---------- table : str or table table against which to query chrom_or_feat : str or feat either a chromoso...
[ "Return", "k", "-", "nearest", "features" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L355-L441
[ "def", "knearest", "(", "self", ",", "table", ",", "chrom_or_feat", ",", "start", "=", "None", ",", "end", "=", "None", ",", "k", "=", "1", ",", "_direction", "=", "None", ")", ":", "assert", "_direction", "in", "(", "None", ",", "\"up\"", ",", "\"...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
Genome.annotate
annotate a file with a number of tables Parameters ---------- fname : str or file file name or file-handle tables : list list of tables with which to annotate `fname` feature_strand : bool if this is True, then the up/downstream designations...
cruzdb/__init__.py
def annotate(self, fname, tables, feature_strand=False, in_memory=False, header=None, out=sys.stdout, parallel=False): """ annotate a file with a number of tables Parameters ---------- fname : str or file file name or file-handle tables : list ...
def annotate(self, fname, tables, feature_strand=False, in_memory=False, header=None, out=sys.stdout, parallel=False): """ annotate a file with a number of tables Parameters ---------- fname : str or file file name or file-handle tables : list ...
[ "annotate", "a", "file", "with", "a", "number", "of", "tables" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L449-L484
[ "def", "annotate", "(", "self", ",", "fname", ",", "tables", ",", "feature_strand", "=", "False", ",", "in_memory", "=", "False", ",", "header", "=", "None", ",", "out", "=", "sys", ".", "stdout", ",", "parallel", "=", "False", ")", ":", "from", ".",...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
Genome.bins
Get all the bin numbers for a particular interval defined by (start, end]
cruzdb/__init__.py
def bins(start, end): """ Get all the bin numbers for a particular interval defined by (start, end] """ if end - start < 536870912: offsets = [585, 73, 9, 1] else: raise BigException offsets = [4681, 585, 73, 9, 1] binFirstShift...
def bins(start, end): """ Get all the bin numbers for a particular interval defined by (start, end] """ if end - start < 536870912: offsets = [585, 73, 9, 1] else: raise BigException offsets = [4681, 585, 73, 9, 1] binFirstShift...
[ "Get", "all", "the", "bin", "numbers", "for", "a", "particular", "interval", "defined", "by", "(", "start", "end", "]" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L487-L508
[ "def", "bins", "(", "start", ",", "end", ")", ":", "if", "end", "-", "start", "<", "536870912", ":", "offsets", "=", "[", "585", ",", "73", ",", "9", ",", "1", "]", "else", ":", "raise", "BigException", "offsets", "=", "[", "4681", ",", "585", ...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
Genome.save_bed
write a bed12 file of the query. Parameters ---------- query : query a table or query to save to file filename : file string or filehandle to write output
cruzdb/__init__.py
def save_bed(cls, query, filename=sys.stdout): """ write a bed12 file of the query. Parameters ---------- query : query a table or query to save to file filename : file string or filehandle to write output """ out = _open(filename...
def save_bed(cls, query, filename=sys.stdout): """ write a bed12 file of the query. Parameters ---------- query : query a table or query to save to file filename : file string or filehandle to write output """ out = _open(filename...
[ "write", "a", "bed12", "file", "of", "the", "query", ".", "Parameters", "----------" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L514-L528
[ "def", "save_bed", "(", "cls", ",", "query", ",", "filename", "=", "sys", ".", "stdout", ")", ":", "out", "=", "_open", "(", "filename", ",", "'w'", ")", "for", "o", "in", "query", ":", "out", ".", "write", "(", "o", ".", "bed", "(", ")", "+", ...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
staticfile_node
For example: {% staticfile "/js/foo.js" %} or {% staticfile "/js/foo.js" as variable_name %} Or for multiples: {% staticfile "/foo.js; /bar.js" %} or {% staticfile "/foo.js; /bar.js" as variable_name %}
django_static/templatetags/django_static.py
def staticfile_node(parser, token, optimize_if_possible=False): """For example: {% staticfile "/js/foo.js" %} or {% staticfile "/js/foo.js" as variable_name %} Or for multiples: {% staticfile "/foo.js; /bar.js" %} or {% staticfile "/foo.js; /bar.js" as varia...
def staticfile_node(parser, token, optimize_if_possible=False): """For example: {% staticfile "/js/foo.js" %} or {% staticfile "/js/foo.js" as variable_name %} Or for multiples: {% staticfile "/foo.js; /bar.js" %} or {% staticfile "/foo.js; /bar.js" as varia...
[ "For", "example", ":", "{", "%", "staticfile", "/", "js", "/", "foo", ".", "js", "%", "}", "or", "{", "%", "staticfile", "/", "js", "/", "foo", ".", "js", "as", "variable_name", "%", "}", "Or", "for", "multiples", ":", "{", "%", "staticfile", "/"...
peterbe/django-static
python
https://github.com/peterbe/django-static/blob/05c0d2f302274b9d3f7df6ad92bd861889316ebd/django_static/templatetags/django_static.py#L185-L209
[ "def", "staticfile_node", "(", "parser", ",", "token", ",", "optimize_if_possible", "=", "False", ")", ":", "args", "=", "token", ".", "split_contents", "(", ")", "tag", "=", "args", "[", "0", "]", "if", "len", "(", "args", ")", "==", "4", "and", "ar...
05c0d2f302274b9d3f7df6ad92bd861889316ebd
train
_mkdir
works the way a good mkdir should :) - already exists, silently complete - regular file in the way, raise an exception - parent directory(ies) does not exist, make them as well
django_static/templatetags/django_static.py
def _mkdir(newdir): """works the way a good mkdir should :) - already exists, silently complete - regular file in the way, raise an exception - parent directory(ies) does not exist, make them as well """ if os.path.isdir(newdir): pass elif os.path.isfile(newdir): ...
def _mkdir(newdir): """works the way a good mkdir should :) - already exists, silently complete - regular file in the way, raise an exception - parent directory(ies) does not exist, make them as well """ if os.path.isdir(newdir): pass elif os.path.isfile(newdir): ...
[ "works", "the", "way", "a", "good", "mkdir", "should", ":", ")", "-", "already", "exists", "silently", "complete", "-", "regular", "file", "in", "the", "way", "raise", "an", "exception", "-", "parent", "directory", "(", "ies", ")", "does", "not", "exist"...
peterbe/django-static
python
https://github.com/peterbe/django-static/blob/05c0d2f302274b9d3f7df6ad92bd861889316ebd/django_static/templatetags/django_static.py#L641-L657
[ "def", "_mkdir", "(", "newdir", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "newdir", ")", ":", "pass", "elif", "os", ".", "path", ".", "isfile", "(", "newdir", ")", ":", "raise", "OSError", "(", "\"a file with the same name as the desired \"", ...
05c0d2f302274b9d3f7df6ad92bd861889316ebd
train
_find_filepath_in_roots
Look for filename in all MEDIA_ROOTS, and return the first one found.
django_static/templatetags/django_static.py
def _find_filepath_in_roots(filename): """Look for filename in all MEDIA_ROOTS, and return the first one found.""" for root in settings.DJANGO_STATIC_MEDIA_ROOTS: filepath = _filename2filepath(filename, root) if os.path.isfile(filepath): return filepath, root # havent found it in...
def _find_filepath_in_roots(filename): """Look for filename in all MEDIA_ROOTS, and return the first one found.""" for root in settings.DJANGO_STATIC_MEDIA_ROOTS: filepath = _filename2filepath(filename, root) if os.path.isfile(filepath): return filepath, root # havent found it in...
[ "Look", "for", "filename", "in", "all", "MEDIA_ROOTS", "and", "return", "the", "first", "one", "found", "." ]
peterbe/django-static
python
https://github.com/peterbe/django-static/blob/05c0d2f302274b9d3f7df6ad92bd861889316ebd/django_static/templatetags/django_static.py#L660-L677
[ "def", "_find_filepath_in_roots", "(", "filename", ")", ":", "for", "root", "in", "settings", ".", "DJANGO_STATIC_MEDIA_ROOTS", ":", "filepath", "=", "_filename2filepath", "(", "filename", ",", "root", ")", "if", "os", ".", "path", ".", "isfile", "(", "filepat...
05c0d2f302274b9d3f7df6ad92bd861889316ebd
train
default_combine_filenames_generator
Return a new filename to use as the combined file name for a bunch of files. A precondition is that they all have the same file extension Given that the list of files can have different paths, we aim to use the most common path. Example: /somewhere/else/foo.js /somewhere/bar.js /...
django_static/templatetags/django_static.py
def default_combine_filenames_generator(filenames, max_length=40): """Return a new filename to use as the combined file name for a bunch of files. A precondition is that they all have the same file extension Given that the list of files can have different paths, we aim to use the most common path. ...
def default_combine_filenames_generator(filenames, max_length=40): """Return a new filename to use as the combined file name for a bunch of files. A precondition is that they all have the same file extension Given that the list of files can have different paths, we aim to use the most common path. ...
[ "Return", "a", "new", "filename", "to", "use", "as", "the", "combined", "file", "name", "for", "a", "bunch", "of", "files", ".", "A", "precondition", "is", "that", "they", "all", "have", "the", "same", "file", "extension" ]
peterbe/django-static
python
https://github.com/peterbe/django-static/blob/05c0d2f302274b9d3f7df6ad92bd861889316ebd/django_static/templatetags/django_static.py#L695-L745
[ "def", "default_combine_filenames_generator", "(", "filenames", ",", "max_length", "=", "40", ")", ":", "path", "=", "None", "names", "=", "[", "]", "extension", "=", "None", "timestamps", "=", "[", "]", "for", "filename", "in", "filenames", ":", "name", "...
05c0d2f302274b9d3f7df6ad92bd861889316ebd
train
StaticFilesNode.render
inspect the code and look for files that can be turned into combos. Basically, the developer could type this: {% slimall %} <link href="/one.css"/> <link href="/two.css"/> {% endslimall %} And it should be reconsidered like this: <link href="{% slimfile "/on...
django_static/templatetags/django_static.py
def render(self, context): """inspect the code and look for files that can be turned into combos. Basically, the developer could type this: {% slimall %} <link href="/one.css"/> <link href="/two.css"/> {% endslimall %} And it should be reconsidered like this: ...
def render(self, context): """inspect the code and look for files that can be turned into combos. Basically, the developer could type this: {% slimall %} <link href="/one.css"/> <link href="/two.css"/> {% endslimall %} And it should be reconsidered like this: ...
[ "inspect", "the", "code", "and", "look", "for", "files", "that", "can", "be", "turned", "into", "combos", ".", "Basically", "the", "developer", "could", "type", "this", ":", "{", "%", "slimall", "%", "}", "<link", "href", "=", "/", "one", ".", "css", ...
peterbe/django-static
python
https://github.com/peterbe/django-static/blob/05c0d2f302274b9d3f7df6ad92bd861889316ebd/django_static/templatetags/django_static.py#L276-L385
[ "def", "render", "(", "self", ",", "context", ")", ":", "code", "=", "self", ".", "nodelist", ".", "render", "(", "context", ")", "if", "not", "settings", ".", "DJANGO_STATIC", ":", "# Append MEDIA_URL if set", "# quick and dirty", "if", "settings", ".", "DJ...
05c0d2f302274b9d3f7df6ad92bd861889316ebd
train
Interval.overlaps
check for overlap with the other interval
cruzdb/models.py
def overlaps(self, other): """ check for overlap with the other interval """ if self.chrom != other.chrom: return False if self.start >= other.end: return False if other.start >= self.end: return False return True
def overlaps(self, other): """ check for overlap with the other interval """ if self.chrom != other.chrom: return False if self.start >= other.end: return False if other.start >= self.end: return False return True
[ "check", "for", "overlap", "with", "the", "other", "interval" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L81-L88
[ "def", "overlaps", "(", "self", ",", "other", ")", ":", "if", "self", ".", "chrom", "!=", "other", ".", "chrom", ":", "return", "False", "if", "self", ".", "start", ">=", "other", ".", "end", ":", "return", "False", "if", "other", ".", "start", ">=...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
Interval.is_upstream_of
check if this is upstream of the `other` interval taking the strand of the other interval into account
cruzdb/models.py
def is_upstream_of(self, other): """ check if this is upstream of the `other` interval taking the strand of the other interval into account """ if self.chrom != other.chrom: return None if getattr(other, "strand", None) == "+": return self.end <= other.start ...
def is_upstream_of(self, other): """ check if this is upstream of the `other` interval taking the strand of the other interval into account """ if self.chrom != other.chrom: return None if getattr(other, "strand", None) == "+": return self.end <= other.start ...
[ "check", "if", "this", "is", "upstream", "of", "the", "other", "interval", "taking", "the", "strand", "of", "the", "other", "interval", "into", "account" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L90-L99
[ "def", "is_upstream_of", "(", "self", ",", "other", ")", ":", "if", "self", ".", "chrom", "!=", "other", ".", "chrom", ":", "return", "None", "if", "getattr", "(", "other", ",", "\"strand\"", ",", "None", ")", "==", "\"+\"", ":", "return", "self", "....
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
Interval.distance
check the distance between this an another interval Parameters ---------- other_or_start : Interval or int either an integer or an Interval with a start attribute indicating the start of the interval end : int if `other_or_start` is an integer, this ...
cruzdb/models.py
def distance(self, other_or_start=None, end=None, features=False): """ check the distance between this an another interval Parameters ---------- other_or_start : Interval or int either an integer or an Interval with a start attribute indicating the start ...
def distance(self, other_or_start=None, end=None, features=False): """ check the distance between this an another interval Parameters ---------- other_or_start : Interval or int either an integer or an Interval with a start attribute indicating the start ...
[ "check", "the", "distance", "between", "this", "an", "another", "interval", "Parameters", "----------" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L101-L128
[ "def", "distance", "(", "self", ",", "other_or_start", "=", "None", ",", "end", "=", "None", ",", "features", "=", "False", ")", ":", "if", "end", "is", "None", ":", "assert", "other_or_start", ".", "chrom", "==", "self", ".", "chrom", "other_start", "...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
ABase.exons
return a list of exons [(start, stop)] for this object if appropriate
cruzdb/models.py
def exons(self): """ return a list of exons [(start, stop)] for this object if appropriate """ # drop the trailing comma if not self.is_gene_pred: return [] if hasattr(self, "exonStarts"): try: starts = (long(s) for s in self.exonStarts[:-1].sp...
def exons(self): """ return a list of exons [(start, stop)] for this object if appropriate """ # drop the trailing comma if not self.is_gene_pred: return [] if hasattr(self, "exonStarts"): try: starts = (long(s) for s in self.exonStarts[:-1].sp...
[ "return", "a", "list", "of", "exons", "[", "(", "start", "stop", ")", "]", "for", "this", "object", "if", "appropriate" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L160-L180
[ "def", "exons", "(", "self", ")", ":", "# drop the trailing comma", "if", "not", "self", ".", "is_gene_pred", ":", "return", "[", "]", "if", "hasattr", "(", "self", ",", "\"exonStarts\"", ")", ":", "try", ":", "starts", "=", "(", "long", "(", "s", ")",...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
ABase.gene_features
return a list of features for the gene features of this object. This would include exons, introns, utrs, etc.
cruzdb/models.py
def gene_features(self): """ return a list of features for the gene features of this object. This would include exons, introns, utrs, etc. """ nm, strand = self.gene_name, self.strand feats = [(self.chrom, self.start, self.end, nm, strand, 'gene')] for feat in ('i...
def gene_features(self): """ return a list of features for the gene features of this object. This would include exons, introns, utrs, etc. """ nm, strand = self.gene_name, self.strand feats = [(self.chrom, self.start, self.end, nm, strand, 'gene')] for feat in ('i...
[ "return", "a", "list", "of", "features", "for", "the", "gene", "features", "of", "this", "object", ".", "This", "would", "include", "exons", "introns", "utrs", "etc", "." ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L183-L203
[ "def", "gene_features", "(", "self", ")", ":", "nm", ",", "strand", "=", "self", ".", "gene_name", ",", "self", ".", "strand", "feats", "=", "[", "(", "self", ".", "chrom", ",", "self", ".", "start", ",", "self", ".", "end", ",", "nm", ",", "stra...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
ABase.tss
Return a start, end tuple of positions around the transcription-start site Parameters ---------- up : int if greature than 0, the strand is used to add this many upstream bases in the appropriate direction down : int if greature than 0, the str...
cruzdb/models.py
def tss(self, up=0, down=0): """ Return a start, end tuple of positions around the transcription-start site Parameters ---------- up : int if greature than 0, the strand is used to add this many upstream bases in the appropriate direction ...
def tss(self, up=0, down=0): """ Return a start, end tuple of positions around the transcription-start site Parameters ---------- up : int if greature than 0, the strand is used to add this many upstream bases in the appropriate direction ...
[ "Return", "a", "start", "end", "tuple", "of", "positions", "around", "the", "transcription", "-", "start", "site" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L205-L231
[ "def", "tss", "(", "self", ",", "up", "=", "0", ",", "down", "=", "0", ")", ":", "if", "not", "self", ".", "is_gene_pred", ":", "return", "None", "tss", "=", "self", ".", "txEnd", "if", "self", ".", "strand", "==", "'-'", "else", "self", ".", "...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
ABase.promoter
Return a start, end tuple of positions for the promoter region of this gene Parameters ---------- up : int this distance upstream that is considered the promoter down : int the strand is used to add this many downstream bases into the gene.
cruzdb/models.py
def promoter(self, up=2000, down=0): """ Return a start, end tuple of positions for the promoter region of this gene Parameters ---------- up : int this distance upstream that is considered the promoter down : int the strand is used to add...
def promoter(self, up=2000, down=0): """ Return a start, end tuple of positions for the promoter region of this gene Parameters ---------- up : int this distance upstream that is considered the promoter down : int the strand is used to add...
[ "Return", "a", "start", "end", "tuple", "of", "positions", "for", "the", "promoter", "region", "of", "this", "gene" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L233-L248
[ "def", "promoter", "(", "self", ",", "up", "=", "2000", ",", "down", "=", "0", ")", ":", "if", "not", "self", ".", "is_gene_pred", ":", "return", "None", "return", "self", ".", "tss", "(", "up", "=", "up", ",", "down", "=", "down", ")" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
ABase.coding_exons
includes the entire exon as long as any of it is > cdsStart and < cdsEnd
cruzdb/models.py
def coding_exons(self): """ includes the entire exon as long as any of it is > cdsStart and < cdsEnd """ # drop the trailing comma starts = (long(s) for s in self.exonStarts[:-1].split(",")) ends = (long(s) for s in self.exonEnds[:-1].split(",")) return [(...
def coding_exons(self): """ includes the entire exon as long as any of it is > cdsStart and < cdsEnd """ # drop the trailing comma starts = (long(s) for s in self.exonStarts[:-1].split(",")) ends = (long(s) for s in self.exonEnds[:-1].split(",")) return [(...
[ "includes", "the", "entire", "exon", "as", "long", "as", "any", "of", "it", "is", ">", "cdsStart", "and", "<", "cdsEnd" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L251-L261
[ "def", "coding_exons", "(", "self", ")", ":", "# drop the trailing comma", "starts", "=", "(", "long", "(", "s", ")", "for", "s", "in", "self", ".", "exonStarts", "[", ":", "-", "1", "]", ".", "split", "(", "\",\"", ")", ")", "ends", "=", "(", "lon...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
ABase.cds
just the parts of the exons that are translated
cruzdb/models.py
def cds(self): """just the parts of the exons that are translated""" ces = self.coding_exons if len(ces) < 1: return ces ces[0] = (self.cdsStart, ces[0][1]) ces[-1] = (ces[-1][0], self.cdsEnd) assert all((s < e for s, e in ces)) return ces
def cds(self): """just the parts of the exons that are translated""" ces = self.coding_exons if len(ces) < 1: return ces ces[0] = (self.cdsStart, ces[0][1]) ces[-1] = (ces[-1][0], self.cdsEnd) assert all((s < e for s, e in ces)) return ces
[ "just", "the", "parts", "of", "the", "exons", "that", "are", "translated" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L264-L271
[ "def", "cds", "(", "self", ")", ":", "ces", "=", "self", ".", "coding_exons", "if", "len", "(", "ces", ")", "<", "1", ":", "return", "ces", "ces", "[", "0", "]", "=", "(", "self", ".", "cdsStart", ",", "ces", "[", "0", "]", "[", "1", "]", "...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
ABase.is_downstream_of
return a boolean indicating whether this feature is downstream of `other` taking the strand of other into account
cruzdb/models.py
def is_downstream_of(self, other): """ return a boolean indicating whether this feature is downstream of `other` taking the strand of other into account """ if self.chrom != other.chrom: return None if getattr(other, "strand", None) == "-": # other feature is ...
def is_downstream_of(self, other): """ return a boolean indicating whether this feature is downstream of `other` taking the strand of other into account """ if self.chrom != other.chrom: return None if getattr(other, "strand", None) == "-": # other feature is ...
[ "return", "a", "boolean", "indicating", "whether", "this", "feature", "is", "downstream", "of", "other", "taking", "the", "strand", "of", "other", "into", "account" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L348-L357
[ "def", "is_downstream_of", "(", "self", ",", "other", ")", ":", "if", "self", ".", "chrom", "!=", "other", ".", "chrom", ":", "return", "None", "if", "getattr", "(", "other", ",", "\"strand\"", ",", "None", ")", "==", "\"-\"", ":", "# other feature is on...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
ABase.features
return e.g. "intron;exon" if the other_start, end overlap introns and exons
cruzdb/models.py
def features(self, other_start, other_end): """ return e.g. "intron;exon" if the other_start, end overlap introns and exons """ # completely encases gene. if other_start <= self.start and other_end >= self.end: return ['gene' if self.cdsStart != self.cdsEnd el...
def features(self, other_start, other_end): """ return e.g. "intron;exon" if the other_start, end overlap introns and exons """ # completely encases gene. if other_start <= self.start and other_end >= self.end: return ['gene' if self.cdsStart != self.cdsEnd el...
[ "return", "e", ".", "g", ".", "intron", ";", "exon", "if", "the", "other_start", "end", "overlap", "introns", "and", "exons" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L359-L382
[ "def", "features", "(", "self", ",", "other_start", ",", "other_end", ")", ":", "# completely encases gene.", "if", "other_start", "<=", "self", ".", "start", "and", "other_end", ">=", "self", ".", "end", ":", "return", "[", "'gene'", "if", "self", ".", "c...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
ABase.upstream
return the (start, end) of the region before the geneStart
cruzdb/models.py
def upstream(self, distance): """ return the (start, end) of the region before the geneStart """ if getattr(self, "strand", None) == "+": e = self.start s = e - distance else: s = self.end e = s + distance return self._xstre...
def upstream(self, distance): """ return the (start, end) of the region before the geneStart """ if getattr(self, "strand", None) == "+": e = self.start s = e - distance else: s = self.end e = s + distance return self._xstre...
[ "return", "the", "(", "start", "end", ")", "of", "the", "region", "before", "the", "geneStart" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L414-L424
[ "def", "upstream", "(", "self", ",", "distance", ")", ":", "if", "getattr", "(", "self", ",", "\"strand\"", ",", "None", ")", "==", "\"+\"", ":", "e", "=", "self", ".", "start", "s", "=", "e", "-", "distance", "else", ":", "s", "=", "self", ".", ...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
ABase.utr5
return the 5' UTR if appropriate
cruzdb/models.py
def utr5(self): """ return the 5' UTR if appropriate """ if not self.is_coding or len(self.exons) < 2: return (None, None) if self.strand == "+": s, e = (self.txStart, self.cdsStart) else: s, e = (self.cdsEnd, self.txEnd) if s == e: return ...
def utr5(self): """ return the 5' UTR if appropriate """ if not self.is_coding or len(self.exons) < 2: return (None, None) if self.strand == "+": s, e = (self.txStart, self.cdsStart) else: s, e = (self.cdsEnd, self.txEnd) if s == e: return ...
[ "return", "the", "5", "UTR", "if", "appropriate" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L439-L449
[ "def", "utr5", "(", "self", ")", ":", "if", "not", "self", ".", "is_coding", "or", "len", "(", "self", ".", "exons", ")", "<", "2", ":", "return", "(", "None", ",", "None", ")", "if", "self", ".", "strand", "==", "\"+\"", ":", "s", ",", "e", ...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
ABase.sequence
Return the sequence for this feature. if per-exon is True, return an array of exon sequences This sequence is never reverse complemented
cruzdb/models.py
def sequence(self, per_exon=False): """ Return the sequence for this feature. if per-exon is True, return an array of exon sequences This sequence is never reverse complemented """ db = self.db if not per_exon: start = self.txStart + 1 retu...
def sequence(self, per_exon=False): """ Return the sequence for this feature. if per-exon is True, return an array of exon sequences This sequence is never reverse complemented """ db = self.db if not per_exon: start = self.txStart + 1 retu...
[ "Return", "the", "sequence", "for", "this", "feature", ".", "if", "per", "-", "exon", "is", "True", "return", "an", "array", "of", "exon", "sequences", "This", "sequence", "is", "never", "reverse", "complemented" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L527-L542
[ "def", "sequence", "(", "self", ",", "per_exon", "=", "False", ")", ":", "db", "=", "self", ".", "db", "if", "not", "per_exon", ":", "start", "=", "self", ".", "txStart", "+", "1", "return", "_sequence", "(", "db", ",", "self", ".", "chrom", ",", ...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
ABase.ncbi_blast
perform an NCBI blast against the sequence of this feature
cruzdb/models.py
def ncbi_blast(self, db="nr", megablast=True, sequence=None): """ perform an NCBI blast against the sequence of this feature """ import requests requests.defaults.max_retries = 4 assert sequence in (None, "cds", "mrna") seq = self.sequence() if sequence is None el...
def ncbi_blast(self, db="nr", megablast=True, sequence=None): """ perform an NCBI blast against the sequence of this feature """ import requests requests.defaults.max_retries = 4 assert sequence in (None, "cds", "mrna") seq = self.sequence() if sequence is None el...
[ "perform", "an", "NCBI", "blast", "against", "the", "sequence", "of", "this", "feature" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L548-L591
[ "def", "ncbi_blast", "(", "self", ",", "db", "=", "\"nr\"", ",", "megablast", "=", "True", ",", "sequence", "=", "None", ")", ":", "import", "requests", "requests", ".", "defaults", ".", "max_retries", "=", "4", "assert", "sequence", "in", "(", "None", ...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
ABase.blat
make a request to the genome-browsers BLAT interface sequence is one of None, "mrna", "cds" returns a list of features that are hits to this sequence.
cruzdb/models.py
def blat(self, db=None, sequence=None, seq_type="DNA"): """ make a request to the genome-browsers BLAT interface sequence is one of None, "mrna", "cds" returns a list of features that are hits to this sequence. """ from . blat_blast import blat, blat_all assert se...
def blat(self, db=None, sequence=None, seq_type="DNA"): """ make a request to the genome-browsers BLAT interface sequence is one of None, "mrna", "cds" returns a list of features that are hits to this sequence. """ from . blat_blast import blat, blat_all assert se...
[ "make", "a", "request", "to", "the", "genome", "-", "browsers", "BLAT", "interface", "sequence", "is", "one", "of", "None", "mrna", "cds", "returns", "a", "list", "of", "features", "that", "are", "hits", "to", "this", "sequence", "." ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L593-L605
[ "def", "blat", "(", "self", ",", "db", "=", "None", ",", "sequence", "=", "None", ",", "seq_type", "=", "\"DNA\"", ")", ":", "from", ".", "blat_blast", "import", "blat", ",", "blat_all", "assert", "sequence", "in", "(", "None", ",", "\"cds\"", ",", "...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
ABase.bed
return a bed formatted string of this feature
cruzdb/models.py
def bed(self, *attrs, **kwargs): """ return a bed formatted string of this feature """ exclude = ("chrom", "start", "end", "txStart", "txEnd", "chromStart", "chromEnd") if self.is_gene_pred: return self.bed12(**kwargs) return "\t".join(map(str,...
def bed(self, *attrs, **kwargs): """ return a bed formatted string of this feature """ exclude = ("chrom", "start", "end", "txStart", "txEnd", "chromStart", "chromEnd") if self.is_gene_pred: return self.bed12(**kwargs) return "\t".join(map(str,...
[ "return", "a", "bed", "formatted", "string", "of", "this", "feature" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L614-L625
[ "def", "bed", "(", "self", ",", "*", "attrs", ",", "*", "*", "kwargs", ")", ":", "exclude", "=", "(", "\"chrom\"", ",", "\"start\"", ",", "\"end\"", ",", "\"txStart\"", ",", "\"txEnd\"", ",", "\"chromStart\"", ",", "\"chromEnd\"", ")", "if", "self", "....
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
ABase.bed12
return a bed12 (http://genome.ucsc.edu/FAQ/FAQformat.html#format1) representation of this interval
cruzdb/models.py
def bed12(self, score="0", rgb="."): """ return a bed12 (http://genome.ucsc.edu/FAQ/FAQformat.html#format1) representation of this interval """ if not self.is_gene_pred: raise CruzException("can't create bed12 from non genepred feature") exons = list(self.exon...
def bed12(self, score="0", rgb="."): """ return a bed12 (http://genome.ucsc.edu/FAQ/FAQformat.html#format1) representation of this interval """ if not self.is_gene_pred: raise CruzException("can't create bed12 from non genepred feature") exons = list(self.exon...
[ "return", "a", "bed12", "(", "http", ":", "//", "genome", ".", "ucsc", ".", "edu", "/", "FAQ", "/", "FAQformat", ".", "html#format1", ")", "representation", "of", "this", "interval" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L628-L644
[ "def", "bed12", "(", "self", ",", "score", "=", "\"0\"", ",", "rgb", "=", "\".\"", ")", ":", "if", "not", "self", ".", "is_gene_pred", ":", "raise", "CruzException", "(", "\"can't create bed12 from non genepred feature\"", ")", "exons", "=", "list", "(", "se...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
ABase.localize
convert global coordinate(s) to local taking introns into account and cds/tx-Start depending on cdna=True kwarg
cruzdb/models.py
def localize(self, *positions, **kwargs): """ convert global coordinate(s) to local taking introns into account and cds/tx-Start depending on cdna=True kwarg """ cdna = kwargs.get('cdna', False) # TODO: account for strand ?? add kwarg ?? # if it's to the CDNA, the...
def localize(self, *positions, **kwargs): """ convert global coordinate(s) to local taking introns into account and cds/tx-Start depending on cdna=True kwarg """ cdna = kwargs.get('cdna', False) # TODO: account for strand ?? add kwarg ?? # if it's to the CDNA, the...
[ "convert", "global", "coordinate", "(", "s", ")", "to", "local", "taking", "introns", "into", "account", "and", "cds", "/", "tx", "-", "Start", "depending", "on", "cdna", "=", "True", "kwarg" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L665-L709
[ "def", "localize", "(", "self", ",", "*", "positions", ",", "*", "*", "kwargs", ")", ":", "cdna", "=", "kwargs", ".", "get", "(", "'cdna'", ",", "False", ")", "# TODO: account for strand ?? add kwarg ??", "# if it's to the CDNA, then it's based on the cdsStart", "st...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
cpgIslandExt.distance
check the distance between this an another interval Parameters ---------- other_or_start : Interval or int either an integer or an Interval with a start attribute indicating the start of the interval end : int if `other_or_start` is an integer, this ...
cruzdb/models.py
def distance(self, other_or_start=None, end=None, features="unused", shore_dist=3000): """ check the distance between this an another interval Parameters ---------- other_or_start : Interval or int either an integer or an Interval with a start attribute i...
def distance(self, other_or_start=None, end=None, features="unused", shore_dist=3000): """ check the distance between this an another interval Parameters ---------- other_or_start : Interval or int either an integer or an Interval with a start attribute i...
[ "check", "the", "distance", "between", "this", "an", "another", "interval", "Parameters", "----------" ]
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L725-L758
[ "def", "distance", "(", "self", ",", "other_or_start", "=", "None", ",", "end", "=", "None", ",", "features", "=", "\"unused\"", ",", "shore_dist", "=", "3000", ")", ":", "# leave features kwarg to match signature from Feature.distance", "if", "end", "is", "None",...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
annotate
annotate bed file in fname with tables. distances are integers for distance. and intron/exon/utr5 etc for gene-pred tables. if the annotation features have a strand, the distance reported is negative if the annotation feature is upstream of the feature in question if feature_strand is True, then the dis...
cruzdb/annotate.py
def annotate(g, fname, tables, feature_strand=False, in_memory=False, header=None, out=sys.stdout, _chrom=None, parallel=False): """ annotate bed file in fname with tables. distances are integers for distance. and intron/exon/utr5 etc for gene-pred tables. if the annotation features have a stran...
def annotate(g, fname, tables, feature_strand=False, in_memory=False, header=None, out=sys.stdout, _chrom=None, parallel=False): """ annotate bed file in fname with tables. distances are integers for distance. and intron/exon/utr5 etc for gene-pred tables. if the annotation features have a stran...
[ "annotate", "bed", "file", "in", "fname", "with", "tables", ".", "distances", "are", "integers", "for", "distance", ".", "and", "intron", "/", "exon", "/", "utr5", "etc", "for", "gene", "-", "pred", "tables", ".", "if", "the", "annotation", "features", "...
brentp/cruzdb
python
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/annotate.py#L28-L171
[ "def", "annotate", "(", "g", ",", "fname", ",", "tables", ",", "feature_strand", "=", "False", ",", "in_memory", "=", "False", ",", "header", "=", "None", ",", "out", "=", "sys", ".", "stdout", ",", "_chrom", "=", "None", ",", "parallel", "=", "False...
9068d46e25952f4a929dde0242beb31fa4c7e89a
train
entry_point
External entry point which calls main() and if Stop is raised, calls sys.exit()
omego/main.py
def entry_point(): """ External entry point which calls main() and if Stop is raised, calls sys.exit() """ try: main("omego", items=[ (InstallCommand.NAME, InstallCommand), (UpgradeCommand.NAME, UpgradeCommand), (ConvertCommand.NAME, ConvertCommand), ...
def entry_point(): """ External entry point which calls main() and if Stop is raised, calls sys.exit() """ try: main("omego", items=[ (InstallCommand.NAME, InstallCommand), (UpgradeCommand.NAME, UpgradeCommand), (ConvertCommand.NAME, ConvertCommand), ...
[ "External", "entry", "point", "which", "calls", "main", "()", "and", "if", "Stop", "is", "raised", "calls", "sys", ".", "exit", "()" ]
ome/omego
python
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/main.py#L40-L58
[ "def", "entry_point", "(", ")", ":", "try", ":", "main", "(", "\"omego\"", ",", "items", "=", "[", "(", "InstallCommand", ".", "NAME", ",", "InstallCommand", ")", ",", "(", "UpgradeCommand", ".", "NAME", ",", "UpgradeCommand", ")", ",", "(", "ConvertComm...
2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb
train
open_url
Open a URL using an opener that will simulate a browser user-agent url: The URL httpuser, httppassword: HTTP authentication credentials (either both or neither must be provided) method: The HTTP method Caller is reponsible for calling close() on the returned object
omego/fileutils.py
def open_url(url, httpuser=None, httppassword=None, method=None): """ Open a URL using an opener that will simulate a browser user-agent url: The URL httpuser, httppassword: HTTP authentication credentials (either both or neither must be provided) method: The HTTP method Caller is reponsi...
def open_url(url, httpuser=None, httppassword=None, method=None): """ Open a URL using an opener that will simulate a browser user-agent url: The URL httpuser, httppassword: HTTP authentication credentials (either both or neither must be provided) method: The HTTP method Caller is reponsi...
[ "Open", "a", "URL", "using", "an", "opener", "that", "will", "simulate", "a", "browser", "user", "-", "agent", "url", ":", "The", "URL", "httpuser", "httppassword", ":", "HTTP", "authentication", "credentials", "(", "either", "both", "or", "neither", "must",...
ome/omego
python
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/fileutils.py#L47-L92
[ "def", "open_url", "(", "url", ",", "httpuser", "=", "None", ",", "httppassword", "=", "None", ",", "method", "=", "None", ")", ":", "if", "os", ".", "getenv", "(", "'OMEGO_SSL_NO_VERIFY'", ")", "==", "'1'", ":", "# This needs to come first to override the def...
2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb
train
dereference_url
Makes a HEAD request to find the final destination of a URL after following any redirects
omego/fileutils.py
def dereference_url(url): """ Makes a HEAD request to find the final destination of a URL after following any redirects """ res = open_url(url, method='HEAD') res.close() return res.url
def dereference_url(url): """ Makes a HEAD request to find the final destination of a URL after following any redirects """ res = open_url(url, method='HEAD') res.close() return res.url
[ "Makes", "a", "HEAD", "request", "to", "find", "the", "final", "destination", "of", "a", "URL", "after", "following", "any", "redirects" ]
ome/omego
python
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/fileutils.py#L95-L102
[ "def", "dereference_url", "(", "url", ")", ":", "res", "=", "open_url", "(", "url", ",", "method", "=", "'HEAD'", ")", "res", ".", "close", "(", ")", "return", "res", ".", "url" ]
2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb
train
read
Read the contents of a URL into memory, return
omego/fileutils.py
def read(url, **kwargs): """ Read the contents of a URL into memory, return """ response = open_url(url, **kwargs) try: return response.read() finally: response.close()
def read(url, **kwargs): """ Read the contents of a URL into memory, return """ response = open_url(url, **kwargs) try: return response.read() finally: response.close()
[ "Read", "the", "contents", "of", "a", "URL", "into", "memory", "return" ]
ome/omego
python
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/fileutils.py#L105-L113
[ "def", "read", "(", "url", ",", "*", "*", "kwargs", ")", ":", "response", "=", "open_url", "(", "url", ",", "*", "*", "kwargs", ")", "try", ":", "return", "response", ".", "read", "(", ")", "finally", ":", "response", ".", "close", "(", ")" ]
2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb
train
download
Download a file, optionally printing a simple progress bar url: The URL to download filename: The filename to save to, default is to use the URL basename print_progress: The length of the progress bar, use 0 to disable delete_fail: If True delete the file if the download was not successful, defaul...
omego/fileutils.py
def download(url, filename=None, print_progress=0, delete_fail=True, **kwargs): """ Download a file, optionally printing a simple progress bar url: The URL to download filename: The filename to save to, default is to use the URL basename print_progress: The length of the progress bar, u...
def download(url, filename=None, print_progress=0, delete_fail=True, **kwargs): """ Download a file, optionally printing a simple progress bar url: The URL to download filename: The filename to save to, default is to use the URL basename print_progress: The length of the progress bar, u...
[ "Download", "a", "file", "optionally", "printing", "a", "simple", "progress", "bar", "url", ":", "The", "URL", "to", "download", "filename", ":", "The", "filename", "to", "save", "to", "default", "is", "to", "use", "the", "URL", "basename", "print_progress",...
ome/omego
python
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/fileutils.py#L116-L158
[ "def", "download", "(", "url", ",", "filename", "=", "None", ",", "print_progress", "=", "0", ",", "delete_fail", "=", "True", ",", "*", "*", "kwargs", ")", ":", "blocksize", "=", "1024", "*", "1024", "downloaded", "=", "0", "progress", "=", "None", ...
2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb
train
rename_backup
Append a backup prefix to a file or directory, with an increasing numeric suffix (.N) if a file already exists
omego/fileutils.py
def rename_backup(name, suffix='.bak'): """ Append a backup prefix to a file or directory, with an increasing numeric suffix (.N) if a file already exists """ newname = '%s%s' % (name, suffix) n = 0 while os.path.exists(newname): n += 1 newname = '%s%s.%d' % (name, suffix, n)...
def rename_backup(name, suffix='.bak'): """ Append a backup prefix to a file or directory, with an increasing numeric suffix (.N) if a file already exists """ newname = '%s%s' % (name, suffix) n = 0 while os.path.exists(newname): n += 1 newname = '%s%s.%d' % (name, suffix, n)...
[ "Append", "a", "backup", "prefix", "to", "a", "file", "or", "directory", "with", "an", "increasing", "numeric", "suffix", "(", ".", "N", ")", "if", "a", "file", "already", "exists" ]
ome/omego
python
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/fileutils.py#L161-L173
[ "def", "rename_backup", "(", "name", ",", "suffix", "=", "'.bak'", ")", ":", "newname", "=", "'%s%s'", "%", "(", "name", ",", "suffix", ")", "n", "=", "0", "while", "os", ".", "path", ".", "exists", "(", "newname", ")", ":", "n", "+=", "1", "newn...
2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb
train
timestamp_filename
Return a string of the form [basename-TIMESTAMP.ext] where TIMESTAMP is of the form YYYYMMDD-HHMMSS-MILSEC
omego/fileutils.py
def timestamp_filename(basename, ext=None): """ Return a string of the form [basename-TIMESTAMP.ext] where TIMESTAMP is of the form YYYYMMDD-HHMMSS-MILSEC """ dt = datetime.now().strftime('%Y%m%d-%H%M%S-%f') if ext: return '%s-%s.%s' % (basename, dt, ext) return '%s-%s' % (basename, ...
def timestamp_filename(basename, ext=None): """ Return a string of the form [basename-TIMESTAMP.ext] where TIMESTAMP is of the form YYYYMMDD-HHMMSS-MILSEC """ dt = datetime.now().strftime('%Y%m%d-%H%M%S-%f') if ext: return '%s-%s.%s' % (basename, dt, ext) return '%s-%s' % (basename, ...
[ "Return", "a", "string", "of", "the", "form", "[", "basename", "-", "TIMESTAMP", ".", "ext", "]", "where", "TIMESTAMP", "is", "of", "the", "form", "YYYYMMDD", "-", "HHMMSS", "-", "MILSEC" ]
ome/omego
python
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/fileutils.py#L176-L184
[ "def", "timestamp_filename", "(", "basename", ",", "ext", "=", "None", ")", ":", "dt", "=", "datetime", ".", "now", "(", ")", ".", "strftime", "(", "'%Y%m%d-%H%M%S-%f'", ")", "if", "ext", ":", "return", "'%s-%s.%s'", "%", "(", "basename", ",", "dt", ",...
2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb
train
check_extracted_paths
Check whether zip file paths are all relative, and optionally in a specified subdirectory, raises an exception if not namelist: A list of paths from the zip file subdir: If specified then check whether all paths in the zip file are under this subdirectory Python docs are unclear about the securi...
omego/fileutils.py
def check_extracted_paths(namelist, subdir=None): """ Check whether zip file paths are all relative, and optionally in a specified subdirectory, raises an exception if not namelist: A list of paths from the zip file subdir: If specified then check whether all paths in the zip file are under t...
def check_extracted_paths(namelist, subdir=None): """ Check whether zip file paths are all relative, and optionally in a specified subdirectory, raises an exception if not namelist: A list of paths from the zip file subdir: If specified then check whether all paths in the zip file are under t...
[ "Check", "whether", "zip", "file", "paths", "are", "all", "relative", "and", "optionally", "in", "a", "specified", "subdirectory", "raises", "an", "exception", "if", "not" ]
ome/omego
python
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/fileutils.py#L194-L228
[ "def", "check_extracted_paths", "(", "namelist", ",", "subdir", "=", "None", ")", ":", "def", "relpath", "(", "p", ")", ":", "# relpath strips a trailing sep", "# Windows paths may also use unix sep", "q", "=", "os", ".", "path", ".", "relpath", "(", "p", ")", ...
2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb
train
unzip
Extract all files from a zip archive filename: The path to the zip file match_dir: If True all files in the zip must be contained in a subdirectory named after the archive file with extension removed destdir: Extract the zip into this directory, default current directory return: If match_dir is T...
omego/fileutils.py
def unzip(filename, match_dir=False, destdir=None): """ Extract all files from a zip archive filename: The path to the zip file match_dir: If True all files in the zip must be contained in a subdirectory named after the archive file with extension removed destdir: Extract the zip into this dir...
def unzip(filename, match_dir=False, destdir=None): """ Extract all files from a zip archive filename: The path to the zip file match_dir: If True all files in the zip must be contained in a subdirectory named after the archive file with extension removed destdir: Extract the zip into this dir...
[ "Extract", "all", "files", "from", "a", "zip", "archive", "filename", ":", "The", "path", "to", "the", "zip", "file", "match_dir", ":", "If", "True", "all", "files", "in", "the", "zip", "must", "be", "contained", "in", "a", "subdirectory", "named", "afte...
ome/omego
python
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/fileutils.py#L231-L266
[ "def", "unzip", "(", "filename", ",", "match_dir", "=", "False", ",", "destdir", "=", "None", ")", ":", "if", "not", "destdir", ":", "destdir", "=", "'.'", "z", "=", "zipfile", ".", "ZipFile", "(", "filename", ")", "unzipped", "=", "'.'", "if", "matc...
2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb
train
zip
Create a new zip archive containing files filename: The name of the zip file to be created paths: A list of files or directories strip_dir: Remove this prefix from all file-paths before adding to zip
omego/fileutils.py
def zip(filename, paths, strip_prefix=''): """ Create a new zip archive containing files filename: The name of the zip file to be created paths: A list of files or directories strip_dir: Remove this prefix from all file-paths before adding to zip """ if isinstance(paths, basestring): ...
def zip(filename, paths, strip_prefix=''): """ Create a new zip archive containing files filename: The name of the zip file to be created paths: A list of files or directories strip_dir: Remove this prefix from all file-paths before adding to zip """ if isinstance(paths, basestring): ...
[ "Create", "a", "new", "zip", "archive", "containing", "files", "filename", ":", "The", "name", "of", "the", "zip", "file", "to", "be", "created", "paths", ":", "A", "list", "of", "files", "or", "directories", "strip_dir", ":", "Remove", "this", "prefix", ...
ome/omego
python
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/fileutils.py#L269-L298
[ "def", "zip", "(", "filename", ",", "paths", ",", "strip_prefix", "=", "''", ")", ":", "if", "isinstance", "(", "paths", ",", "basestring", ")", ":", "paths", "=", "[", "paths", "]", "filelist", "=", "set", "(", ")", "for", "p", "in", "paths", ":",...
2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb
train
get_as_local_path
Automatically handle local and remote URLs, files and directories path: Either a local directory, file or remote URL. If a URL is given it will be fetched. If this is a zip it will be automatically expanded by default. overwrite: Whether to overwrite an existing file: 'error': Raise an except...
omego/fileutils.py
def get_as_local_path(path, overwrite, progress=0, httpuser=None, httppassword=None): """ Automatically handle local and remote URLs, files and directories path: Either a local directory, file or remote URL. If a URL is given it will be fetched. If this is a zip it will be autom...
def get_as_local_path(path, overwrite, progress=0, httpuser=None, httppassword=None): """ Automatically handle local and remote URLs, files and directories path: Either a local directory, file or remote URL. If a URL is given it will be fetched. If this is a zip it will be autom...
[ "Automatically", "handle", "local", "and", "remote", "URLs", "files", "and", "directories" ]
ome/omego
python
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/fileutils.py#L301-L356
[ "def", "get_as_local_path", "(", "path", ",", "overwrite", ",", "progress", "=", "0", ",", "httpuser", "=", "None", ",", "httppassword", "=", "None", ")", ":", "m", "=", "re", ".", "match", "(", "'([A-Za-z]+)://'", ",", "path", ")", "if", "m", ":", "...
2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb
train
create
Allocates and initializes an encoder state.
opus/api/encoder.py
def create(fs, channels, application): """Allocates and initializes an encoder state.""" result_code = ctypes.c_int() result = _create(fs, channels, application, ctypes.byref(result_code)) if result_code.value is not constants.OK: raise OpusError(result_code.value) return result
def create(fs, channels, application): """Allocates and initializes an encoder state.""" result_code = ctypes.c_int() result = _create(fs, channels, application, ctypes.byref(result_code)) if result_code.value is not constants.OK: raise OpusError(result_code.value) return result
[ "Allocates", "and", "initializes", "an", "encoder", "state", "." ]
svartalf/python-opus
python
https://github.com/svartalf/python-opus/blob/a3c1d556d2772b5be659ddd08c033ddd4d566b3a/opus/api/encoder.py#L40-L49
[ "def", "create", "(", "fs", ",", "channels", ",", "application", ")", ":", "result_code", "=", "ctypes", ".", "c_int", "(", ")", "result", "=", "_create", "(", "fs", ",", "channels", ",", "application", ",", "ctypes", ".", "byref", "(", "result_code", ...
a3c1d556d2772b5be659ddd08c033ddd4d566b3a
train
encode
Encodes an Opus frame Returns string output payload
opus/api/encoder.py
def encode(encoder, pcm, frame_size, max_data_bytes): """Encodes an Opus frame Returns string output payload """ pcm = ctypes.cast(pcm, c_int16_pointer) data = (ctypes.c_char * max_data_bytes)() result = _encode(encoder, pcm, frame_size, data, max_data_bytes) if result < 0: raise ...
def encode(encoder, pcm, frame_size, max_data_bytes): """Encodes an Opus frame Returns string output payload """ pcm = ctypes.cast(pcm, c_int16_pointer) data = (ctypes.c_char * max_data_bytes)() result = _encode(encoder, pcm, frame_size, data, max_data_bytes) if result < 0: raise ...
[ "Encodes", "an", "Opus", "frame" ]
svartalf/python-opus
python
https://github.com/svartalf/python-opus/blob/a3c1d556d2772b5be659ddd08c033ddd4d566b3a/opus/api/encoder.py#L68-L81
[ "def", "encode", "(", "encoder", ",", "pcm", ",", "frame_size", ",", "max_data_bytes", ")", ":", "pcm", "=", "ctypes", ".", "cast", "(", "pcm", ",", "c_int16_pointer", ")", "data", "=", "(", "ctypes", ".", "c_char", "*", "max_data_bytes", ")", "(", ")"...
a3c1d556d2772b5be659ddd08c033ddd4d566b3a
train
encode_float
Encodes an Opus frame from floating point input
opus/api/encoder.py
def encode_float(encoder, pcm, frame_size, max_data_bytes): """Encodes an Opus frame from floating point input""" pcm = ctypes.cast(pcm, c_float_pointer) data = (ctypes.c_char * max_data_bytes)() result = _encode_float(encoder, pcm, frame_size, data, max_data_bytes) if result < 0: raise Op...
def encode_float(encoder, pcm, frame_size, max_data_bytes): """Encodes an Opus frame from floating point input""" pcm = ctypes.cast(pcm, c_float_pointer) data = (ctypes.c_char * max_data_bytes)() result = _encode_float(encoder, pcm, frame_size, data, max_data_bytes) if result < 0: raise Op...
[ "Encodes", "an", "Opus", "frame", "from", "floating", "point", "input" ]
svartalf/python-opus
python
https://github.com/svartalf/python-opus/blob/a3c1d556d2772b5be659ddd08c033ddd4d566b3a/opus/api/encoder.py#L89-L99
[ "def", "encode_float", "(", "encoder", ",", "pcm", ",", "frame_size", ",", "max_data_bytes", ")", ":", "pcm", "=", "ctypes", ".", "cast", "(", "pcm", ",", "c_float_pointer", ")", "data", "=", "(", "ctypes", ".", "c_char", "*", "max_data_bytes", ")", "(",...
a3c1d556d2772b5be659ddd08c033ddd4d566b3a
train
MeCab.__parse_tostr
Builds and returns the MeCab function for parsing Unicode text. Args: fn_name: MeCab function name that determines the function behavior, either 'mecab_sparse_tostr' or 'mecab_nbest_sparse_tostr'. Returns: A function definition, tailored to parsi...
natto/mecab.py
def __parse_tostr(self, text, **kwargs): '''Builds and returns the MeCab function for parsing Unicode text. Args: fn_name: MeCab function name that determines the function behavior, either 'mecab_sparse_tostr' or 'mecab_nbest_sparse_tostr'. Returns: ...
def __parse_tostr(self, text, **kwargs): '''Builds and returns the MeCab function for parsing Unicode text. Args: fn_name: MeCab function name that determines the function behavior, either 'mecab_sparse_tostr' or 'mecab_nbest_sparse_tostr'. Returns: ...
[ "Builds", "and", "returns", "the", "MeCab", "function", "for", "parsing", "Unicode", "text", "." ]
buruzaemon/natto-py
python
https://github.com/buruzaemon/natto-py/blob/018fe004c47c45c66bdf2e03fe24e981ae089b76/natto/mecab.py#L248-L322
[ "def", "__parse_tostr", "(", "self", ",", "text", ",", "*", "*", "kwargs", ")", ":", "n", "=", "self", ".", "options", ".", "get", "(", "'nbest'", ",", "1", ")", "if", "self", ".", "_KW_BOUNDARY", "in", "kwargs", ":", "patt", "=", "kwargs", ".", ...
018fe004c47c45c66bdf2e03fe24e981ae089b76
train
MeCab.__parse_tonodes
Builds and returns the MeCab function for parsing to nodes using morpheme boundary constraints. Args: format_feature: flag indicating whether or not to format the feature value for each node yielded. Returns: A function which returns a Generator, tailore...
natto/mecab.py
def __parse_tonodes(self, text, **kwargs): '''Builds and returns the MeCab function for parsing to nodes using morpheme boundary constraints. Args: format_feature: flag indicating whether or not to format the feature value for each node yielded. Returns: ...
def __parse_tonodes(self, text, **kwargs): '''Builds and returns the MeCab function for parsing to nodes using morpheme boundary constraints. Args: format_feature: flag indicating whether or not to format the feature value for each node yielded. Returns: ...
[ "Builds", "and", "returns", "the", "MeCab", "function", "for", "parsing", "to", "nodes", "using", "morpheme", "boundary", "constraints", "." ]
buruzaemon/natto-py
python
https://github.com/buruzaemon/natto-py/blob/018fe004c47c45c66bdf2e03fe24e981ae089b76/natto/mecab.py#L324-L427
[ "def", "__parse_tonodes", "(", "self", ",", "text", ",", "*", "*", "kwargs", ")", ":", "n", "=", "self", ".", "options", ".", "get", "(", "'nbest'", ",", "1", ")", "try", ":", "if", "self", ".", "_KW_BOUNDARY", "in", "kwargs", ":", "patt", "=", "...
018fe004c47c45c66bdf2e03fe24e981ae089b76
train
MeCab.parse
Parse the given text and return result from MeCab. :param text: the text to parse. :type text: str :param as_nodes: return generator of MeCabNodes if True; or string if False. :type as_nodes: bool, defaults to False :param boundary_constraints: regular expression for...
natto/mecab.py
def parse(self, text, **kwargs): '''Parse the given text and return result from MeCab. :param text: the text to parse. :type text: str :param as_nodes: return generator of MeCabNodes if True; or string if False. :type as_nodes: bool, defaults to False :param ...
def parse(self, text, **kwargs): '''Parse the given text and return result from MeCab. :param text: the text to parse. :type text: str :param as_nodes: return generator of MeCabNodes if True; or string if False. :type as_nodes: bool, defaults to False :param ...
[ "Parse", "the", "given", "text", "and", "return", "result", "from", "MeCab", "." ]
buruzaemon/natto-py
python
https://github.com/buruzaemon/natto-py/blob/018fe004c47c45c66bdf2e03fe24e981ae089b76/natto/mecab.py#L441-L488
[ "def", "parse", "(", "self", ",", "text", ",", "*", "*", "kwargs", ")", ":", "if", "text", "is", "None", ":", "logger", ".", "error", "(", "self", ".", "_ERROR_EMPTY_STR", ")", "raise", "MeCabError", "(", "self", ".", "_ERROR_EMPTY_STR", ")", "elif", ...
018fe004c47c45c66bdf2e03fe24e981ae089b76
train
parse
MAX_TERM_COUNT = 10000 # There are 39,000 terms in the GO!
omego/convert.py
def parse(filename, MAX_TERM_COUNT=1000): """ MAX_TERM_COUNT = 10000 # There are 39,000 terms in the GO! """ with open(filename, "r") as f: termId = None name = None desc = None parents = [] termCount = 0 for l in f.readlines(): if l.st...
def parse(filename, MAX_TERM_COUNT=1000): """ MAX_TERM_COUNT = 10000 # There are 39,000 terms in the GO! """ with open(filename, "r") as f: termId = None name = None desc = None parents = [] termCount = 0 for l in f.readlines(): if l.st...
[ "MAX_TERM_COUNT", "=", "10000", "#", "There", "are", "39", "000", "terms", "in", "the", "GO!" ]
ome/omego
python
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/convert.py#L59-L109
[ "def", "parse", "(", "filename", ",", "MAX_TERM_COUNT", "=", "1000", ")", ":", "with", "open", "(", "filename", ",", "\"r\"", ")", "as", "f", ":", "termId", "=", "None", "name", "=", "None", "desc", "=", "None", "parents", "=", "[", "]", "termCount",...
2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb
train
generate
create Tag Groups and Child Tags using data from terms dict
omego/convert.py
def generate(tagGroups, terms): """ create Tag Groups and Child Tags using data from terms dict """ rv = [] for pid in tagGroups: # In testing we may not have complete set if pid not in terms.keys(): continue groupData = terms[pid] groupName = "[%s] %s" ...
def generate(tagGroups, terms): """ create Tag Groups and Child Tags using data from terms dict """ rv = [] for pid in tagGroups: # In testing we may not have complete set if pid not in terms.keys(): continue groupData = terms[pid] groupName = "[%s] %s" ...
[ "create", "Tag", "Groups", "and", "Child", "Tags", "using", "data", "from", "terms", "dict" ]
ome/omego
python
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/convert.py#L112-L137
[ "def", "generate", "(", "tagGroups", ",", "terms", ")", ":", "rv", "=", "[", "]", "for", "pid", "in", "tagGroups", ":", "# In testing we may not have complete set", "if", "pid", "not", "in", "terms", ".", "keys", "(", ")", ":", "continue", "groupData", "="...
2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb
train
Install._handle_args
We need to support deprecated behaviour for now which makes this quite complicated Current behaviour: - install: Installs a new server, existing server causes an error - install --upgrade: Installs or upgrades a server - install --managedb: Automatically initialise or upgrade th...
omego/upgrade.py
def _handle_args(self, cmd, args): """ We need to support deprecated behaviour for now which makes this quite complicated Current behaviour: - install: Installs a new server, existing server causes an error - install --upgrade: Installs or upgrades a server - ins...
def _handle_args(self, cmd, args): """ We need to support deprecated behaviour for now which makes this quite complicated Current behaviour: - install: Installs a new server, existing server causes an error - install --upgrade: Installs or upgrades a server - ins...
[ "We", "need", "to", "support", "deprecated", "behaviour", "for", "now", "which", "makes", "this", "quite", "complicated" ]
ome/omego
python
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/upgrade.py#L75-L132
[ "def", "_handle_args", "(", "self", ",", "cmd", ",", "args", ")", ":", "if", "cmd", "==", "'install'", ":", "if", "args", ".", "upgrade", ":", "# Current behaviour: install or upgrade", "if", "args", ".", "initdb", "or", "args", ".", "upgradedb", ":", "rai...
2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb
train
Install.get_server_dir
Either downloads and/or unzips the server if necessary return: the directory of the unzipped server
omego/upgrade.py
def get_server_dir(self): """ Either downloads and/or unzips the server if necessary return: the directory of the unzipped server """ if not self.args.server: if self.args.skipunzip: raise Stop(0, 'Unzip disabled, exiting') log.info('Downl...
def get_server_dir(self): """ Either downloads and/or unzips the server if necessary return: the directory of the unzipped server """ if not self.args.server: if self.args.skipunzip: raise Stop(0, 'Unzip disabled, exiting') log.info('Downl...
[ "Either", "downloads", "and", "/", "or", "unzips", "the", "server", "if", "necessary", "return", ":", "the", "directory", "of", "the", "unzipped", "server" ]
ome/omego
python
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/upgrade.py#L134-L169
[ "def", "get_server_dir", "(", "self", ")", ":", "if", "not", "self", ".", "args", ".", "server", ":", "if", "self", ".", "args", ".", "skipunzip", ":", "raise", "Stop", "(", "0", ",", "'Unzip disabled, exiting'", ")", "log", ".", "info", "(", "'Downloa...
2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb
train
Install.handle_database
Handle database initialisation and upgrade, taking into account command line arguments
omego/upgrade.py
def handle_database(self): """ Handle database initialisation and upgrade, taking into account command line arguments """ # TODO: When initdb and upgradedb are dropped we can just test # managedb, but for backwards compatibility we need to support # initdb without...
def handle_database(self): """ Handle database initialisation and upgrade, taking into account command line arguments """ # TODO: When initdb and upgradedb are dropped we can just test # managedb, but for backwards compatibility we need to support # initdb without...
[ "Handle", "database", "initialisation", "and", "upgrade", "taking", "into", "account", "command", "line", "arguments" ]
ome/omego
python
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/upgrade.py#L263-L302
[ "def", "handle_database", "(", "self", ")", ":", "# TODO: When initdb and upgradedb are dropped we can just test", "# managedb, but for backwards compatibility we need to support", "# initdb without upgradedb and vice-versa", "if", "self", ".", "args", ".", "initdb", "or", "self", ...
2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb
train
Install.run
Runs a command as if from the command-line without the need for using popen or subprocess
omego/upgrade.py
def run(self, command): """ Runs a command as if from the command-line without the need for using popen or subprocess """ if isinstance(command, basestring): command = command.split() else: command = list(command) self.external.omero_cli(co...
def run(self, command): """ Runs a command as if from the command-line without the need for using popen or subprocess """ if isinstance(command, basestring): command = command.split() else: command = list(command) self.external.omero_cli(co...
[ "Runs", "a", "command", "as", "if", "from", "the", "command", "-", "line", "without", "the", "need", "for", "using", "popen", "or", "subprocess" ]
ome/omego
python
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/upgrade.py#L314-L323
[ "def", "run", "(", "self", ",", "command", ")", ":", "if", "isinstance", "(", "command", ",", "basestring", ")", ":", "command", "=", "command", ".", "split", "(", ")", "else", ":", "command", "=", "list", "(", "command", ")", "self", ".", "external"...
2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb
train
Install.bin
Runs the omero command-line client with an array of arguments using the old environment
omego/upgrade.py
def bin(self, command): """ Runs the omero command-line client with an array of arguments using the old environment """ if isinstance(command, basestring): command = command.split() self.external.omero_bin(command)
def bin(self, command): """ Runs the omero command-line client with an array of arguments using the old environment """ if isinstance(command, basestring): command = command.split() self.external.omero_bin(command)
[ "Runs", "the", "omero", "command", "-", "line", "client", "with", "an", "array", "of", "arguments", "using", "the", "old", "environment" ]
ome/omego
python
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/upgrade.py#L325-L332
[ "def", "bin", "(", "self", ",", "command", ")", ":", "if", "isinstance", "(", "command", ",", "basestring", ")", ":", "command", "=", "command", ".", "split", "(", ")", "self", ".", "external", ".", "omero_bin", "(", "command", ")" ]
2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb
train
Install.symlink_check_and_set
The default symlink was changed from OMERO-CURRENT to OMERO.server. If `--sym` was not specified and OMERO-CURRENT exists in the current directory stop and warn.
omego/upgrade.py
def symlink_check_and_set(self): """ The default symlink was changed from OMERO-CURRENT to OMERO.server. If `--sym` was not specified and OMERO-CURRENT exists in the current directory stop and warn. """ if self.args.sym == '': if os.path.exists('OMERO-CURRENT'...
def symlink_check_and_set(self): """ The default symlink was changed from OMERO-CURRENT to OMERO.server. If `--sym` was not specified and OMERO-CURRENT exists in the current directory stop and warn. """ if self.args.sym == '': if os.path.exists('OMERO-CURRENT'...
[ "The", "default", "symlink", "was", "changed", "from", "OMERO", "-", "CURRENT", "to", "OMERO", ".", "server", ".", "If", "--", "sym", "was", "not", "specified", "and", "OMERO", "-", "CURRENT", "exists", "in", "the", "current", "directory", "stop", "and", ...
ome/omego
python
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/upgrade.py#L334-L348
[ "def", "symlink_check_and_set", "(", "self", ")", ":", "if", "self", ".", "args", ".", "sym", "==", "''", ":", "if", "os", ".", "path", ".", "exists", "(", "'OMERO-CURRENT'", ")", ":", "log", ".", "error", "(", "'Deprecated OMERO-CURRENT found but --sym not ...
2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb