repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
cakebread/yolk
yolk/yolklib.py
get_highest_version
def get_highest_version(versions): """ Returns highest available version for a package in a list of versions Uses pkg_resources to parse the versions @param versions: List of PyPI package versions @type versions: List of strings @returns: string of a PyPI package version """ sorted_v...
python
def get_highest_version(versions): """ Returns highest available version for a package in a list of versions Uses pkg_resources to parse the versions @param versions: List of PyPI package versions @type versions: List of strings @returns: string of a PyPI package version """ sorted_v...
[ "def", "get_highest_version", "(", "versions", ")", ":", "sorted_versions", "=", "[", "]", "for", "ver", "in", "versions", ":", "sorted_versions", ".", "append", "(", "(", "pkg_resources", ".", "parse_version", "(", "ver", ")", ",", "ver", ")", ")", "sorte...
Returns highest available version for a package in a list of versions Uses pkg_resources to parse the versions @param versions: List of PyPI package versions @type versions: List of strings @returns: string of a PyPI package version
[ "Returns", "highest", "available", "version", "for", "a", "package", "in", "a", "list", "of", "versions", "Uses", "pkg_resources", "to", "parse", "the", "versions" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/yolklib.py#L154-L172
train
cakebread/yolk
yolk/yolklib.py
Distributions.get_distributions
def get_distributions(self, show, pkg_name="", version=""): """ Yield installed packages @param show: Type of package(s) to show; active, non-active or all @type show: string: "active", "non-active", "all" @param pkg_name: PyPI project name @type pkg_name: string ...
python
def get_distributions(self, show, pkg_name="", version=""): """ Yield installed packages @param show: Type of package(s) to show; active, non-active or all @type show: string: "active", "non-active", "all" @param pkg_name: PyPI project name @type pkg_name: string ...
[ "def", "get_distributions", "(", "self", ",", "show", ",", "pkg_name", "=", "\"\"", ",", "version", "=", "\"\"", ")", ":", "#pylint: disable-msg=W0612", "#'name' is a placeholder for the sorted list", "for", "name", ",", "dist", "in", "self", ".", "get_alpha", "("...
Yield installed packages @param show: Type of package(s) to show; active, non-active or all @type show: string: "active", "non-active", "all" @param pkg_name: PyPI project name @type pkg_name: string @param version: project's PyPI version @type version: string ...
[ "Yield", "installed", "packages" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/yolklib.py#L49-L77
train
cakebread/yolk
yolk/yolklib.py
Distributions.get_alpha
def get_alpha(self, show, pkg_name="", version=""): """ Return list of alphabetized packages @param pkg_name: PyPI project name @type pkg_name: string @param version: project's PyPI version @type version: string @returns: Alphabetized list of tuples. Each tuple...
python
def get_alpha(self, show, pkg_name="", version=""): """ Return list of alphabetized packages @param pkg_name: PyPI project name @type pkg_name: string @param version: project's PyPI version @type version: string @returns: Alphabetized list of tuples. Each tuple...
[ "def", "get_alpha", "(", "self", ",", "show", ",", "pkg_name", "=", "\"\"", ",", "version", "=", "\"\"", ")", ":", "alpha_list", "=", "[", "]", "for", "dist", "in", "self", ".", "get_packages", "(", "show", ")", ":", "if", "pkg_name", "and", "dist", ...
Return list of alphabetized packages @param pkg_name: PyPI project name @type pkg_name: string @param version: project's PyPI version @type version: string @returns: Alphabetized list of tuples. Each tuple contains a string and a pkg_resources Distribution ob...
[ "Return", "list", "of", "alphabetized", "packages" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/yolklib.py#L79-L105
train
cakebread/yolk
yolk/yolklib.py
Distributions.get_packages
def get_packages(self, show): """ Return list of Distributions filtered by active status or all @param show: Type of package(s) to show; active, non-active or all @type show: string: "active", "non-active", "all" @returns: list of pkg_resources Distribution objects """ ...
python
def get_packages(self, show): """ Return list of Distributions filtered by active status or all @param show: Type of package(s) to show; active, non-active or all @type show: string: "active", "non-active", "all" @returns: list of pkg_resources Distribution objects """ ...
[ "def", "get_packages", "(", "self", ",", "show", ")", ":", "if", "show", "==", "'nonactive'", "or", "show", "==", "\"all\"", ":", "all_packages", "=", "[", "]", "for", "package", "in", "self", ".", "environment", ":", "#There may be multiple versions of same p...
Return list of Distributions filtered by active status or all @param show: Type of package(s) to show; active, non-active or all @type show: string: "active", "non-active", "all" @returns: list of pkg_resources Distribution objects
[ "Return", "list", "of", "Distributions", "filtered", "by", "active", "status", "or", "all" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/yolklib.py#L107-L128
train
cakebread/yolk
yolk/yolklib.py
Distributions.case_sensitive_name
def case_sensitive_name(self, package_name): """ Return case-sensitive package name given any-case package name @param project_name: PyPI project name @type project_name: string """ if len(self.environment[package_name]): return self.environment[package_name...
python
def case_sensitive_name(self, package_name): """ Return case-sensitive package name given any-case package name @param project_name: PyPI project name @type project_name: string """ if len(self.environment[package_name]): return self.environment[package_name...
[ "def", "case_sensitive_name", "(", "self", ",", "package_name", ")", ":", "if", "len", "(", "self", ".", "environment", "[", "package_name", "]", ")", ":", "return", "self", ".", "environment", "[", "package_name", "]", "[", "0", "]", ".", "project_name" ]
Return case-sensitive package name given any-case package name @param project_name: PyPI project name @type project_name: string
[ "Return", "case", "-", "sensitive", "package", "name", "given", "any", "-", "case", "package", "name" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/yolklib.py#L130-L139
train
brutasse/django-ratelimit-backend
ratelimitbackend/backends.py
RateLimitMixin.cache_incr
def cache_incr(self, key): """ Non-atomic cache increment operation. Not optimal but consistent across different cache backends. """ cache.set(key, cache.get(key, 0) + 1, self.expire_after())
python
def cache_incr(self, key): """ Non-atomic cache increment operation. Not optimal but consistent across different cache backends. """ cache.set(key, cache.get(key, 0) + 1, self.expire_after())
[ "def", "cache_incr", "(", "self", ",", "key", ")", ":", "cache", ".", "set", "(", "key", ",", "cache", ".", "get", "(", "key", ",", "0", ")", "+", "1", ",", "self", ".", "expire_after", "(", ")", ")" ]
Non-atomic cache increment operation. Not optimal but consistent across different cache backends.
[ "Non", "-", "atomic", "cache", "increment", "operation", ".", "Not", "optimal", "but", "consistent", "across", "different", "cache", "backends", "." ]
1f8f485c139eb8067f0d821ff77df98038ab9448
https://github.com/brutasse/django-ratelimit-backend/blob/1f8f485c139eb8067f0d821ff77df98038ab9448/ratelimitbackend/backends.py#L84-L89
train
cakebread/yolk
yolk/plugins/__init__.py
call_plugins
def call_plugins(plugins, method, *arg, **kw): """Call all method on plugins in list, that define it, with provided arguments. The first response that is not None is returned. """ for plug in plugins: func = getattr(plug, method, None) if func is None: continue #LOG.d...
python
def call_plugins(plugins, method, *arg, **kw): """Call all method on plugins in list, that define it, with provided arguments. The first response that is not None is returned. """ for plug in plugins: func = getattr(plug, method, None) if func is None: continue #LOG.d...
[ "def", "call_plugins", "(", "plugins", ",", "method", ",", "*", "arg", ",", "*", "*", "kw", ")", ":", "for", "plug", "in", "plugins", ":", "func", "=", "getattr", "(", "plug", ",", "method", ",", "None", ")", "if", "func", "is", "None", ":", "con...
Call all method on plugins in list, that define it, with provided arguments. The first response that is not None is returned.
[ "Call", "all", "method", "on", "plugins", "in", "list", "that", "define", "it", "with", "provided", "arguments", ".", "The", "first", "response", "that", "is", "not", "None", "is", "returned", "." ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/plugins/__init__.py#L75-L87
train
cakebread/yolk
yolk/plugins/__init__.py
load_plugins
def load_plugins(builtin=True, others=True): """Load plugins, either builtin, others, or both. """ for entry_point in pkg_resources.iter_entry_points('yolk.plugins'): #LOG.debug("load plugin %s" % entry_point) try: plugin = entry_point.load() except KeyboardInterrupt: ...
python
def load_plugins(builtin=True, others=True): """Load plugins, either builtin, others, or both. """ for entry_point in pkg_resources.iter_entry_points('yolk.plugins'): #LOG.debug("load plugin %s" % entry_point) try: plugin = entry_point.load() except KeyboardInterrupt: ...
[ "def", "load_plugins", "(", "builtin", "=", "True", ",", "others", "=", "True", ")", ":", "for", "entry_point", "in", "pkg_resources", ".", "iter_entry_points", "(", "'yolk.plugins'", ")", ":", "#LOG.debug(\"load plugin %s\" % entry_point)", "try", ":", "plugin", ...
Load plugins, either builtin, others, or both.
[ "Load", "plugins", "either", "builtin", "others", "or", "both", "." ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/plugins/__init__.py#L89-L109
train
zagaran/mongobackup
mongobackup/s3.py
s3_connect
def s3_connect(bucket_name, s3_access_key_id, s3_secret_key): """ Returns a Boto connection to the provided S3 bucket. """ conn = connect_s3(s3_access_key_id, s3_secret_key) try: return conn.get_bucket(bucket_name) except S3ResponseError as e: if e.status == 403: raise Except...
python
def s3_connect(bucket_name, s3_access_key_id, s3_secret_key): """ Returns a Boto connection to the provided S3 bucket. """ conn = connect_s3(s3_access_key_id, s3_secret_key) try: return conn.get_bucket(bucket_name) except S3ResponseError as e: if e.status == 403: raise Except...
[ "def", "s3_connect", "(", "bucket_name", ",", "s3_access_key_id", ",", "s3_secret_key", ")", ":", "conn", "=", "connect_s3", "(", "s3_access_key_id", ",", "s3_secret_key", ")", "try", ":", "return", "conn", ".", "get_bucket", "(", "bucket_name", ")", "except", ...
Returns a Boto connection to the provided S3 bucket.
[ "Returns", "a", "Boto", "connection", "to", "the", "provided", "S3", "bucket", "." ]
d090d0cca44ecd066974c4de80edca5f26b7eeea
https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/s3.py#L33-L41
train
zagaran/mongobackup
mongobackup/s3.py
s3_list
def s3_list(s3_bucket, s3_access_key_id, s3_secret_key, prefix=None): """ Lists the contents of the S3 bucket that end in .tbz and match the passed prefix, if any. """ bucket = s3_connect(s3_bucket, s3_access_key_id, s3_secret_key) return sorted([key.name for key in bucket.list() ...
python
def s3_list(s3_bucket, s3_access_key_id, s3_secret_key, prefix=None): """ Lists the contents of the S3 bucket that end in .tbz and match the passed prefix, if any. """ bucket = s3_connect(s3_bucket, s3_access_key_id, s3_secret_key) return sorted([key.name for key in bucket.list() ...
[ "def", "s3_list", "(", "s3_bucket", ",", "s3_access_key_id", ",", "s3_secret_key", ",", "prefix", "=", "None", ")", ":", "bucket", "=", "s3_connect", "(", "s3_bucket", ",", "s3_access_key_id", ",", "s3_secret_key", ")", "return", "sorted", "(", "[", "key", "...
Lists the contents of the S3 bucket that end in .tbz and match the passed prefix, if any.
[ "Lists", "the", "contents", "of", "the", "S3", "bucket", "that", "end", "in", ".", "tbz", "and", "match", "the", "passed", "prefix", "if", "any", "." ]
d090d0cca44ecd066974c4de80edca5f26b7eeea
https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/s3.py#L49-L55
train
zagaran/mongobackup
mongobackup/s3.py
s3_download
def s3_download(output_file_path, s3_bucket, s3_access_key_id, s3_secret_key, s3_file_key=None, prefix=None): """ Downloads the file matching the provided key, in the provided bucket, from Amazon S3. If s3_file_key is none, it downloads the last file from the provide...
python
def s3_download(output_file_path, s3_bucket, s3_access_key_id, s3_secret_key, s3_file_key=None, prefix=None): """ Downloads the file matching the provided key, in the provided bucket, from Amazon S3. If s3_file_key is none, it downloads the last file from the provide...
[ "def", "s3_download", "(", "output_file_path", ",", "s3_bucket", ",", "s3_access_key_id", ",", "s3_secret_key", ",", "s3_file_key", "=", "None", ",", "prefix", "=", "None", ")", ":", "bucket", "=", "s3_connect", "(", "s3_bucket", ",", "s3_access_key_id", ",", ...
Downloads the file matching the provided key, in the provided bucket, from Amazon S3. If s3_file_key is none, it downloads the last file from the provided bucket with the .tbz extension, filtering by prefix if it is provided.
[ "Downloads", "the", "file", "matching", "the", "provided", "key", "in", "the", "provided", "bucket", "from", "Amazon", "S3", ".", "If", "s3_file_key", "is", "none", "it", "downloads", "the", "last", "file", "from", "the", "provided", "bucket", "with", "the",...
d090d0cca44ecd066974c4de80edca5f26b7eeea
https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/s3.py#L58-L74
train
zagaran/mongobackup
mongobackup/s3.py
s3_upload
def s3_upload(source_file_path, bucket_name, s3_access_key_id, s3_secret_key): """ Uploads the to Amazon S3 the contents of the provided file, keyed with the name of the file. """ key = s3_key(bucket_name, s3_access_key_id, s3_secret_key) file_name = source_file_path.split("/")[-1] key.key = fil...
python
def s3_upload(source_file_path, bucket_name, s3_access_key_id, s3_secret_key): """ Uploads the to Amazon S3 the contents of the provided file, keyed with the name of the file. """ key = s3_key(bucket_name, s3_access_key_id, s3_secret_key) file_name = source_file_path.split("/")[-1] key.key = fil...
[ "def", "s3_upload", "(", "source_file_path", ",", "bucket_name", ",", "s3_access_key_id", ",", "s3_secret_key", ")", ":", "key", "=", "s3_key", "(", "bucket_name", ",", "s3_access_key_id", ",", "s3_secret_key", ")", "file_name", "=", "source_file_path", ".", "spli...
Uploads the to Amazon S3 the contents of the provided file, keyed with the name of the file.
[ "Uploads", "the", "to", "Amazon", "S3", "the", "contents", "of", "the", "provided", "file", "keyed", "with", "the", "name", "of", "the", "file", "." ]
d090d0cca44ecd066974c4de80edca5f26b7eeea
https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/s3.py#L77-L86
train
ales-erjavec/anyqt
AnyQt/_fixes.py
fix_pyqt5_QGraphicsItem_itemChange
def fix_pyqt5_QGraphicsItem_itemChange(): """ Attempt to remedy: https://www.riverbankcomputing.com/pipermail/pyqt/2016-February/037015.html """ from PyQt5.QtWidgets import QGraphicsObject, QGraphicsItem class Obj(QGraphicsObject): def itemChange(self, change, value): return...
python
def fix_pyqt5_QGraphicsItem_itemChange(): """ Attempt to remedy: https://www.riverbankcomputing.com/pipermail/pyqt/2016-February/037015.html """ from PyQt5.QtWidgets import QGraphicsObject, QGraphicsItem class Obj(QGraphicsObject): def itemChange(self, change, value): return...
[ "def", "fix_pyqt5_QGraphicsItem_itemChange", "(", ")", ":", "from", "PyQt5", ".", "QtWidgets", "import", "QGraphicsObject", ",", "QGraphicsItem", "class", "Obj", "(", "QGraphicsObject", ")", ":", "def", "itemChange", "(", "self", ",", "change", ",", "value", ")"...
Attempt to remedy: https://www.riverbankcomputing.com/pipermail/pyqt/2016-February/037015.html
[ "Attempt", "to", "remedy", ":", "https", ":", "//", "www", ".", "riverbankcomputing", ".", "com", "/", "pipermail", "/", "pyqt", "/", "2016", "-", "February", "/", "037015", ".", "html" ]
07b73c5ccb8f73f70fc6566249c0c7228fc9b921
https://github.com/ales-erjavec/anyqt/blob/07b73c5ccb8f73f70fc6566249c0c7228fc9b921/AnyQt/_fixes.py#L4-L49
train
cakebread/yolk
yolk/cli.py
setup_opt_parser
def setup_opt_parser(): """ Setup the optparser @returns: opt_parser.OptionParser """ #pylint: disable-msg=C0301 #line too long usage = "usage: %prog [options]" opt_parser = optparse.OptionParser(usage=usage) opt_parser.add_option("--version", action='store_true', dest= ...
python
def setup_opt_parser(): """ Setup the optparser @returns: opt_parser.OptionParser """ #pylint: disable-msg=C0301 #line too long usage = "usage: %prog [options]" opt_parser = optparse.OptionParser(usage=usage) opt_parser.add_option("--version", action='store_true', dest= ...
[ "def", "setup_opt_parser", "(", ")", ":", "#pylint: disable-msg=C0301", "#line too long", "usage", "=", "\"usage: %prog [options]\"", "opt_parser", "=", "optparse", ".", "OptionParser", "(", "usage", "=", "usage", ")", "opt_parser", ".", "add_option", "(", "\"--versio...
Setup the optparser @returns: opt_parser.OptionParser
[ "Setup", "the", "optparser" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L928-L1063
train
cakebread/yolk
yolk/cli.py
validate_pypi_opts
def validate_pypi_opts(opt_parser): """ Check parse options that require pkg_spec @returns: pkg_spec """ (options, remaining_args) = opt_parser.parse_args() options_pkg_specs = [ options.versions_available, options.query_metadata_pypi, options.show_download_links, ...
python
def validate_pypi_opts(opt_parser): """ Check parse options that require pkg_spec @returns: pkg_spec """ (options, remaining_args) = opt_parser.parse_args() options_pkg_specs = [ options.versions_available, options.query_metadata_pypi, options.show_download_links, ...
[ "def", "validate_pypi_opts", "(", "opt_parser", ")", ":", "(", "options", ",", "remaining_args", ")", "=", "opt_parser", ".", "parse_args", "(", ")", "options_pkg_specs", "=", "[", "options", ".", "versions_available", ",", "options", ".", "query_metadata_pypi", ...
Check parse options that require pkg_spec @returns: pkg_spec
[ "Check", "parse", "options", "that", "require", "pkg_spec" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L1075-L1093
train
cakebread/yolk
yolk/cli.py
StdOut.write
def write(self, inline): """ Write a line to stdout if it isn't in a blacklist Try to get the name of the calling module to see if we want to filter it. If there is no calling module, use current frame in case there's a traceback before there is any calling module """ ...
python
def write(self, inline): """ Write a line to stdout if it isn't in a blacklist Try to get the name of the calling module to see if we want to filter it. If there is no calling module, use current frame in case there's a traceback before there is any calling module """ ...
[ "def", "write", "(", "self", ",", "inline", ")", ":", "frame", "=", "inspect", ".", "currentframe", "(", ")", ".", "f_back", "if", "frame", ":", "mod", "=", "frame", ".", "f_globals", ".", "get", "(", "'__name__'", ")", "else", ":", "mod", "=", "sy...
Write a line to stdout if it isn't in a blacklist Try to get the name of the calling module to see if we want to filter it. If there is no calling module, use current frame in case there's a traceback before there is any calling module
[ "Write", "a", "line", "to", "stdout", "if", "it", "isn", "t", "in", "a", "blacklist" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L75-L89
train
cakebread/yolk
yolk/cli.py
Yolk.get_plugin
def get_plugin(self, method): """ Return plugin object if CLI option is activated and method exists @param method: name of plugin's method we're calling @type method: string @returns: list of plugins with `method` """ all_plugins = [] for entry_point in...
python
def get_plugin(self, method): """ Return plugin object if CLI option is activated and method exists @param method: name of plugin's method we're calling @type method: string @returns: list of plugins with `method` """ all_plugins = [] for entry_point in...
[ "def", "get_plugin", "(", "self", ",", "method", ")", ":", "all_plugins", "=", "[", "]", "for", "entry_point", "in", "pkg_resources", ".", "iter_entry_points", "(", "'yolk.plugins'", ")", ":", "plugin_obj", "=", "entry_point", ".", "load", "(", ")", "plugin"...
Return plugin object if CLI option is activated and method exists @param method: name of plugin's method we're calling @type method: string @returns: list of plugins with `method`
[ "Return", "plugin", "object", "if", "CLI", "option", "is", "activated", "and", "method", "exists" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L121-L142
train
cakebread/yolk
yolk/cli.py
Yolk.set_log_level
def set_log_level(self): """ Set log level according to command-line options @returns: logger object """ if self.options.debug: self.logger.setLevel(logging.DEBUG) elif self.options.quiet: self.logger.setLevel(logging.ERROR) else: ...
python
def set_log_level(self): """ Set log level according to command-line options @returns: logger object """ if self.options.debug: self.logger.setLevel(logging.DEBUG) elif self.options.quiet: self.logger.setLevel(logging.ERROR) else: ...
[ "def", "set_log_level", "(", "self", ")", ":", "if", "self", ".", "options", ".", "debug", ":", "self", ".", "logger", ".", "setLevel", "(", "logging", ".", "DEBUG", ")", "elif", "self", ".", "options", ".", "quiet", ":", "self", ".", "logger", ".", ...
Set log level according to command-line options @returns: logger object
[ "Set", "log", "level", "according", "to", "command", "-", "line", "options" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L144-L158
train
cakebread/yolk
yolk/cli.py
Yolk.run
def run(self): """ Perform actions based on CLI options @returns: status code """ opt_parser = setup_opt_parser() (self.options, remaining_args) = opt_parser.parse_args() logger = self.set_log_level() pkg_spec = validate_pypi_opts(opt_parser) if ...
python
def run(self): """ Perform actions based on CLI options @returns: status code """ opt_parser = setup_opt_parser() (self.options, remaining_args) = opt_parser.parse_args() logger = self.set_log_level() pkg_spec = validate_pypi_opts(opt_parser) if ...
[ "def", "run", "(", "self", ")", ":", "opt_parser", "=", "setup_opt_parser", "(", ")", "(", "self", ".", "options", ",", "remaining_args", ")", "=", "opt_parser", ".", "parse_args", "(", ")", "logger", "=", "self", ".", "set_log_level", "(", ")", "pkg_spe...
Perform actions based on CLI options @returns: status code
[ "Perform", "actions", "based", "on", "CLI", "options" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L160-L215
train
cakebread/yolk
yolk/cli.py
Yolk.show_updates
def show_updates(self): """ Check installed packages for available updates on PyPI @param project_name: optional package name to check; checks every installed pacakge if none specified @type project_name: string @returns: None """ di...
python
def show_updates(self): """ Check installed packages for available updates on PyPI @param project_name: optional package name to check; checks every installed pacakge if none specified @type project_name: string @returns: None """ di...
[ "def", "show_updates", "(", "self", ")", ":", "dists", "=", "Distributions", "(", ")", "if", "self", ".", "project_name", ":", "#Check for a single package", "pkg_list", "=", "[", "self", ".", "project_name", "]", "else", ":", "#Check for every installed package",...
Check installed packages for available updates on PyPI @param project_name: optional package name to check; checks every installed pacakge if none specified @type project_name: string @returns: None
[ "Check", "installed", "packages", "for", "available", "updates", "on", "PyPI" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L236-L279
train
cakebread/yolk
yolk/cli.py
Yolk.show_distributions
def show_distributions(self, show): """ Show list of installed activated OR non-activated packages @param show: type of pkgs to show (all, active or nonactive) @type show: string @returns: None or 2 if error """ show_metadata = self.options.metadata #Se...
python
def show_distributions(self, show): """ Show list of installed activated OR non-activated packages @param show: type of pkgs to show (all, active or nonactive) @type show: string @returns: None or 2 if error """ show_metadata = self.options.metadata #Se...
[ "def", "show_distributions", "(", "self", ",", "show", ")", ":", "show_metadata", "=", "self", ".", "options", ".", "metadata", "#Search for any plugins with active CLI options with add_column() method", "plugins", "=", "self", ".", "get_plugin", "(", "\"add_column\"", ...
Show list of installed activated OR non-activated packages @param show: type of pkgs to show (all, active or nonactive) @type show: string @returns: None or 2 if error
[ "Show", "list", "of", "installed", "activated", "OR", "non", "-", "activated", "packages" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L282-L344
train
cakebread/yolk
yolk/cli.py
Yolk.print_metadata
def print_metadata(self, metadata, develop, active, installed_by): """ Print out formatted metadata @param metadata: package's metadata @type metadata: pkg_resources Distribution obj @param develop: path to pkg if its deployed in development mode @type develop: string ...
python
def print_metadata(self, metadata, develop, active, installed_by): """ Print out formatted metadata @param metadata: package's metadata @type metadata: pkg_resources Distribution obj @param develop: path to pkg if its deployed in development mode @type develop: string ...
[ "def", "print_metadata", "(", "self", ",", "metadata", ",", "develop", ",", "active", ",", "installed_by", ")", ":", "show_metadata", "=", "self", ".", "options", ".", "metadata", "if", "self", ".", "options", ".", "fields", ":", "fields", "=", "self", "...
Print out formatted metadata @param metadata: package's metadata @type metadata: pkg_resources Distribution obj @param develop: path to pkg if its deployed in development mode @type develop: string @param active: show if package is activated or not @type active: boolea...
[ "Print", "out", "formatted", "metadata", "@param", "metadata", ":", "package", "s", "metadata", "@type", "metadata", ":", "pkg_resources", "Distribution", "obj" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L347-L411
train
cakebread/yolk
yolk/cli.py
Yolk.show_deps
def show_deps(self): """ Show dependencies for package(s) @returns: 0 - sucess 1 - No dependency info supplied """ pkgs = pkg_resources.Environment() for pkg in pkgs[self.project_name]: if not self.version: print(pkg.project_name, pkg.versi...
python
def show_deps(self): """ Show dependencies for package(s) @returns: 0 - sucess 1 - No dependency info supplied """ pkgs = pkg_resources.Environment() for pkg in pkgs[self.project_name]: if not self.version: print(pkg.project_name, pkg.versi...
[ "def", "show_deps", "(", "self", ")", ":", "pkgs", "=", "pkg_resources", ".", "Environment", "(", ")", "for", "pkg", "in", "pkgs", "[", "self", ".", "project_name", "]", ":", "if", "not", "self", ".", "version", ":", "print", "(", "pkg", ".", "projec...
Show dependencies for package(s) @returns: 0 - sucess 1 - No dependency info supplied
[ "Show", "dependencies", "for", "package", "(", "s", ")" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L413-L439
train
cakebread/yolk
yolk/cli.py
Yolk.show_pypi_changelog
def show_pypi_changelog(self): """ Show detailed PyPI ChangeLog for the last `hours` @returns: 0 = sucess or 1 if failed to retrieve from XML-RPC server """ hours = self.options.show_pypi_changelog if not hours.isdigit(): self.logger.error("Error: You must s...
python
def show_pypi_changelog(self): """ Show detailed PyPI ChangeLog for the last `hours` @returns: 0 = sucess or 1 if failed to retrieve from XML-RPC server """ hours = self.options.show_pypi_changelog if not hours.isdigit(): self.logger.error("Error: You must s...
[ "def", "show_pypi_changelog", "(", "self", ")", ":", "hours", "=", "self", ".", "options", ".", "show_pypi_changelog", "if", "not", "hours", ".", "isdigit", "(", ")", ":", "self", ".", "logger", ".", "error", "(", "\"Error: You must supply an integer.\"", ")",...
Show detailed PyPI ChangeLog for the last `hours` @returns: 0 = sucess or 1 if failed to retrieve from XML-RPC server
[ "Show", "detailed", "PyPI", "ChangeLog", "for", "the", "last", "hours" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L441-L469
train
cakebread/yolk
yolk/cli.py
Yolk.show_pypi_releases
def show_pypi_releases(self): """ Show PyPI releases for the last number of `hours` @returns: 0 = success or 1 if failed to retrieve from XML-RPC server """ try: hours = int(self.options.show_pypi_releases) except ValueError: self.logger.error("E...
python
def show_pypi_releases(self): """ Show PyPI releases for the last number of `hours` @returns: 0 = success or 1 if failed to retrieve from XML-RPC server """ try: hours = int(self.options.show_pypi_releases) except ValueError: self.logger.error("E...
[ "def", "show_pypi_releases", "(", "self", ")", ":", "try", ":", "hours", "=", "int", "(", "self", ".", "options", ".", "show_pypi_releases", ")", "except", "ValueError", ":", "self", ".", "logger", ".", "error", "(", "\"ERROR: You must supply an integer.\"", "...
Show PyPI releases for the last number of `hours` @returns: 0 = success or 1 if failed to retrieve from XML-RPC server
[ "Show", "PyPI", "releases", "for", "the", "last", "number", "of", "hours" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L471-L492
train
cakebread/yolk
yolk/cli.py
Yolk.show_download_links
def show_download_links(self): """ Query PyPI for pkg download URI for a packge @returns: 0 """ #In case they specify version as 'dev' instead of using -T svn, #don't show three svn URI's if self.options.file_type == "all" and self.version == "dev": ...
python
def show_download_links(self): """ Query PyPI for pkg download URI for a packge @returns: 0 """ #In case they specify version as 'dev' instead of using -T svn, #don't show three svn URI's if self.options.file_type == "all" and self.version == "dev": ...
[ "def", "show_download_links", "(", "self", ")", ":", "#In case they specify version as 'dev' instead of using -T svn,", "#don't show three svn URI's", "if", "self", ".", "options", ".", "file_type", "==", "\"all\"", "and", "self", ".", "version", "==", "\"dev\"", ":", "...
Query PyPI for pkg download URI for a packge @returns: 0
[ "Query", "PyPI", "for", "pkg", "download", "URI", "for", "a", "packge" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L494-L524
train
cakebread/yolk
yolk/cli.py
Yolk.print_download_uri
def print_download_uri(self, version, source): """ @param version: version number or 'dev' for svn @type version: string @param source: download source or egg @type source: boolean @returns: None """ if version == "dev": pkg_type = "subvers...
python
def print_download_uri(self, version, source): """ @param version: version number or 'dev' for svn @type version: string @param source: download source or egg @type source: boolean @returns: None """ if version == "dev": pkg_type = "subvers...
[ "def", "print_download_uri", "(", "self", ",", "version", ",", "source", ")", ":", "if", "version", "==", "\"dev\"", ":", "pkg_type", "=", "\"subversion\"", "source", "=", "True", "elif", "source", ":", "pkg_type", "=", "\"source\"", "else", ":", "pkg_type",...
@param version: version number or 'dev' for svn @type version: string @param source: download source or egg @type source: boolean @returns: None
[ "@param", "version", ":", "version", "number", "or", "dev", "for", "svn", "@type", "version", ":", "string" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L526-L552
train
cakebread/yolk
yolk/cli.py
Yolk.fetch
def fetch(self): """ Download a package @returns: 0 = success or 1 if failed download """ #Default type to download source = True directory = "." if self.options.file_type == "svn": version = "dev" svn_uri = get_download_uri(self...
python
def fetch(self): """ Download a package @returns: 0 = success or 1 if failed download """ #Default type to download source = True directory = "." if self.options.file_type == "svn": version = "dev" svn_uri = get_download_uri(self...
[ "def", "fetch", "(", "self", ")", ":", "#Default type to download", "source", "=", "True", "directory", "=", "\".\"", "if", "self", ".", "options", ".", "file_type", "==", "\"svn\"", ":", "version", "=", "\"dev\"", "svn_uri", "=", "get_download_uri", "(", "s...
Download a package @returns: 0 = success or 1 if failed download
[ "Download", "a", "package" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L554-L588
train
cakebread/yolk
yolk/cli.py
Yolk.fetch_uri
def fetch_uri(self, directory, uri): """ Use ``urllib.urlretrieve`` to download package to file in sandbox dir. @param directory: directory to download to @type directory: string @param uri: uri to download @type uri: string @returns: 0 = success or 1 for faile...
python
def fetch_uri(self, directory, uri): """ Use ``urllib.urlretrieve`` to download package to file in sandbox dir. @param directory: directory to download to @type directory: string @param uri: uri to download @type uri: string @returns: 0 = success or 1 for faile...
[ "def", "fetch_uri", "(", "self", ",", "directory", ",", "uri", ")", ":", "filename", "=", "os", ".", "path", ".", "basename", "(", "urlparse", "(", "uri", ")", "[", "2", "]", ")", "if", "os", ".", "path", ".", "exists", "(", "filename", ")", ":",...
Use ``urllib.urlretrieve`` to download package to file in sandbox dir. @param directory: directory to download to @type directory: string @param uri: uri to download @type uri: string @returns: 0 = success or 1 for failed download
[ "Use", "urllib", ".", "urlretrieve", "to", "download", "package", "to", "file", "in", "sandbox", "dir", "." ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L590-L623
train
cakebread/yolk
yolk/cli.py
Yolk.fetch_svn
def fetch_svn(self, svn_uri, directory): """ Fetch subversion repository @param svn_uri: subversion repository uri to check out @type svn_uri: string @param directory: directory to download to @type directory: string @returns: 0 = success or 1 for failed downlo...
python
def fetch_svn(self, svn_uri, directory): """ Fetch subversion repository @param svn_uri: subversion repository uri to check out @type svn_uri: string @param directory: directory to download to @type directory: string @returns: 0 = success or 1 for failed downlo...
[ "def", "fetch_svn", "(", "self", ",", "svn_uri", ",", "directory", ")", ":", "if", "not", "command_successful", "(", "\"svn --version\"", ")", ":", "self", ".", "logger", ".", "error", "(", "\"ERROR: Do you have subversion installed?\"", ")", "return", "1", "if"...
Fetch subversion repository @param svn_uri: subversion repository uri to check out @type svn_uri: string @param directory: directory to download to @type directory: string @returns: 0 = success or 1 for failed download
[ "Fetch", "subversion", "repository" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L626-L660
train
cakebread/yolk
yolk/cli.py
Yolk.browse_website
def browse_website(self, browser=None): """ Launch web browser at project's homepage @param browser: name of web browser to use @type browser: string @returns: 0 if homepage found, 1 if no homepage found """ if len(self.all_versions): metadata = self...
python
def browse_website(self, browser=None): """ Launch web browser at project's homepage @param browser: name of web browser to use @type browser: string @returns: 0 if homepage found, 1 if no homepage found """ if len(self.all_versions): metadata = self...
[ "def", "browse_website", "(", "self", ",", "browser", "=", "None", ")", ":", "if", "len", "(", "self", ".", "all_versions", ")", ":", "metadata", "=", "self", ".", "pypi", ".", "release_data", "(", "self", ".", "project_name", ",", "self", ".", "all_ve...
Launch web browser at project's homepage @param browser: name of web browser to use @type browser: string @returns: 0 if homepage found, 1 if no homepage found
[ "Launch", "web", "browser", "at", "project", "s", "homepage" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L662-L686
train
cakebread/yolk
yolk/cli.py
Yolk.query_metadata_pypi
def query_metadata_pypi(self): """ Show pkg metadata queried from PyPI @returns: 0 """ if self.version and self.version in self.all_versions: metadata = self.pypi.release_data(self.project_name, self.version) else: #Give highest version ...
python
def query_metadata_pypi(self): """ Show pkg metadata queried from PyPI @returns: 0 """ if self.version and self.version in self.all_versions: metadata = self.pypi.release_data(self.project_name, self.version) else: #Give highest version ...
[ "def", "query_metadata_pypi", "(", "self", ")", ":", "if", "self", ".", "version", "and", "self", ".", "version", "in", "self", ".", "all_versions", ":", "metadata", "=", "self", ".", "pypi", ".", "release_data", "(", "self", ".", "project_name", ",", "s...
Show pkg metadata queried from PyPI @returns: 0
[ "Show", "pkg", "metadata", "queried", "from", "PyPI" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L689-L708
train
cakebread/yolk
yolk/cli.py
Yolk.versions_available
def versions_available(self): """ Query PyPI for a particular version or all versions of a package @returns: 0 if version(s) found or 1 if none found """ if self.version: spec = "%s==%s" % (self.project_name, self.version) else: spec = self.proje...
python
def versions_available(self): """ Query PyPI for a particular version or all versions of a package @returns: 0 if version(s) found or 1 if none found """ if self.version: spec = "%s==%s" % (self.project_name, self.version) else: spec = self.proje...
[ "def", "versions_available", "(", "self", ")", ":", "if", "self", ".", "version", ":", "spec", "=", "\"%s==%s\"", "%", "(", "self", ".", "project_name", ",", "self", ".", "version", ")", "else", ":", "spec", "=", "self", ".", "project_name", "if", "sel...
Query PyPI for a particular version or all versions of a package @returns: 0 if version(s) found or 1 if none found
[ "Query", "PyPI", "for", "a", "particular", "version", "or", "all", "versions", "of", "a", "package" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L710-L733
train
cakebread/yolk
yolk/cli.py
Yolk.parse_search_spec
def parse_search_spec(self, spec): """ Parse search args and return spec dict for PyPI * Owwww, my eyes!. Re-write this. @param spec: Cheese Shop package search spec e.g. name=Cheetah license=ZPL license...
python
def parse_search_spec(self, spec): """ Parse search args and return spec dict for PyPI * Owwww, my eyes!. Re-write this. @param spec: Cheese Shop package search spec e.g. name=Cheetah license=ZPL license...
[ "def", "parse_search_spec", "(", "self", ",", "spec", ")", ":", "usage", "=", "\"\"\"You can search PyPI by the following:\n name\n version\n author\n author_email\n maintainer\n maintainer_email\n home_page\n license\n summary\n description\n keywords...
Parse search args and return spec dict for PyPI * Owwww, my eyes!. Re-write this. @param spec: Cheese Shop package search spec e.g. name=Cheetah license=ZPL license=ZPL AND name=Cheetah @type spec: string ...
[ "Parse", "search", "args", "and", "return", "spec", "dict", "for", "PyPI", "*", "Owwww", "my", "eyes!", ".", "Re", "-", "write", "this", "." ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L735-L798
train
cakebread/yolk
yolk/cli.py
Yolk.pypi_search
def pypi_search(self): """ Search PyPI by metadata keyword e.g. yolk -S name=yolk AND license=GPL @param spec: Cheese Shop search spec @type spec: list of strings spec examples: ["name=yolk"] ["license=GPL"] ["name=yolk", "AND", "license=GP...
python
def pypi_search(self): """ Search PyPI by metadata keyword e.g. yolk -S name=yolk AND license=GPL @param spec: Cheese Shop search spec @type spec: list of strings spec examples: ["name=yolk"] ["license=GPL"] ["name=yolk", "AND", "license=GP...
[ "def", "pypi_search", "(", "self", ")", ":", "spec", "=", "self", ".", "pkg_spec", "#Add remainging cli arguments to options.pypi_search", "search_arg", "=", "self", ".", "options", ".", "pypi_search", "spec", ".", "insert", "(", "0", ",", "search_arg", ".", "st...
Search PyPI by metadata keyword e.g. yolk -S name=yolk AND license=GPL @param spec: Cheese Shop search spec @type spec: list of strings spec examples: ["name=yolk"] ["license=GPL"] ["name=yolk", "AND", "license=GPL"] @returns: 0 on success or 1 if...
[ "Search", "PyPI", "by", "metadata", "keyword", "e", ".", "g", ".", "yolk", "-", "S", "name", "=", "yolk", "AND", "license", "=", "GPL" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L801-L834
train
cakebread/yolk
yolk/cli.py
Yolk.show_entry_map
def show_entry_map(self): """ Show entry map for a package @param dist: package @param type: srting @returns: 0 for success or 1 if error """ pprinter = pprint.PrettyPrinter() try: entry_map = pkg_resources.get_entry_map(self.options.show_ent...
python
def show_entry_map(self): """ Show entry map for a package @param dist: package @param type: srting @returns: 0 for success or 1 if error """ pprinter = pprint.PrettyPrinter() try: entry_map = pkg_resources.get_entry_map(self.options.show_ent...
[ "def", "show_entry_map", "(", "self", ")", ":", "pprinter", "=", "pprint", ".", "PrettyPrinter", "(", ")", "try", ":", "entry_map", "=", "pkg_resources", ".", "get_entry_map", "(", "self", ".", "options", ".", "show_entry_map", ")", "if", "entry_map", ":", ...
Show entry map for a package @param dist: package @param type: srting @returns: 0 for success or 1 if error
[ "Show", "entry", "map", "for", "a", "package" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L836-L854
train
cakebread/yolk
yolk/cli.py
Yolk.show_entry_points
def show_entry_points(self): """ Show entry points for a module @returns: 0 for success or 1 if error """ found = False for entry_point in \ pkg_resources.iter_entry_points(self.options.show_entry_points): found = True try: ...
python
def show_entry_points(self): """ Show entry points for a module @returns: 0 for success or 1 if error """ found = False for entry_point in \ pkg_resources.iter_entry_points(self.options.show_entry_points): found = True try: ...
[ "def", "show_entry_points", "(", "self", ")", ":", "found", "=", "False", "for", "entry_point", "in", "pkg_resources", ".", "iter_entry_points", "(", "self", ".", "options", ".", "show_entry_points", ")", ":", "found", "=", "True", "try", ":", "plugin", "=",...
Show entry points for a module @returns: 0 for success or 1 if error
[ "Show", "entry", "points", "for", "a", "module" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L856-L880
train
cakebread/yolk
yolk/cli.py
Yolk.parse_pkg_ver
def parse_pkg_ver(self, want_installed): """ Return tuple with project_name and version from CLI args If the user gave the wrong case for the project name, this corrects it @param want_installed: whether package we want is installed or not @type want_installed: boolean ...
python
def parse_pkg_ver(self, want_installed): """ Return tuple with project_name and version from CLI args If the user gave the wrong case for the project name, this corrects it @param want_installed: whether package we want is installed or not @type want_installed: boolean ...
[ "def", "parse_pkg_ver", "(", "self", ",", "want_installed", ")", ":", "all_versions", "=", "[", "]", "arg_str", "=", "(", "\"\"", ")", ".", "join", "(", "self", ".", "pkg_spec", ")", "if", "\"==\"", "not", "in", "arg_str", ":", "#No version specified", "...
Return tuple with project_name and version from CLI args If the user gave the wrong case for the project name, this corrects it @param want_installed: whether package we want is installed or not @type want_installed: boolean @returns: tuple(project_name, version, all_versions)
[ "Return", "tuple", "with", "project_name", "and", "version", "from", "CLI", "args", "If", "the", "user", "gave", "the", "wrong", "case", "for", "the", "project", "name", "this", "corrects", "it" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L891-L926
train
ales-erjavec/anyqt
AnyQt/importhooks.py
install_backport_hook
def install_backport_hook(api): """ Install a backport import hook for Qt4 api Parameters ---------- api : str The Qt4 api whose structure should be intercepted ('pyqt4' or 'pyside'). Example ------- >>> install_backport_hook("pyqt4") >>> import PyQt4 Loaded mod...
python
def install_backport_hook(api): """ Install a backport import hook for Qt4 api Parameters ---------- api : str The Qt4 api whose structure should be intercepted ('pyqt4' or 'pyside'). Example ------- >>> install_backport_hook("pyqt4") >>> import PyQt4 Loaded mod...
[ "def", "install_backport_hook", "(", "api", ")", ":", "if", "api", "==", "USED_API", ":", "raise", "ValueError", "sys", ".", "meta_path", ".", "insert", "(", "0", ",", "ImportHookBackport", "(", "api", ")", ")" ]
Install a backport import hook for Qt4 api Parameters ---------- api : str The Qt4 api whose structure should be intercepted ('pyqt4' or 'pyside'). Example ------- >>> install_backport_hook("pyqt4") >>> import PyQt4 Loaded module AnyQt._backport as a substitute for PyQt...
[ "Install", "a", "backport", "import", "hook", "for", "Qt4", "api" ]
07b73c5ccb8f73f70fc6566249c0c7228fc9b921
https://github.com/ales-erjavec/anyqt/blob/07b73c5ccb8f73f70fc6566249c0c7228fc9b921/AnyQt/importhooks.py#L81-L101
train
ales-erjavec/anyqt
AnyQt/importhooks.py
install_deny_hook
def install_deny_hook(api): """ Install a deny import hook for Qt api. Parameters ---------- api : str The Qt api whose import should be prevented Example ------- >>> install_deny_import("pyqt4") >>> import PyQt4 Traceback (most recent call last):... ImportError: Im...
python
def install_deny_hook(api): """ Install a deny import hook for Qt api. Parameters ---------- api : str The Qt api whose import should be prevented Example ------- >>> install_deny_import("pyqt4") >>> import PyQt4 Traceback (most recent call last):... ImportError: Im...
[ "def", "install_deny_hook", "(", "api", ")", ":", "if", "api", "==", "USED_API", ":", "raise", "ValueError", "sys", ".", "meta_path", ".", "insert", "(", "0", ",", "ImportHookDeny", "(", "api", ")", ")" ]
Install a deny import hook for Qt api. Parameters ---------- api : str The Qt api whose import should be prevented Example ------- >>> install_deny_import("pyqt4") >>> import PyQt4 Traceback (most recent call last):... ImportError: Import of PyQt4 is denied.
[ "Install", "a", "deny", "import", "hook", "for", "Qt", "api", "." ]
07b73c5ccb8f73f70fc6566249c0c7228fc9b921
https://github.com/ales-erjavec/anyqt/blob/07b73c5ccb8f73f70fc6566249c0c7228fc9b921/AnyQt/importhooks.py#L104-L124
train
cakebread/yolk
yolk/utils.py
run_command
def run_command(cmd, env=None, max_timeout=None): """ Run command and return its return status code and its output """ arglist = cmd.split() output = os.tmpfile() try: pipe = Popen(arglist, stdout=output, stderr=STDOUT, env=env) except Exception as errmsg: return 1, errmsg ...
python
def run_command(cmd, env=None, max_timeout=None): """ Run command and return its return status code and its output """ arglist = cmd.split() output = os.tmpfile() try: pipe = Popen(arglist, stdout=output, stderr=STDOUT, env=env) except Exception as errmsg: return 1, errmsg ...
[ "def", "run_command", "(", "cmd", ",", "env", "=", "None", ",", "max_timeout", "=", "None", ")", ":", "arglist", "=", "cmd", ".", "split", "(", ")", "output", "=", "os", ".", "tmpfile", "(", ")", "try", ":", "pipe", "=", "Popen", "(", "arglist", ...
Run command and return its return status code and its output
[ "Run", "command", "and", "return", "its", "return", "status", "code", "and", "its", "output" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/utils.py#L30-L55
train
pyslackers/slack-sansio
slack/io/abc.py
SlackAPI.iter
async def iter( self, url: Union[str, methods], data: Optional[MutableMapping] = None, headers: Optional[MutableMapping] = None, *, limit: int = 200, iterkey: Optional[str] = None, itermode: Optional[str] = None, minimum_time: Optional[int] = None,...
python
async def iter( self, url: Union[str, methods], data: Optional[MutableMapping] = None, headers: Optional[MutableMapping] = None, *, limit: int = 200, iterkey: Optional[str] = None, itermode: Optional[str] = None, minimum_time: Optional[int] = None,...
[ "async", "def", "iter", "(", "self", ",", "url", ":", "Union", "[", "str", ",", "methods", "]", ",", "data", ":", "Optional", "[", "MutableMapping", "]", "=", "None", ",", "headers", ":", "Optional", "[", "MutableMapping", "]", "=", "None", ",", "*",...
Iterate over a slack API method supporting pagination When using :class:`slack.methods` the request is made `as_json` if available Args: url: :class:`slack.methods` or url string data: JSON encodable MutableMapping headers: limit: Maximum number of resul...
[ "Iterate", "over", "a", "slack", "API", "method", "supporting", "pagination" ]
068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/io/abc.py#L88-L149
train
pyslackers/slack-sansio
slack/io/abc.py
SlackAPI._incoming_from_rtm
async def _incoming_from_rtm( self, url: str, bot_id: str ) -> AsyncIterator[events.Event]: """ Connect and discard incoming RTM event if necessary. :param url: Websocket url :param bot_id: Bot ID :return: Incoming events """ async for data in self._r...
python
async def _incoming_from_rtm( self, url: str, bot_id: str ) -> AsyncIterator[events.Event]: """ Connect and discard incoming RTM event if necessary. :param url: Websocket url :param bot_id: Bot ID :return: Incoming events """ async for data in self._r...
[ "async", "def", "_incoming_from_rtm", "(", "self", ",", "url", ":", "str", ",", "bot_id", ":", "str", ")", "->", "AsyncIterator", "[", "events", ".", "Event", "]", ":", "async", "for", "data", "in", "self", ".", "_rtm", "(", "url", ")", ":", "event",...
Connect and discard incoming RTM event if necessary. :param url: Websocket url :param bot_id: Bot ID :return: Incoming events
[ "Connect", "and", "discard", "incoming", "RTM", "event", "if", "necessary", "." ]
068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/io/abc.py#L195-L212
train
brutasse/django-ratelimit-backend
ratelimitbackend/views.py
login
def login(request, template_name='registration/login.html', redirect_field_name=REDIRECT_FIELD_NAME, authentication_form=AuthenticationForm, current_app=None, extra_context=None): """ Displays the login form and handles the login action. """ redirect_to = request.POST.get(r...
python
def login(request, template_name='registration/login.html', redirect_field_name=REDIRECT_FIELD_NAME, authentication_form=AuthenticationForm, current_app=None, extra_context=None): """ Displays the login form and handles the login action. """ redirect_to = request.POST.get(r...
[ "def", "login", "(", "request", ",", "template_name", "=", "'registration/login.html'", ",", "redirect_field_name", "=", "REDIRECT_FIELD_NAME", ",", "authentication_form", "=", "AuthenticationForm", ",", "current_app", "=", "None", ",", "extra_context", "=", "None", "...
Displays the login form and handles the login action.
[ "Displays", "the", "login", "form", "and", "handles", "the", "login", "action", "." ]
1f8f485c139eb8067f0d821ff77df98038ab9448
https://github.com/brutasse/django-ratelimit-backend/blob/1f8f485c139eb8067f0d821ff77df98038ab9448/ratelimitbackend/views.py#L17-L59
train
cakebread/yolk
examples/plugins/yolk_pkg_manager/yolk_acme.py
PackageManagerPlugin.package_manager_owns
def package_manager_owns(self, dist): """ Returns True if package manager 'owns' file Returns False if package manager does not 'own' file There is currently no way to determine if distutils or setuptools installed a package. A future feature of setuptools will make a pa...
python
def package_manager_owns(self, dist): """ Returns True if package manager 'owns' file Returns False if package manager does not 'own' file There is currently no way to determine if distutils or setuptools installed a package. A future feature of setuptools will make a pa...
[ "def", "package_manager_owns", "(", "self", ",", "dist", ")", ":", "#Installed by distutils/setuptools or external package manager?", "#If location is in site-packages dir, check for .egg-info file", "if", "dist", ".", "location", ".", "lower", "(", ")", "==", "get_python_lib",...
Returns True if package manager 'owns' file Returns False if package manager does not 'own' file There is currently no way to determine if distutils or setuptools installed a package. A future feature of setuptools will make a package manifest which can be checked. '...
[ "Returns", "True", "if", "package", "manager", "owns", "file", "Returns", "False", "if", "package", "manager", "does", "not", "own", "file" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/examples/plugins/yolk_pkg_manager/yolk_acme.py#L71-L96
train
cakebread/yolk
yolk/pypi.py
check_proxy_setting
def check_proxy_setting(): """ If the environmental variable 'HTTP_PROXY' is set, it will most likely be in one of these forms: proxyhost:8080 http://proxyhost:8080 urlllib2 requires the proxy URL to start with 'http://' This routine does that, and returns the transport for xml...
python
def check_proxy_setting(): """ If the environmental variable 'HTTP_PROXY' is set, it will most likely be in one of these forms: proxyhost:8080 http://proxyhost:8080 urlllib2 requires the proxy URL to start with 'http://' This routine does that, and returns the transport for xml...
[ "def", "check_proxy_setting", "(", ")", ":", "try", ":", "http_proxy", "=", "os", ".", "environ", "[", "'HTTP_PROXY'", "]", "except", "KeyError", ":", "return", "if", "not", "http_proxy", ".", "startswith", "(", "'http://'", ")", ":", "match", "=", "re", ...
If the environmental variable 'HTTP_PROXY' is set, it will most likely be in one of these forms: proxyhost:8080 http://proxyhost:8080 urlllib2 requires the proxy URL to start with 'http://' This routine does that, and returns the transport for xmlrpc.
[ "If", "the", "environmental", "variable", "HTTP_PROXY", "is", "set", "it", "will", "most", "likely", "be", "in", "one", "of", "these", "forms", ":" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L95-L117
train
cakebread/yolk
yolk/pypi.py
filter_url
def filter_url(pkg_type, url): """ Returns URL of specified file type 'source', 'egg', or 'all' """ bad_stuff = ["?modtime", "#md5="] for junk in bad_stuff: if junk in url: url = url.split(junk)[0] break #pkg_spec==dev (svn) if url.endswith("-dev"): ...
python
def filter_url(pkg_type, url): """ Returns URL of specified file type 'source', 'egg', or 'all' """ bad_stuff = ["?modtime", "#md5="] for junk in bad_stuff: if junk in url: url = url.split(junk)[0] break #pkg_spec==dev (svn) if url.endswith("-dev"): ...
[ "def", "filter_url", "(", "pkg_type", ",", "url", ")", ":", "bad_stuff", "=", "[", "\"?modtime\"", ",", "\"#md5=\"", "]", "for", "junk", "in", "bad_stuff", ":", "if", "junk", "in", "url", ":", "url", "=", "url", ".", "split", "(", "junk", ")", "[", ...
Returns URL of specified file type 'source', 'egg', or 'all'
[ "Returns", "URL", "of", "specified", "file", "type", "source", "egg", "or", "all" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L288-L314
train
cakebread/yolk
yolk/pypi.py
ProxyTransport.request
def request(self, host, handler, request_body, verbose): '''Send xml-rpc request using proxy''' #We get a traceback if we don't have this attribute: self.verbose = verbose url = 'http://' + host + handler request = urllib2.Request(url) request.add_data(request_body) ...
python
def request(self, host, handler, request_body, verbose): '''Send xml-rpc request using proxy''' #We get a traceback if we don't have this attribute: self.verbose = verbose url = 'http://' + host + handler request = urllib2.Request(url) request.add_data(request_body) ...
[ "def", "request", "(", "self", ",", "host", ",", "handler", ",", "request_body", ",", "verbose", ")", ":", "#We get a traceback if we don't have this attribute:", "self", ".", "verbose", "=", "verbose", "url", "=", "'http://'", "+", "host", "+", "handler", "requ...
Send xml-rpc request using proxy
[ "Send", "xml", "-", "rpc", "request", "using", "proxy" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L79-L92
train
cakebread/yolk
yolk/pypi.py
CheeseShop.get_cache
def get_cache(self): """ Get a package name list from disk cache or PyPI """ #This is used by external programs that import `CheeseShop` and don't #want a cache file written to ~/.pypi and query PyPI every time. if self.no_cache: self.pkg_list = self.list_pack...
python
def get_cache(self): """ Get a package name list from disk cache or PyPI """ #This is used by external programs that import `CheeseShop` and don't #want a cache file written to ~/.pypi and query PyPI every time. if self.no_cache: self.pkg_list = self.list_pack...
[ "def", "get_cache", "(", "self", ")", ":", "#This is used by external programs that import `CheeseShop` and don't", "#want a cache file written to ~/.pypi and query PyPI every time.", "if", "self", ".", "no_cache", ":", "self", ".", "pkg_list", "=", "self", ".", "list_packages"...
Get a package name list from disk cache or PyPI
[ "Get", "a", "package", "name", "list", "from", "disk", "cache", "or", "PyPI" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L138-L154
train
cakebread/yolk
yolk/pypi.py
CheeseShop.get_xmlrpc_server
def get_xmlrpc_server(self): """ Returns PyPI's XML-RPC server instance """ check_proxy_setting() if os.environ.has_key('XMLRPC_DEBUG'): debug = 1 else: debug = 0 try: return xmlrpclib.Server(XML_RPC_SERVER, transport=ProxyTrans...
python
def get_xmlrpc_server(self): """ Returns PyPI's XML-RPC server instance """ check_proxy_setting() if os.environ.has_key('XMLRPC_DEBUG'): debug = 1 else: debug = 0 try: return xmlrpclib.Server(XML_RPC_SERVER, transport=ProxyTrans...
[ "def", "get_xmlrpc_server", "(", "self", ")", ":", "check_proxy_setting", "(", ")", "if", "os", ".", "environ", ".", "has_key", "(", "'XMLRPC_DEBUG'", ")", ":", "debug", "=", "1", "else", ":", "debug", "=", "0", "try", ":", "return", "xmlrpclib", ".", ...
Returns PyPI's XML-RPC server instance
[ "Returns", "PyPI", "s", "XML", "-", "RPC", "server", "instance" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L162-L175
train
cakebread/yolk
yolk/pypi.py
CheeseShop.query_versions_pypi
def query_versions_pypi(self, package_name): """Fetch list of available versions for a package from The CheeseShop""" if not package_name in self.pkg_list: self.logger.debug("Package %s not in cache, querying PyPI..." \ % package_name) self.fetch_pkg_list() ...
python
def query_versions_pypi(self, package_name): """Fetch list of available versions for a package from The CheeseShop""" if not package_name in self.pkg_list: self.logger.debug("Package %s not in cache, querying PyPI..." \ % package_name) self.fetch_pkg_list() ...
[ "def", "query_versions_pypi", "(", "self", ",", "package_name", ")", ":", "if", "not", "package_name", "in", "self", ".", "pkg_list", ":", "self", ".", "logger", ".", "debug", "(", "\"Package %s not in cache, querying PyPI...\"", "%", "package_name", ")", "self", ...
Fetch list of available versions for a package from The CheeseShop
[ "Fetch", "list", "of", "available", "versions", "for", "a", "package", "from", "The", "CheeseShop" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L183-L200
train
cakebread/yolk
yolk/pypi.py
CheeseShop.query_cached_package_list
def query_cached_package_list(self): """Return list of pickled package names from PYPI""" if self.debug: self.logger.debug("DEBUG: reading pickled cache file") return cPickle.load(open(self.pkg_cache_file, "r"))
python
def query_cached_package_list(self): """Return list of pickled package names from PYPI""" if self.debug: self.logger.debug("DEBUG: reading pickled cache file") return cPickle.load(open(self.pkg_cache_file, "r"))
[ "def", "query_cached_package_list", "(", "self", ")", ":", "if", "self", ".", "debug", ":", "self", ".", "logger", ".", "debug", "(", "\"DEBUG: reading pickled cache file\"", ")", "return", "cPickle", ".", "load", "(", "open", "(", "self", ".", "pkg_cache_file...
Return list of pickled package names from PYPI
[ "Return", "list", "of", "pickled", "package", "names", "from", "PYPI" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L202-L206
train
cakebread/yolk
yolk/pypi.py
CheeseShop.fetch_pkg_list
def fetch_pkg_list(self): """Fetch and cache master list of package names from PYPI""" self.logger.debug("DEBUG: Fetching package name list from PyPI") package_list = self.list_packages() cPickle.dump(package_list, open(self.pkg_cache_file, "w")) self.pkg_list = package_list
python
def fetch_pkg_list(self): """Fetch and cache master list of package names from PYPI""" self.logger.debug("DEBUG: Fetching package name list from PyPI") package_list = self.list_packages() cPickle.dump(package_list, open(self.pkg_cache_file, "w")) self.pkg_list = package_list
[ "def", "fetch_pkg_list", "(", "self", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"DEBUG: Fetching package name list from PyPI\"", ")", "package_list", "=", "self", ".", "list_packages", "(", ")", "cPickle", ".", "dump", "(", "package_list", ",", "open...
Fetch and cache master list of package names from PYPI
[ "Fetch", "and", "cache", "master", "list", "of", "package", "names", "from", "PYPI" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L208-L213
train
cakebread/yolk
yolk/pypi.py
CheeseShop.search
def search(self, spec, operator): '''Query PYPI via XMLRPC interface using search spec''' return self.xmlrpc.search(spec, operator.lower())
python
def search(self, spec, operator): '''Query PYPI via XMLRPC interface using search spec''' return self.xmlrpc.search(spec, operator.lower())
[ "def", "search", "(", "self", ",", "spec", ",", "operator", ")", ":", "return", "self", ".", "xmlrpc", ".", "search", "(", "spec", ",", "operator", ".", "lower", "(", ")", ")" ]
Query PYPI via XMLRPC interface using search spec
[ "Query", "PYPI", "via", "XMLRPC", "interface", "using", "search", "spec" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L215-L217
train
cakebread/yolk
yolk/pypi.py
CheeseShop.release_data
def release_data(self, package_name, version): """Query PYPI via XMLRPC interface for a pkg's metadata""" try: return self.xmlrpc.release_data(package_name, version) except xmlrpclib.Fault: #XXX Raises xmlrpclib.Fault if you give non-existant version #Could th...
python
def release_data(self, package_name, version): """Query PYPI via XMLRPC interface for a pkg's metadata""" try: return self.xmlrpc.release_data(package_name, version) except xmlrpclib.Fault: #XXX Raises xmlrpclib.Fault if you give non-existant version #Could th...
[ "def", "release_data", "(", "self", ",", "package_name", ",", "version", ")", ":", "try", ":", "return", "self", ".", "xmlrpc", ".", "release_data", "(", "package_name", ",", "version", ")", "except", "xmlrpclib", ".", "Fault", ":", "#XXX Raises xmlrpclib.Faul...
Query PYPI via XMLRPC interface for a pkg's metadata
[ "Query", "PYPI", "via", "XMLRPC", "interface", "for", "a", "pkg", "s", "metadata" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L236-L243
train
cakebread/yolk
yolk/pypi.py
CheeseShop.package_releases
def package_releases(self, package_name): """Query PYPI via XMLRPC interface for a pkg's available versions""" if self.debug: self.logger.debug("DEBUG: querying PyPI for versions of " \ + package_name) return self.xmlrpc.package_releases(package_name)
python
def package_releases(self, package_name): """Query PYPI via XMLRPC interface for a pkg's available versions""" if self.debug: self.logger.debug("DEBUG: querying PyPI for versions of " \ + package_name) return self.xmlrpc.package_releases(package_name)
[ "def", "package_releases", "(", "self", ",", "package_name", ")", ":", "if", "self", ".", "debug", ":", "self", ".", "logger", ".", "debug", "(", "\"DEBUG: querying PyPI for versions of \"", "+", "package_name", ")", "return", "self", ".", "xmlrpc", ".", "pack...
Query PYPI via XMLRPC interface for a pkg's available versions
[ "Query", "PYPI", "via", "XMLRPC", "interface", "for", "a", "pkg", "s", "available", "versions" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L245-L250
train
cakebread/yolk
yolk/pypi.py
CheeseShop.get_download_urls
def get_download_urls(self, package_name, version="", pkg_type="all"): """Query PyPI for pkg download URI for a packge""" if version: versions = [version] else: #If they don't specify version, show em all. (package_name, versions) = self.query_versions_pypi...
python
def get_download_urls(self, package_name, version="", pkg_type="all"): """Query PyPI for pkg download URI for a packge""" if version: versions = [version] else: #If they don't specify version, show em all. (package_name, versions) = self.query_versions_pypi...
[ "def", "get_download_urls", "(", "self", ",", "package_name", ",", "version", "=", "\"\"", ",", "pkg_type", "=", "\"all\"", ")", ":", "if", "version", ":", "versions", "=", "[", "version", "]", "else", ":", "#If they don't specify version, show em all.", "(", ...
Query PyPI for pkg download URI for a packge
[ "Query", "PyPI", "for", "pkg", "download", "URI", "for", "a", "packge" ]
ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L252-L286
train
pyslackers/slack-sansio
slack/events.py
Event.clone
def clone(self) -> "Event": """ Clone the event Returns: :class:`slack.events.Event` """ return self.__class__(copy.deepcopy(self.event), copy.deepcopy(self.metadata))
python
def clone(self) -> "Event": """ Clone the event Returns: :class:`slack.events.Event` """ return self.__class__(copy.deepcopy(self.event), copy.deepcopy(self.metadata))
[ "def", "clone", "(", "self", ")", "->", "\"Event\"", ":", "return", "self", ".", "__class__", "(", "copy", ".", "deepcopy", "(", "self", ".", "event", ")", ",", "copy", ".", "deepcopy", "(", "self", ".", "metadata", ")", ")" ]
Clone the event Returns: :class:`slack.events.Event`
[ "Clone", "the", "event" ]
068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/events.py#L48-L56
train
pyslackers/slack-sansio
slack/events.py
Event.from_rtm
def from_rtm(cls, raw_event: MutableMapping) -> "Event": """ Create an event with data coming from the RTM API. If the event type is a message a :class:`slack.events.Message` is returned. Args: raw_event: JSON decoded data from the RTM API Returns: :cla...
python
def from_rtm(cls, raw_event: MutableMapping) -> "Event": """ Create an event with data coming from the RTM API. If the event type is a message a :class:`slack.events.Message` is returned. Args: raw_event: JSON decoded data from the RTM API Returns: :cla...
[ "def", "from_rtm", "(", "cls", ",", "raw_event", ":", "MutableMapping", ")", "->", "\"Event\"", ":", "if", "raw_event", "[", "\"type\"", "]", ".", "startswith", "(", "\"message\"", ")", ":", "return", "Message", "(", "raw_event", ")", "else", ":", "return"...
Create an event with data coming from the RTM API. If the event type is a message a :class:`slack.events.Message` is returned. Args: raw_event: JSON decoded data from the RTM API Returns: :class:`slack.events.Event` or :class:`slack.events.Message`
[ "Create", "an", "event", "with", "data", "coming", "from", "the", "RTM", "API", "." ]
068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/events.py#L59-L74
train
pyslackers/slack-sansio
slack/events.py
Event.from_http
def from_http( cls, raw_body: MutableMapping, verification_token: Optional[str] = None, team_id: Optional[str] = None, ) -> "Event": """ Create an event with data coming from the HTTP Event API. If the event type is a message a :class:`slack.events.Message` i...
python
def from_http( cls, raw_body: MutableMapping, verification_token: Optional[str] = None, team_id: Optional[str] = None, ) -> "Event": """ Create an event with data coming from the HTTP Event API. If the event type is a message a :class:`slack.events.Message` i...
[ "def", "from_http", "(", "cls", ",", "raw_body", ":", "MutableMapping", ",", "verification_token", ":", "Optional", "[", "str", "]", "=", "None", ",", "team_id", ":", "Optional", "[", "str", "]", "=", "None", ",", ")", "->", "\"Event\"", ":", "if", "ve...
Create an event with data coming from the HTTP Event API. If the event type is a message a :class:`slack.events.Message` is returned. Args: raw_body: Decoded body of the Event API request verification_token: Slack verification token used to verify the request came from slack ...
[ "Create", "an", "event", "with", "data", "coming", "from", "the", "HTTP", "Event", "API", "." ]
068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/events.py#L77-L109
train
pyslackers/slack-sansio
slack/events.py
Message.response
def response(self, in_thread: Optional[bool] = None) -> "Message": """ Create a response message. Depending on the incoming message the response can be in a thread. By default the response follow where the incoming message was posted. Args: in_thread (boolean): Over...
python
def response(self, in_thread: Optional[bool] = None) -> "Message": """ Create a response message. Depending on the incoming message the response can be in a thread. By default the response follow where the incoming message was posted. Args: in_thread (boolean): Over...
[ "def", "response", "(", "self", ",", "in_thread", ":", "Optional", "[", "bool", "]", "=", "None", ")", "->", "\"Message\"", ":", "data", "=", "{", "\"channel\"", ":", "self", "[", "\"channel\"", "]", "}", "if", "in_thread", ":", "if", "\"message\"", "i...
Create a response message. Depending on the incoming message the response can be in a thread. By default the response follow where the incoming message was posted. Args: in_thread (boolean): Overwrite the `threading` behaviour Returns: a new :class:`slack.even...
[ "Create", "a", "response", "message", "." ]
068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/events.py#L129-L157
train
pyslackers/slack-sansio
slack/events.py
Message.serialize
def serialize(self) -> dict: """ Serialize the message for sending to slack API Returns: serialized message """ data = {**self} if "attachments" in self: data["attachments"] = json.dumps(self["attachments"]) return data
python
def serialize(self) -> dict: """ Serialize the message for sending to slack API Returns: serialized message """ data = {**self} if "attachments" in self: data["attachments"] = json.dumps(self["attachments"]) return data
[ "def", "serialize", "(", "self", ")", "->", "dict", ":", "data", "=", "{", "*", "*", "self", "}", "if", "\"attachments\"", "in", "self", ":", "data", "[", "\"attachments\"", "]", "=", "json", ".", "dumps", "(", "self", "[", "\"attachments\"", "]", ")...
Serialize the message for sending to slack API Returns: serialized message
[ "Serialize", "the", "message", "for", "sending", "to", "slack", "API" ]
068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/events.py#L159-L169
train
pyslackers/slack-sansio
slack/events.py
EventRouter.register
def register(self, event_type: str, handler: Any, **detail: Any) -> None: """ Register a new handler for a specific :class:`slack.events.Event` `type` (See `slack event types documentation <https://api.slack.com/events>`_ for a list of event types). The arbitrary keyword argument is use...
python
def register(self, event_type: str, handler: Any, **detail: Any) -> None: """ Register a new handler for a specific :class:`slack.events.Event` `type` (See `slack event types documentation <https://api.slack.com/events>`_ for a list of event types). The arbitrary keyword argument is use...
[ "def", "register", "(", "self", ",", "event_type", ":", "str", ",", "handler", ":", "Any", ",", "*", "*", "detail", ":", "Any", ")", "->", "None", ":", "LOG", ".", "info", "(", "\"Registering %s, %s to %s\"", ",", "event_type", ",", "detail", ",", "han...
Register a new handler for a specific :class:`slack.events.Event` `type` (See `slack event types documentation <https://api.slack.com/events>`_ for a list of event types). The arbitrary keyword argument is used as a key/value pair to compare against what is in the incoming :class:`slack.events....
[ "Register", "a", "new", "handler", "for", "a", "specific", ":", "class", ":", "slack", ".", "events", ".", "Event", "type", "(", "See", "slack", "event", "types", "documentation", "<https", ":", "//", "api", ".", "slack", ".", "com", "/", "events", ">"...
068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/events.py#L185-L212
train
pyslackers/slack-sansio
slack/events.py
EventRouter.dispatch
def dispatch(self, event: Event) -> Iterator[Any]: """ Yields handlers matching the routing of the incoming :class:`slack.events.Event`. Args: event: :class:`slack.events.Event` Yields: handler """ LOG.debug('Dispatching event "%s"', event.get("t...
python
def dispatch(self, event: Event) -> Iterator[Any]: """ Yields handlers matching the routing of the incoming :class:`slack.events.Event`. Args: event: :class:`slack.events.Event` Yields: handler """ LOG.debug('Dispatching event "%s"', event.get("t...
[ "def", "dispatch", "(", "self", ",", "event", ":", "Event", ")", "->", "Iterator", "[", "Any", "]", ":", "LOG", ".", "debug", "(", "'Dispatching event \"%s\"'", ",", "event", ".", "get", "(", "\"type\"", ")", ")", "if", "event", "[", "\"type\"", "]", ...
Yields handlers matching the routing of the incoming :class:`slack.events.Event`. Args: event: :class:`slack.events.Event` Yields: handler
[ "Yields", "handlers", "matching", "the", "routing", "of", "the", "incoming", ":", "class", ":", "slack", ".", "events", ".", "Event", "." ]
068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/events.py#L214-L232
train
pyslackers/slack-sansio
slack/events.py
MessageRouter.register
def register( self, pattern: str, handler: Any, flags: int = 0, channel: str = "*", subtype: Optional[str] = None, ) -> None: """ Register a new handler for a specific :class:`slack.events.Message`. The routing is based on regex pattern matchi...
python
def register( self, pattern: str, handler: Any, flags: int = 0, channel: str = "*", subtype: Optional[str] = None, ) -> None: """ Register a new handler for a specific :class:`slack.events.Message`. The routing is based on regex pattern matchi...
[ "def", "register", "(", "self", ",", "pattern", ":", "str", ",", "handler", ":", "Any", ",", "flags", ":", "int", "=", "0", ",", "channel", ":", "str", "=", "\"*\"", ",", "subtype", ":", "Optional", "[", "str", "]", "=", "None", ",", ")", "->", ...
Register a new handler for a specific :class:`slack.events.Message`. The routing is based on regex pattern matching the message text and the incoming slack channel. Args: pattern: Regex pattern matching the message text. handler: Callback flags: Regex flags. ...
[ "Register", "a", "new", "handler", "for", "a", "specific", ":", "class", ":", "slack", ".", "events", ".", "Message", "." ]
068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/events.py#L247-L276
train
pyslackers/slack-sansio
slack/events.py
MessageRouter.dispatch
def dispatch(self, message: Message) -> Iterator[Any]: """ Yields handlers matching the routing of the incoming :class:`slack.events.Message` Args: message: :class:`slack.events.Message` Yields: handler """ if "text" in message: text ...
python
def dispatch(self, message: Message) -> Iterator[Any]: """ Yields handlers matching the routing of the incoming :class:`slack.events.Message` Args: message: :class:`slack.events.Message` Yields: handler """ if "text" in message: text ...
[ "def", "dispatch", "(", "self", ",", "message", ":", "Message", ")", "->", "Iterator", "[", "Any", "]", ":", "if", "\"text\"", "in", "message", ":", "text", "=", "message", "[", "\"text\"", "]", "or", "\"\"", "elif", "\"message\"", "in", "message", ":"...
Yields handlers matching the routing of the incoming :class:`slack.events.Message` Args: message: :class:`slack.events.Message` Yields: handler
[ "Yields", "handlers", "matching", "the", "routing", "of", "the", "incoming", ":", "class", ":", "slack", ".", "events", ".", "Message" ]
068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/events.py#L278-L303
train
pyslackers/slack-sansio
slack/io/requests.py
SlackAPI.query
def query( # type: ignore self, url: Union[str, methods], data: Optional[MutableMapping] = None, headers: Optional[MutableMapping] = None, as_json: Optional[bool] = None, ) -> dict: """ Query the slack API When using :class:`slack.methods` the reques...
python
def query( # type: ignore self, url: Union[str, methods], data: Optional[MutableMapping] = None, headers: Optional[MutableMapping] = None, as_json: Optional[bool] = None, ) -> dict: """ Query the slack API When using :class:`slack.methods` the reques...
[ "def", "query", "(", "# type: ignore", "self", ",", "url", ":", "Union", "[", "str", ",", "methods", "]", ",", "data", ":", "Optional", "[", "MutableMapping", "]", "=", "None", ",", "headers", ":", "Optional", "[", "MutableMapping", "]", "=", "None", "...
Query the slack API When using :class:`slack.methods` the request is made `as_json` if available Args: url: :class:`slack.methods` or url string data: JSON encodable MutableMapping headers: Custom headers as_json: Post JSON to the slack API Retur...
[ "Query", "the", "slack", "API" ]
068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/io/requests.py#L65-L93
train
pyslackers/slack-sansio
slack/io/requests.py
SlackAPI.rtm
def rtm( # type: ignore self, url: Optional[str] = None, bot_id: Optional[str] = None ) -> Iterator[events.Event]: """ Iterate over event from the RTM API Args: url: Websocket connection url bot_id: Connecting bot ID Returns: :class:`sla...
python
def rtm( # type: ignore self, url: Optional[str] = None, bot_id: Optional[str] = None ) -> Iterator[events.Event]: """ Iterate over event from the RTM API Args: url: Websocket connection url bot_id: Connecting bot ID Returns: :class:`sla...
[ "def", "rtm", "(", "# type: ignore", "self", ",", "url", ":", "Optional", "[", "str", "]", "=", "None", ",", "bot_id", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "Iterator", "[", "events", ".", "Event", "]", ":", "while", "True", ":"...
Iterate over event from the RTM API Args: url: Websocket connection url bot_id: Connecting bot ID Returns: :class:`slack.events.Event` or :class:`slack.events.Message`
[ "Iterate", "over", "event", "from", "the", "RTM", "API" ]
068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/io/requests.py#L159-L178
train
brutasse/django-ratelimit-backend
ratelimitbackend/admin.py
RateLimitAdminSite.login
def login(self, request, extra_context=None): """ Displays the login form for the given HttpRequest. """ context = { 'title': _('Log in'), 'app_path': request.get_full_path(), } if (REDIRECT_FIELD_NAME not in request.GET and REDIREC...
python
def login(self, request, extra_context=None): """ Displays the login form for the given HttpRequest. """ context = { 'title': _('Log in'), 'app_path': request.get_full_path(), } if (REDIRECT_FIELD_NAME not in request.GET and REDIREC...
[ "def", "login", "(", "self", ",", "request", ",", "extra_context", "=", "None", ")", ":", "context", "=", "{", "'title'", ":", "_", "(", "'Log in'", ")", ",", "'app_path'", ":", "request", ".", "get_full_path", "(", ")", ",", "}", "if", "(", "REDIREC...
Displays the login form for the given HttpRequest.
[ "Displays", "the", "login", "form", "for", "the", "given", "HttpRequest", "." ]
1f8f485c139eb8067f0d821ff77df98038ab9448
https://github.com/brutasse/django-ratelimit-backend/blob/1f8f485c139eb8067f0d821ff77df98038ab9448/ratelimitbackend/admin.py#L13-L31
train
crccheck/cloudwatch-to-graphite
leadbutt.py
get_config
def get_config(config_file): """Get configuration from a file.""" def load(fp): try: return yaml.safe_load(fp) except yaml.YAMLError as e: sys.stderr.write(text_type(e)) sys.exit(1) # TODO document exit codes if config_file == '-': return load(sy...
python
def get_config(config_file): """Get configuration from a file.""" def load(fp): try: return yaml.safe_load(fp) except yaml.YAMLError as e: sys.stderr.write(text_type(e)) sys.exit(1) # TODO document exit codes if config_file == '-': return load(sy...
[ "def", "get_config", "(", "config_file", ")", ":", "def", "load", "(", "fp", ")", ":", "try", ":", "return", "yaml", ".", "safe_load", "(", "fp", ")", "except", "yaml", ".", "YAMLError", "as", "e", ":", "sys", ".", "stderr", ".", "write", "(", "tex...
Get configuration from a file.
[ "Get", "configuration", "from", "a", "file", "." ]
28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6
https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/leadbutt.py#L51-L67
train
crccheck/cloudwatch-to-graphite
leadbutt.py
get_options
def get_options(config_options, local_options, cli_options): """ Figure out what options to use based on the four places it can come from. Order of precedence: * cli_options specified by the user at the command line * local_options specified in the config file for the metric * config_op...
python
def get_options(config_options, local_options, cli_options): """ Figure out what options to use based on the four places it can come from. Order of precedence: * cli_options specified by the user at the command line * local_options specified in the config file for the metric * config_op...
[ "def", "get_options", "(", "config_options", ",", "local_options", ",", "cli_options", ")", ":", "options", "=", "DEFAULT_OPTIONS", ".", "copy", "(", ")", "if", "config_options", "is", "not", "None", ":", "options", ".", "update", "(", "config_options", ")", ...
Figure out what options to use based on the four places it can come from. Order of precedence: * cli_options specified by the user at the command line * local_options specified in the config file for the metric * config_options specified in the config file at the base * DEFAULT_OPTIONS h...
[ "Figure", "out", "what", "options", "to", "use", "based", "on", "the", "four", "places", "it", "can", "come", "from", "." ]
28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6
https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/leadbutt.py#L70-L87
train
crccheck/cloudwatch-to-graphite
leadbutt.py
output_results
def output_results(results, metric, options): """ Output the results to stdout. TODO: add AMPQ support for efficiency """ formatter = options['Formatter'] context = metric.copy() # XXX might need to sanitize this try: context['dimension'] = list(metric['Dimensions'].values())[0] ...
python
def output_results(results, metric, options): """ Output the results to stdout. TODO: add AMPQ support for efficiency """ formatter = options['Formatter'] context = metric.copy() # XXX might need to sanitize this try: context['dimension'] = list(metric['Dimensions'].values())[0] ...
[ "def", "output_results", "(", "results", ",", "metric", ",", "options", ")", ":", "formatter", "=", "options", "[", "'Formatter'", "]", "context", "=", "metric", ".", "copy", "(", ")", "# XXX might need to sanitize this", "try", ":", "context", "[", "'dimensio...
Output the results to stdout. TODO: add AMPQ support for efficiency
[ "Output", "the", "results", "to", "stdout", "." ]
28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6
https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/leadbutt.py#L90-L117
train
hammerlab/cohorts
cohorts/io/gcloud_storage.py
GoogleStorageIO.download_to_path
def download_to_path(self, gsuri, localpath, binary_mode=False, tmpdir=None): """ This method is analogous to "gsutil cp gsuri localpath", but in a programatically accesible way. The only difference is that we have to make a guess about the encoding of the file to not upset downs...
python
def download_to_path(self, gsuri, localpath, binary_mode=False, tmpdir=None): """ This method is analogous to "gsutil cp gsuri localpath", but in a programatically accesible way. The only difference is that we have to make a guess about the encoding of the file to not upset downs...
[ "def", "download_to_path", "(", "self", ",", "gsuri", ",", "localpath", ",", "binary_mode", "=", "False", ",", "tmpdir", "=", "None", ")", ":", "bucket_name", ",", "gs_rel_path", "=", "self", ".", "parse_uri", "(", "gsuri", ")", "# And now request the handles ...
This method is analogous to "gsutil cp gsuri localpath", but in a programatically accesible way. The only difference is that we have to make a guess about the encoding of the file to not upset downstream file operations. If you are downloading a VCF, then "False" is great. If this is a B...
[ "This", "method", "is", "analogous", "to", "gsutil", "cp", "gsuri", "localpath", "but", "in", "a", "programatically", "accesible", "way", ".", "The", "only", "difference", "is", "that", "we", "have", "to", "make", "a", "guess", "about", "the", "encoding", ...
278b05e609e6c4d4a77c57d49446460be53ea33e
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/io/gcloud_storage.py#L97-L136
train
hammerlab/cohorts
cohorts/rounding.py
round_float
def round_float(f, digits, rounding=ROUND_HALF_UP): """ Accurate float rounding from http://stackoverflow.com/a/15398691. """ return Decimal(str(f)).quantize(Decimal(10) ** (-1 * digits), rounding=rounding)
python
def round_float(f, digits, rounding=ROUND_HALF_UP): """ Accurate float rounding from http://stackoverflow.com/a/15398691. """ return Decimal(str(f)).quantize(Decimal(10) ** (-1 * digits), rounding=rounding)
[ "def", "round_float", "(", "f", ",", "digits", ",", "rounding", "=", "ROUND_HALF_UP", ")", ":", "return", "Decimal", "(", "str", "(", "f", ")", ")", ".", "quantize", "(", "Decimal", "(", "10", ")", "**", "(", "-", "1", "*", "digits", ")", ",", "r...
Accurate float rounding from http://stackoverflow.com/a/15398691.
[ "Accurate", "float", "rounding", "from", "http", ":", "//", "stackoverflow", ".", "com", "/", "a", "/", "15398691", "." ]
278b05e609e6c4d4a77c57d49446460be53ea33e
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/rounding.py#L17-L22
train
hammerlab/cohorts
cohorts/rounding.py
float_str
def float_str(f, min_digits=2, max_digits=6): """ Returns a string representing a float, where the number of significant digits is min_digits unless it takes more digits to hit a non-zero digit (and the number is 0 < x < 1). We stop looking for a non-zero digit after max_digits. """ if f >= ...
python
def float_str(f, min_digits=2, max_digits=6): """ Returns a string representing a float, where the number of significant digits is min_digits unless it takes more digits to hit a non-zero digit (and the number is 0 < x < 1). We stop looking for a non-zero digit after max_digits. """ if f >= ...
[ "def", "float_str", "(", "f", ",", "min_digits", "=", "2", ",", "max_digits", "=", "6", ")", ":", "if", "f", ">=", "1", "or", "f", "<=", "0", ":", "return", "str", "(", "round_float", "(", "f", ",", "min_digits", ")", ")", "start_str", "=", "str"...
Returns a string representing a float, where the number of significant digits is min_digits unless it takes more digits to hit a non-zero digit (and the number is 0 < x < 1). We stop looking for a non-zero digit after max_digits.
[ "Returns", "a", "string", "representing", "a", "float", "where", "the", "number", "of", "significant", "digits", "is", "min_digits", "unless", "it", "takes", "more", "digits", "to", "hit", "a", "non", "-", "zero", "digit", "(", "and", "the", "number", "is"...
278b05e609e6c4d4a77c57d49446460be53ea33e
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/rounding.py#L24-L46
train
alvarogzp/telegram-bot-framework
bot/action/util/format.py
UserFormatter.default_format
def default_format(self): """ Returns full name (first and last) if name is available. If not, returns username if available. If not available too, returns the user id as a string. """ user = self.user if user.first_name is not None: return self.full_n...
python
def default_format(self): """ Returns full name (first and last) if name is available. If not, returns username if available. If not available too, returns the user id as a string. """ user = self.user if user.first_name is not None: return self.full_n...
[ "def", "default_format", "(", "self", ")", ":", "user", "=", "self", ".", "user", "if", "user", ".", "first_name", "is", "not", "None", ":", "return", "self", ".", "full_name", "elif", "user", ".", "username", "is", "not", "None", ":", "return", "user"...
Returns full name (first and last) if name is available. If not, returns username if available. If not available too, returns the user id as a string.
[ "Returns", "full", "name", "(", "first", "and", "last", ")", "if", "name", "is", "available", ".", "If", "not", "returns", "username", "if", "available", ".", "If", "not", "available", "too", "returns", "the", "user", "id", "as", "a", "string", "." ]
7b597a415c1901901c677976cb13100fc3083107
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/util/format.py#L31-L43
train
alvarogzp/telegram-bot-framework
bot/action/util/format.py
UserFormatter.full_name
def full_name(self): """ Returns the first and last name of the user separated by a space. """ formatted_user = [] if self.user.first_name is not None: formatted_user.append(self.user.first_name) if self.user.last_name is not None: formatted_user.a...
python
def full_name(self): """ Returns the first and last name of the user separated by a space. """ formatted_user = [] if self.user.first_name is not None: formatted_user.append(self.user.first_name) if self.user.last_name is not None: formatted_user.a...
[ "def", "full_name", "(", "self", ")", ":", "formatted_user", "=", "[", "]", "if", "self", ".", "user", ".", "first_name", "is", "not", "None", ":", "formatted_user", ".", "append", "(", "self", ".", "user", ".", "first_name", ")", "if", "self", ".", ...
Returns the first and last name of the user separated by a space.
[ "Returns", "the", "first", "and", "last", "name", "of", "the", "user", "separated", "by", "a", "space", "." ]
7b597a415c1901901c677976cb13100fc3083107
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/util/format.py#L46-L55
train
alvarogzp/telegram-bot-framework
bot/action/util/format.py
UserFormatter.full_format
def full_format(self): """ Returns the full name (first and last parts), and the username between brackets if the user has it. If there is no info about the user, returns the user id between < and >. """ formatted_user = self.full_name if self.user.username is not None: ...
python
def full_format(self): """ Returns the full name (first and last parts), and the username between brackets if the user has it. If there is no info about the user, returns the user id between < and >. """ formatted_user = self.full_name if self.user.username is not None: ...
[ "def", "full_format", "(", "self", ")", ":", "formatted_user", "=", "self", ".", "full_name", "if", "self", ".", "user", ".", "username", "is", "not", "None", ":", "formatted_user", "+=", "\" [\"", "+", "self", ".", "user", ".", "username", "+", "\"]\"",...
Returns the full name (first and last parts), and the username between brackets if the user has it. If there is no info about the user, returns the user id between < and >.
[ "Returns", "the", "full", "name", "(", "first", "and", "last", "parts", ")", "and", "the", "username", "between", "brackets", "if", "the", "user", "has", "it", ".", "If", "there", "is", "no", "info", "about", "the", "user", "returns", "the", "user", "i...
7b597a415c1901901c677976cb13100fc3083107
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/util/format.py#L66-L76
train
alvarogzp/telegram-bot-framework
bot/action/util/format.py
UserFormatter.full_data
def full_data(self): """ Returns all the info available for the user in the following format: name [username] <id> (locale) bot_or_user If any data is not available, it is not added. """ data = [ self.full_name, self._username(), se...
python
def full_data(self): """ Returns all the info available for the user in the following format: name [username] <id> (locale) bot_or_user If any data is not available, it is not added. """ data = [ self.full_name, self._username(), se...
[ "def", "full_data", "(", "self", ")", ":", "data", "=", "[", "self", ".", "full_name", ",", "self", ".", "_username", "(", ")", ",", "self", ".", "_id", "(", ")", ",", "self", ".", "_language_code", "(", ")", ",", "self", ".", "_is_bot", "(", ")"...
Returns all the info available for the user in the following format: name [username] <id> (locale) bot_or_user If any data is not available, it is not added.
[ "Returns", "all", "the", "info", "available", "for", "the", "user", "in", "the", "following", "format", ":", "name", "[", "username", "]", "<id", ">", "(", "locale", ")", "bot_or_user", "If", "any", "data", "is", "not", "available", "it", "is", "not", ...
7b597a415c1901901c677976cb13100fc3083107
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/util/format.py#L79-L92
train
alvarogzp/telegram-bot-framework
bot/action/util/format.py
ChatFormatter.full_data
def full_data(self): """ Returns all the info available for the chat in the following format: title [username] (type) <id> If any data is not available, it is not added. """ data = [ self.chat.title, self._username(), self._type(), ...
python
def full_data(self): """ Returns all the info available for the chat in the following format: title [username] (type) <id> If any data is not available, it is not added. """ data = [ self.chat.title, self._username(), self._type(), ...
[ "def", "full_data", "(", "self", ")", ":", "data", "=", "[", "self", ".", "chat", ".", "title", ",", "self", ".", "_username", "(", ")", ",", "self", ".", "_type", "(", ")", ",", "self", ".", "_id", "(", ")", "]", "return", "\" \"", ".", "join"...
Returns all the info available for the chat in the following format: title [username] (type) <id> If any data is not available, it is not added.
[ "Returns", "all", "the", "info", "available", "for", "the", "chat", "in", "the", "following", "format", ":", "title", "[", "username", "]", "(", "type", ")", "<id", ">", "If", "any", "data", "is", "not", "available", "it", "is", "not", "added", "." ]
7b597a415c1901901c677976cb13100fc3083107
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/util/format.py#L124-L136
train
hammerlab/cohorts
cohorts/functions.py
use_defaults
def use_defaults(func): """ Decorator for functions that should automatically fall back to the Cohort-default filter_fn and normalized_per_mb if not specified. """ @wraps(func) def wrapper(row, cohort, filter_fn=None, normalized_per_mb=None, **kwargs): filter_fn = first_not_none_param([f...
python
def use_defaults(func): """ Decorator for functions that should automatically fall back to the Cohort-default filter_fn and normalized_per_mb if not specified. """ @wraps(func) def wrapper(row, cohort, filter_fn=None, normalized_per_mb=None, **kwargs): filter_fn = first_not_none_param([f...
[ "def", "use_defaults", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "row", ",", "cohort", ",", "filter_fn", "=", "None", ",", "normalized_per_mb", "=", "None", ",", "*", "*", "kwargs", ")", ":", "filter_fn", "=", "fir...
Decorator for functions that should automatically fall back to the Cohort-default filter_fn and normalized_per_mb if not specified.
[ "Decorator", "for", "functions", "that", "should", "automatically", "fall", "back", "to", "the", "Cohort", "-", "default", "filter_fn", "and", "normalized_per_mb", "if", "not", "specified", "." ]
278b05e609e6c4d4a77c57d49446460be53ea33e
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/functions.py#L28-L42
train
hammerlab/cohorts
cohorts/functions.py
count_function
def count_function(func): """ Decorator for functions that return a collection (technically a dict of collections) that should be counted up. Also automatically falls back to the Cohort-default filter_fn and normalized_per_mb if not specified. """ # Fall back to Cohort-level defaults. @use_d...
python
def count_function(func): """ Decorator for functions that return a collection (technically a dict of collections) that should be counted up. Also automatically falls back to the Cohort-default filter_fn and normalized_per_mb if not specified. """ # Fall back to Cohort-level defaults. @use_d...
[ "def", "count_function", "(", "func", ")", ":", "# Fall back to Cohort-level defaults.", "@", "use_defaults", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "row", ",", "cohort", ",", "filter_fn", "=", "None", ",", "normalized_per_mb", "=", "None", ","...
Decorator for functions that return a collection (technically a dict of collections) that should be counted up. Also automatically falls back to the Cohort-default filter_fn and normalized_per_mb if not specified.
[ "Decorator", "for", "functions", "that", "return", "a", "collection", "(", "technically", "a", "dict", "of", "collections", ")", "that", "should", "be", "counted", "up", ".", "Also", "automatically", "falls", "back", "to", "the", "Cohort", "-", "default", "f...
278b05e609e6c4d4a77c57d49446460be53ea33e
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/functions.py#L44-L66
train
hammerlab/cohorts
cohorts/functions.py
count_variants_function_builder
def count_variants_function_builder(function_name, filterable_variant_function=None): """ Creates a function that counts variants that are filtered by the provided filterable_variant_function. The filterable_variant_function is a function that takes a filterable_variant and returns True or False. Users...
python
def count_variants_function_builder(function_name, filterable_variant_function=None): """ Creates a function that counts variants that are filtered by the provided filterable_variant_function. The filterable_variant_function is a function that takes a filterable_variant and returns True or False. Users...
[ "def", "count_variants_function_builder", "(", "function_name", ",", "filterable_variant_function", "=", "None", ")", ":", "@", "count_function", "def", "count", "(", "row", ",", "cohort", ",", "filter_fn", ",", "normalized_per_mb", ",", "*", "*", "kwargs", ")", ...
Creates a function that counts variants that are filtered by the provided filterable_variant_function. The filterable_variant_function is a function that takes a filterable_variant and returns True or False. Users of this builder need not worry about applying e.g. the Cohort's default `filter_fn`. That will be...
[ "Creates", "a", "function", "that", "counts", "variants", "that", "are", "filtered", "by", "the", "provided", "filterable_variant_function", ".", "The", "filterable_variant_function", "is", "a", "function", "that", "takes", "a", "filterable_variant", "and", "returns",...
278b05e609e6c4d4a77c57d49446460be53ea33e
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/functions.py#L73-L93
train
hammerlab/cohorts
cohorts/functions.py
count_effects_function_builder
def count_effects_function_builder(function_name, only_nonsynonymous, filterable_effect_function=None): """ Create a function that counts effects that are filtered by the provided filterable_effect_function. The filterable_effect_function is a function that takes a filterable_effect and returns True or Fals...
python
def count_effects_function_builder(function_name, only_nonsynonymous, filterable_effect_function=None): """ Create a function that counts effects that are filtered by the provided filterable_effect_function. The filterable_effect_function is a function that takes a filterable_effect and returns True or Fals...
[ "def", "count_effects_function_builder", "(", "function_name", ",", "only_nonsynonymous", ",", "filterable_effect_function", "=", "None", ")", ":", "@", "count_function", "def", "count", "(", "row", ",", "cohort", ",", "filter_fn", ",", "normalized_per_mb", ",", "*"...
Create a function that counts effects that are filtered by the provided filterable_effect_function. The filterable_effect_function is a function that takes a filterable_effect and returns True or False. Users of this builder need not worry about applying e.g. the Cohort's default `filter_fn`. That will be appl...
[ "Create", "a", "function", "that", "counts", "effects", "that", "are", "filtered", "by", "the", "provided", "filterable_effect_function", ".", "The", "filterable_effect_function", "is", "a", "function", "that", "takes", "a", "filterable_effect", "and", "returns", "T...
278b05e609e6c4d4a77c57d49446460be53ea33e
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/functions.py#L95-L121
train
hammerlab/cohorts
cohorts/functions.py
median_vaf_purity
def median_vaf_purity(row, cohort, **kwargs): """ Estimate purity based on 2 * median VAF. Even if the Cohort has a default filter_fn, ignore it: we want to use all variants for this estimate. """ patient_id = row["patient_id"] patient = cohort.patient_from_id(patient_id) variants = coh...
python
def median_vaf_purity(row, cohort, **kwargs): """ Estimate purity based on 2 * median VAF. Even if the Cohort has a default filter_fn, ignore it: we want to use all variants for this estimate. """ patient_id = row["patient_id"] patient = cohort.patient_from_id(patient_id) variants = coh...
[ "def", "median_vaf_purity", "(", "row", ",", "cohort", ",", "*", "*", "kwargs", ")", ":", "patient_id", "=", "row", "[", "\"patient_id\"", "]", "patient", "=", "cohort", ".", "patient_from_id", "(", "patient_id", ")", "variants", "=", "cohort", ".", "load_...
Estimate purity based on 2 * median VAF. Even if the Cohort has a default filter_fn, ignore it: we want to use all variants for this estimate.
[ "Estimate", "purity", "based", "on", "2", "*", "median", "VAF", "." ]
278b05e609e6c4d4a77c57d49446460be53ea33e
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/functions.py#L264-L282
train
hammerlab/cohorts
cohorts/model.py
bootstrap_auc
def bootstrap_auc(df, col, pred_col, n_bootstrap=1000): """ Calculate the boostrapped AUC for a given col trying to predict a pred_col. Parameters ---------- df : pandas.DataFrame col : str column to retrieve the values from pred_col : str the column we're trying to predict ...
python
def bootstrap_auc(df, col, pred_col, n_bootstrap=1000): """ Calculate the boostrapped AUC for a given col trying to predict a pred_col. Parameters ---------- df : pandas.DataFrame col : str column to retrieve the values from pred_col : str the column we're trying to predict ...
[ "def", "bootstrap_auc", "(", "df", ",", "col", ",", "pred_col", ",", "n_bootstrap", "=", "1000", ")", ":", "scores", "=", "np", ".", "zeros", "(", "n_bootstrap", ")", "old_len", "=", "len", "(", "df", ")", "df", ".", "dropna", "(", "subset", "=", "...
Calculate the boostrapped AUC for a given col trying to predict a pred_col. Parameters ---------- df : pandas.DataFrame col : str column to retrieve the values from pred_col : str the column we're trying to predict n_boostrap : int the number of bootstrap samples Re...
[ "Calculate", "the", "boostrapped", "AUC", "for", "a", "given", "col", "trying", "to", "predict", "a", "pred_col", "." ]
278b05e609e6c4d4a77c57d49446460be53ea33e
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/model.py#L36-L66
train
alvarogzp/telegram-bot-framework
bot/multithreading/scheduler.py
SchedulerApi.set_callbacks
def set_callbacks(self, worker_start_callback: callable, worker_end_callback: callable, are_async: bool = False): """ :param are_async: True if the callbacks execute asynchronously, posting any heavy work to another thread. """ # We are setting self.worker_start_callback and self.worker_...
python
def set_callbacks(self, worker_start_callback: callable, worker_end_callback: callable, are_async: bool = False): """ :param are_async: True if the callbacks execute asynchronously, posting any heavy work to another thread. """ # We are setting self.worker_start_callback and self.worker_...
[ "def", "set_callbacks", "(", "self", ",", "worker_start_callback", ":", "callable", ",", "worker_end_callback", ":", "callable", ",", "are_async", ":", "bool", "=", "False", ")", ":", "# We are setting self.worker_start_callback and self.worker_end_callback", "# to lambdas ...
:param are_async: True if the callbacks execute asynchronously, posting any heavy work to another thread.
[ ":", "param", "are_async", ":", "True", "if", "the", "callbacks", "execute", "asynchronously", "posting", "any", "heavy", "work", "to", "another", "thread", "." ]
7b597a415c1901901c677976cb13100fc3083107
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/multithreading/scheduler.py#L59-L80
train
alvarogzp/telegram-bot-framework
bot/multithreading/scheduler.py
SchedulerApi._start_worker
def _start_worker(self, worker: Worker): """ Can be safely called multiple times on the same worker (for workers that support it) to start a new thread for it. """ # This function is called from main thread and from worker pools threads to start their children threads wit...
python
def _start_worker(self, worker: Worker): """ Can be safely called multiple times on the same worker (for workers that support it) to start a new thread for it. """ # This function is called from main thread and from worker pools threads to start their children threads wit...
[ "def", "_start_worker", "(", "self", ",", "worker", ":", "Worker", ")", ":", "# This function is called from main thread and from worker pools threads to start their children threads", "with", "self", ".", "running_workers_lock", ":", "self", ".", "running_workers", ".", "app...
Can be safely called multiple times on the same worker (for workers that support it) to start a new thread for it.
[ "Can", "be", "safely", "called", "multiple", "times", "on", "the", "same", "worker", "(", "for", "workers", "that", "support", "it", ")", "to", "start", "a", "new", "thread", "for", "it", "." ]
7b597a415c1901901c677976cb13100fc3083107
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/multithreading/scheduler.py#L95-L106
train
alvarogzp/telegram-bot-framework
bot/multithreading/scheduler.py
SchedulerApi.new_worker
def new_worker(self, name: str): """Creates a new Worker and start a new Thread with it. Returns the Worker.""" if not self.running: return self.immediate_worker worker = self._new_worker(name) self._start_worker(worker) return worker
python
def new_worker(self, name: str): """Creates a new Worker and start a new Thread with it. Returns the Worker.""" if not self.running: return self.immediate_worker worker = self._new_worker(name) self._start_worker(worker) return worker
[ "def", "new_worker", "(", "self", ",", "name", ":", "str", ")", ":", "if", "not", "self", ".", "running", ":", "return", "self", ".", "immediate_worker", "worker", "=", "self", ".", "_new_worker", "(", "name", ")", "self", ".", "_start_worker", "(", "w...
Creates a new Worker and start a new Thread with it. Returns the Worker.
[ "Creates", "a", "new", "Worker", "and", "start", "a", "new", "Thread", "with", "it", ".", "Returns", "the", "Worker", "." ]
7b597a415c1901901c677976cb13100fc3083107
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/multithreading/scheduler.py#L148-L154
train
alvarogzp/telegram-bot-framework
bot/multithreading/scheduler.py
SchedulerApi.new_worker_pool
def new_worker_pool(self, name: str, min_workers: int = 0, max_workers: int = 1, max_seconds_idle: int = DEFAULT_WORKER_POOL_MAX_SECONDS_IDLE): """ Creates a new worker pool and starts it. Returns the Worker that schedules works to the pool. """ if not sel...
python
def new_worker_pool(self, name: str, min_workers: int = 0, max_workers: int = 1, max_seconds_idle: int = DEFAULT_WORKER_POOL_MAX_SECONDS_IDLE): """ Creates a new worker pool and starts it. Returns the Worker that schedules works to the pool. """ if not sel...
[ "def", "new_worker_pool", "(", "self", ",", "name", ":", "str", ",", "min_workers", ":", "int", "=", "0", ",", "max_workers", ":", "int", "=", "1", ",", "max_seconds_idle", ":", "int", "=", "DEFAULT_WORKER_POOL_MAX_SECONDS_IDLE", ")", ":", "if", "not", "se...
Creates a new worker pool and starts it. Returns the Worker that schedules works to the pool.
[ "Creates", "a", "new", "worker", "pool", "and", "starts", "it", ".", "Returns", "the", "Worker", "that", "schedules", "works", "to", "the", "pool", "." ]
7b597a415c1901901c677976cb13100fc3083107
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/multithreading/scheduler.py#L156-L166
train
hammerlab/cohorts
cohorts/cohort.py
Cohort.as_dataframe
def as_dataframe(self, on=None, join_with=None, join_how=None, return_cols=False, rename_cols=False, keep_paren_contents=True, **kwargs): """ Return this Cohort as a DataFrame, and optionally include additional columns using `on`. on : str or fu...
python
def as_dataframe(self, on=None, join_with=None, join_how=None, return_cols=False, rename_cols=False, keep_paren_contents=True, **kwargs): """ Return this Cohort as a DataFrame, and optionally include additional columns using `on`. on : str or fu...
[ "def", "as_dataframe", "(", "self", ",", "on", "=", "None", ",", "join_with", "=", "None", ",", "join_how", "=", "None", ",", "return_cols", "=", "False", ",", "rename_cols", "=", "False", ",", "keep_paren_contents", "=", "True", ",", "*", "*", "kwargs",...
Return this Cohort as a DataFrame, and optionally include additional columns using `on`. on : str or function or list or dict, optional - A column name. - Or a function that creates a new column for comparison, e.g. count.snv_count. - Or a list of column-generating f...
[ "Return", "this", "Cohort", "as", "a", "DataFrame", "and", "optionally", "include", "additional", "columns", "using", "on", "." ]
278b05e609e6c4d4a77c57d49446460be53ea33e
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L302-L400
train
hammerlab/cohorts
cohorts/cohort.py
Cohort.load_dataframe
def load_dataframe(self, df_loader_name): """ Instead of joining a DataFrameJoiner with the Cohort in `as_dataframe`, sometimes we may want to just directly load a particular DataFrame. """ logger.debug("loading dataframe: {}".format(df_loader_name)) # Get the DataFrameLo...
python
def load_dataframe(self, df_loader_name): """ Instead of joining a DataFrameJoiner with the Cohort in `as_dataframe`, sometimes we may want to just directly load a particular DataFrame. """ logger.debug("loading dataframe: {}".format(df_loader_name)) # Get the DataFrameLo...
[ "def", "load_dataframe", "(", "self", ",", "df_loader_name", ")", ":", "logger", ".", "debug", "(", "\"loading dataframe: {}\"", ".", "format", "(", "df_loader_name", ")", ")", "# Get the DataFrameLoader object corresponding to this name.", "df_loaders", "=", "[", "df_l...
Instead of joining a DataFrameJoiner with the Cohort in `as_dataframe`, sometimes we may want to just directly load a particular DataFrame.
[ "Instead", "of", "joining", "a", "DataFrameJoiner", "with", "the", "Cohort", "in", "as_dataframe", "sometimes", "we", "may", "want", "to", "just", "directly", "load", "a", "particular", "DataFrame", "." ]
278b05e609e6c4d4a77c57d49446460be53ea33e
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L402-L416
train
hammerlab/cohorts
cohorts/cohort.py
Cohort._get_function_name
def _get_function_name(self, fn, default="None"): """ Return name of function, using default value if function not defined """ if fn is None: fn_name = default else: fn_name = fn.__name__ return fn_name
python
def _get_function_name(self, fn, default="None"): """ Return name of function, using default value if function not defined """ if fn is None: fn_name = default else: fn_name = fn.__name__ return fn_name
[ "def", "_get_function_name", "(", "self", ",", "fn", ",", "default", "=", "\"None\"", ")", ":", "if", "fn", "is", "None", ":", "fn_name", "=", "default", "else", ":", "fn_name", "=", "fn", ".", "__name__", "return", "fn_name" ]
Return name of function, using default value if function not defined
[ "Return", "name", "of", "function", "using", "default", "value", "if", "function", "not", "defined" ]
278b05e609e6c4d4a77c57d49446460be53ea33e
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L502-L509
train
hammerlab/cohorts
cohorts/cohort.py
Cohort.load_variants
def load_variants(self, patients=None, filter_fn=None, **kwargs): """Load a dictionary of patient_id to varcode.VariantCollection Parameters ---------- patients : str, optional Filter to a subset of patients filter_fn : function Takes a FilterableVariant ...
python
def load_variants(self, patients=None, filter_fn=None, **kwargs): """Load a dictionary of patient_id to varcode.VariantCollection Parameters ---------- patients : str, optional Filter to a subset of patients filter_fn : function Takes a FilterableVariant ...
[ "def", "load_variants", "(", "self", ",", "patients", "=", "None", ",", "filter_fn", "=", "None", ",", "*", "*", "kwargs", ")", ":", "filter_fn", "=", "first_not_none_param", "(", "[", "filter_fn", ",", "self", ".", "filter_fn", "]", ",", "no_filter", ")...
Load a dictionary of patient_id to varcode.VariantCollection Parameters ---------- patients : str, optional Filter to a subset of patients filter_fn : function Takes a FilterableVariant and returns a boolean. Only variants returning True are preserved. ...
[ "Load", "a", "dictionary", "of", "patient_id", "to", "varcode", ".", "VariantCollection" ]
278b05e609e6c4d4a77c57d49446460be53ea33e
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L511-L536
train
hammerlab/cohorts
cohorts/cohort.py
Cohort._hash_filter_fn
def _hash_filter_fn(self, filter_fn, **kwargs): """ Construct string representing state of filter_fn Used to cache filtered variants or effects uniquely depending on filter fn values """ filter_fn_name = self._get_function_name(filter_fn, default="filter-none") logger.debug("...
python
def _hash_filter_fn(self, filter_fn, **kwargs): """ Construct string representing state of filter_fn Used to cache filtered variants or effects uniquely depending on filter fn values """ filter_fn_name = self._get_function_name(filter_fn, default="filter-none") logger.debug("...
[ "def", "_hash_filter_fn", "(", "self", ",", "filter_fn", ",", "*", "*", "kwargs", ")", ":", "filter_fn_name", "=", "self", ".", "_get_function_name", "(", "filter_fn", ",", "default", "=", "\"filter-none\"", ")", "logger", ".", "debug", "(", "\"Computing hash ...
Construct string representing state of filter_fn Used to cache filtered variants or effects uniquely depending on filter fn values
[ "Construct", "string", "representing", "state", "of", "filter_fn", "Used", "to", "cache", "filtered", "variants", "or", "effects", "uniquely", "depending", "on", "filter", "fn", "values" ]
278b05e609e6c4d4a77c57d49446460be53ea33e
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L538-L570
train
hammerlab/cohorts
cohorts/cohort.py
Cohort._load_single_patient_variants
def _load_single_patient_variants(self, patient, filter_fn, use_cache=True, **kwargs): """ Load filtered, merged variants for a single patient, optionally using cache Note that filtered variants are first merged before filtering, and each step is cached independently. Turn on debug ...
python
def _load_single_patient_variants(self, patient, filter_fn, use_cache=True, **kwargs): """ Load filtered, merged variants for a single patient, optionally using cache Note that filtered variants are first merged before filtering, and each step is cached independently. Turn on debug ...
[ "def", "_load_single_patient_variants", "(", "self", ",", "patient", ",", "filter_fn", ",", "use_cache", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "filter_fn", "is", "None", ":", "use_filtered_cache", "=", "False", "else", ":", "filter_fn_name", ...
Load filtered, merged variants for a single patient, optionally using cache Note that filtered variants are first merged before filtering, and each step is cached independently. Turn on debug statements for more details about cached files. Use `_load_single_pati...
[ "Load", "filtered", "merged", "variants", "for", "a", "single", "patient", "optionally", "using", "cache" ]
278b05e609e6c4d4a77c57d49446460be53ea33e
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L572-L626
train
hammerlab/cohorts
cohorts/cohort.py
Cohort._load_single_patient_merged_variants
def _load_single_patient_merged_variants(self, patient, use_cache=True): """ Load merged variants for a single patient, optionally using cache Note that merged variants are not filtered. Use `_load_single_patient_variants` to get filtered variants """ logger.debug("loadi...
python
def _load_single_patient_merged_variants(self, patient, use_cache=True): """ Load merged variants for a single patient, optionally using cache Note that merged variants are not filtered. Use `_load_single_patient_variants` to get filtered variants """ logger.debug("loadi...
[ "def", "_load_single_patient_merged_variants", "(", "self", ",", "patient", ",", "use_cache", "=", "True", ")", ":", "logger", ".", "debug", "(", "\"loading merged variants for patient {}\"", ".", "format", "(", "patient", ".", "id", ")", ")", "no_variants", "=", ...
Load merged variants for a single patient, optionally using cache Note that merged variants are not filtered. Use `_load_single_patient_variants` to get filtered variants
[ "Load", "merged", "variants", "for", "a", "single", "patient", "optionally", "using", "cache" ]
278b05e609e6c4d4a77c57d49446460be53ea33e
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L628-L695
train
hammerlab/cohorts
cohorts/cohort.py
Cohort.load_polyphen_annotations
def load_polyphen_annotations(self, as_dataframe=False, filter_fn=None): """Load a dataframe containing polyphen2 annotations for all variants Parameters ---------- database_file : string, sqlite Path to the WHESS/Polyphen2 SQLite database. ...
python
def load_polyphen_annotations(self, as_dataframe=False, filter_fn=None): """Load a dataframe containing polyphen2 annotations for all variants Parameters ---------- database_file : string, sqlite Path to the WHESS/Polyphen2 SQLite database. ...
[ "def", "load_polyphen_annotations", "(", "self", ",", "as_dataframe", "=", "False", ",", "filter_fn", "=", "None", ")", ":", "filter_fn", "=", "first_not_none_param", "(", "[", "filter_fn", ",", "self", ".", "filter_fn", "]", ",", "no_filter", ")", "patient_an...
Load a dataframe containing polyphen2 annotations for all variants Parameters ---------- database_file : string, sqlite Path to the WHESS/Polyphen2 SQLite database. Can be downloaded and bunzip2"ed from http://bit.ly/208mlIU filter_fn : function Takes...
[ "Load", "a", "dataframe", "containing", "polyphen2", "annotations", "for", "all", "variants" ]
278b05e609e6c4d4a77c57d49446460be53ea33e
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L708-L738
train
hammerlab/cohorts
cohorts/cohort.py
Cohort.load_effects
def load_effects(self, patients=None, only_nonsynonymous=False, all_effects=False, filter_fn=None, **kwargs): """Load a dictionary of patient_id to varcode.EffectCollection Note that this only loads one effect per variant. Parameters ---------- patients : s...
python
def load_effects(self, patients=None, only_nonsynonymous=False, all_effects=False, filter_fn=None, **kwargs): """Load a dictionary of patient_id to varcode.EffectCollection Note that this only loads one effect per variant. Parameters ---------- patients : s...
[ "def", "load_effects", "(", "self", ",", "patients", "=", "None", ",", "only_nonsynonymous", "=", "False", ",", "all_effects", "=", "False", ",", "filter_fn", "=", "None", ",", "*", "*", "kwargs", ")", ":", "filter_fn", "=", "first_not_none_param", "(", "[...
Load a dictionary of patient_id to varcode.EffectCollection Note that this only loads one effect per variant. Parameters ---------- patients : str, optional Filter to a subset of patients only_nonsynonymous : bool, optional If true, load only nonsynonymo...
[ "Load", "a", "dictionary", "of", "patient_id", "to", "varcode", ".", "EffectCollection" ]
278b05e609e6c4d4a77c57d49446460be53ea33e
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L790-L822
train
hammerlab/cohorts
cohorts/cohort.py
Cohort.load_kallisto
def load_kallisto(self): """ Load Kallisto transcript quantification data for a cohort Parameters ---------- Returns ------- kallisto_data : Pandas dataframe Pandas dataframe with Kallisto data for all patients columns include patient_id,...
python
def load_kallisto(self): """ Load Kallisto transcript quantification data for a cohort Parameters ---------- Returns ------- kallisto_data : Pandas dataframe Pandas dataframe with Kallisto data for all patients columns include patient_id,...
[ "def", "load_kallisto", "(", "self", ")", ":", "kallisto_data", "=", "pd", ".", "concat", "(", "[", "self", ".", "_load_single_patient_kallisto", "(", "patient", ")", "for", "patient", "in", "self", "]", ",", "copy", "=", "False", ")", "if", "self", ".",...
Load Kallisto transcript quantification data for a cohort Parameters ---------- Returns ------- kallisto_data : Pandas dataframe Pandas dataframe with Kallisto data for all patients columns include patient_id, gene_name, est_counts
[ "Load", "Kallisto", "transcript", "quantification", "data", "for", "a", "cohort" ]
278b05e609e6c4d4a77c57d49446460be53ea33e
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L865-L895
train