repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
hyperboria/python-cjdns | setup.py | readme | def readme(fname):
"""Reads a markdown file and returns the contents formatted as rst"""
md = open(os.path.join(os.path.dirname(__file__), fname)).read()
output = md
try:
import pypandoc
output = pypandoc.convert(md, 'rst', format='md')
except ImportError:
pass
return out... | python | def readme(fname):
"""Reads a markdown file and returns the contents formatted as rst"""
md = open(os.path.join(os.path.dirname(__file__), fname)).read()
output = md
try:
import pypandoc
output = pypandoc.convert(md, 'rst', format='md')
except ImportError:
pass
return out... | [
"def",
"readme",
"(",
"fname",
")",
":",
"md",
"=",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"fname",
")",
")",
".",
"read",
"(",
")",
"output",
"=",
"md",
"try",
":",
"im... | Reads a markdown file and returns the contents formatted as rst | [
"Reads",
"a",
"markdown",
"file",
"and",
"returns",
"the",
"contents",
"formatted",
"as",
"rst"
] | train | https://github.com/hyperboria/python-cjdns/blob/a9ae5d6d2e99c18f9fc50a9589729cd176efa900/setup.py#L20-L29 |
LordGaav/python-chaos | chaos/config.py | get_config | def get_config(config_base, custom_file=None, configspec=None):
"""
Loads a configuration file from multiple locations, and merge the results into one.
This function will load configuration files from a number of locations in sequence,
and will overwrite values in the previous level if they are redefined in the cu... | python | def get_config(config_base, custom_file=None, configspec=None):
"""
Loads a configuration file from multiple locations, and merge the results into one.
This function will load configuration files from a number of locations in sequence,
and will overwrite values in the previous level if they are redefined in the cu... | [
"def",
"get_config",
"(",
"config_base",
",",
"custom_file",
"=",
"None",
",",
"configspec",
"=",
"None",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"debug",
"(",
"\"Expanding variables\"",
")",
"home",
"=",
... | Loads a configuration file from multiple locations, and merge the results into one.
This function will load configuration files from a number of locations in sequence,
and will overwrite values in the previous level if they are redefined in the current.
The levels are in sequence:
1. Distribution level configura... | [
"Loads",
"a",
"configuration",
"file",
"from",
"multiple",
"locations",
"and",
"merge",
"the",
"results",
"into",
"one",
"."
] | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/config.py#L32-L98 |
LordGaav/python-chaos | chaos/config.py | get_config_dir | def get_config_dir(path, pattern="*.config", configspec=None, allow_errors=False):
"""
Load an entire directory of configuration files, merging them into one.
This function will load multiple configuration files matching the given pattern,
in the given path, and merge them. The found files are first sorted alphabe... | python | def get_config_dir(path, pattern="*.config", configspec=None, allow_errors=False):
"""
Load an entire directory of configuration files, merging them into one.
This function will load multiple configuration files matching the given pattern,
in the given path, and merge them. The found files are first sorted alphabe... | [
"def",
"get_config_dir",
"(",
"path",
",",
"pattern",
"=",
"\"*.config\"",
",",
"configspec",
"=",
"None",
",",
"allow_errors",
"=",
"False",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"debug",
"(",
"\"Loadin... | Load an entire directory of configuration files, merging them into one.
This function will load multiple configuration files matching the given pattern,
in the given path, and merge them. The found files are first sorted alphabetically,
and then loaded and merged. A good practice is to use ConfigObj sections, for e... | [
"Load",
"an",
"entire",
"directory",
"of",
"configuration",
"files",
"merging",
"them",
"into",
"one",
"."
] | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/config.py#L100-L142 |
genepattern/nbtools | nbtools/jsobject/utils.py | SimplePromise.resolve | def resolve(self, *pargs, **kwargs):
"""Resolve the promise."""
self._cached = (pargs, kwargs)
self._try_then() | python | def resolve(self, *pargs, **kwargs):
"""Resolve the promise."""
self._cached = (pargs, kwargs)
self._try_then() | [
"def",
"resolve",
"(",
"self",
",",
"*",
"pargs",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_cached",
"=",
"(",
"pargs",
",",
"kwargs",
")",
"self",
".",
"_try_then",
"(",
")"
] | Resolve the promise. | [
"Resolve",
"the",
"promise",
"."
] | train | https://github.com/genepattern/nbtools/blob/2f74703f59926d8565f9714b1458dc87da8f8574/nbtools/jsobject/utils.py#L25-L28 |
genepattern/nbtools | nbtools/jsobject/utils.py | SimplePromise._try_then | def _try_then(self):
"""Check to see if self has been resolved yet, if so invoke then."""
if self._cached is not None and self._callback is not None:
self._callback(*self._cached[0], **self._cached[1]) | python | def _try_then(self):
"""Check to see if self has been resolved yet, if so invoke then."""
if self._cached is not None and self._callback is not None:
self._callback(*self._cached[0], **self._cached[1]) | [
"def",
"_try_then",
"(",
"self",
")",
":",
"if",
"self",
".",
"_cached",
"is",
"not",
"None",
"and",
"self",
".",
"_callback",
"is",
"not",
"None",
":",
"self",
".",
"_callback",
"(",
"*",
"self",
".",
"_cached",
"[",
"0",
"]",
",",
"*",
"*",
"se... | Check to see if self has been resolved yet, if so invoke then. | [
"Check",
"to",
"see",
"if",
"self",
"has",
"been",
"resolved",
"yet",
"if",
"so",
"invoke",
"then",
"."
] | train | https://github.com/genepattern/nbtools/blob/2f74703f59926d8565f9714b1458dc87da8f8574/nbtools/jsobject/utils.py#L30-L33 |
genepattern/nbtools | nbtools/jsobject/utils.py | SimplePromise.wait_for | def wait_for(self, timeout=3000):
"""Hault execution until self resolves."""
results = [None]
results_called = [False]
def results_callback(val):
results[0] = val
results_called[0] = True
self.then(results_callback)
start = time.time()
w... | python | def wait_for(self, timeout=3000):
"""Hault execution until self resolves."""
results = [None]
results_called = [False]
def results_callback(val):
results[0] = val
results_called[0] = True
self.then(results_callback)
start = time.time()
w... | [
"def",
"wait_for",
"(",
"self",
",",
"timeout",
"=",
"3000",
")",
":",
"results",
"=",
"[",
"None",
"]",
"results_called",
"=",
"[",
"False",
"]",
"def",
"results_callback",
"(",
"val",
")",
":",
"results",
"[",
"0",
"]",
"=",
"val",
"results_called",
... | Hault execution until self resolves. | [
"Hault",
"execution",
"until",
"self",
"resolves",
"."
] | train | https://github.com/genepattern/nbtools/blob/2f74703f59926d8565f9714b1458dc87da8f8574/nbtools/jsobject/utils.py#L35-L51 |
genepattern/nbtools | nbtools/widgets.py | open | def open(path_or_url):
"""
Wrapper for opening an IO object to a local file or URL
:param path_or_url:
:return:
"""
is_url = re.compile(
r'^(?:http|ftp)s?://' # http:// or https://
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' # domain...
... | python | def open(path_or_url):
"""
Wrapper for opening an IO object to a local file or URL
:param path_or_url:
:return:
"""
is_url = re.compile(
r'^(?:http|ftp)s?://' # http:// or https://
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' # domain...
... | [
"def",
"open",
"(",
"path_or_url",
")",
":",
"is_url",
"=",
"re",
".",
"compile",
"(",
"r'^(?:http|ftp)s?://'",
"# http:// or https://",
"r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\\.)+(?:[A-Z]{2,6}\\.?|[A-Z0-9-]{2,}\\.?)|'",
"# domain...",
"r'localhost|'",
"# localhost...",
"r... | Wrapper for opening an IO object to a local file or URL
:param path_or_url:
:return: | [
"Wrapper",
"for",
"opening",
"an",
"IO",
"object",
"to",
"a",
"local",
"file",
"or",
"URL",
":",
"param",
"path_or_url",
":",
":",
"return",
":"
] | train | https://github.com/genepattern/nbtools/blob/2f74703f59926d8565f9714b1458dc87da8f8574/nbtools/widgets.py#L12-L29 |
genepattern/nbtools | nbtools/widgets.py | UIBuilder._is_primitive | def _is_primitive(thing):
"""Determine if the value is a primitive"""
primitive = (int, str, bool, float)
return isinstance(thing, primitive) | python | def _is_primitive(thing):
"""Determine if the value is a primitive"""
primitive = (int, str, bool, float)
return isinstance(thing, primitive) | [
"def",
"_is_primitive",
"(",
"thing",
")",
":",
"primitive",
"=",
"(",
"int",
",",
"str",
",",
"bool",
",",
"float",
")",
"return",
"isinstance",
"(",
"thing",
",",
"primitive",
")"
] | Determine if the value is a primitive | [
"Determine",
"if",
"the",
"value",
"is",
"a",
"primitive"
] | train | https://github.com/genepattern/nbtools/blob/2f74703f59926d8565f9714b1458dc87da8f8574/nbtools/widgets.py#L222-L225 |
genepattern/nbtools | nbtools/widgets.py | UIBuilder._guess_type | def _guess_type(val):
"""Guess the input type of the parameter based off the default value, if unknown use text"""
if isinstance(val, bool):
return "choice"
elif isinstance(val, int):
return "number"
elif isinstance(val, float):
return "number"
... | python | def _guess_type(val):
"""Guess the input type of the parameter based off the default value, if unknown use text"""
if isinstance(val, bool):
return "choice"
elif isinstance(val, int):
return "number"
elif isinstance(val, float):
return "number"
... | [
"def",
"_guess_type",
"(",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"bool",
")",
":",
"return",
"\"choice\"",
"elif",
"isinstance",
"(",
"val",
",",
"int",
")",
":",
"return",
"\"number\"",
"elif",
"isinstance",
"(",
"val",
",",
"float",
"... | Guess the input type of the parameter based off the default value, if unknown use text | [
"Guess",
"the",
"input",
"type",
"of",
"the",
"parameter",
"based",
"off",
"the",
"default",
"value",
"if",
"unknown",
"use",
"text"
] | train | https://github.com/genepattern/nbtools/blob/2f74703f59926d8565f9714b1458dc87da8f8574/nbtools/widgets.py#L237-L250 |
genepattern/nbtools | nbtools/widgets.py | UIBuilder._params | def _params(sig):
"""Read params, values and annotations from the signature"""
params = []
for p in sig.parameters:
param = sig.parameters[p]
optional = param.default != inspect.Signature.empty
default = UIBuilder._safe_default(param.default) if param.default ... | python | def _params(sig):
"""Read params, values and annotations from the signature"""
params = []
for p in sig.parameters:
param = sig.parameters[p]
optional = param.default != inspect.Signature.empty
default = UIBuilder._safe_default(param.default) if param.default ... | [
"def",
"_params",
"(",
"sig",
")",
":",
"params",
"=",
"[",
"]",
"for",
"p",
"in",
"sig",
".",
"parameters",
":",
"param",
"=",
"sig",
".",
"parameters",
"[",
"p",
"]",
"optional",
"=",
"param",
".",
"default",
"!=",
"inspect",
".",
"Signature",
".... | Read params, values and annotations from the signature | [
"Read",
"params",
"values",
"and",
"annotations",
"from",
"the",
"signature"
] | train | https://github.com/genepattern/nbtools/blob/2f74703f59926d8565f9714b1458dc87da8f8574/nbtools/widgets.py#L253-L287 |
genepattern/nbtools | nbtools/widgets.py | UIBuilder._import | def _import(func):
"""Return the namespace path to the function"""
func_name = func.__name__
# from foo.bar import func // func()
# WARNING: May be broken in IPython, in which case the widget will use a fallback
if func_name in globals():
return func_name
# ... | python | def _import(func):
"""Return the namespace path to the function"""
func_name = func.__name__
# from foo.bar import func // func()
# WARNING: May be broken in IPython, in which case the widget will use a fallback
if func_name in globals():
return func_name
# ... | [
"def",
"_import",
"(",
"func",
")",
":",
"func_name",
"=",
"func",
".",
"__name__",
"# from foo.bar import func // func()",
"# WARNING: May be broken in IPython, in which case the widget will use a fallback",
"if",
"func_name",
"in",
"globals",
"(",
")",
":",
"return",
"fun... | Return the namespace path to the function | [
"Return",
"the",
"namespace",
"path",
"to",
"the",
"function"
] | train | https://github.com/genepattern/nbtools/blob/2f74703f59926d8565f9714b1458dc87da8f8574/nbtools/widgets.py#L290-L321 |
LordGaav/python-chaos | chaos/logging.py | get_logger | def get_logger(name=None, level=logging.NOTSET, handlers=None):
"""
Create a Python logging Logger for the given name. A special case is
when the name is None, as this will represent the root Logger object.
When handlers are specified, the currently configured handlers for this name
are removed, and the specified... | python | def get_logger(name=None, level=logging.NOTSET, handlers=None):
"""
Create a Python logging Logger for the given name. A special case is
when the name is None, as this will represent the root Logger object.
When handlers are specified, the currently configured handlers for this name
are removed, and the specified... | [
"def",
"get_logger",
"(",
"name",
"=",
"None",
",",
"level",
"=",
"logging",
".",
"NOTSET",
",",
"handlers",
"=",
"None",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"name",
")",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"\"root\""... | Create a Python logging Logger for the given name. A special case is
when the name is None, as this will represent the root Logger object.
When handlers are specified, the currently configured handlers for this name
are removed, and the specified handlers are set.
Parameters
----------
name: string
Name of th... | [
"Create",
"a",
"Python",
"logging",
"Logger",
"for",
"the",
"given",
"name",
".",
"A",
"special",
"case",
"is",
"when",
"the",
"name",
"is",
"None",
"as",
"this",
"will",
"represent",
"the",
"root",
"Logger",
"object",
"."
] | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/logging.py#L30-L118 |
cbetz/untappd-python | untappd/__init__.py | Untappd._attach_endpoints | def _attach_endpoints(self):
"""Dynamically attaches endpoint callables to this client"""
for name, value in inspect.getmembers(self):
if inspect.isclass(value) and issubclass(value, self._Endpoint) and (value is not self._Endpoint):
endpoint_instance = value(self.requester)
... | python | def _attach_endpoints(self):
"""Dynamically attaches endpoint callables to this client"""
for name, value in inspect.getmembers(self):
if inspect.isclass(value) and issubclass(value, self._Endpoint) and (value is not self._Endpoint):
endpoint_instance = value(self.requester)
... | [
"def",
"_attach_endpoints",
"(",
"self",
")",
":",
"for",
"name",
",",
"value",
"in",
"inspect",
".",
"getmembers",
"(",
"self",
")",
":",
"if",
"inspect",
".",
"isclass",
"(",
"value",
")",
"and",
"issubclass",
"(",
"value",
",",
"self",
".",
"_Endpoi... | Dynamically attaches endpoint callables to this client | [
"Dynamically",
"attaches",
"endpoint",
"callables",
"to",
"this",
"client"
] | train | https://github.com/cbetz/untappd-python/blob/0f98a58948a77f89fe5e1875f5b01cb00623aa9a/untappd/__init__.py#L55-L72 |
jeremymcrae/denovonear | denovonear/load_de_novos.py | load_de_novos | def load_de_novos(path, exclude_indels=True):
""" load mutations into dict indexed by HGNC ID.
Args:
path: path to file containing de novo data. This should have five tab-
separated columns e.g.
hgnc chr pos consequence var_type
CTC1 17 8139190 ... | python | def load_de_novos(path, exclude_indels=True):
""" load mutations into dict indexed by HGNC ID.
Args:
path: path to file containing de novo data. This should have five tab-
separated columns e.g.
hgnc chr pos consequence var_type
CTC1 17 8139190 ... | [
"def",
"load_de_novos",
"(",
"path",
",",
"exclude_indels",
"=",
"True",
")",
":",
"genes",
"=",
"{",
"}",
"with",
"open",
"(",
"path",
",",
"\"r\"",
")",
"as",
"handle",
":",
"header",
"=",
"handle",
".",
"readline",
"(",
")",
".",
"strip",
"(",
"... | load mutations into dict indexed by HGNC ID.
Args:
path: path to file containing de novo data. This should have five tab-
separated columns e.g.
hgnc chr pos consequence var_type
CTC1 17 8139190 missense_variant snv
CTC1 17 813919... | [
"load",
"mutations",
"into",
"dict",
"indexed",
"by",
"HGNC",
"ID",
".",
"Args",
":",
"path",
":",
"path",
"to",
"file",
"containing",
"de",
"novo",
"data",
".",
"This",
"should",
"have",
"five",
"tab",
"-",
"separated",
"columns",
"e",
".",
"g",
".",
... | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/load_de_novos.py#L15-L61 |
LordGaav/python-chaos | chaos/threading/threads.py | Threads.registerThread | def registerThread(self, name, thread):
"""
Register a new Thread , under the given descriptive name.
Trying to register multiple threads under the same name will raise an Exception.
Parameters
----------
name: string
Name to register the given thread under.
thread: threading.Thread, or a subclass
... | python | def registerThread(self, name, thread):
"""
Register a new Thread , under the given descriptive name.
Trying to register multiple threads under the same name will raise an Exception.
Parameters
----------
name: string
Name to register the given thread under.
thread: threading.Thread, or a subclass
... | [
"def",
"registerThread",
"(",
"self",
",",
"name",
",",
"thread",
")",
":",
"if",
"not",
"isinstance",
"(",
"thread",
",",
"threading",
".",
"Thread",
")",
":",
"self",
".",
"logger",
".",
"error",
"(",
"\"Thread {0} is not actually a Thread!\"",
".",
"forma... | Register a new Thread , under the given descriptive name.
Trying to register multiple threads under the same name will raise an Exception.
Parameters
----------
name: string
Name to register the given thread under.
thread: threading.Thread, or a subclass
Thread object to register. | [
"Register",
"a",
"new",
"Thread",
"under",
"the",
"given",
"descriptive",
"name",
"."
] | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/threading/threads.py#L33-L57 |
LordGaav/python-chaos | chaos/threading/threads.py | Threads.getThread | def getThread(self, name):
"""
Retrieve the Thread registered under the given name.
If the given name does not exists in the Thread list, an Exception is raised.
Parameters
----------
name: string
Name of the Thread to retrieve
"""
if not name in self.thread_list:
self.logger.error("Thread {0} i... | python | def getThread(self, name):
"""
Retrieve the Thread registered under the given name.
If the given name does not exists in the Thread list, an Exception is raised.
Parameters
----------
name: string
Name of the Thread to retrieve
"""
if not name in self.thread_list:
self.logger.error("Thread {0} i... | [
"def",
"getThread",
"(",
"self",
",",
"name",
")",
":",
"if",
"not",
"name",
"in",
"self",
".",
"thread_list",
":",
"self",
".",
"logger",
".",
"error",
"(",
"\"Thread {0} is not registered!\"",
".",
"format",
"(",
"name",
")",
")",
"raise",
"Exception",
... | Retrieve the Thread registered under the given name.
If the given name does not exists in the Thread list, an Exception is raised.
Parameters
----------
name: string
Name of the Thread to retrieve | [
"Retrieve",
"the",
"Thread",
"registered",
"under",
"the",
"given",
"name",
"."
] | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/threading/threads.py#L65-L80 |
LordGaav/python-chaos | chaos/threading/threads.py | Threads.unregisterThread | def unregisterThread(self, name):
"""
Unregister the Thread registered under the given name.
Make sure that the given Thread is properly stopped, or that a reference is
kept in another place. Once unregistered, this class will not keep any
other references to the Thread.
Parameters
----------
name: st... | python | def unregisterThread(self, name):
"""
Unregister the Thread registered under the given name.
Make sure that the given Thread is properly stopped, or that a reference is
kept in another place. Once unregistered, this class will not keep any
other references to the Thread.
Parameters
----------
name: st... | [
"def",
"unregisterThread",
"(",
"self",
",",
"name",
")",
":",
"if",
"not",
"name",
"in",
"self",
".",
"thread_list",
":",
"self",
".",
"logger",
".",
"error",
"(",
"\"Thread {0} is not registered!\"",
".",
"format",
"(",
"name",
")",
")",
"raise",
"Except... | Unregister the Thread registered under the given name.
Make sure that the given Thread is properly stopped, or that a reference is
kept in another place. Once unregistered, this class will not keep any
other references to the Thread.
Parameters
----------
name: string
Name of the Thread to unregister | [
"Unregister",
"the",
"Thread",
"registered",
"under",
"the",
"given",
"name",
"."
] | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/threading/threads.py#L82-L100 |
LordGaav/python-chaos | chaos/threading/threads.py | Threads.startAll | def startAll(self):
"""
Start all registered Threads.
"""
self.logger.info("Starting all threads...")
for thread in self.getThreads():
thr = self.getThread(thread)
self.logger.debug("Starting {0}".format(thr.name))
thr.start()
self.logger.info("Started all threads") | python | def startAll(self):
"""
Start all registered Threads.
"""
self.logger.info("Starting all threads...")
for thread in self.getThreads():
thr = self.getThread(thread)
self.logger.debug("Starting {0}".format(thr.name))
thr.start()
self.logger.info("Started all threads") | [
"def",
"startAll",
"(",
"self",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"Starting all threads...\"",
")",
"for",
"thread",
"in",
"self",
".",
"getThreads",
"(",
")",
":",
"thr",
"=",
"self",
".",
"getThread",
"(",
"thread",
")",
"self",
".... | Start all registered Threads. | [
"Start",
"all",
"registered",
"Threads",
"."
] | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/threading/threads.py#L102-L113 |
LordGaav/python-chaos | chaos/threading/threads.py | Threads.stopAll | def stopAll(self, stop=False):
"""
Stop all registered Threads. This is method assumes that the Thread is using
and internal variable called stop to control its main loop. Stopping a Thread
is achieved as follows:
1. The Thread is retrieved.
2. $thread.stop is set to False.
3. The Thread is joined, and w... | python | def stopAll(self, stop=False):
"""
Stop all registered Threads. This is method assumes that the Thread is using
and internal variable called stop to control its main loop. Stopping a Thread
is achieved as follows:
1. The Thread is retrieved.
2. $thread.stop is set to False.
3. The Thread is joined, and w... | [
"def",
"stopAll",
"(",
"self",
",",
"stop",
"=",
"False",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"Stopping all threads...\"",
")",
"for",
"thread",
"in",
"self",
".",
"getThreads",
"(",
")",
":",
"thr",
"=",
"self",
".",
"getThread",
"(",... | Stop all registered Threads. This is method assumes that the Thread is using
and internal variable called stop to control its main loop. Stopping a Thread
is achieved as follows:
1. The Thread is retrieved.
2. $thread.stop is set to False.
3. The Thread is joined, and will wait until the Thread exits.
4. T... | [
"Stop",
"all",
"registered",
"Threads",
".",
"This",
"is",
"method",
"assumes",
"that",
"the",
"Thread",
"is",
"using",
"and",
"internal",
"variable",
"called",
"stop",
"to",
"control",
"its",
"main",
"loop",
".",
"Stopping",
"a",
"Thread",
"is",
"achieved",... | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/threading/threads.py#L115-L143 |
mishbahr/django-usersettings2 | usersettings/context_processors.py | usersettings | def usersettings(request):
"""
Returns the current ``UserSettings`` based on
the SITE_ID in the project's settings as context variables
If there is no 'usersettings' attribute in the request, fetches the
current UserSettings (from usersettings.shortcuts.get_current_usersettings).
"""
if has... | python | def usersettings(request):
"""
Returns the current ``UserSettings`` based on
the SITE_ID in the project's settings as context variables
If there is no 'usersettings' attribute in the request, fetches the
current UserSettings (from usersettings.shortcuts.get_current_usersettings).
"""
if has... | [
"def",
"usersettings",
"(",
"request",
")",
":",
"if",
"hasattr",
"(",
"request",
",",
"'usersettings'",
")",
":",
"usersettings",
"=",
"request",
".",
"usersettings",
"else",
":",
"from",
".",
"shortcuts",
"import",
"get_current_usersettings",
"usersettings",
"... | Returns the current ``UserSettings`` based on
the SITE_ID in the project's settings as context variables
If there is no 'usersettings' attribute in the request, fetches the
current UserSettings (from usersettings.shortcuts.get_current_usersettings). | [
"Returns",
"the",
"current",
"UserSettings",
"based",
"on",
"the",
"SITE_ID",
"in",
"the",
"project",
"s",
"settings",
"as",
"context",
"variables"
] | train | https://github.com/mishbahr/django-usersettings2/blob/cbc2f4b2e01d5401bec8a3fa39151730cd2dcd2a/usersettings/context_processors.py#L2-L18 |
jeremymcrae/denovonear | denovonear/ensembl_requester.py | EnsemblRequest.check_ensembl_api_version | def check_ensembl_api_version(self):
""" check the ensembl api version matches a currently working version
This function is included so when the api version changes, we notice the
change, and we can manually check the responses for the new version.
"""
self.atte... | python | def check_ensembl_api_version(self):
""" check the ensembl api version matches a currently working version
This function is included so when the api version changes, we notice the
change, and we can manually check the responses for the new version.
"""
self.atte... | [
"def",
"check_ensembl_api_version",
"(",
"self",
")",
":",
"self",
".",
"attempt",
"=",
"0",
"headers",
"=",
"{",
"\"content-type\"",
":",
"\"application/json\"",
"}",
"ext",
"=",
"\"/info/rest\"",
"r",
"=",
"self",
".",
"ensembl_request",
"(",
"ext",
",",
"... | check the ensembl api version matches a currently working version
This function is included so when the api version changes, we notice the
change, and we can manually check the responses for the new version. | [
"check",
"the",
"ensembl",
"api",
"version",
"matches",
"a",
"currently",
"working",
"version",
"This",
"function",
"is",
"included",
"so",
"when",
"the",
"api",
"version",
"changes",
"we",
"notice",
"the",
"change",
"and",
"we",
"can",
"manually",
"check",
... | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/ensembl_requester.py#L55-L68 |
jeremymcrae/denovonear | denovonear/ensembl_requester.py | EnsemblRequest.open_url | def open_url(self, url, headers):
""" open url with python libraries
"""
data = self.cache.get_cached_data(url)
if data is not None:
return data, 200, headers
self.rate_limit_ensembl_requests()
req = request.Request(url, headers=headers)
... | python | def open_url(self, url, headers):
""" open url with python libraries
"""
data = self.cache.get_cached_data(url)
if data is not None:
return data, 200, headers
self.rate_limit_ensembl_requests()
req = request.Request(url, headers=headers)
... | [
"def",
"open_url",
"(",
"self",
",",
"url",
",",
"headers",
")",
":",
"data",
"=",
"self",
".",
"cache",
".",
"get_cached_data",
"(",
"url",
")",
"if",
"data",
"is",
"not",
"None",
":",
"return",
"data",
",",
"200",
",",
"headers",
"self",
".",
"ra... | open url with python libraries | [
"open",
"url",
"with",
"python",
"libraries"
] | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/ensembl_requester.py#L70-L103 |
jeremymcrae/denovonear | denovonear/ensembl_requester.py | EnsemblRequest.ensembl_request | def ensembl_request(self, ext, headers):
""" obtain sequence via the ensembl REST API
"""
self.attempt += 1
if self.attempt > 5:
raise ValueError("too many attempts, figure out why its failing")
response, status, requested_headers = self.open_url(sel... | python | def ensembl_request(self, ext, headers):
""" obtain sequence via the ensembl REST API
"""
self.attempt += 1
if self.attempt > 5:
raise ValueError("too many attempts, figure out why its failing")
response, status, requested_headers = self.open_url(sel... | [
"def",
"ensembl_request",
"(",
"self",
",",
"ext",
",",
"headers",
")",
":",
"self",
".",
"attempt",
"+=",
"1",
"if",
"self",
".",
"attempt",
">",
"5",
":",
"raise",
"ValueError",
"(",
"\"too many attempts, figure out why its failing\"",
")",
"response",
",",
... | obtain sequence via the ensembl REST API | [
"obtain",
"sequence",
"via",
"the",
"ensembl",
"REST",
"API"
] | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/ensembl_requester.py#L105-L148 |
jeremymcrae/denovonear | denovonear/ensembl_requester.py | EnsemblRequest.get_genes_for_hgnc_id | def get_genes_for_hgnc_id(self, hgnc_symbol):
""" obtain the ensembl gene IDs that correspond to a HGNC symbol
"""
headers = {"content-type": "application/json"}
# http://grch37.rest.ensembl.org/xrefs/symbol/homo_sapiens/KMT2A?content-type=application/json
... | python | def get_genes_for_hgnc_id(self, hgnc_symbol):
""" obtain the ensembl gene IDs that correspond to a HGNC symbol
"""
headers = {"content-type": "application/json"}
# http://grch37.rest.ensembl.org/xrefs/symbol/homo_sapiens/KMT2A?content-type=application/json
... | [
"def",
"get_genes_for_hgnc_id",
"(",
"self",
",",
"hgnc_symbol",
")",
":",
"headers",
"=",
"{",
"\"content-type\"",
":",
"\"application/json\"",
"}",
"# http://grch37.rest.ensembl.org/xrefs/symbol/homo_sapiens/KMT2A?content-type=application/json",
"self",
".",
"attempt",
"=",
... | obtain the ensembl gene IDs that correspond to a HGNC symbol | [
"obtain",
"the",
"ensembl",
"gene",
"IDs",
"that",
"correspond",
"to",
"a",
"HGNC",
"symbol"
] | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/ensembl_requester.py#L150-L167 |
jeremymcrae/denovonear | denovonear/ensembl_requester.py | EnsemblRequest.get_previous_symbol | def get_previous_symbol(self, hgnc_symbol):
""" sometimes we get HGNC symbols that do not match the ensembl rest version
that we are currently using. We can look for earlier HGNC symbols for
the gene using the service at rest.genenames.org
Args:
hgnc_symbol: HGNC sym... | python | def get_previous_symbol(self, hgnc_symbol):
""" sometimes we get HGNC symbols that do not match the ensembl rest version
that we are currently using. We can look for earlier HGNC symbols for
the gene using the service at rest.genenames.org
Args:
hgnc_symbol: HGNC sym... | [
"def",
"get_previous_symbol",
"(",
"self",
",",
"hgnc_symbol",
")",
":",
"ensembl_server",
"=",
"self",
".",
"server",
"gene_names_server",
"=",
"\"http://rest.genenames.org\"",
"self",
".",
"server",
"=",
"gene_names_server",
"headers",
"=",
"{",
"\"accept\"",
":",... | sometimes we get HGNC symbols that do not match the ensembl rest version
that we are currently using. We can look for earlier HGNC symbols for
the gene using the service at rest.genenames.org
Args:
hgnc_symbol: HGNC symbol for the gene (eg "MLL2")
Returns:
... | [
"sometimes",
"we",
"get",
"HGNC",
"symbols",
"that",
"do",
"not",
"match",
"the",
"ensembl",
"rest",
"version",
"that",
"we",
"are",
"currently",
"using",
".",
"We",
"can",
"look",
"for",
"earlier",
"HGNC",
"symbols",
"for",
"the",
"gene",
"using",
"the",
... | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/ensembl_requester.py#L169-L207 |
jeremymcrae/denovonear | denovonear/ensembl_requester.py | EnsemblRequest.get_transcript_ids_for_ensembl_gene_ids | def get_transcript_ids_for_ensembl_gene_ids(self, gene_ids, hgnc_symbols):
""" fetch the ensembl transcript IDs for a given ensembl gene ID.
Args:
gene_ids: list of Ensembl gene IDs for the gene
hgnc_symbols: list of possible HGNC symbols for gene
"""
... | python | def get_transcript_ids_for_ensembl_gene_ids(self, gene_ids, hgnc_symbols):
""" fetch the ensembl transcript IDs for a given ensembl gene ID.
Args:
gene_ids: list of Ensembl gene IDs for the gene
hgnc_symbols: list of possible HGNC symbols for gene
"""
... | [
"def",
"get_transcript_ids_for_ensembl_gene_ids",
"(",
"self",
",",
"gene_ids",
",",
"hgnc_symbols",
")",
":",
"chroms",
"=",
"{",
"\"1\"",
",",
"\"2\"",
",",
"\"3\"",
",",
"\"4\"",
",",
"\"5\"",
",",
"\"6\"",
",",
"\"7\"",
",",
"\"8\"",
",",
"\"9\"",
",",... | fetch the ensembl transcript IDs for a given ensembl gene ID.
Args:
gene_ids: list of Ensembl gene IDs for the gene
hgnc_symbols: list of possible HGNC symbols for gene | [
"fetch",
"the",
"ensembl",
"transcript",
"IDs",
"for",
"a",
"given",
"ensembl",
"gene",
"ID",
".",
"Args",
":",
"gene_ids",
":",
"list",
"of",
"Ensembl",
"gene",
"IDs",
"for",
"the",
"gene",
"hgnc_symbols",
":",
"list",
"of",
"possible",
"HGNC",
"symbols",... | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/ensembl_requester.py#L209-L243 |
jeremymcrae/denovonear | denovonear/ensembl_requester.py | EnsemblRequest.get_genomic_seq_for_transcript | def get_genomic_seq_for_transcript(self, transcript_id, expand):
""" obtain the sequence for a transcript from ensembl
"""
headers = {"content-type": "application/json"}
self.attempt = 0
ext = "/sequence/id/{0}?type=genomic;expand_3prime={1};expand_5prime={1}".f... | python | def get_genomic_seq_for_transcript(self, transcript_id, expand):
""" obtain the sequence for a transcript from ensembl
"""
headers = {"content-type": "application/json"}
self.attempt = 0
ext = "/sequence/id/{0}?type=genomic;expand_3prime={1};expand_5prime={1}".f... | [
"def",
"get_genomic_seq_for_transcript",
"(",
"self",
",",
"transcript_id",
",",
"expand",
")",
":",
"headers",
"=",
"{",
"\"content-type\"",
":",
"\"application/json\"",
"}",
"self",
".",
"attempt",
"=",
"0",
"ext",
"=",
"\"/sequence/id/{0}?type=genomic;expand_3prime... | obtain the sequence for a transcript from ensembl | [
"obtain",
"the",
"sequence",
"for",
"a",
"transcript",
"from",
"ensembl"
] | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/ensembl_requester.py#L245-L273 |
jeremymcrae/denovonear | denovonear/ensembl_requester.py | EnsemblRequest.get_cds_seq_for_transcript | def get_cds_seq_for_transcript(self, transcript_id):
""" obtain the sequence for a transcript from ensembl
"""
headers = {"content-type": "text/plain"}
self.attempt = 0
ext = "/sequence/id/{}?type=cds".format(transcript_id)
return self.ensembl_r... | python | def get_cds_seq_for_transcript(self, transcript_id):
""" obtain the sequence for a transcript from ensembl
"""
headers = {"content-type": "text/plain"}
self.attempt = 0
ext = "/sequence/id/{}?type=cds".format(transcript_id)
return self.ensembl_r... | [
"def",
"get_cds_seq_for_transcript",
"(",
"self",
",",
"transcript_id",
")",
":",
"headers",
"=",
"{",
"\"content-type\"",
":",
"\"text/plain\"",
"}",
"self",
".",
"attempt",
"=",
"0",
"ext",
"=",
"\"/sequence/id/{}?type=cds\"",
".",
"format",
"(",
"transcript_id"... | obtain the sequence for a transcript from ensembl | [
"obtain",
"the",
"sequence",
"for",
"a",
"transcript",
"from",
"ensembl"
] | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/ensembl_requester.py#L275-L284 |
jeremymcrae/denovonear | denovonear/ensembl_requester.py | EnsemblRequest.get_protein_seq_for_transcript | def get_protein_seq_for_transcript(self, transcript_id):
""" obtain the sequence for a transcript from ensembl
"""
headers = {"content-type": "text/plain"}
self.attempt = 0
ext = "/sequence/id/{}?type=protein".format(transcript_id)
return self.e... | python | def get_protein_seq_for_transcript(self, transcript_id):
""" obtain the sequence for a transcript from ensembl
"""
headers = {"content-type": "text/plain"}
self.attempt = 0
ext = "/sequence/id/{}?type=protein".format(transcript_id)
return self.e... | [
"def",
"get_protein_seq_for_transcript",
"(",
"self",
",",
"transcript_id",
")",
":",
"headers",
"=",
"{",
"\"content-type\"",
":",
"\"text/plain\"",
"}",
"self",
".",
"attempt",
"=",
"0",
"ext",
"=",
"\"/sequence/id/{}?type=protein\"",
".",
"format",
"(",
"transc... | obtain the sequence for a transcript from ensembl | [
"obtain",
"the",
"sequence",
"for",
"a",
"transcript",
"from",
"ensembl"
] | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/ensembl_requester.py#L286-L295 |
jeremymcrae/denovonear | denovonear/ensembl_requester.py | EnsemblRequest.get_genomic_seq_for_region | def get_genomic_seq_for_region(self, chrom, start_pos, end_pos):
""" obtain the sequence for a genomic region
"""
headers = {"content-type": "text/plain"}
self.attempt = 0
ext = "/sequence/region/human/{}:{}..{}:1".format(chrom, start_pos, end_pos)
... | python | def get_genomic_seq_for_region(self, chrom, start_pos, end_pos):
""" obtain the sequence for a genomic region
"""
headers = {"content-type": "text/plain"}
self.attempt = 0
ext = "/sequence/region/human/{}:{}..{}:1".format(chrom, start_pos, end_pos)
... | [
"def",
"get_genomic_seq_for_region",
"(",
"self",
",",
"chrom",
",",
"start_pos",
",",
"end_pos",
")",
":",
"headers",
"=",
"{",
"\"content-type\"",
":",
"\"text/plain\"",
"}",
"self",
".",
"attempt",
"=",
"0",
"ext",
"=",
"\"/sequence/region/human/{}:{}..{}:1\"",... | obtain the sequence for a genomic region | [
"obtain",
"the",
"sequence",
"for",
"a",
"genomic",
"region"
] | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/ensembl_requester.py#L297-L306 |
jeremymcrae/denovonear | denovonear/ensembl_requester.py | EnsemblRequest.get_chrom_for_transcript | def get_chrom_for_transcript(self, transcript_id, hgnc_id):
""" obtain the sequence for a transcript from ensembl
"""
headers = {"content-type": "application/json"}
self.attempt = 0
ext = "/overlap/id/{}?feature=gene".format(transcript_id)
r = self.ense... | python | def get_chrom_for_transcript(self, transcript_id, hgnc_id):
""" obtain the sequence for a transcript from ensembl
"""
headers = {"content-type": "application/json"}
self.attempt = 0
ext = "/overlap/id/{}?feature=gene".format(transcript_id)
r = self.ense... | [
"def",
"get_chrom_for_transcript",
"(",
"self",
",",
"transcript_id",
",",
"hgnc_id",
")",
":",
"headers",
"=",
"{",
"\"content-type\"",
":",
"\"application/json\"",
"}",
"self",
".",
"attempt",
"=",
"0",
"ext",
"=",
"\"/overlap/id/{}?feature=gene\"",
".",
"format... | obtain the sequence for a transcript from ensembl | [
"obtain",
"the",
"sequence",
"for",
"a",
"transcript",
"from",
"ensembl"
] | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/ensembl_requester.py#L308-L322 |
jeremymcrae/denovonear | denovonear/ensembl_requester.py | EnsemblRequest.get_exon_ranges_for_transcript | def get_exon_ranges_for_transcript(self, transcript_id):
""" obtain the sequence for a transcript from ensembl
"""
headers = {"content-type": "application/json"}
self.attempt = 0
ext = "/overlap/id/{}?feature=exon".format(transcript_id)
r = self.ensembl_... | python | def get_exon_ranges_for_transcript(self, transcript_id):
""" obtain the sequence for a transcript from ensembl
"""
headers = {"content-type": "application/json"}
self.attempt = 0
ext = "/overlap/id/{}?feature=exon".format(transcript_id)
r = self.ensembl_... | [
"def",
"get_exon_ranges_for_transcript",
"(",
"self",
",",
"transcript_id",
")",
":",
"headers",
"=",
"{",
"\"content-type\"",
":",
"\"application/json\"",
"}",
"self",
".",
"attempt",
"=",
"0",
"ext",
"=",
"\"/overlap/id/{}?feature=exon\"",
".",
"format",
"(",
"t... | obtain the sequence for a transcript from ensembl | [
"obtain",
"the",
"sequence",
"for",
"a",
"transcript",
"from",
"ensembl"
] | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/ensembl_requester.py#L324-L344 |
jeremymcrae/denovonear | denovonear/ensembl_requester.py | EnsemblRequest.get_cds_ranges_for_transcript | def get_cds_ranges_for_transcript(self, transcript_id):
""" obtain the sequence for a transcript from ensembl
"""
headers = {"content-type": "application/json"}
self.attempt = 0
ext = "/overlap/id/{}?feature=cds".format(transcript_id)
r = self.ensembl_re... | python | def get_cds_ranges_for_transcript(self, transcript_id):
""" obtain the sequence for a transcript from ensembl
"""
headers = {"content-type": "application/json"}
self.attempt = 0
ext = "/overlap/id/{}?feature=cds".format(transcript_id)
r = self.ensembl_re... | [
"def",
"get_cds_ranges_for_transcript",
"(",
"self",
",",
"transcript_id",
")",
":",
"headers",
"=",
"{",
"\"content-type\"",
":",
"\"application/json\"",
"}",
"self",
".",
"attempt",
"=",
"0",
"ext",
"=",
"\"/overlap/id/{}?feature=cds\"",
".",
"format",
"(",
"tra... | obtain the sequence for a transcript from ensembl | [
"obtain",
"the",
"sequence",
"for",
"a",
"transcript",
"from",
"ensembl"
] | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/ensembl_requester.py#L346-L366 |
jeremymcrae/denovonear | denovonear/ensembl_requester.py | EnsemblRequest.rate_limit_ensembl_requests | def rate_limit_ensembl_requests(self):
""" limit ensembl requests to one per 0.067 s
"""
current_time = time.time()
diff_time = current_time - self.prior_time
# sleep until the current rate limit period is finished
if diff_time < self.rate_limit:
... | python | def rate_limit_ensembl_requests(self):
""" limit ensembl requests to one per 0.067 s
"""
current_time = time.time()
diff_time = current_time - self.prior_time
# sleep until the current rate limit period is finished
if diff_time < self.rate_limit:
... | [
"def",
"rate_limit_ensembl_requests",
"(",
"self",
")",
":",
"current_time",
"=",
"time",
".",
"time",
"(",
")",
"diff_time",
"=",
"current_time",
"-",
"self",
".",
"prior_time",
"# sleep until the current rate limit period is finished",
"if",
"diff_time",
"<",
"self"... | limit ensembl requests to one per 0.067 s | [
"limit",
"ensembl",
"requests",
"to",
"one",
"per",
"0",
".",
"067",
"s"
] | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/ensembl_requester.py#L368-L380 |
genepattern/nbtools | nbtools/manager.py | register | def register(nbtool):
"""
Register the provided NBTool object
"""
global _py_funcs
_lazy_init()
# Save references to the tool's load() and render() functions
load_key = nbtool.origin + '|' + nbtool.id + '|load'
render_key = nbtool.origin + '|' + nbtool.id + '|render'
_py_funcs[load_... | python | def register(nbtool):
"""
Register the provided NBTool object
"""
global _py_funcs
_lazy_init()
# Save references to the tool's load() and render() functions
load_key = nbtool.origin + '|' + nbtool.id + '|load'
render_key = nbtool.origin + '|' + nbtool.id + '|render'
_py_funcs[load_... | [
"def",
"register",
"(",
"nbtool",
")",
":",
"global",
"_py_funcs",
"_lazy_init",
"(",
")",
"# Save references to the tool's load() and render() functions",
"load_key",
"=",
"nbtool",
".",
"origin",
"+",
"'|'",
"+",
"nbtool",
".",
"id",
"+",
"'|load'",
"render_key",
... | Register the provided NBTool object | [
"Register",
"the",
"provided",
"NBTool",
"object"
] | train | https://github.com/genepattern/nbtools/blob/2f74703f59926d8565f9714b1458dc87da8f8574/nbtools/manager.py#L104-L172 |
LordGaav/python-chaos | chaos/cli.py | call_simple_cli | def call_simple_cli(command, cwd=None, universal_newlines=False, redirect_stderr=False):
""" Simple wrapper around SimpleCliTool. Simple. """
return SimpleCliTool()._call_cli(command, cwd, universal_newlines, redirect_stderr) | python | def call_simple_cli(command, cwd=None, universal_newlines=False, redirect_stderr=False):
""" Simple wrapper around SimpleCliTool. Simple. """
return SimpleCliTool()._call_cli(command, cwd, universal_newlines, redirect_stderr) | [
"def",
"call_simple_cli",
"(",
"command",
",",
"cwd",
"=",
"None",
",",
"universal_newlines",
"=",
"False",
",",
"redirect_stderr",
"=",
"False",
")",
":",
"return",
"SimpleCliTool",
"(",
")",
".",
"_call_cli",
"(",
"command",
",",
"cwd",
",",
"universal_new... | Simple wrapper around SimpleCliTool. Simple. | [
"Simple",
"wrapper",
"around",
"SimpleCliTool",
".",
"Simple",
"."
] | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/cli.py#L31-L33 |
LordGaav/python-chaos | chaos/cli.py | SimpleCliTool._call_cli | def _call_cli(self, command, cwd=None, universal_newlines=False, redirect_stderr=False):
"""
Executes the given command, internally using Popen. The output of
stdout and stderr are returned as a tuple. The returned tuple looks
like: (stdout, stderr, returncode)
Parameters
----------
command: string
Th... | python | def _call_cli(self, command, cwd=None, universal_newlines=False, redirect_stderr=False):
"""
Executes the given command, internally using Popen. The output of
stdout and stderr are returned as a tuple. The returned tuple looks
like: (stdout, stderr, returncode)
Parameters
----------
command: string
Th... | [
"def",
"_call_cli",
"(",
"self",
",",
"command",
",",
"cwd",
"=",
"None",
",",
"universal_newlines",
"=",
"False",
",",
"redirect_stderr",
"=",
"False",
")",
":",
"command",
"=",
"str",
"(",
"command",
".",
"encode",
"(",
"\"utf-8\"",
")",
".",
"decode",... | Executes the given command, internally using Popen. The output of
stdout and stderr are returned as a tuple. The returned tuple looks
like: (stdout, stderr, returncode)
Parameters
----------
command: string
The command to execute.
cwd: string
Change the working directory of the program to the specifi... | [
"Executes",
"the",
"given",
"command",
"internally",
"using",
"Popen",
".",
"The",
"output",
"of",
"stdout",
"and",
"stderr",
"are",
"returned",
"as",
"a",
"tuple",
".",
"The",
"returned",
"tuple",
"looks",
"like",
":",
"(",
"stdout",
"stderr",
"returncode",... | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/cli.py#L58-L82 |
jakewins/neo4jdb-python | neo4j/connection.py | Connection._execute | def _execute(self, cursor, statements):
""""
Executes a list of statements, returning an iterator of results sets. Each
statement should be a tuple of (statement, params).
"""
payload = [{'statement': s, 'parameters': p, 'resultDataContents':['rest']} for (s, p) in statements]
... | python | def _execute(self, cursor, statements):
""""
Executes a list of statements, returning an iterator of results sets. Each
statement should be a tuple of (statement, params).
"""
payload = [{'statement': s, 'parameters': p, 'resultDataContents':['rest']} for (s, p) in statements]
... | [
"def",
"_execute",
"(",
"self",
",",
"cursor",
",",
"statements",
")",
":",
"payload",
"=",
"[",
"{",
"'statement'",
":",
"s",
",",
"'parameters'",
":",
"p",
",",
"'resultDataContents'",
":",
"[",
"'rest'",
"]",
"}",
"for",
"(",
"s",
",",
"p",
")",
... | Executes a list of statements, returning an iterator of results sets. Each
statement should be a tuple of (statement, params). | [
"Executes",
"a",
"list",
"of",
"statements",
"returning",
"an",
"iterator",
"of",
"results",
"sets",
".",
"Each",
"statement",
"should",
"be",
"a",
"tuple",
"of",
"(",
"statement",
"params",
")",
"."
] | train | https://github.com/jakewins/neo4jdb-python/blob/cd78cb8397885f219500fb1080d301f0c900f7be/neo4j/connection.py#L140-L155 |
genepattern/nbtools | nbtools/jsobject/jsobject.py | BrowserContext._on_msg | def _on_msg(self, msg):
"""Handle messages from the front-end"""
data = msg['content']['data']
# If the message is a call invoke, run the function and send
# the results.
if 'callback' in data:
guid = data['callback']
callback = callback_registry[guid]
... | python | def _on_msg(self, msg):
"""Handle messages from the front-end"""
data = msg['content']['data']
# If the message is a call invoke, run the function and send
# the results.
if 'callback' in data:
guid = data['callback']
callback = callback_registry[guid]
... | [
"def",
"_on_msg",
"(",
"self",
",",
"msg",
")",
":",
"data",
"=",
"msg",
"[",
"'content'",
"]",
"[",
"'data'",
"]",
"# If the message is a call invoke, run the function and send",
"# the results.",
"if",
"'callback'",
"in",
"data",
":",
"guid",
"=",
"data",
"[",... | Handle messages from the front-end | [
"Handle",
"messages",
"from",
"the",
"front",
"-",
"end"
] | train | https://github.com/genepattern/nbtools/blob/2f74703f59926d8565f9714b1458dc87da8f8574/nbtools/jsobject/jsobject.py#L60-L87 |
genepattern/nbtools | nbtools/jsobject/jsobject.py | BrowserContext.serialize | def serialize(self, obj):
"""Serialize an object for sending to the front-end."""
if hasattr(obj, '_jsid'):
return {'immutable': False, 'value': obj._jsid}
else:
obj_json = {'immutable': True}
try:
json.dumps(obj)
obj_json['valu... | python | def serialize(self, obj):
"""Serialize an object for sending to the front-end."""
if hasattr(obj, '_jsid'):
return {'immutable': False, 'value': obj._jsid}
else:
obj_json = {'immutable': True}
try:
json.dumps(obj)
obj_json['valu... | [
"def",
"serialize",
"(",
"self",
",",
"obj",
")",
":",
"if",
"hasattr",
"(",
"obj",
",",
"'_jsid'",
")",
":",
"return",
"{",
"'immutable'",
":",
"False",
",",
"'value'",
":",
"obj",
".",
"_jsid",
"}",
"else",
":",
"obj_json",
"=",
"{",
"'immutable'",... | Serialize an object for sending to the front-end. | [
"Serialize",
"an",
"object",
"for",
"sending",
"to",
"the",
"front",
"-",
"end",
"."
] | train | https://github.com/genepattern/nbtools/blob/2f74703f59926d8565f9714b1458dc87da8f8574/nbtools/jsobject/jsobject.py#L89-L104 |
genepattern/nbtools | nbtools/jsobject/jsobject.py | BrowserContext.deserialize | def deserialize(self, obj):
"""Deserialize an object from the front-end."""
if obj['immutable']:
return obj['value']
else:
guid = obj['value']
if not guid in object_registry:
instance = JSObject(self, guid)
object_registry[guid]... | python | def deserialize(self, obj):
"""Deserialize an object from the front-end."""
if obj['immutable']:
return obj['value']
else:
guid = obj['value']
if not guid in object_registry:
instance = JSObject(self, guid)
object_registry[guid]... | [
"def",
"deserialize",
"(",
"self",
",",
"obj",
")",
":",
"if",
"obj",
"[",
"'immutable'",
"]",
":",
"return",
"obj",
"[",
"'value'",
"]",
"else",
":",
"guid",
"=",
"obj",
"[",
"'value'",
"]",
"if",
"not",
"guid",
"in",
"object_registry",
":",
"instan... | Deserialize an object from the front-end. | [
"Deserialize",
"an",
"object",
"from",
"the",
"front",
"-",
"end",
"."
] | train | https://github.com/genepattern/nbtools/blob/2f74703f59926d8565f9714b1458dc87da8f8574/nbtools/jsobject/jsobject.py#L106-L115 |
genepattern/nbtools | nbtools/jsobject/jsobject.py | BrowserContext._send | def _send(self, method, **parameters):
"""Sends a message to the front-end and returns a promise."""
msg = {
'index': self._calls,
'method': method,
}
msg.update(parameters)
promise = SimplePromise()
self._callbacks[self._calls] = promise
... | python | def _send(self, method, **parameters):
"""Sends a message to the front-end and returns a promise."""
msg = {
'index': self._calls,
'method': method,
}
msg.update(parameters)
promise = SimplePromise()
self._callbacks[self._calls] = promise
... | [
"def",
"_send",
"(",
"self",
",",
"method",
",",
"*",
"*",
"parameters",
")",
":",
"msg",
"=",
"{",
"'index'",
":",
"self",
".",
"_calls",
",",
"'method'",
":",
"method",
",",
"}",
"msg",
".",
"update",
"(",
"parameters",
")",
"promise",
"=",
"Simp... | Sends a message to the front-end and returns a promise. | [
"Sends",
"a",
"message",
"to",
"the",
"front",
"-",
"end",
"and",
"returns",
"a",
"promise",
"."
] | train | https://github.com/genepattern/nbtools/blob/2f74703f59926d8565f9714b1458dc87da8f8574/nbtools/jsobject/jsobject.py#L127-L141 |
LordGaav/python-chaos | chaos/amqp/rpc.py | rpc_reply | def rpc_reply(channel, original_headers, message, properties=None):
"""
Reply to a RPC request. This function will use the default exchange, to directly contact the reply_to queue.
Parameters
----------
channel: object
Properly initialized AMQP channel to use.
original_headers: dict
The headers of the origin... | python | def rpc_reply(channel, original_headers, message, properties=None):
"""
Reply to a RPC request. This function will use the default exchange, to directly contact the reply_to queue.
Parameters
----------
channel: object
Properly initialized AMQP channel to use.
original_headers: dict
The headers of the origin... | [
"def",
"rpc_reply",
"(",
"channel",
",",
"original_headers",
",",
"message",
",",
"properties",
"=",
"None",
")",
":",
"if",
"not",
"properties",
":",
"properties",
"=",
"{",
"}",
"properties",
"[",
"'correlation_id'",
"]",
"=",
"original_headers",
".",
"cor... | Reply to a RPC request. This function will use the default exchange, to directly contact the reply_to queue.
Parameters
----------
channel: object
Properly initialized AMQP channel to use.
original_headers: dict
The headers of the originating message that caused this reply.
message: string
Message to reply ... | [
"Reply",
"to",
"a",
"RPC",
"request",
".",
"This",
"function",
"will",
"use",
"the",
"default",
"exchange",
"to",
"directly",
"contact",
"the",
"reply_to",
"queue",
"."
] | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/amqp/rpc.py#L323-L345 |
LordGaav/python-chaos | chaos/amqp/rpc.py | Rpc.consume | def consume(self, consumer_callback=None, exclusive=False):
"""
Initialize consuming of messages from an AMQP RPC queue. Messages will be consumed after start_consuming() is called.
An internal callback will be used to handle incoming RPC responses. Only responses that have been registered with register_response... | python | def consume(self, consumer_callback=None, exclusive=False):
"""
Initialize consuming of messages from an AMQP RPC queue. Messages will be consumed after start_consuming() is called.
An internal callback will be used to handle incoming RPC responses. Only responses that have been registered with register_response... | [
"def",
"consume",
"(",
"self",
",",
"consumer_callback",
"=",
"None",
",",
"exclusive",
"=",
"False",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"queue_name\"",
")",
"and",
"consumer_callback",
":",
"raise",
"ValueError",
"(",
"\"Trying to set a cal... | Initialize consuming of messages from an AMQP RPC queue. Messages will be consumed after start_consuming() is called.
An internal callback will be used to handle incoming RPC responses. Only responses that have been registered with register_response()
will be kept internally, all other responses will be dropped si... | [
"Initialize",
"consuming",
"of",
"messages",
"from",
"an",
"AMQP",
"RPC",
"queue",
".",
"Messages",
"will",
"be",
"consumed",
"after",
"start_consuming",
"()",
"is",
"called",
"."
] | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/amqp/rpc.py#L109-L143 |
LordGaav/python-chaos | chaos/amqp/rpc.py | Rpc._rpc_response_callback | def _rpc_response_callback(self, channel, method_frame, header_frame, body):
"""
Internal callback used by consume()
Parameters
----------
channel: object
Channel from which the callback originated
method_frame: dict
Information about the message
header_frame: dict
Headers of the message
body:... | python | def _rpc_response_callback(self, channel, method_frame, header_frame, body):
"""
Internal callback used by consume()
Parameters
----------
channel: object
Channel from which the callback originated
method_frame: dict
Information about the message
header_frame: dict
Headers of the message
body:... | [
"def",
"_rpc_response_callback",
"(",
"self",
",",
"channel",
",",
"method_frame",
",",
"header_frame",
",",
"body",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"Received RPC response with correlation_id: {0}\"",
".",
"format",
"(",
"header_frame",
".",
... | Internal callback used by consume()
Parameters
----------
channel: object
Channel from which the callback originated
method_frame: dict
Information about the message
header_frame: dict
Headers of the message
body: string
Body of the message | [
"Internal",
"callback",
"used",
"by",
"consume",
"()"
] | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/amqp/rpc.py#L145-L167 |
LordGaav/python-chaos | chaos/amqp/rpc.py | Rpc.register_response | def register_response(self, correlation_id=None):
"""
Register the receiving of a RPC response. Will return the given correlation_id after registering, or if correlation_id is None, will
generate a correlation_id and return it after registering. If the given correlation_id has already been used, an KeyError will ... | python | def register_response(self, correlation_id=None):
"""
Register the receiving of a RPC response. Will return the given correlation_id after registering, or if correlation_id is None, will
generate a correlation_id and return it after registering. If the given correlation_id has already been used, an KeyError will ... | [
"def",
"register_response",
"(",
"self",
",",
"correlation_id",
"=",
"None",
")",
":",
"if",
"not",
"correlation_id",
":",
"correlation_id",
"=",
"str",
"(",
"uuid",
".",
"uuid1",
"(",
")",
")",
"if",
"correlation_id",
"in",
"self",
".",
"responses",
":",
... | Register the receiving of a RPC response. Will return the given correlation_id after registering, or if correlation_id is None, will
generate a correlation_id and return it after registering. If the given correlation_id has already been used, an KeyError will be
raised.
UUID version 1 will be used when generatin... | [
"Register",
"the",
"receiving",
"of",
"a",
"RPC",
"response",
".",
"Will",
"return",
"the",
"given",
"correlation_id",
"after",
"registering",
"or",
"if",
"correlation_id",
"is",
"None",
"will",
"generate",
"a",
"correlation_id",
"and",
"return",
"it",
"after",
... | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/amqp/rpc.py#L169-L191 |
LordGaav/python-chaos | chaos/amqp/rpc.py | Rpc.retrieve_response | def retrieve_response(self, correlation_id):
"""
Retrieve a registered RPC response. If the correlation_id was not registered, an KeyError will the raised. If not value has been
received yet, None will be returned. After retrieving the response, the value will be unset internally.
The returned value will inclu... | python | def retrieve_response(self, correlation_id):
"""
Retrieve a registered RPC response. If the correlation_id was not registered, an KeyError will the raised. If not value has been
received yet, None will be returned. After retrieving the response, the value will be unset internally.
The returned value will inclu... | [
"def",
"retrieve_response",
"(",
"self",
",",
"correlation_id",
")",
":",
"if",
"correlation_id",
"not",
"in",
"self",
".",
"responses",
":",
"raise",
"KeyError",
"(",
"\"Given RPC response correlation_id was not registered.\"",
")",
"if",
"not",
"self",
".",
"respo... | Retrieve a registered RPC response. If the correlation_id was not registered, an KeyError will the raised. If not value has been
received yet, None will be returned. After retrieving the response, the value will be unset internally.
The returned value will include the entire RabbitMQ message, consisting of a dict ... | [
"Retrieve",
"a",
"registered",
"RPC",
"response",
".",
"If",
"the",
"correlation_id",
"was",
"not",
"registered",
"an",
"KeyError",
"will",
"the",
"raised",
".",
"If",
"not",
"value",
"has",
"been",
"received",
"yet",
"None",
"will",
"be",
"returned",
".",
... | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/amqp/rpc.py#L199-L225 |
LordGaav/python-chaos | chaos/amqp/rpc.py | Rpc.request_response | def request_response(self, exchange, routing_key, message, properties=None, correlation_id=None, timeout=6):
"""
This function wraps publish, and sets the properties necessary to allow end-to-end communication using the Rpc paradigm.
This function assumes that the named exchange and routing_key combination will ... | python | def request_response(self, exchange, routing_key, message, properties=None, correlation_id=None, timeout=6):
"""
This function wraps publish, and sets the properties necessary to allow end-to-end communication using the Rpc paradigm.
This function assumes that the named exchange and routing_key combination will ... | [
"def",
"request_response",
"(",
"self",
",",
"exchange",
",",
"routing_key",
",",
"message",
",",
"properties",
"=",
"None",
",",
"correlation_id",
"=",
"None",
",",
"timeout",
"=",
"6",
")",
":",
"if",
"not",
"properties",
":",
"properties",
"=",
"{",
"... | This function wraps publish, and sets the properties necessary to allow end-to-end communication using the Rpc paradigm.
This function assumes that the named exchange and routing_key combination will result in a AMQP queue to pickup the request, and
reply using another AMQP message. To achieve this, the following ... | [
"This",
"function",
"wraps",
"publish",
"and",
"sets",
"the",
"properties",
"necessary",
"to",
"allow",
"end",
"-",
"to",
"-",
"end",
"communication",
"using",
"the",
"Rpc",
"paradigm",
"."
] | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/amqp/rpc.py#L227-L280 |
LordGaav/python-chaos | chaos/amqp/rpc.py | Rpc.publish | def publish(self, exchange, routing_key, message, properties=None, mandatory=False):
"""
Publish a message to an AMQP exchange.
Parameters
----------
exchange: string
Exchange to publish to.
routing_key: string
Routing key to use for this message.
message: string
Message to publish.
properties... | python | def publish(self, exchange, routing_key, message, properties=None, mandatory=False):
"""
Publish a message to an AMQP exchange.
Parameters
----------
exchange: string
Exchange to publish to.
routing_key: string
Routing key to use for this message.
message: string
Message to publish.
properties... | [
"def",
"publish",
"(",
"self",
",",
"exchange",
",",
"routing_key",
",",
"message",
",",
"properties",
"=",
"None",
",",
"mandatory",
"=",
"False",
")",
":",
"return",
"publish_message",
"(",
"self",
".",
"channel",
",",
"exchange",
",",
"routing_key",
","... | Publish a message to an AMQP exchange.
Parameters
----------
exchange: string
Exchange to publish to.
routing_key: string
Routing key to use for this message.
message: string
Message to publish.
properties: dict
Properties to set on message. This parameter is optional, but if set, at least the ... | [
"Publish",
"a",
"message",
"to",
"an",
"AMQP",
"exchange",
"."
] | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/amqp/rpc.py#L282-L302 |
LordGaav/python-chaos | chaos/amqp/rpc.py | Rpc.reply | def reply(self, original_headers, message, properties=None):
"""
Reply to a RPC request. This function will use the default exchange, to directly contact the reply_to queue.
Parameters
----------
original_headers: dict
The headers of the originating message that caused this reply.
message: string
Mes... | python | def reply(self, original_headers, message, properties=None):
"""
Reply to a RPC request. This function will use the default exchange, to directly contact the reply_to queue.
Parameters
----------
original_headers: dict
The headers of the originating message that caused this reply.
message: string
Mes... | [
"def",
"reply",
"(",
"self",
",",
"original_headers",
",",
"message",
",",
"properties",
"=",
"None",
")",
":",
"rpc_reply",
"(",
"self",
".",
"channel",
",",
"original_headers",
",",
"message",
",",
"properties",
")"
] | Reply to a RPC request. This function will use the default exchange, to directly contact the reply_to queue.
Parameters
----------
original_headers: dict
The headers of the originating message that caused this reply.
message: string
Message to reply with
properties: dict
Properties to set on message... | [
"Reply",
"to",
"a",
"RPC",
"request",
".",
"This",
"function",
"will",
"use",
"the",
"default",
"exchange",
"to",
"directly",
"contact",
"the",
"reply_to",
"queue",
"."
] | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/amqp/rpc.py#L304-L320 |
mishbahr/django-usersettings2 | usersettings/models.py | clear_usersettings_cache | def clear_usersettings_cache(sender, **kwargs):
"""
Clears the cache (if primed) each time a ``UserSettings`` is saved or deleted
"""
instance = kwargs['instance']
try:
del USERSETTINGS_CACHE[instance.site.pk]
except KeyError:
pass | python | def clear_usersettings_cache(sender, **kwargs):
"""
Clears the cache (if primed) each time a ``UserSettings`` is saved or deleted
"""
instance = kwargs['instance']
try:
del USERSETTINGS_CACHE[instance.site.pk]
except KeyError:
pass | [
"def",
"clear_usersettings_cache",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"instance",
"=",
"kwargs",
"[",
"'instance'",
"]",
"try",
":",
"del",
"USERSETTINGS_CACHE",
"[",
"instance",
".",
"site",
".",
"pk",
"]",
"except",
"KeyError",
":",
"pass"... | Clears the cache (if primed) each time a ``UserSettings`` is saved or deleted | [
"Clears",
"the",
"cache",
"(",
"if",
"primed",
")",
"each",
"time",
"a",
"UserSettings",
"is",
"saved",
"or",
"deleted"
] | train | https://github.com/mishbahr/django-usersettings2/blob/cbc2f4b2e01d5401bec8a3fa39151730cd2dcd2a/usersettings/models.py#L100-L108 |
mishbahr/django-usersettings2 | usersettings/models.py | UserSettingsManager.get_current | def get_current(self):
"""
Returns the current ``UserSettings`` based on the SITE_ID in the
project's settings. The ``UserSettings`` object is cached the first
time it's retrieved from the database.
"""
from django.conf import settings
try:
site_id = s... | python | def get_current(self):
"""
Returns the current ``UserSettings`` based on the SITE_ID in the
project's settings. The ``UserSettings`` object is cached the first
time it's retrieved from the database.
"""
from django.conf import settings
try:
site_id = s... | [
"def",
"get_current",
"(",
"self",
")",
":",
"from",
"django",
".",
"conf",
"import",
"settings",
"try",
":",
"site_id",
"=",
"settings",
".",
"SITE_ID",
"except",
"AttributeError",
":",
"raise",
"ImproperlyConfigured",
"(",
"'You\\'re using the Django \"sites frame... | Returns the current ``UserSettings`` based on the SITE_ID in the
project's settings. The ``UserSettings`` object is cached the first
time it's retrieved from the database. | [
"Returns",
"the",
"current",
"UserSettings",
"based",
"on",
"the",
"SITE_ID",
"in",
"the",
"project",
"s",
"settings",
".",
"The",
"UserSettings",
"object",
"is",
"cached",
"the",
"first",
"time",
"it",
"s",
"retrieved",
"from",
"the",
"database",
"."
] | train | https://github.com/mishbahr/django-usersettings2/blob/cbc2f4b2e01d5401bec8a3fa39151730cd2dcd2a/usersettings/models.py#L22-L42 |
unfoldingWord-dev/python-gogs-client | gogs_client/_implementation/http_utils.py | append_url | def append_url(base_url, path):
"""
Append path to base_url in a sensible way.
"""
if base_url[-1] != "/":
base_url += "/"
if path[0] == "/":
path = path[1:]
return urljoin(base_url, path) | python | def append_url(base_url, path):
"""
Append path to base_url in a sensible way.
"""
if base_url[-1] != "/":
base_url += "/"
if path[0] == "/":
path = path[1:]
return urljoin(base_url, path) | [
"def",
"append_url",
"(",
"base_url",
",",
"path",
")",
":",
"if",
"base_url",
"[",
"-",
"1",
"]",
"!=",
"\"/\"",
":",
"base_url",
"+=",
"\"/\"",
"if",
"path",
"[",
"0",
"]",
"==",
"\"/\"",
":",
"path",
"=",
"path",
"[",
"1",
":",
"]",
"return",
... | Append path to base_url in a sensible way. | [
"Append",
"path",
"to",
"base_url",
"in",
"a",
"sensible",
"way",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/_implementation/http_utils.py#L49-L57 |
jeremymcrae/denovonear | denovonear/frameshift_rate.py | include_frameshift_rates | def include_frameshift_rates(path):
""" add per-gene frameshift mutation rates to the output file
We make a crude estimate of the frameshift mutation rate by assessing the
total frameshift burden (across all genes in a dataset) as 1.25 times the
nonsense burden. Then apportion the frameshift burden... | python | def include_frameshift_rates(path):
""" add per-gene frameshift mutation rates to the output file
We make a crude estimate of the frameshift mutation rate by assessing the
total frameshift burden (across all genes in a dataset) as 1.25 times the
nonsense burden. Then apportion the frameshift burden... | [
"def",
"include_frameshift_rates",
"(",
"path",
")",
":",
"with",
"open",
"(",
"path",
")",
"as",
"handle",
":",
"lines",
"=",
"[",
"x",
".",
"strip",
"(",
")",
".",
"split",
"(",
"'\\t'",
")",
"for",
"x",
"in",
"handle",
"]",
"nonsense",
"=",
"sum... | add per-gene frameshift mutation rates to the output file
We make a crude estimate of the frameshift mutation rate by assessing the
total frameshift burden (across all genes in a dataset) as 1.25 times the
nonsense burden. Then apportion the frameshift burden proportional to each
genes CDS length.
... | [
"add",
"per",
"-",
"gene",
"frameshift",
"mutation",
"rates",
"to",
"the",
"output",
"file",
"We",
"make",
"a",
"crude",
"estimate",
"of",
"the",
"frameshift",
"mutation",
"rate",
"by",
"assessing",
"the",
"total",
"frameshift",
"burden",
"(",
"across",
"all... | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/frameshift_rate.py#L4-L42 |
hyperboria/python-cjdns | cjdns/cjdns.py | _randomString | def _randomString():
"""Random string for message signing"""
return ''.join(
random.choice(string.ascii_uppercase + string.digits)
for x in range(10)) | python | def _randomString():
"""Random string for message signing"""
return ''.join(
random.choice(string.ascii_uppercase + string.digits)
for x in range(10)) | [
"def",
"_randomString",
"(",
")",
":",
"return",
"''",
".",
"join",
"(",
"random",
".",
"choice",
"(",
"string",
".",
"ascii_uppercase",
"+",
"string",
".",
"digits",
")",
"for",
"x",
"in",
"range",
"(",
"10",
")",
")"
] | Random string for message signing | [
"Random",
"string",
"for",
"message",
"signing"
] | train | https://github.com/hyperboria/python-cjdns/blob/a9ae5d6d2e99c18f9fc50a9589729cd176efa900/cjdns/cjdns.py#L63-L68 |
hyperboria/python-cjdns | cjdns/cjdns.py | _callFunc | def _callFunc(session, funcName, password, args):
"""Call custom cjdns admin function"""
txid = _randomString()
sock = session.socket
sock.send(bytearray('d1:q6:cookie4:txid10:%se' % txid, 'utf-8'))
msg = _getMessage(session, txid)
cookie = msg['cookie']
txid = _randomString()
tohash = ... | python | def _callFunc(session, funcName, password, args):
"""Call custom cjdns admin function"""
txid = _randomString()
sock = session.socket
sock.send(bytearray('d1:q6:cookie4:txid10:%se' % txid, 'utf-8'))
msg = _getMessage(session, txid)
cookie = msg['cookie']
txid = _randomString()
tohash = ... | [
"def",
"_callFunc",
"(",
"session",
",",
"funcName",
",",
"password",
",",
"args",
")",
":",
"txid",
"=",
"_randomString",
"(",
")",
"sock",
"=",
"session",
".",
"socket",
"sock",
".",
"send",
"(",
"bytearray",
"(",
"'d1:q6:cookie4:txid10:%se'",
"%",
"txid... | Call custom cjdns admin function | [
"Call",
"custom",
"cjdns",
"admin",
"function"
] | train | https://github.com/hyperboria/python-cjdns/blob/a9ae5d6d2e99c18f9fc50a9589729cd176efa900/cjdns/cjdns.py#L71-L97 |
hyperboria/python-cjdns | cjdns/cjdns.py | _receiverThread | def _receiverThread(session):
"""Receiving messages from cjdns admin server"""
timeOfLastSend = time.time()
timeOfLastRecv = time.time()
try:
while True:
if timeOfLastSend + KEEPALIVE_INTERVAL_SECONDS < time.time():
if timeOfLastRecv + 10 < time.time():
... | python | def _receiverThread(session):
"""Receiving messages from cjdns admin server"""
timeOfLastSend = time.time()
timeOfLastRecv = time.time()
try:
while True:
if timeOfLastSend + KEEPALIVE_INTERVAL_SECONDS < time.time():
if timeOfLastRecv + 10 < time.time():
... | [
"def",
"_receiverThread",
"(",
"session",
")",
":",
"timeOfLastSend",
"=",
"time",
".",
"time",
"(",
")",
"timeOfLastRecv",
"=",
"time",
".",
"time",
"(",
")",
"try",
":",
"while",
"True",
":",
"if",
"timeOfLastSend",
"+",
"KEEPALIVE_INTERVAL_SECONDS",
"<",
... | Receiving messages from cjdns admin server | [
"Receiving",
"messages",
"from",
"cjdns",
"admin",
"server"
] | train | https://github.com/hyperboria/python-cjdns/blob/a9ae5d6d2e99c18f9fc50a9589729cd176efa900/cjdns/cjdns.py#L100-L135 |
hyperboria/python-cjdns | cjdns/cjdns.py | _getMessage | def _getMessage(session, txid):
"""Getting message associated with txid"""
while True:
if txid in session.messages:
msg = session.messages[txid]
del session.messages[txid]
return msg
else:
try:
# apparently any timeout at all allow... | python | def _getMessage(session, txid):
"""Getting message associated with txid"""
while True:
if txid in session.messages:
msg = session.messages[txid]
del session.messages[txid]
return msg
else:
try:
# apparently any timeout at all allow... | [
"def",
"_getMessage",
"(",
"session",
",",
"txid",
")",
":",
"while",
"True",
":",
"if",
"txid",
"in",
"session",
".",
"messages",
":",
"msg",
"=",
"session",
".",
"messages",
"[",
"txid",
"]",
"del",
"session",
".",
"messages",
"[",
"txid",
"]",
"re... | Getting message associated with txid | [
"Getting",
"message",
"associated",
"with",
"txid"
] | train | https://github.com/hyperboria/python-cjdns/blob/a9ae5d6d2e99c18f9fc50a9589729cd176efa900/cjdns/cjdns.py#L138-L156 |
hyperboria/python-cjdns | cjdns/cjdns.py | _functionFabric | def _functionFabric(func_name, argList, oargList, password):
"""Function fabric for Session class"""
def functionHandler(self, *args, **kwargs):
call_args = {}
for (key, value) in oargList.items():
call_args[key] = value
for i, arg in enumerate(argList):
if i <... | python | def _functionFabric(func_name, argList, oargList, password):
"""Function fabric for Session class"""
def functionHandler(self, *args, **kwargs):
call_args = {}
for (key, value) in oargList.items():
call_args[key] = value
for i, arg in enumerate(argList):
if i <... | [
"def",
"_functionFabric",
"(",
"func_name",
",",
"argList",
",",
"oargList",
",",
"password",
")",
":",
"def",
"functionHandler",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"call_args",
"=",
"{",
"}",
"for",
"(",
"key",
",",
"v... | Function fabric for Session class | [
"Function",
"fabric",
"for",
"Session",
"class"
] | train | https://github.com/hyperboria/python-cjdns/blob/a9ae5d6d2e99c18f9fc50a9589729cd176efa900/cjdns/cjdns.py#L159-L178 |
hyperboria/python-cjdns | cjdns/cjdns.py | connect | def connect(ipAddr, port, password):
"""Connect to cjdns admin with this attributes"""
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.connect((ipAddr, port))
sock.settimeout(2)
# Make sure it pongs.
sock.send(b'd1:q4:pinge')
data = sock.recv(BUFFER_SIZE)
if not data.endsw... | python | def connect(ipAddr, port, password):
"""Connect to cjdns admin with this attributes"""
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.connect((ipAddr, port))
sock.settimeout(2)
# Make sure it pongs.
sock.send(b'd1:q4:pinge')
data = sock.recv(BUFFER_SIZE)
if not data.endsw... | [
"def",
"connect",
"(",
"ipAddr",
",",
"port",
",",
"password",
")",
":",
"sock",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_DGRAM",
")",
"sock",
".",
"connect",
"(",
"(",
"ipAddr",
",",
"port",
")",
")",
... | Connect to cjdns admin with this attributes | [
"Connect",
"to",
"cjdns",
"admin",
"with",
"this",
"attributes"
] | train | https://github.com/hyperboria/python-cjdns/blob/a9ae5d6d2e99c18f9fc50a9589729cd176efa900/cjdns/cjdns.py#L181-L260 |
hyperboria/python-cjdns | cjdns/cjdns.py | connectWithAdminInfo | def connectWithAdminInfo(path=None):
"""Connect to cjdns admin with data from user file"""
if path is None:
path = os.path.expanduser('~/.cjdnsadmin')
try:
with open(path, 'r') as adminInfo:
data = json.load(adminInfo)
except IOError:
logger.info('~/.cjdnsadmin not f... | python | def connectWithAdminInfo(path=None):
"""Connect to cjdns admin with data from user file"""
if path is None:
path = os.path.expanduser('~/.cjdnsadmin')
try:
with open(path, 'r') as adminInfo:
data = json.load(adminInfo)
except IOError:
logger.info('~/.cjdnsadmin not f... | [
"def",
"connectWithAdminInfo",
"(",
"path",
"=",
"None",
")",
":",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~/.cjdnsadmin'",
")",
"try",
":",
"with",
"open",
"(",
"path",
",",
"'r'",
")",
"as",
"admin... | Connect to cjdns admin with data from user file | [
"Connect",
"to",
"cjdns",
"admin",
"with",
"data",
"from",
"user",
"file"
] | train | https://github.com/hyperboria/python-cjdns/blob/a9ae5d6d2e99c18f9fc50a9589729cd176efa900/cjdns/cjdns.py#L263-L279 |
LordGaav/python-chaos | chaos/amqp/exchange.py | publish_message | def publish_message(channel, exchange, routing_key, message, properties=None, mandatory=False):
"""
Publish a message to an AMQP exchange.
Parameters
----------
channel: object
Properly initialized AMQP channel to use.
exchange: string
Exchange to publish to.
routing_key: string
Routing key to use for thi... | python | def publish_message(channel, exchange, routing_key, message, properties=None, mandatory=False):
"""
Publish a message to an AMQP exchange.
Parameters
----------
channel: object
Properly initialized AMQP channel to use.
exchange: string
Exchange to publish to.
routing_key: string
Routing key to use for thi... | [
"def",
"publish_message",
"(",
"channel",
",",
"exchange",
",",
"routing_key",
",",
"message",
",",
"properties",
"=",
"None",
",",
"mandatory",
"=",
"False",
")",
":",
"if",
"properties",
"is",
"None",
":",
"properties",
"=",
"{",
"}",
"if",
"properties",... | Publish a message to an AMQP exchange.
Parameters
----------
channel: object
Properly initialized AMQP channel to use.
exchange: string
Exchange to publish to.
routing_key: string
Routing key to use for this message.
message: string
Message to publish.
properties: dict
Properties to set on message. Th... | [
"Publish",
"a",
"message",
"to",
"an",
"AMQP",
"exchange",
"."
] | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/amqp/exchange.py#L107-L159 |
LordGaav/python-chaos | chaos/amqp/exchange.py | Exchange.publish | def publish(self, message, properties=None, mandatory=False):
"""
Publish a message to an AMQP exchange.
Parameters
----------
message: string
Message to publish.
properties: dict
Properties to set on message. This parameter is optional, but if set, at least the following options must be set:
con... | python | def publish(self, message, properties=None, mandatory=False):
"""
Publish a message to an AMQP exchange.
Parameters
----------
message: string
Message to publish.
properties: dict
Properties to set on message. This parameter is optional, but if set, at least the following options must be set:
con... | [
"def",
"publish",
"(",
"self",
",",
"message",
",",
"properties",
"=",
"None",
",",
"mandatory",
"=",
"False",
")",
":",
"return",
"publish_message",
"(",
"self",
".",
"channel",
",",
"self",
".",
"exchange_name",
",",
"self",
".",
"default_routing_key",
"... | Publish a message to an AMQP exchange.
Parameters
----------
message: string
Message to publish.
properties: dict
Properties to set on message. This parameter is optional, but if set, at least the following options must be set:
content_type: string - what content_type to specify, default is 'text/pla... | [
"Publish",
"a",
"message",
"to",
"an",
"AMQP",
"exchange",
"."
] | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/amqp/exchange.py#L74-L104 |
jeremymcrae/denovonear | denovonear/__main__.py | load_genes | def load_genes(path):
""" load a file listing gene and transcript IDs
Args:
path: path to file containing gene IDs and transcript IDs e.g.
gene_1 transcript_1.1 length_1 denovo_count
gene_2 transcript_2.1 length_3 denovo_count
Returns:
dict... | python | def load_genes(path):
""" load a file listing gene and transcript IDs
Args:
path: path to file containing gene IDs and transcript IDs e.g.
gene_1 transcript_1.1 length_1 denovo_count
gene_2 transcript_2.1 length_3 denovo_count
Returns:
dict... | [
"def",
"load_genes",
"(",
"path",
")",
":",
"with",
"open",
"(",
"path",
",",
"'rt'",
")",
"as",
"f",
":",
"lines",
"=",
"[",
"x",
".",
"split",
"(",
"'\\t'",
")",
"[",
":",
"2",
"]",
"for",
"x",
"in",
"f",
"if",
"not",
"x",
".",
"startswith"... | load a file listing gene and transcript IDs
Args:
path: path to file containing gene IDs and transcript IDs e.g.
gene_1 transcript_1.1 length_1 denovo_count
gene_2 transcript_2.1 length_3 denovo_count
Returns:
dict of transcripts eg {'CTC1': ["... | [
"load",
"a",
"file",
"listing",
"gene",
"and",
"transcript",
"IDs",
"Args",
":",
"path",
":",
"path",
"to",
"file",
"containing",
"gene",
"IDs",
"and",
"transcript",
"IDs",
"e",
".",
"g",
".",
"gene_1",
"transcript_1",
".",
"1",
"length_1",
"denovo_count",... | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/__main__.py#L70-L91 |
jeremymcrae/denovonear | denovonear/__main__.py | get_mutation_rates | def get_mutation_rates(transcripts, mut_dict, ensembl):
""" determines mutation rates per functional category for transcripts
Args:
transcripts: list of transcript IDs for a gene
mut_dict: dictionary of local sequence context mutation rates
ensembl: EnsemblRequest object, to retriev... | python | def get_mutation_rates(transcripts, mut_dict, ensembl):
""" determines mutation rates per functional category for transcripts
Args:
transcripts: list of transcript IDs for a gene
mut_dict: dictionary of local sequence context mutation rates
ensembl: EnsemblRequest object, to retriev... | [
"def",
"get_mutation_rates",
"(",
"transcripts",
",",
"mut_dict",
",",
"ensembl",
")",
":",
"rates",
"=",
"{",
"'missense'",
":",
"0",
",",
"'nonsense'",
":",
"0",
",",
"'splice_lof'",
":",
"0",
",",
"'splice_region'",
":",
"0",
",",
"'synonymous'",
":",
... | determines mutation rates per functional category for transcripts
Args:
transcripts: list of transcript IDs for a gene
mut_dict: dictionary of local sequence context mutation rates
ensembl: EnsemblRequest object, to retrieve information from Ensembl.
Returns:
tuple of (... | [
"determines",
"mutation",
"rates",
"per",
"functional",
"category",
"for",
"transcripts",
"Args",
":",
"transcripts",
":",
"list",
"of",
"transcript",
"IDs",
"for",
"a",
"gene",
"mut_dict",
":",
"dictionary",
"of",
"local",
"sequence",
"context",
"mutation",
"ra... | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/__main__.py#L93-L133 |
jeremymcrae/denovonear | denovonear/__main__.py | get_options | def get_options():
""" get the command line switches
"""
parser = argparse.ArgumentParser(description='denovonear cli interface')
############################################################################
# CLI options in common
parent = argparse.ArgumentParser(add_help=False)
pa... | python | def get_options():
""" get the command line switches
"""
parser = argparse.ArgumentParser(description='denovonear cli interface')
############################################################################
# CLI options in common
parent = argparse.ArgumentParser(add_help=False)
pa... | [
"def",
"get_options",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'denovonear cli interface'",
")",
"############################################################################",
"# CLI options in common",
"parent",
"=",
"argparse... | get the command line switches | [
"get",
"the",
"command",
"line",
"switches"
] | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/__main__.py#L159-L221 |
hyperboria/python-cjdns | cjdns/key_utils.py | to_ipv6 | def to_ipv6(key):
"""Get IPv6 address from a public key."""
if key[-2:] != '.k':
raise ValueError('Key does not end with .k')
key_bytes = base32.decode(key[:-2])
hash_one = sha512(key_bytes).digest()
hash_two = sha512(hash_one).hexdigest()
return ':'.join([hash_two[i:i+4] for i in ran... | python | def to_ipv6(key):
"""Get IPv6 address from a public key."""
if key[-2:] != '.k':
raise ValueError('Key does not end with .k')
key_bytes = base32.decode(key[:-2])
hash_one = sha512(key_bytes).digest()
hash_two = sha512(hash_one).hexdigest()
return ':'.join([hash_two[i:i+4] for i in ran... | [
"def",
"to_ipv6",
"(",
"key",
")",
":",
"if",
"key",
"[",
"-",
"2",
":",
"]",
"!=",
"'.k'",
":",
"raise",
"ValueError",
"(",
"'Key does not end with .k'",
")",
"key_bytes",
"=",
"base32",
".",
"decode",
"(",
"key",
"[",
":",
"-",
"2",
"]",
")",
"ha... | Get IPv6 address from a public key. | [
"Get",
"IPv6",
"address",
"from",
"a",
"public",
"key",
"."
] | train | https://github.com/hyperboria/python-cjdns/blob/a9ae5d6d2e99c18f9fc50a9589729cd176efa900/cjdns/key_utils.py#L18-L28 |
LordGaav/python-chaos | chaos/globber.py | Globber.glob | def glob(self):
"""
Traverse directory, and return all absolute filenames of files that
match the globbing patterns.
"""
matches = []
for root, dirnames, filenames in os.walk(self.path):
if not self.recursive:
while len(dirnames) > 0:
dirnames.pop()
for include in self.include:
for filena... | python | def glob(self):
"""
Traverse directory, and return all absolute filenames of files that
match the globbing patterns.
"""
matches = []
for root, dirnames, filenames in os.walk(self.path):
if not self.recursive:
while len(dirnames) > 0:
dirnames.pop()
for include in self.include:
for filena... | [
"def",
"glob",
"(",
"self",
")",
":",
"matches",
"=",
"[",
"]",
"for",
"root",
",",
"dirnames",
",",
"filenames",
"in",
"os",
".",
"walk",
"(",
"self",
".",
"path",
")",
":",
"if",
"not",
"self",
".",
"recursive",
":",
"while",
"len",
"(",
"dirna... | Traverse directory, and return all absolute filenames of files that
match the globbing patterns. | [
"Traverse",
"directory",
"and",
"return",
"all",
"absolute",
"filenames",
"of",
"files",
"that",
"match",
"the",
"globbing",
"patterns",
"."
] | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/globber.py#L49-L62 |
mishbahr/django-usersettings2 | usersettings/admin.py | SettingsAdmin.select_site_view | def select_site_view(self, request, form_url=''):
"""
Display a choice form to select which site to add settings.
"""
if not self.has_add_permission(request):
raise PermissionDenied
extra_qs = ''
if request.META['QUERY_STRING']:
extra_qs = '&' + r... | python | def select_site_view(self, request, form_url=''):
"""
Display a choice form to select which site to add settings.
"""
if not self.has_add_permission(request):
raise PermissionDenied
extra_qs = ''
if request.META['QUERY_STRING']:
extra_qs = '&' + r... | [
"def",
"select_site_view",
"(",
"self",
",",
"request",
",",
"form_url",
"=",
"''",
")",
":",
"if",
"not",
"self",
".",
"has_add_permission",
"(",
"request",
")",
":",
"raise",
"PermissionDenied",
"extra_qs",
"=",
"''",
"if",
"request",
".",
"META",
"[",
... | Display a choice form to select which site to add settings. | [
"Display",
"a",
"choice",
"form",
"to",
"select",
"which",
"site",
"to",
"add",
"settings",
"."
] | train | https://github.com/mishbahr/django-usersettings2/blob/cbc2f4b2e01d5401bec8a3fa39151730cd2dcd2a/usersettings/admin.py#L84-L126 |
mishbahr/django-usersettings2 | usersettings/admin.py | SettingsAdmin.render_select_site_form | def render_select_site_form(self, request, context, form_url=''):
"""
Render the site choice form.
"""
app_label = self.opts.app_label
context.update({
'has_change_permission': self.has_change_permission(request),
'form_url': mark_safe(form_url),
... | python | def render_select_site_form(self, request, context, form_url=''):
"""
Render the site choice form.
"""
app_label = self.opts.app_label
context.update({
'has_change_permission': self.has_change_permission(request),
'form_url': mark_safe(form_url),
... | [
"def",
"render_select_site_form",
"(",
"self",
",",
"request",
",",
"context",
",",
"form_url",
"=",
"''",
")",
":",
"app_label",
"=",
"self",
".",
"opts",
".",
"app_label",
"context",
".",
"update",
"(",
"{",
"'has_change_permission'",
":",
"self",
".",
"... | Render the site choice form. | [
"Render",
"the",
"site",
"choice",
"form",
"."
] | train | https://github.com/mishbahr/django-usersettings2/blob/cbc2f4b2e01d5401bec8a3fa39151730cd2dcd2a/usersettings/admin.py#L128-L146 |
ReadabilityHoldings/python-readability-api | readability/auth.py | xauth | def xauth(base_url_template=DEFAULT_READER_URL_TEMPLATE, **xargs):
"""
Returns an OAuth token tuple that can be used with clients.ReaderClient.
:param base_url_template: Template for generating Readability API urls.
:param consumer_key: Readability consumer key, otherwise read from READABILITY_CONSUME... | python | def xauth(base_url_template=DEFAULT_READER_URL_TEMPLATE, **xargs):
"""
Returns an OAuth token tuple that can be used with clients.ReaderClient.
:param base_url_template: Template for generating Readability API urls.
:param consumer_key: Readability consumer key, otherwise read from READABILITY_CONSUME... | [
"def",
"xauth",
"(",
"base_url_template",
"=",
"DEFAULT_READER_URL_TEMPLATE",
",",
"*",
"*",
"xargs",
")",
":",
"consumer_key",
"=",
"xargs",
".",
"get",
"(",
"'consumer_key'",
")",
"or",
"required_from_env",
"(",
"'READABILITY_CONSUMER_KEY'",
")",
"consumer_secret"... | Returns an OAuth token tuple that can be used with clients.ReaderClient.
:param base_url_template: Template for generating Readability API urls.
:param consumer_key: Readability consumer key, otherwise read from READABILITY_CONSUMER_KEY.
:param consumer_secret: Readability consumer secret, otherwise read ... | [
"Returns",
"an",
"OAuth",
"token",
"tuple",
"that",
"can",
"be",
"used",
"with",
"clients",
".",
"ReaderClient",
"."
] | train | https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/auth.py#L37-L79 |
jeremymcrae/denovonear | denovonear/log_transform_rates.py | log_transform | def log_transform(rates):
""" log transform a numeric value, unless it is zero, or negative
"""
transformed = []
for key in ['missense', 'nonsense', 'splice_lof', 'splice_region',
'synonymous']:
try:
value = math.log10(rates[key])
except ValueError:
... | python | def log_transform(rates):
""" log transform a numeric value, unless it is zero, or negative
"""
transformed = []
for key in ['missense', 'nonsense', 'splice_lof', 'splice_region',
'synonymous']:
try:
value = math.log10(rates[key])
except ValueError:
... | [
"def",
"log_transform",
"(",
"rates",
")",
":",
"transformed",
"=",
"[",
"]",
"for",
"key",
"in",
"[",
"'missense'",
",",
"'nonsense'",
",",
"'splice_lof'",
",",
"'splice_region'",
",",
"'synonymous'",
"]",
":",
"try",
":",
"value",
"=",
"math",
".",
"lo... | log transform a numeric value, unless it is zero, or negative | [
"log",
"transform",
"a",
"numeric",
"value",
"unless",
"it",
"is",
"zero",
"or",
"negative"
] | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/log_transform_rates.py#L4-L21 |
mishbahr/django-usersettings2 | usersettings/shortcuts.py | get_usersettings_model | def get_usersettings_model():
"""
Returns the ``UserSettings`` model that is active in this project.
"""
try:
from django.apps import apps
get_model = apps.get_model
except ImportError:
from django.db.models.loading import get_model
try:
app_label, model_name = s... | python | def get_usersettings_model():
"""
Returns the ``UserSettings`` model that is active in this project.
"""
try:
from django.apps import apps
get_model = apps.get_model
except ImportError:
from django.db.models.loading import get_model
try:
app_label, model_name = s... | [
"def",
"get_usersettings_model",
"(",
")",
":",
"try",
":",
"from",
"django",
".",
"apps",
"import",
"apps",
"get_model",
"=",
"apps",
".",
"get_model",
"except",
"ImportError",
":",
"from",
"django",
".",
"db",
".",
"models",
".",
"loading",
"import",
"ge... | Returns the ``UserSettings`` model that is active in this project. | [
"Returns",
"the",
"UserSettings",
"model",
"that",
"is",
"active",
"in",
"this",
"project",
"."
] | train | https://github.com/mishbahr/django-usersettings2/blob/cbc2f4b2e01d5401bec8a3fa39151730cd2dcd2a/usersettings/shortcuts.py#L5-L24 |
mishbahr/django-usersettings2 | usersettings/shortcuts.py | get_current_usersettings | def get_current_usersettings():
"""
Returns the current ``UserSettings`` based on
the SITE_ID in the project's settings
"""
USERSETTINGS_MODEL = get_usersettings_model()
try:
current_usersettings = USERSETTINGS_MODEL.objects.get_current()
except USERSETTINGS_MODEL.DoesNotExist:
... | python | def get_current_usersettings():
"""
Returns the current ``UserSettings`` based on
the SITE_ID in the project's settings
"""
USERSETTINGS_MODEL = get_usersettings_model()
try:
current_usersettings = USERSETTINGS_MODEL.objects.get_current()
except USERSETTINGS_MODEL.DoesNotExist:
... | [
"def",
"get_current_usersettings",
"(",
")",
":",
"USERSETTINGS_MODEL",
"=",
"get_usersettings_model",
"(",
")",
"try",
":",
"current_usersettings",
"=",
"USERSETTINGS_MODEL",
".",
"objects",
".",
"get_current",
"(",
")",
"except",
"USERSETTINGS_MODEL",
".",
"DoesNotE... | Returns the current ``UserSettings`` based on
the SITE_ID in the project's settings | [
"Returns",
"the",
"current",
"UserSettings",
"based",
"on",
"the",
"SITE_ID",
"in",
"the",
"project",
"s",
"settings"
] | train | https://github.com/mishbahr/django-usersettings2/blob/cbc2f4b2e01d5401bec8a3fa39151730cd2dcd2a/usersettings/shortcuts.py#L27-L37 |
jeremymcrae/denovonear | denovonear/simulate.py | get_p_value | def get_p_value(transcript, rates, iterations, consequence, de_novos):
""" find the probability of getting de novos with a mean conservation
The probability is the number of simulations where the mean conservation
between simulated de novos is less than the observed conservation.
Args:
... | python | def get_p_value(transcript, rates, iterations, consequence, de_novos):
""" find the probability of getting de novos with a mean conservation
The probability is the number of simulations where the mean conservation
between simulated de novos is less than the observed conservation.
Args:
... | [
"def",
"get_p_value",
"(",
"transcript",
",",
"rates",
",",
"iterations",
",",
"consequence",
",",
"de_novos",
")",
":",
"if",
"len",
"(",
"de_novos",
")",
"<",
"2",
":",
"return",
"(",
"float",
"(",
"'nan'",
")",
",",
"float",
"(",
"'nan'",
")",
")"... | find the probability of getting de novos with a mean conservation
The probability is the number of simulations where the mean conservation
between simulated de novos is less than the observed conservation.
Args:
transcript: Transcript object for the current gene.
rates: SiteRates o... | [
"find",
"the",
"probability",
"of",
"getting",
"de",
"novos",
"with",
"a",
"mean",
"conservation",
"The",
"probability",
"is",
"the",
"number",
"of",
"simulations",
"where",
"the",
"mean",
"conservation",
"between",
"simulated",
"de",
"novos",
"is",
"less",
"t... | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/simulate.py#L8-L49 |
jeremymcrae/denovonear | scripts/run_batch.py | get_options | def get_options():
""" get the command line options
"""
parser = argparse.ArgumentParser(description="Script to batch process de"
"novo clustering.")
parser.add_argument("--in", dest="input", required=True, help="Path to"
"file listing known mutations in genes. See example file in d... | python | def get_options():
""" get the command line options
"""
parser = argparse.ArgumentParser(description="Script to batch process de"
"novo clustering.")
parser.add_argument("--in", dest="input", required=True, help="Path to"
"file listing known mutations in genes. See example file in d... | [
"def",
"get_options",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Script to batch process de\"",
"\"novo clustering.\"",
")",
"parser",
".",
"add_argument",
"(",
"\"--in\"",
",",
"dest",
"=",
"\"input\"",
",",
"requ... | get the command line options | [
"get",
"the",
"command",
"line",
"options"
] | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/scripts/run_batch.py#L11-L25 |
jeremymcrae/denovonear | scripts/run_batch.py | count_missense_per_gene | def count_missense_per_gene(lines):
""" count the number of missense variants in each gene.
"""
counts = {}
for x in lines:
x = x.split("\t")
gene = x[0]
consequence = x[3]
if gene not in counts:
counts[gene] = 0
if consequence !... | python | def count_missense_per_gene(lines):
""" count the number of missense variants in each gene.
"""
counts = {}
for x in lines:
x = x.split("\t")
gene = x[0]
consequence = x[3]
if gene not in counts:
counts[gene] = 0
if consequence !... | [
"def",
"count_missense_per_gene",
"(",
"lines",
")",
":",
"counts",
"=",
"{",
"}",
"for",
"x",
"in",
"lines",
":",
"x",
"=",
"x",
".",
"split",
"(",
"\"\\t\"",
")",
"gene",
"=",
"x",
"[",
"0",
"]",
"consequence",
"=",
"x",
"[",
"3",
"]",
"if",
... | count the number of missense variants in each gene. | [
"count",
"the",
"number",
"of",
"missense",
"variants",
"in",
"each",
"gene",
"."
] | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/scripts/run_batch.py#L27-L45 |
jeremymcrae/denovonear | scripts/run_batch.py | split_denovos | def split_denovos(denovo_path, temp_dir):
""" split de novos from an input file into files, one for each gene
"""
# open the de novos, drop the header line, then sort them (which will be by
# HGNC symbol, as the first element of each line)
with open(denovo_path, "r") as handle:
lines = ... | python | def split_denovos(denovo_path, temp_dir):
""" split de novos from an input file into files, one for each gene
"""
# open the de novos, drop the header line, then sort them (which will be by
# HGNC symbol, as the first element of each line)
with open(denovo_path, "r") as handle:
lines = ... | [
"def",
"split_denovos",
"(",
"denovo_path",
",",
"temp_dir",
")",
":",
"# open the de novos, drop the header line, then sort them (which will be by",
"# HGNC symbol, as the first element of each line)",
"with",
"open",
"(",
"denovo_path",
",",
"\"r\"",
")",
"as",
"handle",
":",... | split de novos from an input file into files, one for each gene | [
"split",
"de",
"novos",
"from",
"an",
"input",
"file",
"into",
"files",
"one",
"for",
"each",
"gene"
] | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/scripts/run_batch.py#L47-L77 |
jeremymcrae/denovonear | scripts/run_batch.py | get_random_string | def get_random_string():
""" make a random string, which we can use for bsub job IDs, so that
different jobs do not have the same job IDs.
"""
# set up a random string to associate with the run
hash_string = "%8x" % random.getrandbits(32)
hash_string = hash_string.strip()
# done't ... | python | def get_random_string():
""" make a random string, which we can use for bsub job IDs, so that
different jobs do not have the same job IDs.
"""
# set up a random string to associate with the run
hash_string = "%8x" % random.getrandbits(32)
hash_string = hash_string.strip()
# done't ... | [
"def",
"get_random_string",
"(",
")",
":",
"# set up a random string to associate with the run",
"hash_string",
"=",
"\"%8x\"",
"%",
"random",
".",
"getrandbits",
"(",
"32",
")",
"hash_string",
"=",
"hash_string",
".",
"strip",
"(",
")",
"# done't allow the random strin... | make a random string, which we can use for bsub job IDs, so that
different jobs do not have the same job IDs. | [
"make",
"a",
"random",
"string",
"which",
"we",
"can",
"use",
"for",
"bsub",
"job",
"IDs",
"so",
"that",
"different",
"jobs",
"do",
"not",
"have",
"the",
"same",
"job",
"IDs",
"."
] | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/scripts/run_batch.py#L96-L112 |
jeremymcrae/denovonear | scripts/run_batch.py | submit_bsub_job | def submit_bsub_job(command, job_id=None, dependent_id=None, memory=None, requeue_code=None, logfile=None):
""" construct a bsub job submission command
Args:
command: list of strings that forma unix command
job_id: string for job ID for submission
dependent_id: job ID, or list of jo... | python | def submit_bsub_job(command, job_id=None, dependent_id=None, memory=None, requeue_code=None, logfile=None):
""" construct a bsub job submission command
Args:
command: list of strings that forma unix command
job_id: string for job ID for submission
dependent_id: job ID, or list of jo... | [
"def",
"submit_bsub_job",
"(",
"command",
",",
"job_id",
"=",
"None",
",",
"dependent_id",
"=",
"None",
",",
"memory",
"=",
"None",
",",
"requeue_code",
"=",
"None",
",",
"logfile",
"=",
"None",
")",
":",
"if",
"job_id",
"is",
"None",
":",
"job_id",
"=... | construct a bsub job submission command
Args:
command: list of strings that forma unix command
job_id: string for job ID for submission
dependent_id: job ID, or list of job IDs which the current command needs
to have finished before the current command will start. Note that
... | [
"construct",
"a",
"bsub",
"job",
"submission",
"command",
"Args",
":",
"command",
":",
"list",
"of",
"strings",
"that",
"forma",
"unix",
"command",
"job_id",
":",
"string",
"for",
"job",
"ID",
"for",
"submission",
"dependent_id",
":",
"job",
"ID",
"or",
"l... | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/scripts/run_batch.py#L114-L156 |
jeremymcrae/denovonear | scripts/run_batch.py | batch_process | def batch_process(de_novo_path, temp_dir, output_path):
""" sets up a lsf job array
"""
temp_dir = tempfile.mkdtemp(dir=temp_dir)
count = split_denovos(de_novo_path, temp_dir)
# set up run parameters
job_name = "denovonear"
job_id = "{0}[1-{1}]%20".format(job_name, count)
... | python | def batch_process(de_novo_path, temp_dir, output_path):
""" sets up a lsf job array
"""
temp_dir = tempfile.mkdtemp(dir=temp_dir)
count = split_denovos(de_novo_path, temp_dir)
# set up run parameters
job_name = "denovonear"
job_id = "{0}[1-{1}]%20".format(job_name, count)
... | [
"def",
"batch_process",
"(",
"de_novo_path",
",",
"temp_dir",
",",
"output_path",
")",
":",
"temp_dir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"dir",
"=",
"temp_dir",
")",
"count",
"=",
"split_denovos",
"(",
"de_novo_path",
",",
"temp_dir",
")",
"# set up run p... | sets up a lsf job array | [
"sets",
"up",
"a",
"lsf",
"job",
"array"
] | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/scripts/run_batch.py#L158-L188 |
jeremymcrae/denovonear | denovonear/load_mutation_rates.py | load_mutation_rates | def load_mutation_rates(path=None):
""" load sequence context-based mutation rates
Args:
path: path to table of sequence context-based mutation rates. If None,
this defaults to per-trinucleotide rates provided by Kaitlin Samocha
(Broad Institute).
Returns:
l... | python | def load_mutation_rates(path=None):
""" load sequence context-based mutation rates
Args:
path: path to table of sequence context-based mutation rates. If None,
this defaults to per-trinucleotide rates provided by Kaitlin Samocha
(Broad Institute).
Returns:
l... | [
"def",
"load_mutation_rates",
"(",
"path",
"=",
"None",
")",
":",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"resource_filename",
"(",
"__name__",
",",
"\"data/rates.txt\"",
")",
"rates",
"=",
"[",
"]",
"with",
"open",
"(",
"path",
")",
"as",
"handle"... | load sequence context-based mutation rates
Args:
path: path to table of sequence context-based mutation rates. If None,
this defaults to per-trinucleotide rates provided by Kaitlin Samocha
(Broad Institute).
Returns:
list of [initial, changed, rate] lists e.g. [... | [
"load",
"sequence",
"context",
"-",
"based",
"mutation",
"rates",
"Args",
":",
"path",
":",
"path",
"to",
"table",
"of",
"sequence",
"context",
"-",
"based",
"mutation",
"rates",
".",
"If",
"None",
"this",
"defaults",
"to",
"per",
"-",
"trinucleotide",
"ra... | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/load_mutation_rates.py#L6-L30 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.authenticated_user | def authenticated_user(self, auth):
"""
Returns the user authenticated by ``auth``
:param auth.Authentication auth: authentication for user to retrieve
:return: user authenticated by the provided authentication
:rtype: GogsUser
:raises NetworkFailure: if there is an err... | python | def authenticated_user(self, auth):
"""
Returns the user authenticated by ``auth``
:param auth.Authentication auth: authentication for user to retrieve
:return: user authenticated by the provided authentication
:rtype: GogsUser
:raises NetworkFailure: if there is an err... | [
"def",
"authenticated_user",
"(",
"self",
",",
"auth",
")",
":",
"response",
"=",
"self",
".",
"get",
"(",
"\"/user\"",
",",
"auth",
"=",
"auth",
")",
"return",
"GogsUser",
".",
"from_json",
"(",
"response",
".",
"json",
"(",
")",
")"
] | Returns the user authenticated by ``auth``
:param auth.Authentication auth: authentication for user to retrieve
:return: user authenticated by the provided authentication
:rtype: GogsUser
:raises NetworkFailure: if there is an error communicating with the server
:raises ApiFail... | [
"Returns",
"the",
"user",
"authenticated",
"by",
"auth"
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L33-L45 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.get_tokens | def get_tokens(self, auth, username=None):
"""
Returns the tokens owned by the specified user. If no user is specified,
uses the user authenticated by ``auth``.
:param auth.Authentication auth: authentication for user to retrieve.
Must be a usern... | python | def get_tokens(self, auth, username=None):
"""
Returns the tokens owned by the specified user. If no user is specified,
uses the user authenticated by ``auth``.
:param auth.Authentication auth: authentication for user to retrieve.
Must be a usern... | [
"def",
"get_tokens",
"(",
"self",
",",
"auth",
",",
"username",
"=",
"None",
")",
":",
"if",
"username",
"is",
"None",
":",
"username",
"=",
"self",
".",
"authenticated_user",
"(",
"auth",
")",
".",
"username",
"response",
"=",
"self",
".",
"get",
"(",... | Returns the tokens owned by the specified user. If no user is specified,
uses the user authenticated by ``auth``.
:param auth.Authentication auth: authentication for user to retrieve.
Must be a username-password authentication,
... | [
"Returns",
"the",
"tokens",
"owned",
"by",
"the",
"specified",
"user",
".",
"If",
"no",
"user",
"is",
"specified",
"uses",
"the",
"user",
"authenticated",
"by",
"auth",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L47-L65 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.create_token | def create_token(self, auth, name, username=None):
"""
Creates a new token with the specified name for the specified user.
If no user is specified, uses user authenticated by ``auth``.
:param auth.Authentication auth: authentication for user to retrieve.
... | python | def create_token(self, auth, name, username=None):
"""
Creates a new token with the specified name for the specified user.
If no user is specified, uses user authenticated by ``auth``.
:param auth.Authentication auth: authentication for user to retrieve.
... | [
"def",
"create_token",
"(",
"self",
",",
"auth",
",",
"name",
",",
"username",
"=",
"None",
")",
":",
"if",
"username",
"is",
"None",
":",
"username",
"=",
"self",
".",
"authenticated_user",
"(",
"auth",
")",
".",
"username",
"data",
"=",
"{",
"\"name\... | Creates a new token with the specified name for the specified user.
If no user is specified, uses user authenticated by ``auth``.
:param auth.Authentication auth: authentication for user to retrieve.
Must be a username-password authentication,
... | [
"Creates",
"a",
"new",
"token",
"with",
"the",
"specified",
"name",
"for",
"the",
"specified",
"user",
".",
"If",
"no",
"user",
"is",
"specified",
"uses",
"user",
"authenticated",
"by",
"auth",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L67-L87 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.ensure_token | def ensure_token(self, auth, name, username=None):
"""
Ensures the existence of a token with the specified name for the
specified user. Creates a new token if none exists. If no user is
specified, uses user authenticated by ``auth``.
:param auth.Authentication auth: authenticati... | python | def ensure_token(self, auth, name, username=None):
"""
Ensures the existence of a token with the specified name for the
specified user. Creates a new token if none exists. If no user is
specified, uses user authenticated by ``auth``.
:param auth.Authentication auth: authenticati... | [
"def",
"ensure_token",
"(",
"self",
",",
"auth",
",",
"name",
",",
"username",
"=",
"None",
")",
":",
"if",
"username",
"is",
"None",
":",
"username",
"=",
"self",
".",
"authenticated_user",
"(",
"auth",
")",
".",
"username",
"tokens",
"=",
"[",
"token... | Ensures the existence of a token with the specified name for the
specified user. Creates a new token if none exists. If no user is
specified, uses user authenticated by ``auth``.
:param auth.Authentication auth: authentication for user to retrieve.
Must ... | [
"Ensures",
"the",
"existence",
"of",
"a",
"token",
"with",
"the",
"specified",
"name",
"for",
"the",
"specified",
"user",
".",
"Creates",
"a",
"new",
"token",
"if",
"none",
"exists",
".",
"If",
"no",
"user",
"is",
"specified",
"uses",
"user",
"authenticate... | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L89-L111 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.create_repo | def create_repo(self, auth, name, description=None, private=False, auto_init=False,
gitignore_templates=None, license_template=None, readme_template=None,
organization=None):
"""
Creates a new repository, and returns the created repository.
:param auth.Au... | python | def create_repo(self, auth, name, description=None, private=False, auto_init=False,
gitignore_templates=None, license_template=None, readme_template=None,
organization=None):
"""
Creates a new repository, and returns the created repository.
:param auth.Au... | [
"def",
"create_repo",
"(",
"self",
",",
"auth",
",",
"name",
",",
"description",
"=",
"None",
",",
"private",
"=",
"False",
",",
"auto_init",
"=",
"False",
",",
"gitignore_templates",
"=",
"None",
",",
"license_template",
"=",
"None",
",",
"readme_template",... | Creates a new repository, and returns the created repository.
:param auth.Authentication auth: authentication object
:param str name: name of the repository to create
:param str description: description of the repository to create
:param bool private: whether the create repository shoul... | [
"Creates",
"a",
"new",
"repository",
"and",
"returns",
"the",
"created",
"repository",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L113-L147 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.repo_exists | def repo_exists(self, auth, username, repo_name):
"""
Returns whether a repository with name ``repo_name`` owned by the user with username ``username`` exists.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:param str ... | python | def repo_exists(self, auth, username, repo_name):
"""
Returns whether a repository with name ``repo_name`` owned by the user with username ``username`` exists.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:param str ... | [
"def",
"repo_exists",
"(",
"self",
",",
"auth",
",",
"username",
",",
"repo_name",
")",
":",
"path",
"=",
"\"/repos/{u}/{r}\"",
".",
"format",
"(",
"u",
"=",
"username",
",",
"r",
"=",
"repo_name",
")",
"return",
"self",
".",
"_get",
"(",
"path",
",",
... | Returns whether a repository with name ``repo_name`` owned by the user with username ``username`` exists.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:param str repo_name: name of repository
:return: whether the repository ... | [
"Returns",
"whether",
"a",
"repository",
"with",
"name",
"repo_name",
"owned",
"by",
"the",
"user",
"with",
"username",
"username",
"exists",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L149-L162 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.get_repo | def get_repo(self, auth, username, repo_name):
"""
Returns a the repository with name ``repo_name`` owned by
the user with username ``username``.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:param str repo_n... | python | def get_repo(self, auth, username, repo_name):
"""
Returns a the repository with name ``repo_name`` owned by
the user with username ``username``.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:param str repo_n... | [
"def",
"get_repo",
"(",
"self",
",",
"auth",
",",
"username",
",",
"repo_name",
")",
":",
"path",
"=",
"\"/repos/{u}/{r}\"",
".",
"format",
"(",
"u",
"=",
"username",
",",
"r",
"=",
"repo_name",
")",
"response",
"=",
"self",
".",
"get",
"(",
"path",
... | Returns a the repository with name ``repo_name`` owned by
the user with username ``username``.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:param str repo_name: name of repository
:return: a representation of the re... | [
"Returns",
"a",
"the",
"repository",
"with",
"name",
"repo_name",
"owned",
"by",
"the",
"user",
"with",
"username",
"username",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L164-L179 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.get_user_repos | def get_user_repos(self, auth, username):
"""
Returns the repositories owned by
the user with username ``username``.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:return: a list of repositories
:rtyp... | python | def get_user_repos(self, auth, username):
"""
Returns the repositories owned by
the user with username ``username``.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:return: a list of repositories
:rtyp... | [
"def",
"get_user_repos",
"(",
"self",
",",
"auth",
",",
"username",
")",
":",
"path",
"=",
"\"/users/{u}/repos\"",
".",
"format",
"(",
"u",
"=",
"username",
")",
"response",
"=",
"self",
".",
"get",
"(",
"path",
",",
"auth",
"=",
"auth",
")",
"return",... | Returns the repositories owned by
the user with username ``username``.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:return: a list of repositories
:rtype: List[GogsRepo]
:raises NetworkFailure: if there is ... | [
"Returns",
"the",
"repositories",
"owned",
"by",
"the",
"user",
"with",
"username",
"username",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L181-L195 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.get_branch | def get_branch(self, auth, username, repo_name, branch_name):
"""
Returns the branch with name ``branch_name`` in the repository with name ``repo_name``
owned by the user with username ``username``.
:param auth.Authentication auth: authentication object
:param str username: use... | python | def get_branch(self, auth, username, repo_name, branch_name):
"""
Returns the branch with name ``branch_name`` in the repository with name ``repo_name``
owned by the user with username ``username``.
:param auth.Authentication auth: authentication object
:param str username: use... | [
"def",
"get_branch",
"(",
"self",
",",
"auth",
",",
"username",
",",
"repo_name",
",",
"branch_name",
")",
":",
"path",
"=",
"\"/repos/{u}/{r}/branches/{b}\"",
".",
"format",
"(",
"u",
"=",
"username",
",",
"r",
"=",
"repo_name",
",",
"b",
"=",
"branch_nam... | Returns the branch with name ``branch_name`` in the repository with name ``repo_name``
owned by the user with username ``username``.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository containing the branch
:param str repo_name: n... | [
"Returns",
"the",
"branch",
"with",
"name",
"branch_name",
"in",
"the",
"repository",
"with",
"name",
"repo_name",
"owned",
"by",
"the",
"user",
"with",
"username",
"username",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L197-L213 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.get_branches | def get_branches(self, auth, username, repo_name):
"""
Returns the branches in the repository with name ``repo_name`` owned by the user
with username ``username``.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository contai... | python | def get_branches(self, auth, username, repo_name):
"""
Returns the branches in the repository with name ``repo_name`` owned by the user
with username ``username``.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository contai... | [
"def",
"get_branches",
"(",
"self",
",",
"auth",
",",
"username",
",",
"repo_name",
")",
":",
"path",
"=",
"\"/repos/{u}/{r}/branches\"",
".",
"format",
"(",
"u",
"=",
"username",
",",
"r",
"=",
"repo_name",
")",
"response",
"=",
"self",
".",
"get",
"(",... | Returns the branches in the repository with name ``repo_name`` owned by the user
with username ``username``.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository containing the branch
:param str repo_name: name of the repository wi... | [
"Returns",
"the",
"branches",
"in",
"the",
"repository",
"with",
"name",
"repo_name",
"owned",
"by",
"the",
"user",
"with",
"username",
"username",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L215-L230 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.delete_repo | def delete_repo(self, auth, username, repo_name):
"""
Deletes the repository with name ``repo_name`` owned by the user with username ``username``.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository to delete
:param str rep... | python | def delete_repo(self, auth, username, repo_name):
"""
Deletes the repository with name ``repo_name`` owned by the user with username ``username``.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository to delete
:param str rep... | [
"def",
"delete_repo",
"(",
"self",
",",
"auth",
",",
"username",
",",
"repo_name",
")",
":",
"path",
"=",
"\"/repos/{u}/{r}\"",
".",
"format",
"(",
"u",
"=",
"username",
",",
"r",
"=",
"repo_name",
")",
"self",
".",
"delete",
"(",
"path",
",",
"auth",
... | Deletes the repository with name ``repo_name`` owned by the user with username ``username``.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository to delete
:param str repo_name: name of repository to delete
:raises NetworkFailure: i... | [
"Deletes",
"the",
"repository",
"with",
"name",
"repo_name",
"owned",
"by",
"the",
"user",
"with",
"username",
"username",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L232-L243 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.migrate_repo | def migrate_repo(self, auth, clone_addr,
uid, repo_name, auth_username=None, auth_password=None,
mirror=False, private=False, description=None):
"""
Migrate a repository from another Git hosting source for the authenticated user.
:param auth.Authenticat... | python | def migrate_repo(self, auth, clone_addr,
uid, repo_name, auth_username=None, auth_password=None,
mirror=False, private=False, description=None):
"""
Migrate a repository from another Git hosting source for the authenticated user.
:param auth.Authenticat... | [
"def",
"migrate_repo",
"(",
"self",
",",
"auth",
",",
"clone_addr",
",",
"uid",
",",
"repo_name",
",",
"auth_username",
"=",
"None",
",",
"auth_password",
"=",
"None",
",",
"mirror",
"=",
"False",
",",
"private",
"=",
"False",
",",
"description",
"=",
"N... | Migrate a repository from another Git hosting source for the authenticated user.
:param auth.Authentication auth: authentication object
:param str clone_addr: Remote Git address (HTTP/HTTPS URL or local path)
:param int uid: user ID of repository owner
:param str repo_name: Repository n... | [
"Migrate",
"a",
"repository",
"from",
"another",
"Git",
"hosting",
"source",
"for",
"the",
"authenticated",
"user",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L245-L277 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.create_user | def create_user(self, auth, login_name, username, email, password, send_notify=False):
"""
Creates a new user, and returns the created user.
:param auth.Authentication auth: authentication object, must be admin-level
:param str login_name: login name for created user
:param str ... | python | def create_user(self, auth, login_name, username, email, password, send_notify=False):
"""
Creates a new user, and returns the created user.
:param auth.Authentication auth: authentication object, must be admin-level
:param str login_name: login name for created user
:param str ... | [
"def",
"create_user",
"(",
"self",
",",
"auth",
",",
"login_name",
",",
"username",
",",
"email",
",",
"password",
",",
"send_notify",
"=",
"False",
")",
":",
"# Since the source_id parameter was not well-documented at the time this method was",
"# written, force the defaul... | Creates a new user, and returns the created user.
:param auth.Authentication auth: authentication object, must be admin-level
:param str login_name: login name for created user
:param str username: username for created user
:param str email: email address for created user
:param... | [
"Creates",
"a",
"new",
"user",
"and",
"returns",
"the",
"created",
"user",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L279-L304 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.user_exists | def user_exists(self, username):
"""
Returns whether a user with username ``username`` exists.
:param str username: username of user
:return: whether a user with the specified username exists
:rtype: bool
:raises NetworkFailure: if there is an error communicating with th... | python | def user_exists(self, username):
"""
Returns whether a user with username ``username`` exists.
:param str username: username of user
:return: whether a user with the specified username exists
:rtype: bool
:raises NetworkFailure: if there is an error communicating with th... | [
"def",
"user_exists",
"(",
"self",
",",
"username",
")",
":",
"path",
"=",
"\"/users/{}\"",
".",
"format",
"(",
"username",
")",
"return",
"self",
".",
"_get",
"(",
"path",
")",
".",
"ok"
] | Returns whether a user with username ``username`` exists.
:param str username: username of user
:return: whether a user with the specified username exists
:rtype: bool
:raises NetworkFailure: if there is an error communicating with the server
:return: | [
"Returns",
"whether",
"a",
"user",
"with",
"username",
"username",
"exists",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L306-L317 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.search_users | def search_users(self, username_keyword, limit=10):
"""
Searches for users whose username matches ``username_keyword``, and returns
a list of matched users.
:param str username_keyword: keyword to search with
:param int limit: maximum number of returned users
:return: a ... | python | def search_users(self, username_keyword, limit=10):
"""
Searches for users whose username matches ``username_keyword``, and returns
a list of matched users.
:param str username_keyword: keyword to search with
:param int limit: maximum number of returned users
:return: a ... | [
"def",
"search_users",
"(",
"self",
",",
"username_keyword",
",",
"limit",
"=",
"10",
")",
":",
"params",
"=",
"{",
"\"q\"",
":",
"username_keyword",
",",
"\"limit\"",
":",
"limit",
"}",
"response",
"=",
"self",
".",
"get",
"(",
"\"/users/search\"",
",",
... | Searches for users whose username matches ``username_keyword``, and returns
a list of matched users.
:param str username_keyword: keyword to search with
:param int limit: maximum number of returned users
:return: a list of matched users
:rtype: List[GogsUser]
:raises Net... | [
"Searches",
"for",
"users",
"whose",
"username",
"matches",
"username_keyword",
"and",
"returns",
"a",
"list",
"of",
"matched",
"users",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L319-L333 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.get_user | def get_user(self, auth, username):
"""
Returns a representing the user with username ``username``.
:param auth.Authentication auth: authentication object, can be ``None``
:param str username: username of user to get
:return: the retrieved user
:rtype: GogsUser
:... | python | def get_user(self, auth, username):
"""
Returns a representing the user with username ``username``.
:param auth.Authentication auth: authentication object, can be ``None``
:param str username: username of user to get
:return: the retrieved user
:rtype: GogsUser
:... | [
"def",
"get_user",
"(",
"self",
",",
"auth",
",",
"username",
")",
":",
"path",
"=",
"\"/users/{}\"",
".",
"format",
"(",
"username",
")",
"response",
"=",
"self",
".",
"get",
"(",
"path",
",",
"auth",
"=",
"auth",
")",
"return",
"GogsUser",
".",
"fr... | Returns a representing the user with username ``username``.
:param auth.Authentication auth: authentication object, can be ``None``
:param str username: username of user to get
:return: the retrieved user
:rtype: GogsUser
:raises NetworkFailure: if there is an error communicatin... | [
"Returns",
"a",
"representing",
"the",
"user",
"with",
"username",
"username",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L335-L348 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.update_user | def update_user(self, auth, username, update):
"""
Updates the user with username ``username`` according to ``update``.
:param auth.Authentication auth: authentication object, must be admin-level
:param str username: username of user to update
:param GogsUserUpdate update: a ``G... | python | def update_user(self, auth, username, update):
"""
Updates the user with username ``username`` according to ``update``.
:param auth.Authentication auth: authentication object, must be admin-level
:param str username: username of user to update
:param GogsUserUpdate update: a ``G... | [
"def",
"update_user",
"(",
"self",
",",
"auth",
",",
"username",
",",
"update",
")",
":",
"path",
"=",
"\"/admin/users/{}\"",
".",
"format",
"(",
"username",
")",
"response",
"=",
"self",
".",
"patch",
"(",
"path",
",",
"auth",
"=",
"auth",
",",
"data"... | Updates the user with username ``username`` according to ``update``.
:param auth.Authentication auth: authentication object, must be admin-level
:param str username: username of user to update
:param GogsUserUpdate update: a ``GogsUserUpdate`` object describing the requested update
:ret... | [
"Updates",
"the",
"user",
"with",
"username",
"username",
"according",
"to",
"update",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L350-L364 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.delete_user | def delete_user(self, auth, username):
"""
Deletes the user with username ``username``. Should only be called if the
to-be-deleted user has no repositories.
:param auth.Authentication auth: authentication object, must be admin-level
:param str username: username of user to delet... | python | def delete_user(self, auth, username):
"""
Deletes the user with username ``username``. Should only be called if the
to-be-deleted user has no repositories.
:param auth.Authentication auth: authentication object, must be admin-level
:param str username: username of user to delet... | [
"def",
"delete_user",
"(",
"self",
",",
"auth",
",",
"username",
")",
":",
"path",
"=",
"\"/admin/users/{}\"",
".",
"format",
"(",
"username",
")",
"self",
".",
"delete",
"(",
"path",
",",
"auth",
"=",
"auth",
")"
] | Deletes the user with username ``username``. Should only be called if the
to-be-deleted user has no repositories.
:param auth.Authentication auth: authentication object, must be admin-level
:param str username: username of user to delete | [
"Deletes",
"the",
"user",
"with",
"username",
"username",
".",
"Should",
"only",
"be",
"called",
"if",
"the",
"to",
"-",
"be",
"-",
"deleted",
"user",
"has",
"no",
"repositories",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L366-L375 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.