id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
53,400 | joowani/quadriga | quadriga/client.py | QuadrigaClient.get_deposit_address | def get_deposit_address(self, currency):
"""Return the deposit address for the given major currency.
:param currency: Major currency name in lowercase (e.g. "btc", "eth").
:type currency: str | unicode
:return: Deposit address.
:rtype: str | unicode
"""
self._val... | python | def get_deposit_address(self, currency):
"""Return the deposit address for the given major currency.
:param currency: Major currency name in lowercase (e.g. "btc", "eth").
:type currency: str | unicode
:return: Deposit address.
:rtype: str | unicode
"""
self._val... | [
"def",
"get_deposit_address",
"(",
"self",
",",
"currency",
")",
":",
"self",
".",
"_validate_currency",
"(",
"currency",
")",
"self",
".",
"_log",
"(",
"'get deposit address for {}'",
".",
"format",
"(",
"currency",
")",
")",
"coin_name",
"=",
"self",
".",
... | Return the deposit address for the given major currency.
:param currency: Major currency name in lowercase (e.g. "btc", "eth").
:type currency: str | unicode
:return: Deposit address.
:rtype: str | unicode | [
"Return",
"the",
"deposit",
"address",
"for",
"the",
"given",
"major",
"currency",
"."
] | 412f88f414ef0cb53efa6d5841b9674eb9718359 | https://github.com/joowani/quadriga/blob/412f88f414ef0cb53efa6d5841b9674eb9718359/quadriga/client.py#L191-L204 |
53,401 | joowani/quadriga | quadriga/client.py | QuadrigaClient.withdraw | def withdraw(self, currency, amount, address):
"""Withdraw a major currency from QuadrigaCX to the given wallet.
:param currency: Major currency name in lowercase (e.g. "btc", "eth").
:type currency: str | unicode
:param amount: Withdrawal amount.
:type amount: int | float | str... | python | def withdraw(self, currency, amount, address):
"""Withdraw a major currency from QuadrigaCX to the given wallet.
:param currency: Major currency name in lowercase (e.g. "btc", "eth").
:type currency: str | unicode
:param amount: Withdrawal amount.
:type amount: int | float | str... | [
"def",
"withdraw",
"(",
"self",
",",
"currency",
",",
"amount",
",",
"address",
")",
":",
"self",
".",
"_validate_currency",
"(",
"currency",
")",
"self",
".",
"_log",
"(",
"'withdraw {} {} to {}'",
".",
"format",
"(",
"amount",
",",
"currency",
",",
"addr... | Withdraw a major currency from QuadrigaCX to the given wallet.
:param currency: Major currency name in lowercase (e.g. "btc", "eth").
:type currency: str | unicode
:param amount: Withdrawal amount.
:type amount: int | float | str | unicode | decimal.Decimal
:param address: Walle... | [
"Withdraw",
"a",
"major",
"currency",
"from",
"QuadrigaCX",
"to",
"the",
"given",
"wallet",
"."
] | 412f88f414ef0cb53efa6d5841b9674eb9718359 | https://github.com/joowani/quadriga/blob/412f88f414ef0cb53efa6d5841b9674eb9718359/quadriga/client.py#L206-L226 |
53,402 | eleme/ruskit | ruskit/cluster.py | Cluster.add_nodes | def add_nodes(self, nodes):
'''The format of node is similar to add_node.
If node contains a key 'cluster_node'
whose value is an instance of ClusterNode,
it will be used directly.
'''
new_nodes, master_map = self._add_nodes_as_master(nodes)
for n in new_nodes:
... | python | def add_nodes(self, nodes):
'''The format of node is similar to add_node.
If node contains a key 'cluster_node'
whose value is an instance of ClusterNode,
it will be used directly.
'''
new_nodes, master_map = self._add_nodes_as_master(nodes)
for n in new_nodes:
... | [
"def",
"add_nodes",
"(",
"self",
",",
"nodes",
")",
":",
"new_nodes",
",",
"master_map",
"=",
"self",
".",
"_add_nodes_as_master",
"(",
"nodes",
")",
"for",
"n",
"in",
"new_nodes",
":",
"if",
"n",
".",
"name",
"not",
"in",
"master_map",
":",
"continue",
... | The format of node is similar to add_node.
If node contains a key 'cluster_node'
whose value is an instance of ClusterNode,
it will be used directly. | [
"The",
"format",
"of",
"node",
"is",
"similar",
"to",
"add_node",
".",
"If",
"node",
"contains",
"a",
"key",
"cluster_node",
"whose",
"value",
"is",
"an",
"instance",
"of",
"ClusterNode",
"it",
"will",
"be",
"used",
"directly",
"."
] | 2e8c5a3f6a65b8aeb07012b4e2c8ba324d887c3b | https://github.com/eleme/ruskit/blob/2e8c5a3f6a65b8aeb07012b4e2c8ba324d887c3b/ruskit/cluster.py#L393-L410 |
53,403 | eleme/ruskit | ruskit/cluster.py | Cluster.add_slaves | def add_slaves(self, new_slaves, fast_mode=False):
'''This is almost the same with `add_nodes`. The difference is that
it will add slaves in two slower way.
This is mainly used to avoid huge overhead caused by full sync
when large amount of slaves are added to cluster.
If fast_mo... | python | def add_slaves(self, new_slaves, fast_mode=False):
'''This is almost the same with `add_nodes`. The difference is that
it will add slaves in two slower way.
This is mainly used to avoid huge overhead caused by full sync
when large amount of slaves are added to cluster.
If fast_mo... | [
"def",
"add_slaves",
"(",
"self",
",",
"new_slaves",
",",
"fast_mode",
"=",
"False",
")",
":",
"new_nodes",
",",
"master_map",
"=",
"self",
".",
"_prepare_for_adding",
"(",
"new_slaves",
")",
"slaves",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"s",
"in"... | This is almost the same with `add_nodes`. The difference is that
it will add slaves in two slower way.
This is mainly used to avoid huge overhead caused by full sync
when large amount of slaves are added to cluster.
If fast_mode is False, there is only one master node doing
repli... | [
"This",
"is",
"almost",
"the",
"same",
"with",
"add_nodes",
".",
"The",
"difference",
"is",
"that",
"it",
"will",
"add",
"slaves",
"in",
"two",
"slower",
"way",
".",
"This",
"is",
"mainly",
"used",
"to",
"avoid",
"huge",
"overhead",
"caused",
"by",
"full... | 2e8c5a3f6a65b8aeb07012b4e2c8ba324d887c3b | https://github.com/eleme/ruskit/blob/2e8c5a3f6a65b8aeb07012b4e2c8ba324d887c3b/ruskit/cluster.py#L412-L466 |
53,404 | eleme/ruskit | ruskit/cluster.py | Cluster.add_node | def add_node(self, node):
"""Add a node to cluster.
:param node: should be formated like this
`{"addr": "", "role": "slave", "master": "master_node_id"}
"""
new = ClusterNode.from_uri(node["addr"])
cluster_member = self.nodes[0]
check_new_nodes([new], [cluster_me... | python | def add_node(self, node):
"""Add a node to cluster.
:param node: should be formated like this
`{"addr": "", "role": "slave", "master": "master_node_id"}
"""
new = ClusterNode.from_uri(node["addr"])
cluster_member = self.nodes[0]
check_new_nodes([new], [cluster_me... | [
"def",
"add_node",
"(",
"self",
",",
"node",
")",
":",
"new",
"=",
"ClusterNode",
".",
"from_uri",
"(",
"node",
"[",
"\"addr\"",
"]",
")",
"cluster_member",
"=",
"self",
".",
"nodes",
"[",
"0",
"]",
"check_new_nodes",
"(",
"[",
"new",
"]",
",",
"[",
... | Add a node to cluster.
:param node: should be formated like this
`{"addr": "", "role": "slave", "master": "master_node_id"} | [
"Add",
"a",
"node",
"to",
"cluster",
"."
] | 2e8c5a3f6a65b8aeb07012b4e2c8ba324d887c3b | https://github.com/eleme/ruskit/blob/2e8c5a3f6a65b8aeb07012b4e2c8ba324d887c3b/ruskit/cluster.py#L509-L537 |
53,405 | keleshev/mini | mini.py | Mini.ifelse | def ifelse(self, node):
'ifelse = "if" expr "then" expr "else" expr'
_, cond, _, cons, _, alt = node
return self.eval(cons) if self.eval(cond) else self.eval(alt) | python | def ifelse(self, node):
'ifelse = "if" expr "then" expr "else" expr'
_, cond, _, cons, _, alt = node
return self.eval(cons) if self.eval(cond) else self.eval(alt) | [
"def",
"ifelse",
"(",
"self",
",",
"node",
")",
":",
"_",
",",
"cond",
",",
"_",
",",
"cons",
",",
"_",
",",
"alt",
"=",
"node",
"return",
"self",
".",
"eval",
"(",
"cons",
")",
"if",
"self",
".",
"eval",
"(",
"cond",
")",
"else",
"self",
"."... | ifelse = "if" expr "then" expr "else" expr | [
"ifelse",
"=",
"if",
"expr",
"then",
"expr",
"else",
"expr"
] | da7893a1ee72aca315d6921f25604316462ec019 | https://github.com/keleshev/mini/blob/da7893a1ee72aca315d6921f25604316462ec019/mini.py#L45-L48 |
53,406 | keleshev/mini | mini.py | Mini.assignment | def assignment(self, node, children):
'assignment = lvalue "=" expr'
lvalue, _, expr = children
self.env[lvalue] = expr
return expr | python | def assignment(self, node, children):
'assignment = lvalue "=" expr'
lvalue, _, expr = children
self.env[lvalue] = expr
return expr | [
"def",
"assignment",
"(",
"self",
",",
"node",
",",
"children",
")",
":",
"lvalue",
",",
"_",
",",
"expr",
"=",
"children",
"self",
".",
"env",
"[",
"lvalue",
"]",
"=",
"expr",
"return",
"expr"
] | assignment = lvalue "=" expr | [
"assignment",
"=",
"lvalue",
"=",
"expr"
] | da7893a1ee72aca315d6921f25604316462ec019 | https://github.com/keleshev/mini/blob/da7893a1ee72aca315d6921f25604316462ec019/mini.py#L69-L73 |
53,407 | inveniosoftware/invenio-i18n | invenio_i18n/babel.py | set_locale | def set_locale(ln):
"""Set Babel localization in request context.
:param ln: Language identifier.
"""
ctx = _request_ctx_stack.top
if ctx is None:
raise RuntimeError('Working outside of request context.')
new_locale = current_app.extensions['babel'].load_locale(ln)
old_locale = geta... | python | def set_locale(ln):
"""Set Babel localization in request context.
:param ln: Language identifier.
"""
ctx = _request_ctx_stack.top
if ctx is None:
raise RuntimeError('Working outside of request context.')
new_locale = current_app.extensions['babel'].load_locale(ln)
old_locale = geta... | [
"def",
"set_locale",
"(",
"ln",
")",
":",
"ctx",
"=",
"_request_ctx_stack",
".",
"top",
"if",
"ctx",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"'Working outside of request context.'",
")",
"new_locale",
"=",
"current_app",
".",
"extensions",
"[",
"'babel'... | Set Babel localization in request context.
:param ln: Language identifier. | [
"Set",
"Babel",
"localization",
"in",
"request",
"context",
"."
] | 3119bb7db3369b8ae0aecce5d7d7c79f807e2763 | https://github.com/inveniosoftware/invenio-i18n/blob/3119bb7db3369b8ae0aecce5d7d7c79f807e2763/invenio_i18n/babel.py#L23-L35 |
53,408 | inveniosoftware/invenio-i18n | invenio_i18n/babel.py | MultidirDomain.add_entrypoint | def add_entrypoint(self, entry_point_group):
"""Load translations from an entry point."""
for ep in iter_entry_points(group=entry_point_group):
if not resource_isdir(ep.module_name, 'translations'):
continue
dirname = resource_filename(ep.module_name, 'translation... | python | def add_entrypoint(self, entry_point_group):
"""Load translations from an entry point."""
for ep in iter_entry_points(group=entry_point_group):
if not resource_isdir(ep.module_name, 'translations'):
continue
dirname = resource_filename(ep.module_name, 'translation... | [
"def",
"add_entrypoint",
"(",
"self",
",",
"entry_point_group",
")",
":",
"for",
"ep",
"in",
"iter_entry_points",
"(",
"group",
"=",
"entry_point_group",
")",
":",
"if",
"not",
"resource_isdir",
"(",
"ep",
".",
"module_name",
",",
"'translations'",
")",
":",
... | Load translations from an entry point. | [
"Load",
"translations",
"from",
"an",
"entry",
"point",
"."
] | 3119bb7db3369b8ae0aecce5d7d7c79f807e2763 | https://github.com/inveniosoftware/invenio-i18n/blob/3119bb7db3369b8ae0aecce5d7d7c79f807e2763/invenio_i18n/babel.py#L67-L73 |
53,409 | inveniosoftware/invenio-i18n | invenio_i18n/babel.py | MultidirDomain.add_path | def add_path(self, path):
"""Load translations from an existing path."""
if not os.path.exists(path):
raise RuntimeError('Path does not exists: %s.' % path)
self.paths.append(path) | python | def add_path(self, path):
"""Load translations from an existing path."""
if not os.path.exists(path):
raise RuntimeError('Path does not exists: %s.' % path)
self.paths.append(path) | [
"def",
"add_path",
"(",
"self",
",",
"path",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"raise",
"RuntimeError",
"(",
"'Path does not exists: %s.'",
"%",
"path",
")",
"self",
".",
"paths",
".",
"append",
"(",
"path"... | Load translations from an existing path. | [
"Load",
"translations",
"from",
"an",
"existing",
"path",
"."
] | 3119bb7db3369b8ae0aecce5d7d7c79f807e2763 | https://github.com/inveniosoftware/invenio-i18n/blob/3119bb7db3369b8ae0aecce5d7d7c79f807e2763/invenio_i18n/babel.py#L75-L79 |
53,410 | inveniosoftware/invenio-i18n | invenio_i18n/babel.py | MultidirDomain._get_translation_for_locale | def _get_translation_for_locale(self, locale):
"""Get translation for a specific locale."""
translations = None
for dirname in self.paths:
# Load a single catalog.
catalog = Translations.load(dirname, [locale], domain=self.domain)
if translations is None:
... | python | def _get_translation_for_locale(self, locale):
"""Get translation for a specific locale."""
translations = None
for dirname in self.paths:
# Load a single catalog.
catalog = Translations.load(dirname, [locale], domain=self.domain)
if translations is None:
... | [
"def",
"_get_translation_for_locale",
"(",
"self",
",",
"locale",
")",
":",
"translations",
"=",
"None",
"for",
"dirname",
"in",
"self",
".",
"paths",
":",
"# Load a single catalog.",
"catalog",
"=",
"Translations",
".",
"load",
"(",
"dirname",
",",
"[",
"loca... | Get translation for a specific locale. | [
"Get",
"translation",
"for",
"a",
"specific",
"locale",
"."
] | 3119bb7db3369b8ae0aecce5d7d7c79f807e2763 | https://github.com/inveniosoftware/invenio-i18n/blob/3119bb7db3369b8ae0aecce5d7d7c79f807e2763/invenio_i18n/babel.py#L81-L105 |
53,411 | inveniosoftware/invenio-i18n | invenio_i18n/babel.py | MultidirDomain.get_translations | def get_translations(self):
"""Return the correct gettext translations for a request.
This will never fail and return a dummy translation object if used
outside of the request or if a translation cannot be found.
"""
ctx = _request_ctx_stack.top
if ctx is None:
... | python | def get_translations(self):
"""Return the correct gettext translations for a request.
This will never fail and return a dummy translation object if used
outside of the request or if a translation cannot be found.
"""
ctx = _request_ctx_stack.top
if ctx is None:
... | [
"def",
"get_translations",
"(",
"self",
")",
":",
"ctx",
"=",
"_request_ctx_stack",
".",
"top",
"if",
"ctx",
"is",
"None",
":",
"return",
"NullTranslations",
"(",
")",
"locale",
"=",
"get_locale",
"(",
")",
"cache",
"=",
"self",
".",
"get_translations_cache"... | Return the correct gettext translations for a request.
This will never fail and return a dummy translation object if used
outside of the request or if a translation cannot be found. | [
"Return",
"the",
"correct",
"gettext",
"translations",
"for",
"a",
"request",
"."
] | 3119bb7db3369b8ae0aecce5d7d7c79f807e2763 | https://github.com/inveniosoftware/invenio-i18n/blob/3119bb7db3369b8ae0aecce5d7d7c79f807e2763/invenio_i18n/babel.py#L107-L127 |
53,412 | inveniosoftware/invenio-i18n | invenio_i18n/ext.py | get_lazystring_encoder | def get_lazystring_encoder(app):
"""Return a JSONEncoder for handling lazy strings from Babel.
Installed on Flask application by default by :class:`InvenioI18N`.
"""
from speaklater import _LazyString
class JSONEncoder(app.json_encoder):
def default(self, o):
if isinstance(o, ... | python | def get_lazystring_encoder(app):
"""Return a JSONEncoder for handling lazy strings from Babel.
Installed on Flask application by default by :class:`InvenioI18N`.
"""
from speaklater import _LazyString
class JSONEncoder(app.json_encoder):
def default(self, o):
if isinstance(o, ... | [
"def",
"get_lazystring_encoder",
"(",
"app",
")",
":",
"from",
"speaklater",
"import",
"_LazyString",
"class",
"JSONEncoder",
"(",
"app",
".",
"json_encoder",
")",
":",
"def",
"default",
"(",
"self",
",",
"o",
")",
":",
"if",
"isinstance",
"(",
"o",
",",
... | Return a JSONEncoder for handling lazy strings from Babel.
Installed on Flask application by default by :class:`InvenioI18N`. | [
"Return",
"a",
"JSONEncoder",
"for",
"handling",
"lazy",
"strings",
"from",
"Babel",
"."
] | 3119bb7db3369b8ae0aecce5d7d7c79f807e2763 | https://github.com/inveniosoftware/invenio-i18n/blob/3119bb7db3369b8ae0aecce5d7d7c79f807e2763/invenio_i18n/ext.py#L32-L46 |
53,413 | inveniosoftware/invenio-i18n | invenio_i18n/ext.py | InvenioI18N.iter_languages | def iter_languages(self):
"""Iterate over list of languages."""
default_lang = self.babel.default_locale.language
default_title = self.babel.default_locale.get_display_name(
default_lang)
yield (default_lang, default_title)
for l, title in current_app.config.get('I1... | python | def iter_languages(self):
"""Iterate over list of languages."""
default_lang = self.babel.default_locale.language
default_title = self.babel.default_locale.get_display_name(
default_lang)
yield (default_lang, default_title)
for l, title in current_app.config.get('I1... | [
"def",
"iter_languages",
"(",
"self",
")",
":",
"default_lang",
"=",
"self",
".",
"babel",
".",
"default_locale",
".",
"language",
"default_title",
"=",
"self",
".",
"babel",
".",
"default_locale",
".",
"get_display_name",
"(",
"default_lang",
")",
"yield",
"(... | Iterate over list of languages. | [
"Iterate",
"over",
"list",
"of",
"languages",
"."
] | 3119bb7db3369b8ae0aecce5d7d7c79f807e2763 | https://github.com/inveniosoftware/invenio-i18n/blob/3119bb7db3369b8ae0aecce5d7d7c79f807e2763/invenio_i18n/ext.py#L140-L149 |
53,414 | inveniosoftware/invenio-i18n | invenio_i18n/ext.py | InvenioI18N.get_languages | def get_languages(self):
"""Get list of languages."""
if self._languages_cache is None:
self._languages_cache = list(self.iter_languages())
return self._languages_cache | python | def get_languages(self):
"""Get list of languages."""
if self._languages_cache is None:
self._languages_cache = list(self.iter_languages())
return self._languages_cache | [
"def",
"get_languages",
"(",
"self",
")",
":",
"if",
"self",
".",
"_languages_cache",
"is",
"None",
":",
"self",
".",
"_languages_cache",
"=",
"list",
"(",
"self",
".",
"iter_languages",
"(",
")",
")",
"return",
"self",
".",
"_languages_cache"
] | Get list of languages. | [
"Get",
"list",
"of",
"languages",
"."
] | 3119bb7db3369b8ae0aecce5d7d7c79f807e2763 | https://github.com/inveniosoftware/invenio-i18n/blob/3119bb7db3369b8ae0aecce5d7d7c79f807e2763/invenio_i18n/ext.py#L151-L155 |
53,415 | inveniosoftware/invenio-i18n | invenio_i18n/ext.py | InvenioI18N.get_locales | def get_locales(self):
"""Get a list of supported locales.
Computes the list using ``I18N_LANGUAGES`` configuration variable.
"""
if self._locales_cache is None:
langs = [self.babel.default_locale]
for l, dummy_title in current_app.config.get('I18N_LANGUAGES', []... | python | def get_locales(self):
"""Get a list of supported locales.
Computes the list using ``I18N_LANGUAGES`` configuration variable.
"""
if self._locales_cache is None:
langs = [self.babel.default_locale]
for l, dummy_title in current_app.config.get('I18N_LANGUAGES', []... | [
"def",
"get_locales",
"(",
"self",
")",
":",
"if",
"self",
".",
"_locales_cache",
"is",
"None",
":",
"langs",
"=",
"[",
"self",
".",
"babel",
".",
"default_locale",
"]",
"for",
"l",
",",
"dummy_title",
"in",
"current_app",
".",
"config",
".",
"get",
"(... | Get a list of supported locales.
Computes the list using ``I18N_LANGUAGES`` configuration variable. | [
"Get",
"a",
"list",
"of",
"supported",
"locales",
"."
] | 3119bb7db3369b8ae0aecce5d7d7c79f807e2763 | https://github.com/inveniosoftware/invenio-i18n/blob/3119bb7db3369b8ae0aecce5d7d7c79f807e2763/invenio_i18n/ext.py#L157-L167 |
53,416 | eleme/ruskit | ruskit/distribute.py | MaxFlowSolver.from_nodes | def from_nodes(cls, nodes, new_nodes, max_slaves_limit=None):
'''When this is used only for peeking reuslt
`new_nodes` can be any type with `host` and `port` attributes
'''
param = gen_distribution(nodes, new_nodes)
param['max_slaves_limit'] = max_slaves_limit
return c... | python | def from_nodes(cls, nodes, new_nodes, max_slaves_limit=None):
'''When this is used only for peeking reuslt
`new_nodes` can be any type with `host` and `port` attributes
'''
param = gen_distribution(nodes, new_nodes)
param['max_slaves_limit'] = max_slaves_limit
return c... | [
"def",
"from_nodes",
"(",
"cls",
",",
"nodes",
",",
"new_nodes",
",",
"max_slaves_limit",
"=",
"None",
")",
":",
"param",
"=",
"gen_distribution",
"(",
"nodes",
",",
"new_nodes",
")",
"param",
"[",
"'max_slaves_limit'",
"]",
"=",
"max_slaves_limit",
"return",
... | When this is used only for peeking reuslt
`new_nodes` can be any type with `host` and `port` attributes | [
"When",
"this",
"is",
"used",
"only",
"for",
"peeking",
"reuslt",
"new_nodes",
"can",
"be",
"any",
"type",
"with",
"host",
"and",
"port",
"attributes"
] | 2e8c5a3f6a65b8aeb07012b4e2c8ba324d887c3b | https://github.com/eleme/ruskit/blob/2e8c5a3f6a65b8aeb07012b4e2c8ba324d887c3b/ruskit/distribute.py#L83-L89 |
53,417 | metavee/batchproc | batchproc/core.py | BatchProcessor._gen_tasks | def _gen_tasks(self):
"""generate doit tasks for each file"""
for filename in self.args:
path = os.path.abspath(filename)
yield {
'name': path,
# 'file_dep': [path],
'actions': [(self.fun, (filename,))],
} | python | def _gen_tasks(self):
"""generate doit tasks for each file"""
for filename in self.args:
path = os.path.abspath(filename)
yield {
'name': path,
# 'file_dep': [path],
'actions': [(self.fun, (filename,))],
} | [
"def",
"_gen_tasks",
"(",
"self",
")",
":",
"for",
"filename",
"in",
"self",
".",
"args",
":",
"path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"filename",
")",
"yield",
"{",
"'name'",
":",
"path",
",",
"# 'file_dep': [path],",
"'actions'",
":",
"[... | generate doit tasks for each file | [
"generate",
"doit",
"tasks",
"for",
"each",
"file"
] | aa084a2ac8ab7950f7a7d3adb54b0cf010c6a935 | https://github.com/metavee/batchproc/blob/aa084a2ac8ab7950f7a7d3adb54b0cf010c6a935/batchproc/core.py#L56-L64 |
53,418 | metavee/batchproc | batchproc/core.py | BatchProcessor.start | def start(self):
"""Begin executing tasks."""
if self.log_filename:
print('Output will be logged to `%s`.' % self.log_filename)
start_time = time.strftime(self.timestamp_fmt)
print('Started %s' % start_time)
if self.log_filename:
orig_stdout = sys.stdou... | python | def start(self):
"""Begin executing tasks."""
if self.log_filename:
print('Output will be logged to `%s`.' % self.log_filename)
start_time = time.strftime(self.timestamp_fmt)
print('Started %s' % start_time)
if self.log_filename:
orig_stdout = sys.stdou... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"self",
".",
"log_filename",
":",
"print",
"(",
"'Output will be logged to `%s`.'",
"%",
"self",
".",
"log_filename",
")",
"start_time",
"=",
"time",
".",
"strftime",
"(",
"self",
".",
"timestamp_fmt",
")",
"print... | Begin executing tasks. | [
"Begin",
"executing",
"tasks",
"."
] | aa084a2ac8ab7950f7a7d3adb54b0cf010c6a935 | https://github.com/metavee/batchproc/blob/aa084a2ac8ab7950f7a7d3adb54b0cf010c6a935/batchproc/core.py#L66-L97 |
53,419 | wglass/zoonado | zoonado/iterables.py | drain | def drain(iterable):
"""
Helper method that empties an iterable as it is iterated over.
Works for:
* ``dict``
* ``collections.deque``
* ``list``
* ``set``
"""
if getattr(iterable, "popleft", False):
def next_item(coll):
return coll.popleft()
elif getattr(ite... | python | def drain(iterable):
"""
Helper method that empties an iterable as it is iterated over.
Works for:
* ``dict``
* ``collections.deque``
* ``list``
* ``set``
"""
if getattr(iterable, "popleft", False):
def next_item(coll):
return coll.popleft()
elif getattr(ite... | [
"def",
"drain",
"(",
"iterable",
")",
":",
"if",
"getattr",
"(",
"iterable",
",",
"\"popleft\"",
",",
"False",
")",
":",
"def",
"next_item",
"(",
"coll",
")",
":",
"return",
"coll",
".",
"popleft",
"(",
")",
"elif",
"getattr",
"(",
"iterable",
",",
"... | Helper method that empties an iterable as it is iterated over.
Works for:
* ``dict``
* ``collections.deque``
* ``list``
* ``set`` | [
"Helper",
"method",
"that",
"empties",
"an",
"iterable",
"as",
"it",
"is",
"iterated",
"over",
"."
] | 8f143b3dd26be88131356f731e7ca51809bc69cb | https://github.com/wglass/zoonado/blob/8f143b3dd26be88131356f731e7ca51809bc69cb/zoonado/iterables.py#L4-L29 |
53,420 | eleme/ruskit | ruskit/utils.py | divide | def divide(n, m):
"""Divide integer n to m chunks
"""
avg = int(n / m)
remain = n - m * avg
data = list(itertools.repeat(avg, m))
for i in range(len(data)):
if not remain:
break
data[i] += 1
remain -= 1
return data | python | def divide(n, m):
"""Divide integer n to m chunks
"""
avg = int(n / m)
remain = n - m * avg
data = list(itertools.repeat(avg, m))
for i in range(len(data)):
if not remain:
break
data[i] += 1
remain -= 1
return data | [
"def",
"divide",
"(",
"n",
",",
"m",
")",
":",
"avg",
"=",
"int",
"(",
"n",
"/",
"m",
")",
"remain",
"=",
"n",
"-",
"m",
"*",
"avg",
"data",
"=",
"list",
"(",
"itertools",
".",
"repeat",
"(",
"avg",
",",
"m",
")",
")",
"for",
"i",
"in",
"... | Divide integer n to m chunks | [
"Divide",
"integer",
"n",
"to",
"m",
"chunks"
] | 2e8c5a3f6a65b8aeb07012b4e2c8ba324d887c3b | https://github.com/eleme/ruskit/blob/2e8c5a3f6a65b8aeb07012b4e2c8ba324d887c3b/ruskit/utils.py#L43-L54 |
53,421 | eleme/ruskit | ruskit/utils.py | spread | def spread(nodes, n):
"""Distrubute master instances in different nodes
{
"192.168.0.1": [node1, node2],
"192.168.0.2": [node3, node4],
"192.168.0.3": [node5, node6]
} => [node1, node3, node5]
"""
target = []
while len(target) < n and nodes:
for ip, node_group i... | python | def spread(nodes, n):
"""Distrubute master instances in different nodes
{
"192.168.0.1": [node1, node2],
"192.168.0.2": [node3, node4],
"192.168.0.3": [node5, node6]
} => [node1, node3, node5]
"""
target = []
while len(target) < n and nodes:
for ip, node_group i... | [
"def",
"spread",
"(",
"nodes",
",",
"n",
")",
":",
"target",
"=",
"[",
"]",
"while",
"len",
"(",
"target",
")",
"<",
"n",
"and",
"nodes",
":",
"for",
"ip",
",",
"node_group",
"in",
"list",
"(",
"nodes",
".",
"items",
"(",
")",
")",
":",
"if",
... | Distrubute master instances in different nodes
{
"192.168.0.1": [node1, node2],
"192.168.0.2": [node3, node4],
"192.168.0.3": [node5, node6]
} => [node1, node3, node5] | [
"Distrubute",
"master",
"instances",
"in",
"different",
"nodes"
] | 2e8c5a3f6a65b8aeb07012b4e2c8ba324d887c3b | https://github.com/eleme/ruskit/blob/2e8c5a3f6a65b8aeb07012b4e2c8ba324d887c3b/ruskit/utils.py#L57-L76 |
53,422 | inveniosoftware/invenio-i18n | invenio_i18n/views.py | is_local_url | def is_local_url(target):
"""Determine if URL is safe to redirect to."""
ref_url = urlparse(request.host_url)
test_url = urlparse(urljoin(request.host_url, target))
return test_url.scheme in ('http', 'https') and \
ref_url.netloc == test_url.netloc | python | def is_local_url(target):
"""Determine if URL is safe to redirect to."""
ref_url = urlparse(request.host_url)
test_url = urlparse(urljoin(request.host_url, target))
return test_url.scheme in ('http', 'https') and \
ref_url.netloc == test_url.netloc | [
"def",
"is_local_url",
"(",
"target",
")",
":",
"ref_url",
"=",
"urlparse",
"(",
"request",
".",
"host_url",
")",
"test_url",
"=",
"urlparse",
"(",
"urljoin",
"(",
"request",
".",
"host_url",
",",
"target",
")",
")",
"return",
"test_url",
".",
"scheme",
... | Determine if URL is safe to redirect to. | [
"Determine",
"if",
"URL",
"is",
"safe",
"to",
"redirect",
"to",
"."
] | 3119bb7db3369b8ae0aecce5d7d7c79f807e2763 | https://github.com/inveniosoftware/invenio-i18n/blob/3119bb7db3369b8ae0aecce5d7d7c79f807e2763/invenio_i18n/views.py#L20-L25 |
53,423 | inveniosoftware/invenio-i18n | invenio_i18n/views.py | set_lang | def set_lang(lang_code=None):
"""Set language in session and redirect."""
# Check if language is available.
lang_code = lang_code or request.values.get('lang_code')
languages = dict(current_app.extensions['invenio-i18n'].get_languages())
if lang_code is None or lang_code not in languages:
ab... | python | def set_lang(lang_code=None):
"""Set language in session and redirect."""
# Check if language is available.
lang_code = lang_code or request.values.get('lang_code')
languages = dict(current_app.extensions['invenio-i18n'].get_languages())
if lang_code is None or lang_code not in languages:
ab... | [
"def",
"set_lang",
"(",
"lang_code",
"=",
"None",
")",
":",
"# Check if language is available.",
"lang_code",
"=",
"lang_code",
"or",
"request",
".",
"values",
".",
"get",
"(",
"'lang_code'",
")",
"languages",
"=",
"dict",
"(",
"current_app",
".",
"extensions",
... | Set language in session and redirect. | [
"Set",
"language",
"in",
"session",
"and",
"redirect",
"."
] | 3119bb7db3369b8ae0aecce5d7d7c79f807e2763 | https://github.com/inveniosoftware/invenio-i18n/blob/3119bb7db3369b8ae0aecce5d7d7c79f807e2763/invenio_i18n/views.py#L35-L52 |
53,424 | inveniosoftware/invenio-i18n | invenio_i18n/views.py | create_blueprint | def create_blueprint(register_default_routes=True):
"""Create Invenio-I18N blueprint."""
blueprint = Blueprint(
'invenio_i18n',
__name__,
template_folder='templates',
static_folder='static',
)
if register_default_routes:
blueprint.add_url_rule('/', view_func=set_... | python | def create_blueprint(register_default_routes=True):
"""Create Invenio-I18N blueprint."""
blueprint = Blueprint(
'invenio_i18n',
__name__,
template_folder='templates',
static_folder='static',
)
if register_default_routes:
blueprint.add_url_rule('/', view_func=set_... | [
"def",
"create_blueprint",
"(",
"register_default_routes",
"=",
"True",
")",
":",
"blueprint",
"=",
"Blueprint",
"(",
"'invenio_i18n'",
",",
"__name__",
",",
"template_folder",
"=",
"'templates'",
",",
"static_folder",
"=",
"'static'",
",",
")",
"if",
"register_de... | Create Invenio-I18N blueprint. | [
"Create",
"Invenio",
"-",
"I18N",
"blueprint",
"."
] | 3119bb7db3369b8ae0aecce5d7d7c79f807e2763 | https://github.com/inveniosoftware/invenio-i18n/blob/3119bb7db3369b8ae0aecce5d7d7c79f807e2763/invenio_i18n/views.py#L55-L69 |
53,425 | realitix/pyshaderc | pyshaderc/__init__.py | compile_file_into_spirv | def compile_file_into_spirv(filepath, stage, optimization='size',
warnings_as_errors=False):
"""Compile shader file into Spir-V binary.
This function uses shaderc to compile your glsl file code into Spir-V
code.
Args:
filepath (strs): Absolute path to your shader fi... | python | def compile_file_into_spirv(filepath, stage, optimization='size',
warnings_as_errors=False):
"""Compile shader file into Spir-V binary.
This function uses shaderc to compile your glsl file code into Spir-V
code.
Args:
filepath (strs): Absolute path to your shader fi... | [
"def",
"compile_file_into_spirv",
"(",
"filepath",
",",
"stage",
",",
"optimization",
"=",
"'size'",
",",
"warnings_as_errors",
"=",
"False",
")",
":",
"with",
"open",
"(",
"filepath",
",",
"'rb'",
")",
"as",
"f",
":",
"content",
"=",
"f",
".",
"read",
"... | Compile shader file into Spir-V binary.
This function uses shaderc to compile your glsl file code into Spir-V
code.
Args:
filepath (strs): Absolute path to your shader file
stage (str): Pipeline stage in ['vert', 'tesc', 'tese', 'geom',
'frag', 'comp']
optimiza... | [
"Compile",
"shader",
"file",
"into",
"Spir",
"-",
"V",
"binary",
"."
] | ab96e82287f86851471e4c3f0c610004bf7a7a41 | https://github.com/realitix/pyshaderc/blob/ab96e82287f86851471e4c3f0c610004bf7a7a41/pyshaderc/__init__.py#L149-L174 |
53,426 | realitix/pyshaderc | pyshaderc/__init__.py | compile_into_spirv | def compile_into_spirv(raw, stage, filepath, language="glsl",
optimization='size', suppress_warnings=False,
warnings_as_errors=False):
"""Compile shader code into Spir-V binary.
This function uses shaderc to compile your glsl or hlsl code into Spir-V
code. You ... | python | def compile_into_spirv(raw, stage, filepath, language="glsl",
optimization='size', suppress_warnings=False,
warnings_as_errors=False):
"""Compile shader code into Spir-V binary.
This function uses shaderc to compile your glsl or hlsl code into Spir-V
code. You ... | [
"def",
"compile_into_spirv",
"(",
"raw",
",",
"stage",
",",
"filepath",
",",
"language",
"=",
"\"glsl\"",
",",
"optimization",
"=",
"'size'",
",",
"suppress_warnings",
"=",
"False",
",",
"warnings_as_errors",
"=",
"False",
")",
":",
"# extract parameters",
"stag... | Compile shader code into Spir-V binary.
This function uses shaderc to compile your glsl or hlsl code into Spir-V
code. You can refer to the shaderc documentation.
Args:
raw (bytes): glsl or hlsl code (bytes format, not str)
stage (str): Pipeline stage in ['vert', 'tesc', 'tese', 'geom',
... | [
"Compile",
"shader",
"code",
"into",
"Spir",
"-",
"V",
"binary",
"."
] | ab96e82287f86851471e4c3f0c610004bf7a7a41 | https://github.com/realitix/pyshaderc/blob/ab96e82287f86851471e4c3f0c610004bf7a7a41/pyshaderc/__init__.py#L177-L250 |
53,427 | metavee/batchproc | batchproc/util.py | expand_folder | def expand_folder(files):
"""Return a clone of file list files where all directories are recursively replaced with their contents."""
expfiles = []
for file in files:
if os.path.isdir(file):
for dirpath, dirnames, filenames in os.walk(file):
for filename in filenames:
... | python | def expand_folder(files):
"""Return a clone of file list files where all directories are recursively replaced with their contents."""
expfiles = []
for file in files:
if os.path.isdir(file):
for dirpath, dirnames, filenames in os.walk(file):
for filename in filenames:
... | [
"def",
"expand_folder",
"(",
"files",
")",
":",
"expfiles",
"=",
"[",
"]",
"for",
"file",
"in",
"files",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"file",
")",
":",
"for",
"dirpath",
",",
"dirnames",
",",
"filenames",
"in",
"os",
".",
"walk"... | Return a clone of file list files where all directories are recursively replaced with their contents. | [
"Return",
"a",
"clone",
"of",
"file",
"list",
"files",
"where",
"all",
"directories",
"are",
"recursively",
"replaced",
"with",
"their",
"contents",
"."
] | aa084a2ac8ab7950f7a7d3adb54b0cf010c6a935 | https://github.com/metavee/batchproc/blob/aa084a2ac8ab7950f7a7d3adb54b0cf010c6a935/batchproc/util.py#L11-L26 |
53,428 | metavee/batchproc | batchproc/util.py | get_file_list | def get_file_list():
"""Return a list of strings corresponding to file names supplied by drag and drop or standard input."""
if len(sys.argv) > 1:
file_list = list(sys.argv[1:]) # make copy
else:
files_str = input('Select the files you want to process and drag and drop them onto this windo... | python | def get_file_list():
"""Return a list of strings corresponding to file names supplied by drag and drop or standard input."""
if len(sys.argv) > 1:
file_list = list(sys.argv[1:]) # make copy
else:
files_str = input('Select the files you want to process and drag and drop them onto this windo... | [
"def",
"get_file_list",
"(",
")",
":",
"if",
"len",
"(",
"sys",
".",
"argv",
")",
">",
"1",
":",
"file_list",
"=",
"list",
"(",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
")",
"# make copy",
"else",
":",
"files_str",
"=",
"input",
"(",
"'Select the fi... | Return a list of strings corresponding to file names supplied by drag and drop or standard input. | [
"Return",
"a",
"list",
"of",
"strings",
"corresponding",
"to",
"file",
"names",
"supplied",
"by",
"drag",
"and",
"drop",
"or",
"standard",
"input",
"."
] | aa084a2ac8ab7950f7a7d3adb54b0cf010c6a935 | https://github.com/metavee/batchproc/blob/aa084a2ac8ab7950f7a7d3adb54b0cf010c6a935/batchproc/util.py#L29-L52 |
53,429 | eleme/ruskit | ruskit/cmds/manage.py | delete | def delete(args):
"""Delete nodes from the cluster
"""
nodes = [ClusterNode.from_uri(n) for n in args.nodes]
cluster = Cluster.from_node(ClusterNode.from_uri(args.cluster))
echo("Deleting...")
for node in nodes:
cluster.delete_node(node)
cluster.wait() | python | def delete(args):
"""Delete nodes from the cluster
"""
nodes = [ClusterNode.from_uri(n) for n in args.nodes]
cluster = Cluster.from_node(ClusterNode.from_uri(args.cluster))
echo("Deleting...")
for node in nodes:
cluster.delete_node(node)
cluster.wait() | [
"def",
"delete",
"(",
"args",
")",
":",
"nodes",
"=",
"[",
"ClusterNode",
".",
"from_uri",
"(",
"n",
")",
"for",
"n",
"in",
"args",
".",
"nodes",
"]",
"cluster",
"=",
"Cluster",
".",
"from_node",
"(",
"ClusterNode",
".",
"from_uri",
"(",
"args",
".",... | Delete nodes from the cluster | [
"Delete",
"nodes",
"from",
"the",
"cluster"
] | 2e8c5a3f6a65b8aeb07012b4e2c8ba324d887c3b | https://github.com/eleme/ruskit/blob/2e8c5a3f6a65b8aeb07012b4e2c8ba324d887c3b/ruskit/cmds/manage.py#L63-L72 |
53,430 | eleme/ruskit | ruskit/cmds/manage.py | reshard | def reshard(args):
"""Balance slots in the cluster.
This command will try its best to distribute slots equally.
"""
cluster = Cluster.from_node(ClusterNode.from_uri(args.cluster))
cluster.reshard() | python | def reshard(args):
"""Balance slots in the cluster.
This command will try its best to distribute slots equally.
"""
cluster = Cluster.from_node(ClusterNode.from_uri(args.cluster))
cluster.reshard() | [
"def",
"reshard",
"(",
"args",
")",
":",
"cluster",
"=",
"Cluster",
".",
"from_node",
"(",
"ClusterNode",
".",
"from_uri",
"(",
"args",
".",
"cluster",
")",
")",
"cluster",
".",
"reshard",
"(",
")"
] | Balance slots in the cluster.
This command will try its best to distribute slots equally. | [
"Balance",
"slots",
"in",
"the",
"cluster",
"."
] | 2e8c5a3f6a65b8aeb07012b4e2c8ba324d887c3b | https://github.com/eleme/ruskit/blob/2e8c5a3f6a65b8aeb07012b4e2c8ba324d887c3b/ruskit/cmds/manage.py#L107-L113 |
53,431 | eleme/ruskit | ruskit/cmds/manage.py | replicate | def replicate(ctx, args):
"""Make node to be the slave of a master.
"""
slave = ClusterNode.from_uri(args.node)
master = ClusterNode.from_uri(args.master)
if not master.is_master():
ctx.abort("Node {!r} is not a master.".format(args.master))
try:
slave.replicate(master.name)
... | python | def replicate(ctx, args):
"""Make node to be the slave of a master.
"""
slave = ClusterNode.from_uri(args.node)
master = ClusterNode.from_uri(args.master)
if not master.is_master():
ctx.abort("Node {!r} is not a master.".format(args.master))
try:
slave.replicate(master.name)
... | [
"def",
"replicate",
"(",
"ctx",
",",
"args",
")",
":",
"slave",
"=",
"ClusterNode",
".",
"from_uri",
"(",
"args",
".",
"node",
")",
"master",
"=",
"ClusterNode",
".",
"from_uri",
"(",
"args",
".",
"master",
")",
"if",
"not",
"master",
".",
"is_master",... | Make node to be the slave of a master. | [
"Make",
"node",
"to",
"be",
"the",
"slave",
"of",
"a",
"master",
"."
] | 2e8c5a3f6a65b8aeb07012b4e2c8ba324d887c3b | https://github.com/eleme/ruskit/blob/2e8c5a3f6a65b8aeb07012b4e2c8ba324d887c3b/ruskit/cmds/manage.py#L121-L134 |
53,432 | eleme/ruskit | ruskit/cmds/manage.py | flushall | def flushall(args):
"""Execute flushall in all cluster nodes.
"""
cluster = Cluster.from_node(ClusterNode.from_uri(args.cluster))
for node in cluster.masters:
node.flushall() | python | def flushall(args):
"""Execute flushall in all cluster nodes.
"""
cluster = Cluster.from_node(ClusterNode.from_uri(args.cluster))
for node in cluster.masters:
node.flushall() | [
"def",
"flushall",
"(",
"args",
")",
":",
"cluster",
"=",
"Cluster",
".",
"from_node",
"(",
"ClusterNode",
".",
"from_uri",
"(",
"args",
".",
"cluster",
")",
")",
"for",
"node",
"in",
"cluster",
".",
"masters",
":",
"node",
".",
"flushall",
"(",
")"
] | Execute flushall in all cluster nodes. | [
"Execute",
"flushall",
"in",
"all",
"cluster",
"nodes",
"."
] | 2e8c5a3f6a65b8aeb07012b4e2c8ba324d887c3b | https://github.com/eleme/ruskit/blob/2e8c5a3f6a65b8aeb07012b4e2c8ba324d887c3b/ruskit/cmds/manage.py#L152-L157 |
53,433 | ekalinin/marktime.py | marktime.py | start | def start(label, at=None):
"""Begins the countdown"""
t = at if at is not None else time.time()
marker = Marker().start(t)
labels[label] = marker.dumps() | python | def start(label, at=None):
"""Begins the countdown"""
t = at if at is not None else time.time()
marker = Marker().start(t)
labels[label] = marker.dumps() | [
"def",
"start",
"(",
"label",
",",
"at",
"=",
"None",
")",
":",
"t",
"=",
"at",
"if",
"at",
"is",
"not",
"None",
"else",
"time",
".",
"time",
"(",
")",
"marker",
"=",
"Marker",
"(",
")",
".",
"start",
"(",
"t",
")",
"labels",
"[",
"label",
"]... | Begins the countdown | [
"Begins",
"the",
"countdown"
] | 111897cfa30f570155bb009ea653ce402457b17d | https://github.com/ekalinin/marktime.py/blob/111897cfa30f570155bb009ea653ce402457b17d/marktime.py#L96-L100 |
53,434 | ekalinin/marktime.py | marktime.py | stop | def stop(label, at=None, remove_from_labels=False, stop_once=True):
"""Stops the countdown"""
t = at if at is not None else time.time()
if label not in labels:
return None
timer = Marker().loads(labels[label])
if timer.is_running() or (timer.is_stopped() and not stop_once):
timer.... | python | def stop(label, at=None, remove_from_labels=False, stop_once=True):
"""Stops the countdown"""
t = at if at is not None else time.time()
if label not in labels:
return None
timer = Marker().loads(labels[label])
if timer.is_running() or (timer.is_stopped() and not stop_once):
timer.... | [
"def",
"stop",
"(",
"label",
",",
"at",
"=",
"None",
",",
"remove_from_labels",
"=",
"False",
",",
"stop_once",
"=",
"True",
")",
":",
"t",
"=",
"at",
"if",
"at",
"is",
"not",
"None",
"else",
"time",
".",
"time",
"(",
")",
"if",
"label",
"not",
"... | Stops the countdown | [
"Stops",
"the",
"countdown"
] | 111897cfa30f570155bb009ea653ce402457b17d | https://github.com/ekalinin/marktime.py/blob/111897cfa30f570155bb009ea653ce402457b17d/marktime.py#L103-L120 |
53,435 | ekalinin/marktime.py | marktime.py | duration | def duration(label, stop_it=True, stop_at=None):
"""Returns duration in seconds for label"""
if label not in labels:
return None
if "duration" in labels[label]:
return Duration(labels[label]["duration"])
if stop_it:
return stop(label, at=stop_at)
else:
return None | python | def duration(label, stop_it=True, stop_at=None):
"""Returns duration in seconds for label"""
if label not in labels:
return None
if "duration" in labels[label]:
return Duration(labels[label]["duration"])
if stop_it:
return stop(label, at=stop_at)
else:
return None | [
"def",
"duration",
"(",
"label",
",",
"stop_it",
"=",
"True",
",",
"stop_at",
"=",
"None",
")",
":",
"if",
"label",
"not",
"in",
"labels",
":",
"return",
"None",
"if",
"\"duration\"",
"in",
"labels",
"[",
"label",
"]",
":",
"return",
"Duration",
"(",
... | Returns duration in seconds for label | [
"Returns",
"duration",
"in",
"seconds",
"for",
"label"
] | 111897cfa30f570155bb009ea653ce402457b17d | https://github.com/ekalinin/marktime.py/blob/111897cfa30f570155bb009ea653ce402457b17d/marktime.py#L123-L135 |
53,436 | joowani/quadriga | quadriga/rest.py | RestClient._handle_response | def _handle_response(self, resp):
"""Handle the response from QuadrigaCX.
:param resp: Response from QuadrigaCX.
:type resp: requests.models.Response
:return: Response body.
:rtype: dict
:raise quadriga.exceptions.RequestError: If HTTP OK was not returned.
"""
... | python | def _handle_response(self, resp):
"""Handle the response from QuadrigaCX.
:param resp: Response from QuadrigaCX.
:type resp: requests.models.Response
:return: Response body.
:rtype: dict
:raise quadriga.exceptions.RequestError: If HTTP OK was not returned.
"""
... | [
"def",
"_handle_response",
"(",
"self",
",",
"resp",
")",
":",
"http_code",
"=",
"resp",
".",
"status_code",
"if",
"http_code",
"not",
"in",
"self",
".",
"http_success_status_codes",
":",
"raise",
"RequestError",
"(",
"response",
"=",
"resp",
",",
"message",
... | Handle the response from QuadrigaCX.
:param resp: Response from QuadrigaCX.
:type resp: requests.models.Response
:return: Response body.
:rtype: dict
:raise quadriga.exceptions.RequestError: If HTTP OK was not returned. | [
"Handle",
"the",
"response",
"from",
"QuadrigaCX",
"."
] | 412f88f414ef0cb53efa6d5841b9674eb9718359 | https://github.com/joowani/quadriga/blob/412f88f414ef0cb53efa6d5841b9674eb9718359/quadriga/rest.py#L38-L75 |
53,437 | joowani/quadriga | quadriga/rest.py | RestClient.get | def get(self, endpoint, params=None):
"""Send an HTTP GET request to QuadrigaCX.
:param endpoint: API endpoint.
:type endpoint: str | unicode
:param params: URL parameters.
:type params: dict
:return: Response body from QuadrigaCX.
:rtype: dict
:raise qua... | python | def get(self, endpoint, params=None):
"""Send an HTTP GET request to QuadrigaCX.
:param endpoint: API endpoint.
:type endpoint: str | unicode
:param params: URL parameters.
:type params: dict
:return: Response body from QuadrigaCX.
:rtype: dict
:raise qua... | [
"def",
"get",
"(",
"self",
",",
"endpoint",
",",
"params",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"_session",
".",
"get",
"(",
"url",
"=",
"self",
".",
"_url",
"+",
"endpoint",
",",
"params",
"=",
"params",
",",
"timeout",
"=",
"self"... | Send an HTTP GET request to QuadrigaCX.
:param endpoint: API endpoint.
:type endpoint: str | unicode
:param params: URL parameters.
:type params: dict
:return: Response body from QuadrigaCX.
:rtype: dict
:raise quadriga.exceptions.RequestError: If HTTP OK was not... | [
"Send",
"an",
"HTTP",
"GET",
"request",
"to",
"QuadrigaCX",
"."
] | 412f88f414ef0cb53efa6d5841b9674eb9718359 | https://github.com/joowani/quadriga/blob/412f88f414ef0cb53efa6d5841b9674eb9718359/quadriga/rest.py#L77-L93 |
53,438 | joowani/quadriga | quadriga/rest.py | RestClient.post | def post(self, endpoint, payload=None):
"""Send an HTTP POST request to QuadrigaCX.
:param endpoint: API endpoint.
:type endpoint: str | unicode
:param payload: Request payload.
:type payload: dict
:return: Response body from QuadrigaCX.
:rtype: dict
:rai... | python | def post(self, endpoint, payload=None):
"""Send an HTTP POST request to QuadrigaCX.
:param endpoint: API endpoint.
:type endpoint: str | unicode
:param payload: Request payload.
:type payload: dict
:return: Response body from QuadrigaCX.
:rtype: dict
:rai... | [
"def",
"post",
"(",
"self",
",",
"endpoint",
",",
"payload",
"=",
"None",
")",
":",
"nonce",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
"*",
"10000",
")",
"hmac_msg",
"=",
"str",
"(",
"nonce",
")",
"+",
"self",
".",
"_client_id",
"+",
"self"... | Send an HTTP POST request to QuadrigaCX.
:param endpoint: API endpoint.
:type endpoint: str | unicode
:param payload: Request payload.
:type payload: dict
:return: Response body from QuadrigaCX.
:rtype: dict
:raise quadriga.exceptions.RequestError: If HTTP OK was... | [
"Send",
"an",
"HTTP",
"POST",
"request",
"to",
"QuadrigaCX",
"."
] | 412f88f414ef0cb53efa6d5841b9674eb9718359 | https://github.com/joowani/quadriga/blob/412f88f414ef0cb53efa6d5841b9674eb9718359/quadriga/rest.py#L95-L125 |
53,439 | spantaleev/sftpman | sftpman/cli.py | SftpCli.command_help | def command_help(self, *args, **kwargs):
"""Displays this help menu."""
print("Commands available:\n")
for name in dir(self):
if not name.startswith("command_"):
continue
name_clean = name[len("command_"):]
print("%s:\n - %s\n" % (name_clean, g... | python | def command_help(self, *args, **kwargs):
"""Displays this help menu."""
print("Commands available:\n")
for name in dir(self):
if not name.startswith("command_"):
continue
name_clean = name[len("command_"):]
print("%s:\n - %s\n" % (name_clean, g... | [
"def",
"command_help",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"print",
"(",
"\"Commands available:\\n\"",
")",
"for",
"name",
"in",
"dir",
"(",
"self",
")",
":",
"if",
"not",
"name",
".",
"startswith",
"(",
"\"command_\"",
")... | Displays this help menu. | [
"Displays",
"this",
"help",
"menu",
"."
] | e4fc3e3e3af975937469e0b8944ba62c01b12a47 | https://github.com/spantaleev/sftpman/blob/e4fc3e3e3af975937469e0b8944ba62c01b12a47/sftpman/cli.py#L14-L21 |
53,440 | spantaleev/sftpman | sftpman/cli.py | SftpCli.command_preflight_check | def command_preflight_check(self):
"""Detects whether we have everything needed to mount sshfs filesystems.
"""
checks_pass, failures = self.environment.perform_preflight_check()
if checks_pass:
print('All checks pass.')
else:
sys.stderr.write('Problems en... | python | def command_preflight_check(self):
"""Detects whether we have everything needed to mount sshfs filesystems.
"""
checks_pass, failures = self.environment.perform_preflight_check()
if checks_pass:
print('All checks pass.')
else:
sys.stderr.write('Problems en... | [
"def",
"command_preflight_check",
"(",
"self",
")",
":",
"checks_pass",
",",
"failures",
"=",
"self",
".",
"environment",
".",
"perform_preflight_check",
"(",
")",
"if",
"checks_pass",
":",
"print",
"(",
"'All checks pass.'",
")",
"else",
":",
"sys",
".",
"std... | Detects whether we have everything needed to mount sshfs filesystems. | [
"Detects",
"whether",
"we",
"have",
"everything",
"needed",
"to",
"mount",
"sshfs",
"filesystems",
"."
] | e4fc3e3e3af975937469e0b8944ba62c01b12a47 | https://github.com/spantaleev/sftpman/blob/e4fc3e3e3af975937469e0b8944ba62c01b12a47/sftpman/cli.py#L116-L126 |
53,441 | joowani/quadriga | quadriga/book.py | OrderBook._log | def _log(self, message):
"""Log a debug message prefixed with order book name.
:param message: Debug message.
:type message: str | unicode
"""
self._logger.debug("{}: {}".format(self.name, message)) | python | def _log(self, message):
"""Log a debug message prefixed with order book name.
:param message: Debug message.
:type message: str | unicode
"""
self._logger.debug("{}: {}".format(self.name, message)) | [
"def",
"_log",
"(",
"self",
",",
"message",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"{}: {}\"",
".",
"format",
"(",
"self",
".",
"name",
",",
"message",
")",
")"
] | Log a debug message prefixed with order book name.
:param message: Debug message.
:type message: str | unicode | [
"Log",
"a",
"debug",
"message",
"prefixed",
"with",
"order",
"book",
"name",
"."
] | 412f88f414ef0cb53efa6d5841b9674eb9718359 | https://github.com/joowani/quadriga/blob/412f88f414ef0cb53efa6d5841b9674eb9718359/quadriga/book.py#L29-L35 |
53,442 | joowani/quadriga | quadriga/book.py | OrderBook.get_ticker | def get_ticker(self):
"""Return the latest ticker information.
:return: Latest ticker information.
:rtype: dict
"""
self._log('get ticker')
return self._rest_client.get(
endpoint='/ticker',
params={'book': self.name}
) | python | def get_ticker(self):
"""Return the latest ticker information.
:return: Latest ticker information.
:rtype: dict
"""
self._log('get ticker')
return self._rest_client.get(
endpoint='/ticker',
params={'book': self.name}
) | [
"def",
"get_ticker",
"(",
"self",
")",
":",
"self",
".",
"_log",
"(",
"'get ticker'",
")",
"return",
"self",
".",
"_rest_client",
".",
"get",
"(",
"endpoint",
"=",
"'/ticker'",
",",
"params",
"=",
"{",
"'book'",
":",
"self",
".",
"name",
"}",
")"
] | Return the latest ticker information.
:return: Latest ticker information.
:rtype: dict | [
"Return",
"the",
"latest",
"ticker",
"information",
"."
] | 412f88f414ef0cb53efa6d5841b9674eb9718359 | https://github.com/joowani/quadriga/blob/412f88f414ef0cb53efa6d5841b9674eb9718359/quadriga/book.py#L37-L47 |
53,443 | joowani/quadriga | quadriga/book.py | OrderBook.get_public_orders | def get_public_orders(self, group=False):
"""Return public orders that are currently open.
:param group: If set to True (default: False), orders with the same
price are grouped.
:type group: bool
:return: Public orders currently open.
:rtype: dict
"""
... | python | def get_public_orders(self, group=False):
"""Return public orders that are currently open.
:param group: If set to True (default: False), orders with the same
price are grouped.
:type group: bool
:return: Public orders currently open.
:rtype: dict
"""
... | [
"def",
"get_public_orders",
"(",
"self",
",",
"group",
"=",
"False",
")",
":",
"self",
".",
"_log",
"(",
"'get public orders'",
")",
"return",
"self",
".",
"_rest_client",
".",
"get",
"(",
"endpoint",
"=",
"'/order_book'",
",",
"params",
"=",
"{",
"'book'"... | Return public orders that are currently open.
:param group: If set to True (default: False), orders with the same
price are grouped.
:type group: bool
:return: Public orders currently open.
:rtype: dict | [
"Return",
"public",
"orders",
"that",
"are",
"currently",
"open",
"."
] | 412f88f414ef0cb53efa6d5841b9674eb9718359 | https://github.com/joowani/quadriga/blob/412f88f414ef0cb53efa6d5841b9674eb9718359/quadriga/book.py#L49-L62 |
53,444 | joowani/quadriga | quadriga/book.py | OrderBook.get_public_trades | def get_public_trades(self, time_frame='hour'):
"""Return public trades that were completed recently.
:param time_frame: Time frame. Allowed values are "minute" for trades
in the last minute, or "hour" for trades in the last hour (default:
"hour").
:type time_frame: str ... | python | def get_public_trades(self, time_frame='hour'):
"""Return public trades that were completed recently.
:param time_frame: Time frame. Allowed values are "minute" for trades
in the last minute, or "hour" for trades in the last hour (default:
"hour").
:type time_frame: str ... | [
"def",
"get_public_trades",
"(",
"self",
",",
"time_frame",
"=",
"'hour'",
")",
":",
"self",
".",
"_log",
"(",
"'get public trades'",
")",
"return",
"self",
".",
"_rest_client",
".",
"get",
"(",
"endpoint",
"=",
"'/transactions'",
",",
"params",
"=",
"{",
... | Return public trades that were completed recently.
:param time_frame: Time frame. Allowed values are "minute" for trades
in the last minute, or "hour" for trades in the last hour (default:
"hour").
:type time_frame: str | unicode
:return: Public trades completed recently... | [
"Return",
"public",
"trades",
"that",
"were",
"completed",
"recently",
"."
] | 412f88f414ef0cb53efa6d5841b9674eb9718359 | https://github.com/joowani/quadriga/blob/412f88f414ef0cb53efa6d5841b9674eb9718359/quadriga/book.py#L64-L78 |
53,445 | joowani/quadriga | quadriga/book.py | OrderBook.get_user_orders | def get_user_orders(self):
"""Return user's orders that are currently open.
:return: User's orders currently open.
:rtype: [dict]
"""
self._log('get user orders')
return self._rest_client.post(
endpoint='/open_orders',
payload={'book': self.name}
... | python | def get_user_orders(self):
"""Return user's orders that are currently open.
:return: User's orders currently open.
:rtype: [dict]
"""
self._log('get user orders')
return self._rest_client.post(
endpoint='/open_orders',
payload={'book': self.name}
... | [
"def",
"get_user_orders",
"(",
"self",
")",
":",
"self",
".",
"_log",
"(",
"'get user orders'",
")",
"return",
"self",
".",
"_rest_client",
".",
"post",
"(",
"endpoint",
"=",
"'/open_orders'",
",",
"payload",
"=",
"{",
"'book'",
":",
"self",
".",
"name",
... | Return user's orders that are currently open.
:return: User's orders currently open.
:rtype: [dict] | [
"Return",
"user",
"s",
"orders",
"that",
"are",
"currently",
"open",
"."
] | 412f88f414ef0cb53efa6d5841b9674eb9718359 | https://github.com/joowani/quadriga/blob/412f88f414ef0cb53efa6d5841b9674eb9718359/quadriga/book.py#L80-L90 |
53,446 | joowani/quadriga | quadriga/book.py | OrderBook.get_user_trades | def get_user_trades(self, limit=0, offset=0, sort='desc'):
"""Return user's trade history.
:param limit: Maximum number of trades to return. If set to 0 or lower,
all trades are returned (default: 0).
:type limit: int
:param offset: Number of trades to skip.
:type of... | python | def get_user_trades(self, limit=0, offset=0, sort='desc'):
"""Return user's trade history.
:param limit: Maximum number of trades to return. If set to 0 or lower,
all trades are returned (default: 0).
:type limit: int
:param offset: Number of trades to skip.
:type of... | [
"def",
"get_user_trades",
"(",
"self",
",",
"limit",
"=",
"0",
",",
"offset",
"=",
"0",
",",
"sort",
"=",
"'desc'",
")",
":",
"self",
".",
"_log",
"(",
"'get user trades'",
")",
"res",
"=",
"self",
".",
"_rest_client",
".",
"post",
"(",
"endpoint",
"... | Return user's trade history.
:param limit: Maximum number of trades to return. If set to 0 or lower,
all trades are returned (default: 0).
:type limit: int
:param offset: Number of trades to skip.
:type offset: int
:param sort: Method used to sort the results by date... | [
"Return",
"user",
"s",
"trade",
"history",
"."
] | 412f88f414ef0cb53efa6d5841b9674eb9718359 | https://github.com/joowani/quadriga/blob/412f88f414ef0cb53efa6d5841b9674eb9718359/quadriga/book.py#L92-L118 |
53,447 | joowani/quadriga | quadriga/book.py | OrderBook.buy_market_order | def buy_market_order(self, amount):
"""Place a buy order at market price.
:param amount: Amount of major currency to buy at market price.
:type amount: int | float | str | unicode | decimal.Decimal
:return: Order details.
:rtype: dict
"""
amount = str(amount)
... | python | def buy_market_order(self, amount):
"""Place a buy order at market price.
:param amount: Amount of major currency to buy at market price.
:type amount: int | float | str | unicode | decimal.Decimal
:return: Order details.
:rtype: dict
"""
amount = str(amount)
... | [
"def",
"buy_market_order",
"(",
"self",
",",
"amount",
")",
":",
"amount",
"=",
"str",
"(",
"amount",
")",
"self",
".",
"_log",
"(",
"\"buy {} {} at market price\"",
".",
"format",
"(",
"amount",
",",
"self",
".",
"major",
")",
")",
"return",
"self",
"."... | Place a buy order at market price.
:param amount: Amount of major currency to buy at market price.
:type amount: int | float | str | unicode | decimal.Decimal
:return: Order details.
:rtype: dict | [
"Place",
"a",
"buy",
"order",
"at",
"market",
"price",
"."
] | 412f88f414ef0cb53efa6d5841b9674eb9718359 | https://github.com/joowani/quadriga/blob/412f88f414ef0cb53efa6d5841b9674eb9718359/quadriga/book.py#L120-L133 |
53,448 | joowani/quadriga | quadriga/book.py | OrderBook.buy_limit_order | def buy_limit_order(self, amount, price):
"""Place a buy order at the given limit price.
:param amount: Amount of major currency to buy at limit price.
:type amount: int | float | str | unicode | decimal.Decimal
:param price: Limit price.
:type price: int | float | str | unicode... | python | def buy_limit_order(self, amount, price):
"""Place a buy order at the given limit price.
:param amount: Amount of major currency to buy at limit price.
:type amount: int | float | str | unicode | decimal.Decimal
:param price: Limit price.
:type price: int | float | str | unicode... | [
"def",
"buy_limit_order",
"(",
"self",
",",
"amount",
",",
"price",
")",
":",
"amount",
"=",
"str",
"(",
"amount",
")",
"price",
"=",
"str",
"(",
"price",
")",
"self",
".",
"_log",
"(",
"\"buy {} {} at limit price of {} {}\"",
".",
"format",
"(",
"amount",... | Place a buy order at the given limit price.
:param amount: Amount of major currency to buy at limit price.
:type amount: int | float | str | unicode | decimal.Decimal
:param price: Limit price.
:type price: int | float | str | unicode | decimal.Decimal
:return: Order details.
... | [
"Place",
"a",
"buy",
"order",
"at",
"the",
"given",
"limit",
"price",
"."
] | 412f88f414ef0cb53efa6d5841b9674eb9718359 | https://github.com/joowani/quadriga/blob/412f88f414ef0cb53efa6d5841b9674eb9718359/quadriga/book.py#L135-L153 |
53,449 | eavanvalkenburg/brunt-api | brunt/brunt.py | BruntAPI._is_logged_in | def _is_logged_in(self):
""" Check whether or not the user is logged in. """
# if the user has not logged in in 24 hours, relogin
if not self._http._has_session() or datetime.utcnow() >= self._lastlogin + timedelta(hours=24):
return self._login()
else:
return {} | python | def _is_logged_in(self):
""" Check whether or not the user is logged in. """
# if the user has not logged in in 24 hours, relogin
if not self._http._has_session() or datetime.utcnow() >= self._lastlogin + timedelta(hours=24):
return self._login()
else:
return {} | [
"def",
"_is_logged_in",
"(",
"self",
")",
":",
"# if the user has not logged in in 24 hours, relogin",
"if",
"not",
"self",
".",
"_http",
".",
"_has_session",
"(",
")",
"or",
"datetime",
".",
"utcnow",
"(",
")",
">=",
"self",
".",
"_lastlogin",
"+",
"timedelta",... | Check whether or not the user is logged in. | [
"Check",
"whether",
"or",
"not",
"the",
"user",
"is",
"logged",
"in",
"."
] | c6bae43f56e0fd8f79b7af67d524611dd104dafa | https://github.com/eavanvalkenburg/brunt-api/blob/c6bae43f56e0fd8f79b7af67d524611dd104dafa/brunt/brunt.py#L121-L127 |
53,450 | eavanvalkenburg/brunt-api | brunt/brunt.py | BruntAPI.getState | def getState(self, **kwargs):
"""Get the state of a thing
:param thing: a string with the name of the thing, which is then checked using getThings.
:param thingUri: Uri (string) of the thing you are getting the state from, not checked against getThings.
:return: a dict with the state of... | python | def getState(self, **kwargs):
"""Get the state of a thing
:param thing: a string with the name of the thing, which is then checked using getThings.
:param thingUri: Uri (string) of the thing you are getting the state from, not checked against getThings.
:return: a dict with the state of... | [
"def",
"getState",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"login_return",
"=",
"self",
".",
"_is_logged_in",
"(",
")",
"if",
"\"thingUri\"",
"in",
"kwargs",
":",
"thingUri",
"=",
"kwargs",
"[",
"'thingUri'",
"]",
"elif",
"\"thing\"",
"in",
"kwar... | Get the state of a thing
:param thing: a string with the name of the thing, which is then checked using getThings.
:param thingUri: Uri (string) of the thing you are getting the state from, not checked against getThings.
:return: a dict with the state of the Thing.
:raises: ValueError i... | [
"Get",
"the",
"state",
"of",
"a",
"thing"
] | c6bae43f56e0fd8f79b7af67d524611dd104dafa | https://github.com/eavanvalkenburg/brunt-api/blob/c6bae43f56e0fd8f79b7af67d524611dd104dafa/brunt/brunt.py#L154-L185 |
53,451 | eavanvalkenburg/brunt-api | brunt/brunt.py | BruntAPI.changeKey | def changeKey(self, **kwargs):
"""Change a variable of the thing. Mostly included for future additions.
:param key: The value you want to change
:param value: The new value
:param thing: a string with the name of the thing, which is then checked using getThings.
:param thingUri... | python | def changeKey(self, **kwargs):
"""Change a variable of the thing. Mostly included for future additions.
:param key: The value you want to change
:param value: The new value
:param thing: a string with the name of the thing, which is then checked using getThings.
:param thingUri... | [
"def",
"changeKey",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"login_return",
"=",
"self",
".",
"_is_logged_in",
"(",
")",
"#check the thing being changed",
"if",
"\"thingUri\"",
"in",
"kwargs",
":",
"thingUri",
"=",
"kwargs",
"[",
"'thingUri'",
"]",
"... | Change a variable of the thing. Mostly included for future additions.
:param key: The value you want to change
:param value: The new value
:param thing: a string with the name of the thing, which is then checked using getThings.
:param thingUri: Uri (string) of the thing you are gettin... | [
"Change",
"a",
"variable",
"of",
"the",
"thing",
".",
"Mostly",
"included",
"for",
"future",
"additions",
"."
] | c6bae43f56e0fd8f79b7af67d524611dd104dafa | https://github.com/eavanvalkenburg/brunt-api/blob/c6bae43f56e0fd8f79b7af67d524611dd104dafa/brunt/brunt.py#L187-L242 |
53,452 | eavanvalkenburg/brunt-api | brunt/brunt.py | BruntAPI.changeRequestPosition | def changeRequestPosition(self, request_position, **kwargs):
"""Change the position of the thing.
:param request_position: The new position for the slide (0-100)
:param thing: a string with the name of the thing, which is then checked using getThings.
:param thingUri: Uri (string) of th... | python | def changeRequestPosition(self, request_position, **kwargs):
"""Change the position of the thing.
:param request_position: The new position for the slide (0-100)
:param thing: a string with the name of the thing, which is then checked using getThings.
:param thingUri: Uri (string) of th... | [
"def",
"changeRequestPosition",
"(",
"self",
",",
"request_position",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'key'",
"]",
"=",
"\"requestPosition\"",
"kwargs",
"[",
"'value'",
"]",
"=",
"request_position",
"return",
"self",
".",
"changeKey",
"(",
... | Change the position of the thing.
:param request_position: The new position for the slide (0-100)
:param thing: a string with the name of the thing, which is then checked using getThings.
:param thingUri: Uri (string) of the thing you are getting the state from, not checked against getThings.
... | [
"Change",
"the",
"position",
"of",
"the",
"thing",
"."
] | c6bae43f56e0fd8f79b7af67d524611dd104dafa | https://github.com/eavanvalkenburg/brunt-api/blob/c6bae43f56e0fd8f79b7af67d524611dd104dafa/brunt/brunt.py#L244-L256 |
53,453 | synw/dataswim | dataswim/charts/bokeh.py | Bokeh.ndlayout_ | def ndlayout_(self, dataset, kdims, cols=3):
"""
Create a Holoview NdLayout from a dictionnary of chart objects
"""
try:
return hv.NdLayout(dataset, kdims=kdims).cols(cols)
except Exception as e:
self.err(e, self.layout_, "Can not create layout") | python | def ndlayout_(self, dataset, kdims, cols=3):
"""
Create a Holoview NdLayout from a dictionnary of chart objects
"""
try:
return hv.NdLayout(dataset, kdims=kdims).cols(cols)
except Exception as e:
self.err(e, self.layout_, "Can not create layout") | [
"def",
"ndlayout_",
"(",
"self",
",",
"dataset",
",",
"kdims",
",",
"cols",
"=",
"3",
")",
":",
"try",
":",
"return",
"hv",
".",
"NdLayout",
"(",
"dataset",
",",
"kdims",
"=",
"kdims",
")",
".",
"cols",
"(",
"cols",
")",
"except",
"Exception",
"as"... | Create a Holoview NdLayout from a dictionnary of chart objects | [
"Create",
"a",
"Holoview",
"NdLayout",
"from",
"a",
"dictionnary",
"of",
"chart",
"objects"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/bokeh.py#L28-L35 |
53,454 | synw/dataswim | dataswim/charts/bokeh.py | Bokeh.layout_ | def layout_(self, chart_objs, cols=3):
"""
Returns a Holoview Layout from chart objects
"""
try:
return hv.Layout(chart_objs).cols(cols)
except Exception as e:
self.err(e, self.layout_, "Can not build layout") | python | def layout_(self, chart_objs, cols=3):
"""
Returns a Holoview Layout from chart objects
"""
try:
return hv.Layout(chart_objs).cols(cols)
except Exception as e:
self.err(e, self.layout_, "Can not build layout") | [
"def",
"layout_",
"(",
"self",
",",
"chart_objs",
",",
"cols",
"=",
"3",
")",
":",
"try",
":",
"return",
"hv",
".",
"Layout",
"(",
"chart_objs",
")",
".",
"cols",
"(",
"cols",
")",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"err",
"(",
"... | Returns a Holoview Layout from chart objects | [
"Returns",
"a",
"Holoview",
"Layout",
"from",
"chart",
"objects"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/bokeh.py#L37-L44 |
53,455 | synw/dataswim | dataswim/charts/bokeh.py | Bokeh._hline_bokeh_ | def _hline_bokeh_(self, col):
"""
Returns an horizontal line from a column mean value
"""
c = hv.HLine(self.df[col].mean())
return c | python | def _hline_bokeh_(self, col):
"""
Returns an horizontal line from a column mean value
"""
c = hv.HLine(self.df[col].mean())
return c | [
"def",
"_hline_bokeh_",
"(",
"self",
",",
"col",
")",
":",
"c",
"=",
"hv",
".",
"HLine",
"(",
"self",
".",
"df",
"[",
"col",
"]",
".",
"mean",
"(",
")",
")",
"return",
"c"
] | Returns an horizontal line from a column mean value | [
"Returns",
"an",
"horizontal",
"line",
"from",
"a",
"column",
"mean",
"value"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/bokeh.py#L60-L65 |
53,456 | synw/dataswim | dataswim/charts/bokeh.py | Bokeh._sline_bokeh | def _sline_bokeh(self, window_size, y_label):
"""
Returns a chart with a smooth line from a serie
"""
try:
ds2 = self.clone_()
window = np.ones(int(window_size)) / float(window_size)
ds2.df[y_label] = np.convolve(self.df[self.y], window, 'same')
... | python | def _sline_bokeh(self, window_size, y_label):
"""
Returns a chart with a smooth line from a serie
"""
try:
ds2 = self.clone_()
window = np.ones(int(window_size)) / float(window_size)
ds2.df[y_label] = np.convolve(self.df[self.y], window, 'same')
... | [
"def",
"_sline_bokeh",
"(",
"self",
",",
"window_size",
",",
"y_label",
")",
":",
"try",
":",
"ds2",
"=",
"self",
".",
"clone_",
"(",
")",
"window",
"=",
"np",
".",
"ones",
"(",
"int",
"(",
"window_size",
")",
")",
"/",
"float",
"(",
"window_size",
... | Returns a chart with a smooth line from a serie | [
"Returns",
"a",
"chart",
"with",
"a",
"smooth",
"line",
"from",
"a",
"serie"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/bokeh.py#L77-L88 |
53,457 | synw/dataswim | dataswim/charts/bokeh.py | Bokeh._lreg_bokeh | def _lreg_bokeh(self, **kwargs):
"""
Returns a Bokeh linear regression line
"""
try:
ds2 = self._duplicate_()
ds2.timestamps(ds2.x)
ds2.lreg("Timestamps", ds2.y)
ds2.drop(ds2.y)
ds2.df = ds2.df.rename(columns={'Regression': ds2.... | python | def _lreg_bokeh(self, **kwargs):
"""
Returns a Bokeh linear regression line
"""
try:
ds2 = self._duplicate_()
ds2.timestamps(ds2.x)
ds2.lreg("Timestamps", ds2.y)
ds2.drop(ds2.y)
ds2.df = ds2.df.rename(columns={'Regression': ds2.... | [
"def",
"_lreg_bokeh",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"ds2",
"=",
"self",
".",
"_duplicate_",
"(",
")",
"ds2",
".",
"timestamps",
"(",
"ds2",
".",
"x",
")",
"ds2",
".",
"lreg",
"(",
"\"Timestamps\"",
",",
"ds2",
".",
"... | Returns a Bokeh linear regression line | [
"Returns",
"a",
"Bokeh",
"linear",
"regression",
"line"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/bokeh.py#L90-L105 |
53,458 | synw/dataswim | dataswim/charts/bokeh.py | Bokeh._get_bokeh_chart | def _get_bokeh_chart(self, x_field, y_field, chart_type,
label, opts, style, options={}, **kwargs):
"""
Get a Bokeh chart object
"""
if isinstance(x_field, list):
kdims = x_field
else:
kdims = [x_field]
if isinstance(y_fiel... | python | def _get_bokeh_chart(self, x_field, y_field, chart_type,
label, opts, style, options={}, **kwargs):
"""
Get a Bokeh chart object
"""
if isinstance(x_field, list):
kdims = x_field
else:
kdims = [x_field]
if isinstance(y_fiel... | [
"def",
"_get_bokeh_chart",
"(",
"self",
",",
"x_field",
",",
"y_field",
",",
"chart_type",
",",
"label",
",",
"opts",
",",
"style",
",",
"options",
"=",
"{",
"}",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"x_field",
",",
"list",
")"... | Get a Bokeh chart object | [
"Get",
"a",
"Bokeh",
"chart",
"object"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/bokeh.py#L134-L189 |
53,459 | synw/dataswim | dataswim/charts/bokeh.py | Bokeh._get_bokeh_html | def _get_bokeh_html(self, chart_obj):
"""
Get the html for a Bokeh chart
"""
global bokeh_renderer
try:
renderer = bokeh_renderer
p = renderer.get_plot(chart_obj).state
script, div = components(p)
return script + "\n" + div
... | python | def _get_bokeh_html(self, chart_obj):
"""
Get the html for a Bokeh chart
"""
global bokeh_renderer
try:
renderer = bokeh_renderer
p = renderer.get_plot(chart_obj).state
script, div = components(p)
return script + "\n" + div
... | [
"def",
"_get_bokeh_html",
"(",
"self",
",",
"chart_obj",
")",
":",
"global",
"bokeh_renderer",
"try",
":",
"renderer",
"=",
"bokeh_renderer",
"p",
"=",
"renderer",
".",
"get_plot",
"(",
"chart_obj",
")",
".",
"state",
"script",
",",
"div",
"=",
"components",... | Get the html for a Bokeh chart | [
"Get",
"the",
"html",
"for",
"a",
"Bokeh",
"chart"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/bokeh.py#L191-L204 |
53,460 | genepattern/genepattern-python | gp/data.py | GCT | def GCT(gct_obj):
"""
Create a Dataframe with the contents of the GCT file
"""
# Handle all the various initialization types and get an IO object
gct_io = _obtain_io(gct_obj)
# Load the GCT file into a DataFrame
df = pd.read_csv(gct_io, sep='\t', header=2, index_col=[0, 1], skip_blank_lines... | python | def GCT(gct_obj):
"""
Create a Dataframe with the contents of the GCT file
"""
# Handle all the various initialization types and get an IO object
gct_io = _obtain_io(gct_obj)
# Load the GCT file into a DataFrame
df = pd.read_csv(gct_io, sep='\t', header=2, index_col=[0, 1], skip_blank_lines... | [
"def",
"GCT",
"(",
"gct_obj",
")",
":",
"# Handle all the various initialization types and get an IO object",
"gct_io",
"=",
"_obtain_io",
"(",
"gct_obj",
")",
"# Load the GCT file into a DataFrame",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"gct_io",
",",
"sep",
"=",
"'... | Create a Dataframe with the contents of the GCT file | [
"Create",
"a",
"Dataframe",
"with",
"the",
"contents",
"of",
"the",
"GCT",
"file"
] | 9478ea65362b91c72a94f7300c3de8d710bebb71 | https://github.com/genepattern/genepattern-python/blob/9478ea65362b91c72a94f7300c3de8d710bebb71/gp/data.py#L23-L37 |
53,461 | genepattern/genepattern-python | gp/data.py | ODF | def ODF(odf_obj):
"""
Create a Dataframe with the contents of the ODF file
For more information on the ODF format see:
http://software.broadinstitute.org/cancer/software/genepattern/file-formats-guide
:odf_obj: The ODF file. Accepts a file-like object, a file path, a URL to the file
... | python | def ODF(odf_obj):
"""
Create a Dataframe with the contents of the ODF file
For more information on the ODF format see:
http://software.broadinstitute.org/cancer/software/genepattern/file-formats-guide
:odf_obj: The ODF file. Accepts a file-like object, a file path, a URL to the file
... | [
"def",
"ODF",
"(",
"odf_obj",
")",
":",
"# Handle all the various initialization types and get an IO object",
"odf_io",
"=",
"_obtain_io",
"(",
"odf_obj",
")",
"# Read the file as an array of lines",
"raw_lines",
"=",
"odf_io",
".",
"readlines",
"(",
")",
"# Convert byte st... | Create a Dataframe with the contents of the ODF file
For more information on the ODF format see:
http://software.broadinstitute.org/cancer/software/genepattern/file-formats-guide
:odf_obj: The ODF file. Accepts a file-like object, a file path, a URL to the file
or a string containing the raw... | [
"Create",
"a",
"Dataframe",
"with",
"the",
"contents",
"of",
"the",
"ODF",
"file"
] | 9478ea65362b91c72a94f7300c3de8d710bebb71 | https://github.com/genepattern/genepattern-python/blob/9478ea65362b91c72a94f7300c3de8d710bebb71/gp/data.py#L40-L93 |
53,462 | genepattern/genepattern-python | gp/data.py | write_odf | def write_odf(df, file_path, headers=None):
"""
Writes the provided DataFrame to a ODF file.
Assumes that the DataFrame matches the structure of those produced
by the ODF() function in this library
:param df: the DataFrame to write to ODF
:param file_path: path to which to write the ODF file
... | python | def write_odf(df, file_path, headers=None):
"""
Writes the provided DataFrame to a ODF file.
Assumes that the DataFrame matches the structure of those produced
by the ODF() function in this library
:param df: the DataFrame to write to ODF
:param file_path: path to which to write the ODF file
... | [
"def",
"write_odf",
"(",
"df",
",",
"file_path",
",",
"headers",
"=",
"None",
")",
":",
"if",
"headers",
"is",
"None",
"and",
"hasattr",
"(",
"df",
",",
"'headers'",
")",
":",
"headers",
"=",
"df",
".",
"headers",
"else",
":",
"raise",
"AttributeError"... | Writes the provided DataFrame to a ODF file.
Assumes that the DataFrame matches the structure of those produced
by the ODF() function in this library
:param df: the DataFrame to write to ODF
:param file_path: path to which to write the ODF file
:param headers: A dict of ODF headers, if none are pr... | [
"Writes",
"the",
"provided",
"DataFrame",
"to",
"a",
"ODF",
"file",
"."
] | 9478ea65362b91c72a94f7300c3de8d710bebb71 | https://github.com/genepattern/genepattern-python/blob/9478ea65362b91c72a94f7300c3de8d710bebb71/gp/data.py#L100-L119 |
53,463 | genepattern/genepattern-python | gp/data.py | write_gct | def write_gct(df, file_path):
"""
Writes the provided DataFrame to a GCT file.
Assumes that the DataFrame matches the structure of those produced
by the GCT() function in this library
:param df:
:param file_path:
:return:
"""
with open(file_path, 'w') as file:
file.write('#... | python | def write_gct(df, file_path):
"""
Writes the provided DataFrame to a GCT file.
Assumes that the DataFrame matches the structure of those produced
by the GCT() function in this library
:param df:
:param file_path:
:return:
"""
with open(file_path, 'w') as file:
file.write('#... | [
"def",
"write_gct",
"(",
"df",
",",
"file_path",
")",
":",
"with",
"open",
"(",
"file_path",
",",
"'w'",
")",
"as",
"file",
":",
"file",
".",
"write",
"(",
"'#1.2\\n'",
"+",
"str",
"(",
"len",
"(",
"df",
".",
"index",
")",
")",
"+",
"'\\t'",
"+",... | Writes the provided DataFrame to a GCT file.
Assumes that the DataFrame matches the structure of those produced
by the GCT() function in this library
:param df:
:param file_path:
:return: | [
"Writes",
"the",
"provided",
"DataFrame",
"to",
"a",
"GCT",
"file",
"."
] | 9478ea65362b91c72a94f7300c3de8d710bebb71 | https://github.com/genepattern/genepattern-python/blob/9478ea65362b91c72a94f7300c3de8d710bebb71/gp/data.py#L122-L135 |
53,464 | genepattern/genepattern-python | gp/data.py | _is_url | def _is_url(url):
"""
Used to determine if a given string represents a URL
"""
regex = 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...
... | python | def _is_url(url):
"""
Used to determine if a given string represents a URL
"""
regex = 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...
... | [
"def",
"_is_url",
"(",
"url",
")",
":",
"regex",
"=",
"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'\\d{1... | Used to determine if a given string represents a URL | [
"Used",
"to",
"determine",
"if",
"a",
"given",
"string",
"represents",
"a",
"URL"
] | 9478ea65362b91c72a94f7300c3de8d710bebb71 | https://github.com/genepattern/genepattern-python/blob/9478ea65362b91c72a94f7300c3de8d710bebb71/gp/data.py#L138-L152 |
53,465 | genepattern/genepattern-python | gp/data.py | _apply_backwards_compatibility | def _apply_backwards_compatibility(df):
"""
Attach properties to the Dataframe to make it backwards compatible with older versions of this library
:param df: The dataframe to be modified
"""
df.row_count = types.MethodType(lambda self: len(self.index), df)
df.col_count = types.MethodType(lambda... | python | def _apply_backwards_compatibility(df):
"""
Attach properties to the Dataframe to make it backwards compatible with older versions of this library
:param df: The dataframe to be modified
"""
df.row_count = types.MethodType(lambda self: len(self.index), df)
df.col_count = types.MethodType(lambda... | [
"def",
"_apply_backwards_compatibility",
"(",
"df",
")",
":",
"df",
".",
"row_count",
"=",
"types",
".",
"MethodType",
"(",
"lambda",
"self",
":",
"len",
"(",
"self",
".",
"index",
")",
",",
"df",
")",
"df",
".",
"col_count",
"=",
"types",
".",
"Method... | Attach properties to the Dataframe to make it backwards compatible with older versions of this library
:param df: The dataframe to be modified | [
"Attach",
"properties",
"to",
"the",
"Dataframe",
"to",
"make",
"it",
"backwards",
"compatible",
"with",
"older",
"versions",
"of",
"this",
"library"
] | 9478ea65362b91c72a94f7300c3de8d710bebb71 | https://github.com/genepattern/genepattern-python/blob/9478ea65362b91c72a94f7300c3de8d710bebb71/gp/data.py#L155-L163 |
53,466 | genepattern/genepattern-python | gp/data.py | _apply_odf_properties | def _apply_odf_properties(df, headers, model):
"""
Attach properties to the Dataframe to carry along ODF metadata
:param df: The dataframe to be modified
:param headers: The ODF header lines
:param model: The ODF model type
"""
df.headers = headers
df.model = model | python | def _apply_odf_properties(df, headers, model):
"""
Attach properties to the Dataframe to carry along ODF metadata
:param df: The dataframe to be modified
:param headers: The ODF header lines
:param model: The ODF model type
"""
df.headers = headers
df.model = model | [
"def",
"_apply_odf_properties",
"(",
"df",
",",
"headers",
",",
"model",
")",
":",
"df",
".",
"headers",
"=",
"headers",
"df",
".",
"model",
"=",
"model"
] | Attach properties to the Dataframe to carry along ODF metadata
:param df: The dataframe to be modified
:param headers: The ODF header lines
:param model: The ODF model type | [
"Attach",
"properties",
"to",
"the",
"Dataframe",
"to",
"carry",
"along",
"ODF",
"metadata"
] | 9478ea65362b91c72a94f7300c3de8d710bebb71 | https://github.com/genepattern/genepattern-python/blob/9478ea65362b91c72a94f7300c3de8d710bebb71/gp/data.py#L251-L260 |
53,467 | genepattern/genepattern-python | gp/data.py | _bytes_to_str | def _bytes_to_str(lines):
"""
Convert all lines from byte string to unicode string, if necessary
"""
if len(lines) >= 1 and hasattr(lines[0], 'decode'):
return [line.decode('utf-8') for line in lines]
else:
return lines | python | def _bytes_to_str(lines):
"""
Convert all lines from byte string to unicode string, if necessary
"""
if len(lines) >= 1 and hasattr(lines[0], 'decode'):
return [line.decode('utf-8') for line in lines]
else:
return lines | [
"def",
"_bytes_to_str",
"(",
"lines",
")",
":",
"if",
"len",
"(",
"lines",
")",
">=",
"1",
"and",
"hasattr",
"(",
"lines",
"[",
"0",
"]",
",",
"'decode'",
")",
":",
"return",
"[",
"line",
".",
"decode",
"(",
"'utf-8'",
")",
"for",
"line",
"in",
"... | Convert all lines from byte string to unicode string, if necessary | [
"Convert",
"all",
"lines",
"from",
"byte",
"string",
"to",
"unicode",
"string",
"if",
"necessary"
] | 9478ea65362b91c72a94f7300c3de8d710bebb71 | https://github.com/genepattern/genepattern-python/blob/9478ea65362b91c72a94f7300c3de8d710bebb71/gp/data.py#L263-L270 |
53,468 | genepattern/genepattern-python | gp/data.py | _extract_header_number | def _extract_header_number(lines):
"""
Extracts the number of header lines from the second line of the ODF file
"""
pair = _extract_header_value(lines[1])
value_list = list(pair.values())
return int(value_list[0]) | python | def _extract_header_number(lines):
"""
Extracts the number of header lines from the second line of the ODF file
"""
pair = _extract_header_value(lines[1])
value_list = list(pair.values())
return int(value_list[0]) | [
"def",
"_extract_header_number",
"(",
"lines",
")",
":",
"pair",
"=",
"_extract_header_value",
"(",
"lines",
"[",
"1",
"]",
")",
"value_list",
"=",
"list",
"(",
"pair",
".",
"values",
"(",
")",
")",
"return",
"int",
"(",
"value_list",
"[",
"0",
"]",
")... | Extracts the number of header lines from the second line of the ODF file | [
"Extracts",
"the",
"number",
"of",
"header",
"lines",
"from",
"the",
"second",
"line",
"of",
"the",
"ODF",
"file"
] | 9478ea65362b91c72a94f7300c3de8d710bebb71 | https://github.com/genepattern/genepattern-python/blob/9478ea65362b91c72a94f7300c3de8d710bebb71/gp/data.py#L315-L321 |
53,469 | genepattern/genepattern-python | gp/data.py | count_header_blanks | def count_header_blanks(lines, count):
"""
Count the number of blank lines in the header
"""
blanks = 0
for i in range(2, count + 2):
pair = _extract_header_value(lines[i])
if not pair:
blanks += 1
return blanks | python | def count_header_blanks(lines, count):
"""
Count the number of blank lines in the header
"""
blanks = 0
for i in range(2, count + 2):
pair = _extract_header_value(lines[i])
if not pair:
blanks += 1
return blanks | [
"def",
"count_header_blanks",
"(",
"lines",
",",
"count",
")",
":",
"blanks",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"2",
",",
"count",
"+",
"2",
")",
":",
"pair",
"=",
"_extract_header_value",
"(",
"lines",
"[",
"i",
"]",
")",
"if",
"not",
"pai... | Count the number of blank lines in the header | [
"Count",
"the",
"number",
"of",
"blank",
"lines",
"in",
"the",
"header"
] | 9478ea65362b91c72a94f7300c3de8d710bebb71 | https://github.com/genepattern/genepattern-python/blob/9478ea65362b91c72a94f7300c3de8d710bebb71/gp/data.py#L340-L349 |
53,470 | genepattern/genepattern-python | gp/data.py | _join_data_lines | def _join_data_lines(lines, skip):
"""
Join all the data lines into a byte string
"""
lines = list(map(str.strip, lines))
blank_lines = count_header_blanks(lines, skip)
body = lines[skip + blank_lines + 2:]
return '\n'.join(body) | python | def _join_data_lines(lines, skip):
"""
Join all the data lines into a byte string
"""
lines = list(map(str.strip, lines))
blank_lines = count_header_blanks(lines, skip)
body = lines[skip + blank_lines + 2:]
return '\n'.join(body) | [
"def",
"_join_data_lines",
"(",
"lines",
",",
"skip",
")",
":",
"lines",
"=",
"list",
"(",
"map",
"(",
"str",
".",
"strip",
",",
"lines",
")",
")",
"blank_lines",
"=",
"count_header_blanks",
"(",
"lines",
",",
"skip",
")",
"body",
"=",
"lines",
"[",
... | Join all the data lines into a byte string | [
"Join",
"all",
"the",
"data",
"lines",
"into",
"a",
"byte",
"string"
] | 9478ea65362b91c72a94f7300c3de8d710bebb71 | https://github.com/genepattern/genepattern-python/blob/9478ea65362b91c72a94f7300c3de8d710bebb71/gp/data.py#L352-L359 |
53,471 | synw/dataswim | dataswim/data/search.py | Search.contains | def contains(self, column, value):
"""
Set the main dataframe instance to rows that contains a string
value in a column
"""
df = self.df[self.df[column].str.contains(value) == True]
if df is None:
self.err("Can not select contained data")
return
... | python | def contains(self, column, value):
"""
Set the main dataframe instance to rows that contains a string
value in a column
"""
df = self.df[self.df[column].str.contains(value) == True]
if df is None:
self.err("Can not select contained data")
return
... | [
"def",
"contains",
"(",
"self",
",",
"column",
",",
"value",
")",
":",
"df",
"=",
"self",
".",
"df",
"[",
"self",
".",
"df",
"[",
"column",
"]",
".",
"str",
".",
"contains",
"(",
"value",
")",
"==",
"True",
"]",
"if",
"df",
"is",
"None",
":",
... | Set the main dataframe instance to rows that contains a string
value in a column | [
"Set",
"the",
"main",
"dataframe",
"instance",
"to",
"rows",
"that",
"contains",
"a",
"string",
"value",
"in",
"a",
"column"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/search.py#L9-L18 |
53,472 | synw/dataswim | dataswim/data/search.py | Search.ncontains | def ncontains(self, column, value):
"""
Set the main dataframe instance to rows that do not
contains a string value in a column
"""
df = self.df[self.df[column].str.contains(value) == False]
if df is None:
self.err("Can not select contained data")
... | python | def ncontains(self, column, value):
"""
Set the main dataframe instance to rows that do not
contains a string value in a column
"""
df = self.df[self.df[column].str.contains(value) == False]
if df is None:
self.err("Can not select contained data")
... | [
"def",
"ncontains",
"(",
"self",
",",
"column",
",",
"value",
")",
":",
"df",
"=",
"self",
".",
"df",
"[",
"self",
".",
"df",
"[",
"column",
"]",
".",
"str",
".",
"contains",
"(",
"value",
")",
"==",
"False",
"]",
"if",
"df",
"is",
"None",
":",... | Set the main dataframe instance to rows that do not
contains a string value in a column | [
"Set",
"the",
"main",
"dataframe",
"instance",
"to",
"rows",
"that",
"do",
"not",
"contains",
"a",
"string",
"value",
"in",
"a",
"column"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/search.py#L20-L29 |
53,473 | synw/dataswim | dataswim/data/search.py | Search.exact | def exact(self, column, *values):
"""
Sets the main dataframe to rows that has the exact string
value in a column
"""
df = self._exact(column, *values)
if df is None:
self.err("Can not select exact data")
self.df = df | python | def exact(self, column, *values):
"""
Sets the main dataframe to rows that has the exact string
value in a column
"""
df = self._exact(column, *values)
if df is None:
self.err("Can not select exact data")
self.df = df | [
"def",
"exact",
"(",
"self",
",",
"column",
",",
"*",
"values",
")",
":",
"df",
"=",
"self",
".",
"_exact",
"(",
"column",
",",
"*",
"values",
")",
"if",
"df",
"is",
"None",
":",
"self",
".",
"err",
"(",
"\"Can not select exact data\"",
")",
"self",
... | Sets the main dataframe to rows that has the exact string
value in a column | [
"Sets",
"the",
"main",
"dataframe",
"to",
"rows",
"that",
"has",
"the",
"exact",
"string",
"value",
"in",
"a",
"column"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/search.py#L31-L39 |
53,474 | synw/dataswim | dataswim/data/search.py | Search.exact_ | def exact_(self, column, *values):
"""
Returns a Dataswim instance with rows that has the exact string
value in a column
"""
df = self._exact(column, *values)
if df is None:
self.err("Can not select exact data")
return self._duplicate_(df) | python | def exact_(self, column, *values):
"""
Returns a Dataswim instance with rows that has the exact string
value in a column
"""
df = self._exact(column, *values)
if df is None:
self.err("Can not select exact data")
return self._duplicate_(df) | [
"def",
"exact_",
"(",
"self",
",",
"column",
",",
"*",
"values",
")",
":",
"df",
"=",
"self",
".",
"_exact",
"(",
"column",
",",
"*",
"values",
")",
"if",
"df",
"is",
"None",
":",
"self",
".",
"err",
"(",
"\"Can not select exact data\"",
")",
"return... | Returns a Dataswim instance with rows that has the exact string
value in a column | [
"Returns",
"a",
"Dataswim",
"instance",
"with",
"rows",
"that",
"has",
"the",
"exact",
"string",
"value",
"in",
"a",
"column"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/search.py#L41-L49 |
53,475 | wummel/dosage | dosagelib/output.py | Output.debug | def debug(self, s, level=2):
"""Write a debug message."""
self.write(s, level=level, color='white') | python | def debug(self, s, level=2):
"""Write a debug message."""
self.write(s, level=level, color='white') | [
"def",
"debug",
"(",
"self",
",",
"s",
",",
"level",
"=",
"2",
")",
":",
"self",
".",
"write",
"(",
"s",
",",
"level",
"=",
"level",
",",
"color",
"=",
"'white'",
")"
] | Write a debug message. | [
"Write",
"a",
"debug",
"message",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/output.py#L47-L49 |
53,476 | wummel/dosage | dosagelib/output.py | Output.exception | def exception(self, s):
"""Write error message with traceback info."""
self.error(s)
type, value, tb = sys.exc_info()
self.writelines(traceback.format_stack(), 1)
self.writelines(traceback.format_tb(tb)[1:], 1)
self.writelines(traceback.format_exception_only(type, value),... | python | def exception(self, s):
"""Write error message with traceback info."""
self.error(s)
type, value, tb = sys.exc_info()
self.writelines(traceback.format_stack(), 1)
self.writelines(traceback.format_tb(tb)[1:], 1)
self.writelines(traceback.format_exception_only(type, value),... | [
"def",
"exception",
"(",
"self",
",",
"s",
")",
":",
"self",
".",
"error",
"(",
"s",
")",
"type",
",",
"value",
",",
"tb",
"=",
"sys",
".",
"exc_info",
"(",
")",
"self",
".",
"writelines",
"(",
"traceback",
".",
"format_stack",
"(",
")",
",",
"1"... | Write error message with traceback info. | [
"Write",
"error",
"message",
"with",
"traceback",
"info",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/output.py#L61-L67 |
53,477 | wummel/dosage | dosagelib/output.py | Output.write | def write(self, s, level=0, color=None):
"""Write message with indentation, context and optional timestamp."""
if level > self.level:
return
if self.timestamps:
timestamp = time.strftime(u'%H:%M:%S ')
else:
timestamp = u''
with lock:
... | python | def write(self, s, level=0, color=None):
"""Write message with indentation, context and optional timestamp."""
if level > self.level:
return
if self.timestamps:
timestamp = time.strftime(u'%H:%M:%S ')
else:
timestamp = u''
with lock:
... | [
"def",
"write",
"(",
"self",
",",
"s",
",",
"level",
"=",
"0",
",",
"color",
"=",
"None",
")",
":",
"if",
"level",
">",
"self",
".",
"level",
":",
"return",
"if",
"self",
".",
"timestamps",
":",
"timestamp",
"=",
"time",
".",
"strftime",
"(",
"u'... | Write message with indentation, context and optional timestamp. | [
"Write",
"message",
"with",
"indentation",
"context",
"and",
"optional",
"timestamp",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/output.py#L69-L88 |
53,478 | wummel/dosage | dosagelib/output.py | Output.writelines | def writelines(self, lines, level=0):
"""Write multiple messages."""
for line in lines:
for line in line.rstrip(u'\n').split(u'\n'):
self.write(line.rstrip(u'\n'), level=level) | python | def writelines(self, lines, level=0):
"""Write multiple messages."""
for line in lines:
for line in line.rstrip(u'\n').split(u'\n'):
self.write(line.rstrip(u'\n'), level=level) | [
"def",
"writelines",
"(",
"self",
",",
"lines",
",",
"level",
"=",
"0",
")",
":",
"for",
"line",
"in",
"lines",
":",
"for",
"line",
"in",
"line",
".",
"rstrip",
"(",
"u'\\n'",
")",
".",
"split",
"(",
"u'\\n'",
")",
":",
"self",
".",
"write",
"(",... | Write multiple messages. | [
"Write",
"multiple",
"messages",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/output.py#L90-L94 |
53,479 | ojii/django-multilingual-ng | multilingual/templatetags/multilingual_tags.py | reorder_translation_formset_by_language_code | def reorder_translation_formset_by_language_code(inline_admin_form):
"""
Shuffle the forms in the formset of multilingual model in the
order of their language_ids.
"""
lang_to_form = dict([(form.form.initial['language_id'], form)
for form in inline_admin_form])
return [l... | python | def reorder_translation_formset_by_language_code(inline_admin_form):
"""
Shuffle the forms in the formset of multilingual model in the
order of their language_ids.
"""
lang_to_form = dict([(form.form.initial['language_id'], form)
for form in inline_admin_form])
return [l... | [
"def",
"reorder_translation_formset_by_language_code",
"(",
"inline_admin_form",
")",
":",
"lang_to_form",
"=",
"dict",
"(",
"[",
"(",
"form",
".",
"form",
".",
"initial",
"[",
"'language_id'",
"]",
",",
"form",
")",
"for",
"form",
"in",
"inline_admin_form",
"]"... | Shuffle the forms in the formset of multilingual model in the
order of their language_ids. | [
"Shuffle",
"the",
"forms",
"in",
"the",
"formset",
"of",
"multilingual",
"model",
"in",
"the",
"order",
"of",
"their",
"language_ids",
"."
] | 0d320a0732ec59949380d4b5f21e153174d3ecf7 | https://github.com/ojii/django-multilingual-ng/blob/0d320a0732ec59949380d4b5f21e153174d3ecf7/multilingual/templatetags/multilingual_tags.py#L73-L81 |
53,480 | gmr/tinman | tinman/controller.py | main | def main():
"""Invoked by the script installed by setuptools."""
parser.name('tinman')
parser.description(__desc__)
p = parser.get()
p.add_argument('-p', '--path',
action='store',
dest='path',
help='Path to prepend to the Python system path')... | python | def main():
"""Invoked by the script installed by setuptools."""
parser.name('tinman')
parser.description(__desc__)
p = parser.get()
p.add_argument('-p', '--path',
action='store',
dest='path',
help='Path to prepend to the Python system path')... | [
"def",
"main",
"(",
")",
":",
"parser",
".",
"name",
"(",
"'tinman'",
")",
"parser",
".",
"description",
"(",
"__desc__",
")",
"p",
"=",
"parser",
".",
"get",
"(",
")",
"p",
".",
"add_argument",
"(",
"'-p'",
",",
"'--path'",
",",
"action",
"=",
"'s... | Invoked by the script installed by setuptools. | [
"Invoked",
"by",
"the",
"script",
"installed",
"by",
"setuptools",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/controller.py#L164-L175 |
53,481 | gmr/tinman | tinman/controller.py | Controller.enable_debug | def enable_debug(self):
"""If the cli arg for foreground is set, set the configuration option
for debug.
"""
if self.args.foreground:
self.config.application[config.DEBUG] = True | python | def enable_debug(self):
"""If the cli arg for foreground is set, set the configuration option
for debug.
"""
if self.args.foreground:
self.config.application[config.DEBUG] = True | [
"def",
"enable_debug",
"(",
"self",
")",
":",
"if",
"self",
".",
"args",
".",
"foreground",
":",
"self",
".",
"config",
".",
"application",
"[",
"config",
".",
"DEBUG",
"]",
"=",
"True"
] | If the cli arg for foreground is set, set the configuration option
for debug. | [
"If",
"the",
"cli",
"arg",
"for",
"foreground",
"is",
"set",
"set",
"the",
"configuration",
"option",
"for",
"debug",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/controller.py#L35-L41 |
53,482 | gmr/tinman | tinman/controller.py | Controller.insert_paths | def insert_paths(self):
"""Inserts a base path into the sys.path list if one is specified in
the configuration.
"""
if self.args.path:
sys.path.insert(0, self.args.path)
if hasattr(self.config.application, config.PATHS):
if hasattr(self.config.applicatio... | python | def insert_paths(self):
"""Inserts a base path into the sys.path list if one is specified in
the configuration.
"""
if self.args.path:
sys.path.insert(0, self.args.path)
if hasattr(self.config.application, config.PATHS):
if hasattr(self.config.applicatio... | [
"def",
"insert_paths",
"(",
"self",
")",
":",
"if",
"self",
".",
"args",
".",
"path",
":",
"sys",
".",
"path",
".",
"insert",
"(",
"0",
",",
"self",
".",
"args",
".",
"path",
")",
"if",
"hasattr",
"(",
"self",
".",
"config",
".",
"application",
"... | Inserts a base path into the sys.path list if one is specified in
the configuration. | [
"Inserts",
"a",
"base",
"path",
"into",
"the",
"sys",
".",
"path",
"list",
"if",
"one",
"is",
"specified",
"in",
"the",
"configuration",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/controller.py#L43-L53 |
53,483 | gmr/tinman | tinman/controller.py | Controller.process | def process(self):
"""Check up on child processes and make sure everything is running as
it should be.
"""
children = len(self.living_children)
LOGGER.debug('%i active child%s',
children, '' if children == 1 else 'ren') | python | def process(self):
"""Check up on child processes and make sure everything is running as
it should be.
"""
children = len(self.living_children)
LOGGER.debug('%i active child%s',
children, '' if children == 1 else 'ren') | [
"def",
"process",
"(",
"self",
")",
":",
"children",
"=",
"len",
"(",
"self",
".",
"living_children",
")",
"LOGGER",
".",
"debug",
"(",
"'%i active child%s'",
",",
"children",
",",
"''",
"if",
"children",
"==",
"1",
"else",
"'ren'",
")"
] | Check up on child processes and make sure everything is running as
it should be. | [
"Check",
"up",
"on",
"child",
"processes",
"and",
"make",
"sure",
"everything",
"is",
"running",
"as",
"it",
"should",
"be",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/controller.py#L69-L76 |
53,484 | gmr/tinman | tinman/controller.py | Controller.ports_to_spawn | def ports_to_spawn(self):
"""Return the list of ports to spawn
:rtype: list
"""
return (self.config.get(config.HTTP_SERVER, dict()).get(config.PORTS)
or self.DEFAULT_PORTS) | python | def ports_to_spawn(self):
"""Return the list of ports to spawn
:rtype: list
"""
return (self.config.get(config.HTTP_SERVER, dict()).get(config.PORTS)
or self.DEFAULT_PORTS) | [
"def",
"ports_to_spawn",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"config",
".",
"get",
"(",
"config",
".",
"HTTP_SERVER",
",",
"dict",
"(",
")",
")",
".",
"get",
"(",
"config",
".",
"PORTS",
")",
"or",
"self",
".",
"DEFAULT_PORTS",
")"
] | Return the list of ports to spawn
:rtype: list | [
"Return",
"the",
"list",
"of",
"ports",
"to",
"spawn"
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/controller.py#L79-L86 |
53,485 | gmr/tinman | tinman/controller.py | Controller.set_base_path | def set_base_path(self, value):
"""Munge in the base path into the configuration values
:param str value: The path value
"""
if config.PATHS not in self.config.application:
self.config.application[config.PATHS] = dict()
if config.BASE not in self.config.application... | python | def set_base_path(self, value):
"""Munge in the base path into the configuration values
:param str value: The path value
"""
if config.PATHS not in self.config.application:
self.config.application[config.PATHS] = dict()
if config.BASE not in self.config.application... | [
"def",
"set_base_path",
"(",
"self",
",",
"value",
")",
":",
"if",
"config",
".",
"PATHS",
"not",
"in",
"self",
".",
"config",
".",
"application",
":",
"self",
".",
"config",
".",
"application",
"[",
"config",
".",
"PATHS",
"]",
"=",
"dict",
"(",
")"... | Munge in the base path into the configuration values
:param str value: The path value | [
"Munge",
"in",
"the",
"base",
"path",
"into",
"the",
"configuration",
"values"
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/controller.py#L88-L98 |
53,486 | gmr/tinman | tinman/controller.py | Controller.setup | def setup(self):
"""Additional setup steps."""
LOGGER.info('Tinman v%s starting up with Tornado v%s',
__version__, tornado_version)
# Setup debugging and paths
self.enable_debug()
self.set_base_path(os.getcwd())
self.insert_paths()
# Setup chi... | python | def setup(self):
"""Additional setup steps."""
LOGGER.info('Tinman v%s starting up with Tornado v%s',
__version__, tornado_version)
# Setup debugging and paths
self.enable_debug()
self.set_base_path(os.getcwd())
self.insert_paths()
# Setup chi... | [
"def",
"setup",
"(",
"self",
")",
":",
"LOGGER",
".",
"info",
"(",
"'Tinman v%s starting up with Tornado v%s'",
",",
"__version__",
",",
"tornado_version",
")",
"# Setup debugging and paths",
"self",
".",
"enable_debug",
"(",
")",
"self",
".",
"set_base_path",
"(",
... | Additional setup steps. | [
"Additional",
"setup",
"steps",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/controller.py#L100-L119 |
53,487 | gmr/tinman | tinman/controller.py | Controller.shutdown | def shutdown(self):
"""Send SIGABRT to child processes to instruct them to stop"""
self.signal_children(signal.SIGABRT)
# Wait a few iterations when trying to stop children before terminating
waiting = 0
while self.living_children:
time.sleep(0.5)
waiting... | python | def shutdown(self):
"""Send SIGABRT to child processes to instruct them to stop"""
self.signal_children(signal.SIGABRT)
# Wait a few iterations when trying to stop children before terminating
waiting = 0
while self.living_children:
time.sleep(0.5)
waiting... | [
"def",
"shutdown",
"(",
"self",
")",
":",
"self",
".",
"signal_children",
"(",
"signal",
".",
"SIGABRT",
")",
"# Wait a few iterations when trying to stop children before terminating",
"waiting",
"=",
"0",
"while",
"self",
".",
"living_children",
":",
"time",
".",
"... | Send SIGABRT to child processes to instruct them to stop | [
"Send",
"SIGABRT",
"to",
"child",
"processes",
"to",
"instruct",
"them",
"to",
"stop"
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/controller.py#L121-L132 |
53,488 | gmr/tinman | tinman/controller.py | Controller.signal_children | def signal_children(self, signum):
"""Send a signal to all children
:param int signum: The signal to send
"""
LOGGER.info('Sending signal %i to children', signum)
for child in self.living_children:
if child.pid != os.getpid():
os.kill(child.pid, sign... | python | def signal_children(self, signum):
"""Send a signal to all children
:param int signum: The signal to send
"""
LOGGER.info('Sending signal %i to children', signum)
for child in self.living_children:
if child.pid != os.getpid():
os.kill(child.pid, sign... | [
"def",
"signal_children",
"(",
"self",
",",
"signum",
")",
":",
"LOGGER",
".",
"info",
"(",
"'Sending signal %i to children'",
",",
"signum",
")",
"for",
"child",
"in",
"self",
".",
"living_children",
":",
"if",
"child",
".",
"pid",
"!=",
"os",
".",
"getpi... | Send a signal to all children
:param int signum: The signal to send | [
"Send",
"a",
"signal",
"to",
"all",
"children"
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/controller.py#L134-L143 |
53,489 | gmr/tinman | tinman/controller.py | Controller.spawn_process | def spawn_process(self, port):
"""Create an Application and HTTPServer for the given port.
:param int port: The port to listen on
:rtype: multiprocessing.Process
"""
return process.Process(name="ServerProcess.%i" % port,
kwargs={'namespace': self.... | python | def spawn_process(self, port):
"""Create an Application and HTTPServer for the given port.
:param int port: The port to listen on
:rtype: multiprocessing.Process
"""
return process.Process(name="ServerProcess.%i" % port,
kwargs={'namespace': self.... | [
"def",
"spawn_process",
"(",
"self",
",",
"port",
")",
":",
"return",
"process",
".",
"Process",
"(",
"name",
"=",
"\"ServerProcess.%i\"",
"%",
"port",
",",
"kwargs",
"=",
"{",
"'namespace'",
":",
"self",
".",
"namespace",
",",
"'port'",
":",
"port",
"}"... | Create an Application and HTTPServer for the given port.
:param int port: The port to listen on
:rtype: multiprocessing.Process | [
"Create",
"an",
"Application",
"and",
"HTTPServer",
"for",
"the",
"given",
"port",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/controller.py#L145-L154 |
53,490 | gmr/tinman | tinman/controller.py | Controller.spawn_processes | def spawn_processes(self):
"""Spawn of the appropriate number of application processes"""
for port in self.ports_to_spawn:
process = self.spawn_process(port)
process.start()
self.children.append(process) | python | def spawn_processes(self):
"""Spawn of the appropriate number of application processes"""
for port in self.ports_to_spawn:
process = self.spawn_process(port)
process.start()
self.children.append(process) | [
"def",
"spawn_processes",
"(",
"self",
")",
":",
"for",
"port",
"in",
"self",
".",
"ports_to_spawn",
":",
"process",
"=",
"self",
".",
"spawn_process",
"(",
"port",
")",
"process",
".",
"start",
"(",
")",
"self",
".",
"children",
".",
"append",
"(",
"p... | Spawn of the appropriate number of application processes | [
"Spawn",
"of",
"the",
"appropriate",
"number",
"of",
"application",
"processes"
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/controller.py#L156-L161 |
53,491 | AntagonistHQ/openprovider.py | openprovider/util.py | snake_to_camel | def snake_to_camel(value):
"""
Converts a snake_case_string to a camelCaseString.
>>> snake_to_camel("foo_bar_baz")
'fooBarBaz'
"""
camel = "".join(word.title() for word in value.split("_"))
return value[:1].lower() + camel[1:] | python | def snake_to_camel(value):
"""
Converts a snake_case_string to a camelCaseString.
>>> snake_to_camel("foo_bar_baz")
'fooBarBaz'
"""
camel = "".join(word.title() for word in value.split("_"))
return value[:1].lower() + camel[1:] | [
"def",
"snake_to_camel",
"(",
"value",
")",
":",
"camel",
"=",
"\"\"",
".",
"join",
"(",
"word",
".",
"title",
"(",
")",
"for",
"word",
"in",
"value",
".",
"split",
"(",
"\"_\"",
")",
")",
"return",
"value",
"[",
":",
"1",
"]",
".",
"lower",
"(",... | Converts a snake_case_string to a camelCaseString.
>>> snake_to_camel("foo_bar_baz")
'fooBarBaz' | [
"Converts",
"a",
"snake_case_string",
"to",
"a",
"camelCaseString",
"."
] | 5871c3d5b3661e23667f147f49f20389c817a0a4 | https://github.com/AntagonistHQ/openprovider.py/blob/5871c3d5b3661e23667f147f49f20389c817a0a4/openprovider/util.py#L25-L33 |
53,492 | synw/dataswim | dataswim/db/select.py | Select.getall | def getall(self, table):
"""
Get all rows values for a table
"""
try:
self._check_db()
except Exception as e:
self.err(e, "Can not connect to database")
return
if table not in self.db.tables:
self.warning("The table " + tabl... | python | def getall(self, table):
"""
Get all rows values for a table
"""
try:
self._check_db()
except Exception as e:
self.err(e, "Can not connect to database")
return
if table not in self.db.tables:
self.warning("The table " + tabl... | [
"def",
"getall",
"(",
"self",
",",
"table",
")",
":",
"try",
":",
"self",
".",
"_check_db",
"(",
")",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"err",
"(",
"e",
",",
"\"Can not connect to database\"",
")",
"return",
"if",
"table",
"not",
"in"... | Get all rows values for a table | [
"Get",
"all",
"rows",
"values",
"for",
"a",
"table"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/db/select.py#L16-L33 |
53,493 | synw/dataswim | dataswim/data/transform/calculations.py | Calculations.diffsp | def diffsp(self, col: str, serie: "iterable", name: str="Diff"):
"""
Add a diff column in percentage from a serie. The serie is
an iterable of the same length than the dataframe
:param col: column to diff
:type col: str
:param serie: serie to diff from
:type ser... | python | def diffsp(self, col: str, serie: "iterable", name: str="Diff"):
"""
Add a diff column in percentage from a serie. The serie is
an iterable of the same length than the dataframe
:param col: column to diff
:type col: str
:param serie: serie to diff from
:type ser... | [
"def",
"diffsp",
"(",
"self",
",",
"col",
":",
"str",
",",
"serie",
":",
"\"iterable\"",
",",
"name",
":",
"str",
"=",
"\"Diff\"",
")",
":",
"try",
":",
"d",
"=",
"[",
"]",
"for",
"i",
",",
"row",
"in",
"self",
".",
"df",
".",
"iterrows",
"(",
... | Add a diff column in percentage from a serie. The serie is
an iterable of the same length than the dataframe
:param col: column to diff
:type col: str
:param serie: serie to diff from
:type serie: iterable
:param name: name of the diff col, defaults to "Diff"
:p... | [
"Add",
"a",
"diff",
"column",
"in",
"percentage",
"from",
"a",
"serie",
".",
"The",
"serie",
"is",
"an",
"iterable",
"of",
"the",
"same",
"length",
"than",
"the",
"dataframe"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/calculations.py#L129-L150 |
53,494 | synw/dataswim | dataswim/data/transform/calculations.py | Calculations.gmean_ | def gmean_(self, col: str, index_col: bool=True) -> "Ds":
"""
Group by and mean column
:param col: column to group
:type col: str
:param index_col:
:type index_col: bool
:return: a dataswim instance
:rtype: Ds
:example: ``ds2 = ds.gmean("Col 1")... | python | def gmean_(self, col: str, index_col: bool=True) -> "Ds":
"""
Group by and mean column
:param col: column to group
:type col: str
:param index_col:
:type index_col: bool
:return: a dataswim instance
:rtype: Ds
:example: ``ds2 = ds.gmean("Col 1")... | [
"def",
"gmean_",
"(",
"self",
",",
"col",
":",
"str",
",",
"index_col",
":",
"bool",
"=",
"True",
")",
"->",
"\"Ds\"",
":",
"try",
":",
"df",
"=",
"self",
".",
"df",
".",
"copy",
"(",
")",
"df",
"=",
"df",
".",
"groupby",
"(",
"[",
"col",
"]"... | Group by and mean column
:param col: column to group
:type col: str
:param index_col:
:type index_col: bool
:return: a dataswim instance
:rtype: Ds
:example: ``ds2 = ds.gmean("Col 1")`` | [
"Group",
"by",
"and",
"mean",
"column"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/calculations.py#L152-L172 |
53,495 | synw/dataswim | dataswim/data/transform/calculations.py | Calculations.gsum_ | def gsum_(self, col: str, index_col: bool=True) -> "Ds":
"""
Group by and sum column
:param col: column to group
:type col: str
:param index_col:
:type index_col: bool
:return: a dataswim instance
:rtype: Ds
:example: ``ds2 = ds.gsum("Col 1")``
... | python | def gsum_(self, col: str, index_col: bool=True) -> "Ds":
"""
Group by and sum column
:param col: column to group
:type col: str
:param index_col:
:type index_col: bool
:return: a dataswim instance
:rtype: Ds
:example: ``ds2 = ds.gsum("Col 1")``
... | [
"def",
"gsum_",
"(",
"self",
",",
"col",
":",
"str",
",",
"index_col",
":",
"bool",
"=",
"True",
")",
"->",
"\"Ds\"",
":",
"try",
":",
"df",
"=",
"self",
".",
"df",
".",
"copy",
"(",
")",
"df",
"=",
"df",
".",
"groupby",
"(",
"[",
"col",
"]",... | Group by and sum column
:param col: column to group
:type col: str
:param index_col:
:type index_col: bool
:return: a dataswim instance
:rtype: Ds
:example: ``ds2 = ds.gsum("Col 1")`` | [
"Group",
"by",
"and",
"sum",
"column"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/calculations.py#L174-L194 |
53,496 | synw/dataswim | dataswim/data/transform/calculations.py | Calculations.ratio | def ratio(self, col: str, ratio_col: str="Ratio"):
"""
Add a column whith the percentages ratio from a column
:param col: column to calculate ratio from
:type col: str
:param ratio_col: new ratio column name, defaults to "Ratio"
:param ratio_col: str, optional
:... | python | def ratio(self, col: str, ratio_col: str="Ratio"):
"""
Add a column whith the percentages ratio from a column
:param col: column to calculate ratio from
:type col: str
:param ratio_col: new ratio column name, defaults to "Ratio"
:param ratio_col: str, optional
:... | [
"def",
"ratio",
"(",
"self",
",",
"col",
":",
"str",
",",
"ratio_col",
":",
"str",
"=",
"\"Ratio\"",
")",
":",
"try",
":",
"df",
"=",
"self",
".",
"df",
".",
"copy",
"(",
")",
"df",
"[",
"ratio_col",
"]",
"=",
"df",
"[",
"[",
"col",
"]",
"]",... | Add a column whith the percentages ratio from a column
:param col: column to calculate ratio from
:type col: str
:param ratio_col: new ratio column name, defaults to "Ratio"
:param ratio_col: str, optional
:example: ``ds2 = ds.ratio("Col 1")`` | [
"Add",
"a",
"column",
"whith",
"the",
"percentages",
"ratio",
"from",
"a",
"column"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/calculations.py#L196-L213 |
53,497 | gmr/tinman | tinman/model.py | Model.from_dict | def from_dict(self, value):
"""Set the values of the model based upon the content of the passed in
dictionary.
:param dict value: The dictionary of values to assign to this model
"""
for key in self.keys():
setattr(self, key, value.get(key, None)) | python | def from_dict(self, value):
"""Set the values of the model based upon the content of the passed in
dictionary.
:param dict value: The dictionary of values to assign to this model
"""
for key in self.keys():
setattr(self, key, value.get(key, None)) | [
"def",
"from_dict",
"(",
"self",
",",
"value",
")",
":",
"for",
"key",
"in",
"self",
".",
"keys",
"(",
")",
":",
"setattr",
"(",
"self",
",",
"key",
",",
"value",
".",
"get",
"(",
"key",
",",
"None",
")",
")"
] | Set the values of the model based upon the content of the passed in
dictionary.
:param dict value: The dictionary of values to assign to this model | [
"Set",
"the",
"values",
"of",
"the",
"model",
"based",
"upon",
"the",
"content",
"of",
"the",
"passed",
"in",
"dictionary",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/model.py#L93-L101 |
53,498 | gmr/tinman | tinman/model.py | Model.sha1 | def sha1(self):
"""Return a sha1 hash of the model items.
:rtype: str
"""
sha1 = hashlib.sha1(''.join(['%s:%s' % (k,v) for k,v in self.items()]))
return str(sha1.hexdigest()) | python | def sha1(self):
"""Return a sha1 hash of the model items.
:rtype: str
"""
sha1 = hashlib.sha1(''.join(['%s:%s' % (k,v) for k,v in self.items()]))
return str(sha1.hexdigest()) | [
"def",
"sha1",
"(",
"self",
")",
":",
"sha1",
"=",
"hashlib",
".",
"sha1",
"(",
"''",
".",
"join",
"(",
"[",
"'%s:%s'",
"%",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"items",
"(",
")",
"]",
")",
")",
"return",
"str"... | Return a sha1 hash of the model items.
:rtype: str | [
"Return",
"a",
"sha1",
"hash",
"of",
"the",
"model",
"items",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/model.py#L103-L110 |
53,499 | gmr/tinman | tinman/model.py | AsyncRedisModel.save | def save(self):
"""Store the model in Redis.
:rtype: bool
"""
pipeline = self._redis_client.pipeline()
pipeline.set(self._key, base64.b64encode(self.dumps()))
if self._ttl:
pipeline.expire(self._key, self._ttl)
result = yield gen.Task(pipeline.execut... | python | def save(self):
"""Store the model in Redis.
:rtype: bool
"""
pipeline = self._redis_client.pipeline()
pipeline.set(self._key, base64.b64encode(self.dumps()))
if self._ttl:
pipeline.expire(self._key, self._ttl)
result = yield gen.Task(pipeline.execut... | [
"def",
"save",
"(",
"self",
")",
":",
"pipeline",
"=",
"self",
".",
"_redis_client",
".",
"pipeline",
"(",
")",
"pipeline",
".",
"set",
"(",
"self",
".",
"_key",
",",
"base64",
".",
"b64encode",
"(",
"self",
".",
"dumps",
"(",
")",
")",
")",
"if",
... | Store the model in Redis.
:rtype: bool | [
"Store",
"the",
"model",
"in",
"Redis",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/model.py#L231-L243 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.