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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
246,800 | minhhoit/yacms | yacms/core/templatetags/yacms_tags.py | try_url | def try_url(url_name):
"""
Mimics Django's ``url`` template tag but fails silently. Used for
url names in admin templates as these won't resolve when admin
tests are running.
"""
from warnings import warn
warn("try_url is deprecated, use the url tag with the 'as' arg instead.")
try:
... | python | def try_url(url_name):
"""
Mimics Django's ``url`` template tag but fails silently. Used for
url names in admin templates as these won't resolve when admin
tests are running.
"""
from warnings import warn
warn("try_url is deprecated, use the url tag with the 'as' arg instead.")
try:
... | [
"def",
"try_url",
"(",
"url_name",
")",
":",
"from",
"warnings",
"import",
"warn",
"warn",
"(",
"\"try_url is deprecated, use the url tag with the 'as' arg instead.\"",
")",
"try",
":",
"url",
"=",
"reverse",
"(",
"url_name",
")",
"except",
"NoReverseMatch",
":",
"r... | Mimics Django's ``url`` template tag but fails silently. Used for
url names in admin templates as these won't resolve when admin
tests are running. | [
"Mimics",
"Django",
"s",
"url",
"template",
"tag",
"but",
"fails",
"silently",
".",
"Used",
"for",
"url",
"names",
"in",
"admin",
"templates",
"as",
"these",
"won",
"t",
"resolve",
"when",
"admin",
"tests",
"are",
"running",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/templatetags/yacms_tags.py#L518-L530 |
246,801 | minhhoit/yacms | yacms/core/templatetags/yacms_tags.py | admin_dropdown_menu | def admin_dropdown_menu(context):
"""
Renders the app list for the admin dropdown menu navigation.
"""
template_vars = context.flatten()
user = context["request"].user
if user.is_staff:
template_vars["dropdown_menu_app_list"] = admin_app_list(
context["request"])
if u... | python | def admin_dropdown_menu(context):
"""
Renders the app list for the admin dropdown menu navigation.
"""
template_vars = context.flatten()
user = context["request"].user
if user.is_staff:
template_vars["dropdown_menu_app_list"] = admin_app_list(
context["request"])
if u... | [
"def",
"admin_dropdown_menu",
"(",
"context",
")",
":",
"template_vars",
"=",
"context",
".",
"flatten",
"(",
")",
"user",
"=",
"context",
"[",
"\"request\"",
"]",
".",
"user",
"if",
"user",
".",
"is_staff",
":",
"template_vars",
"[",
"\"dropdown_menu_app_list... | Renders the app list for the admin dropdown menu navigation. | [
"Renders",
"the",
"app",
"list",
"for",
"the",
"admin",
"dropdown",
"menu",
"navigation",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/templatetags/yacms_tags.py#L646-L666 |
246,802 | minhhoit/yacms | yacms/core/templatetags/yacms_tags.py | dashboard_column | def dashboard_column(context, token):
"""
Takes an index for retrieving the sequence of template tags from
``yacms.conf.DASHBOARD_TAGS`` to render into the admin
dashboard.
"""
column_index = int(token.split_contents()[1])
output = []
for tag in settings.DASHBOARD_TAGS[column_index]:
... | python | def dashboard_column(context, token):
"""
Takes an index for retrieving the sequence of template tags from
``yacms.conf.DASHBOARD_TAGS`` to render into the admin
dashboard.
"""
column_index = int(token.split_contents()[1])
output = []
for tag in settings.DASHBOARD_TAGS[column_index]:
... | [
"def",
"dashboard_column",
"(",
"context",
",",
"token",
")",
":",
"column_index",
"=",
"int",
"(",
"token",
".",
"split_contents",
"(",
")",
"[",
"1",
"]",
")",
"output",
"=",
"[",
"]",
"for",
"tag",
"in",
"settings",
".",
"DASHBOARD_TAGS",
"[",
"colu... | Takes an index for retrieving the sequence of template tags from
``yacms.conf.DASHBOARD_TAGS`` to render into the admin
dashboard. | [
"Takes",
"an",
"index",
"for",
"retrieving",
"the",
"sequence",
"of",
"template",
"tags",
"from",
"yacms",
".",
"conf",
".",
"DASHBOARD_TAGS",
"to",
"render",
"into",
"the",
"admin",
"dashboard",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/templatetags/yacms_tags.py#L688-L699 |
246,803 | mushkevych/synergy_odm | odm/fields.py | BaseField.raise_error | def raise_error(self, message='', errors=None, field_name=None):
"""Raises a ValidationError. """
field_name = field_name if field_name else self.field_name
raise ValidationError(message, errors=errors, field_name=field_name) | python | def raise_error(self, message='', errors=None, field_name=None):
"""Raises a ValidationError. """
field_name = field_name if field_name else self.field_name
raise ValidationError(message, errors=errors, field_name=field_name) | [
"def",
"raise_error",
"(",
"self",
",",
"message",
"=",
"''",
",",
"errors",
"=",
"None",
",",
"field_name",
"=",
"None",
")",
":",
"field_name",
"=",
"field_name",
"if",
"field_name",
"else",
"self",
".",
"field_name",
"raise",
"ValidationError",
"(",
"me... | Raises a ValidationError. | [
"Raises",
"a",
"ValidationError",
"."
] | 3a5ac37333fc6391478564ef653a4be38e332f68 | https://github.com/mushkevych/synergy_odm/blob/3a5ac37333fc6391478564ef653a4be38e332f68/odm/fields.py#L98-L101 |
246,804 | mushkevych/synergy_odm | odm/fields.py | NestedDocumentField.validate | def validate(self, value):
"""Make sure that value is of the right type """
if not isinstance(value, self.nested_klass):
self.raise_error('NestedClass is of the wrong type: {0} vs expected {1}'
.format(value.__class__.__name__, self.nested_klass.__name__))
... | python | def validate(self, value):
"""Make sure that value is of the right type """
if not isinstance(value, self.nested_klass):
self.raise_error('NestedClass is of the wrong type: {0} vs expected {1}'
.format(value.__class__.__name__, self.nested_klass.__name__))
... | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"self",
".",
"nested_klass",
")",
":",
"self",
".",
"raise_error",
"(",
"'NestedClass is of the wrong type: {0} vs expected {1}'",
".",
"format",
"(",
"value",
... | Make sure that value is of the right type | [
"Make",
"sure",
"that",
"value",
"is",
"of",
"the",
"right",
"type"
] | 3a5ac37333fc6391478564ef653a4be38e332f68 | https://github.com/mushkevych/synergy_odm/blob/3a5ac37333fc6391478564ef653a4be38e332f68/odm/fields.py#L141-L146 |
246,805 | mushkevych/synergy_odm | odm/fields.py | ListField.validate | def validate(self, value):
"""Make sure that the inspected value is of type `list` or `tuple` """
if not isinstance(value, (list, tuple)) or isinstance(value, str_types):
self.raise_error('Only lists and tuples may be used in the ListField vs provided {0}'
.forma... | python | def validate(self, value):
"""Make sure that the inspected value is of type `list` or `tuple` """
if not isinstance(value, (list, tuple)) or isinstance(value, str_types):
self.raise_error('Only lists and tuples may be used in the ListField vs provided {0}'
.forma... | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"(",
"list",
",",
"tuple",
")",
")",
"or",
"isinstance",
"(",
"value",
",",
"str_types",
")",
":",
"self",
".",
"raise_error",
"(",
"'Only lists and t... | Make sure that the inspected value is of type `list` or `tuple` | [
"Make",
"sure",
"that",
"the",
"inspected",
"value",
"is",
"of",
"type",
"list",
"or",
"tuple"
] | 3a5ac37333fc6391478564ef653a4be38e332f68 | https://github.com/mushkevych/synergy_odm/blob/3a5ac37333fc6391478564ef653a4be38e332f68/odm/fields.py#L156-L161 |
246,806 | mushkevych/synergy_odm | odm/fields.py | DictField.validate | def validate(self, value):
"""Make sure that the inspected value is of type `dict` """
if not isinstance(value, dict):
self.raise_error('Only Python dict may be used in the DictField vs provided {0}'
.format(type(value).__name__))
super(DictField, self).v... | python | def validate(self, value):
"""Make sure that the inspected value is of type `dict` """
if not isinstance(value, dict):
self.raise_error('Only Python dict may be used in the DictField vs provided {0}'
.format(type(value).__name__))
super(DictField, self).v... | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"self",
".",
"raise_error",
"(",
"'Only Python dict may be used in the DictField vs provided {0}'",
".",
"format",
"(",
"type",
"(",
"value",
... | Make sure that the inspected value is of type `dict` | [
"Make",
"sure",
"that",
"the",
"inspected",
"value",
"is",
"of",
"type",
"dict"
] | 3a5ac37333fc6391478564ef653a4be38e332f68 | https://github.com/mushkevych/synergy_odm/blob/3a5ac37333fc6391478564ef653a4be38e332f68/odm/fields.py#L172-L177 |
246,807 | scraperwiki/data-services-helpers | dshelpers.py | install_cache | def install_cache(expire_after=12 * 3600, cache_post=False):
"""
Patches the requests library with requests_cache.
"""
allowable_methods = ['GET']
if cache_post:
allowable_methods.append('POST')
requests_cache.install_cache(
expire_after=expire_after,
allowable_methods=al... | python | def install_cache(expire_after=12 * 3600, cache_post=False):
"""
Patches the requests library with requests_cache.
"""
allowable_methods = ['GET']
if cache_post:
allowable_methods.append('POST')
requests_cache.install_cache(
expire_after=expire_after,
allowable_methods=al... | [
"def",
"install_cache",
"(",
"expire_after",
"=",
"12",
"*",
"3600",
",",
"cache_post",
"=",
"False",
")",
":",
"allowable_methods",
"=",
"[",
"'GET'",
"]",
"if",
"cache_post",
":",
"allowable_methods",
".",
"append",
"(",
"'POST'",
")",
"requests_cache",
".... | Patches the requests library with requests_cache. | [
"Patches",
"the",
"requests",
"library",
"with",
"requests_cache",
"."
] | a31ea2f40d20fd99d4c0938b87466330679db2c9 | https://github.com/scraperwiki/data-services-helpers/blob/a31ea2f40d20fd99d4c0938b87466330679db2c9/dshelpers.py#L97-L106 |
246,808 | scraperwiki/data-services-helpers | dshelpers.py | download_url | def download_url(url, back_off=True, **kwargs):
"""
Get the content of a URL and return a file-like object.
back_off=True provides retry
"""
if back_off:
return _download_with_backoff(url, as_file=True, **kwargs)
else:
return _download_without_backoff(url, as_file=True, **kwargs) | python | def download_url(url, back_off=True, **kwargs):
"""
Get the content of a URL and return a file-like object.
back_off=True provides retry
"""
if back_off:
return _download_with_backoff(url, as_file=True, **kwargs)
else:
return _download_without_backoff(url, as_file=True, **kwargs) | [
"def",
"download_url",
"(",
"url",
",",
"back_off",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"back_off",
":",
"return",
"_download_with_backoff",
"(",
"url",
",",
"as_file",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
"else",
":",
"return",... | Get the content of a URL and return a file-like object.
back_off=True provides retry | [
"Get",
"the",
"content",
"of",
"a",
"URL",
"and",
"return",
"a",
"file",
"-",
"like",
"object",
".",
"back_off",
"=",
"True",
"provides",
"retry"
] | a31ea2f40d20fd99d4c0938b87466330679db2c9 | https://github.com/scraperwiki/data-services-helpers/blob/a31ea2f40d20fd99d4c0938b87466330679db2c9/dshelpers.py#L109-L117 |
246,809 | scraperwiki/data-services-helpers | dshelpers.py | _download_without_backoff | def _download_without_backoff(url, as_file=True, method='GET', **kwargs):
"""
Get the content of a URL and return a file-like object.
"""
# Make requests consistently hashable for caching.
# 'headers' is handled by requests itself.
# 'cookies' and 'proxies' contributes to headers.
# 'files' ... | python | def _download_without_backoff(url, as_file=True, method='GET', **kwargs):
"""
Get the content of a URL and return a file-like object.
"""
# Make requests consistently hashable for caching.
# 'headers' is handled by requests itself.
# 'cookies' and 'proxies' contributes to headers.
# 'files' ... | [
"def",
"_download_without_backoff",
"(",
"url",
",",
"as_file",
"=",
"True",
",",
"method",
"=",
"'GET'",
",",
"*",
"*",
"kwargs",
")",
":",
"# Make requests consistently hashable for caching.",
"# 'headers' is handled by requests itself.",
"# 'cookies' and 'proxies' contribu... | Get the content of a URL and return a file-like object. | [
"Get",
"the",
"content",
"of",
"a",
"URL",
"and",
"return",
"a",
"file",
"-",
"like",
"object",
"."
] | a31ea2f40d20fd99d4c0938b87466330679db2c9 | https://github.com/scraperwiki/data-services-helpers/blob/a31ea2f40d20fd99d4c0938b87466330679db2c9/dshelpers.py#L137-L177 |
246,810 | scraperwiki/data-services-helpers | dshelpers.py | _is_url_in_cache | def _is_url_in_cache(*args, **kwargs):
""" Return True if request has been cached or False otherwise. """
# Only include allowed arguments for a PreparedRequest.
allowed_args = inspect.getargspec(
requests.models.PreparedRequest.prepare).args
# self is in there as .prepare() is a method.
all... | python | def _is_url_in_cache(*args, **kwargs):
""" Return True if request has been cached or False otherwise. """
# Only include allowed arguments for a PreparedRequest.
allowed_args = inspect.getargspec(
requests.models.PreparedRequest.prepare).args
# self is in there as .prepare() is a method.
all... | [
"def",
"_is_url_in_cache",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Only include allowed arguments for a PreparedRequest.",
"allowed_args",
"=",
"inspect",
".",
"getargspec",
"(",
"requests",
".",
"models",
".",
"PreparedRequest",
".",
"prepare",
")",... | Return True if request has been cached or False otherwise. | [
"Return",
"True",
"if",
"request",
"has",
"been",
"cached",
"or",
"False",
"otherwise",
"."
] | a31ea2f40d20fd99d4c0938b87466330679db2c9 | https://github.com/scraperwiki/data-services-helpers/blob/a31ea2f40d20fd99d4c0938b87466330679db2c9/dshelpers.py#L195-L215 |
246,811 | ulf1/oxyba | oxyba/block_idxmat_sets.py | block_idxmat_sets | def block_idxmat_sets(idxmat, b):
"""Reshapes idxmat into the idx vectors for the training set and validation set
Parameters:
-----------
idxmat : ndarray
Matrix with N shuffled row indicies assigned to K blocks/columns
from the oxyba.block_idxmat_shuffle function
b : int
T... | python | def block_idxmat_sets(idxmat, b):
"""Reshapes idxmat into the idx vectors for the training set and validation set
Parameters:
-----------
idxmat : ndarray
Matrix with N shuffled row indicies assigned to K blocks/columns
from the oxyba.block_idxmat_shuffle function
b : int
T... | [
"def",
"block_idxmat_sets",
"(",
"idxmat",
",",
"b",
")",
":",
"import",
"numpy",
"as",
"np",
"idx_train",
"=",
"idxmat",
"[",
":",
",",
"[",
"c",
"for",
"c",
"in",
"range",
"(",
"idxmat",
".",
"shape",
"[",
"1",
"]",
")",
"if",
"c",
"is",
"not",... | Reshapes idxmat into the idx vectors for the training set and validation set
Parameters:
-----------
idxmat : ndarray
Matrix with N shuffled row indicies assigned to K blocks/columns
from the oxyba.block_idxmat_shuffle function
b : int
The id of the current validation block b=[... | [
"Reshapes",
"idxmat",
"into",
"the",
"idx",
"vectors",
"for",
"the",
"training",
"set",
"and",
"validation",
"set"
] | b3043116050de275124365cb11e7df91fb40169d | https://github.com/ulf1/oxyba/blob/b3043116050de275124365cb11e7df91fb40169d/oxyba/block_idxmat_sets.py#L2-L35 |
246,812 | markpasc/arghlog | arghlog.py | add_logging | def add_logging(parser, log_format=LOG_FORMAT, log_level=LOG_LEVEL, color=True):
"""Configures the `argparse.ArgumentParser` with arguments to configure
logging.
This adds arguments:
* ``-v`` to increase the log level
* ``-q`` to decrease the log level
* ``--color`` to enable color logging whe... | python | def add_logging(parser, log_format=LOG_FORMAT, log_level=LOG_LEVEL, color=True):
"""Configures the `argparse.ArgumentParser` with arguments to configure
logging.
This adds arguments:
* ``-v`` to increase the log level
* ``-q`` to decrease the log level
* ``--color`` to enable color logging whe... | [
"def",
"add_logging",
"(",
"parser",
",",
"log_format",
"=",
"LOG_FORMAT",
",",
"log_level",
"=",
"LOG_LEVEL",
",",
"color",
"=",
"True",
")",
":",
"parser",
".",
"set_defaults",
"(",
"log_level",
"=",
"log_level",
")",
"parser",
".",
"add_argument",
"(",
... | Configures the `argparse.ArgumentParser` with arguments to configure
logging.
This adds arguments:
* ``-v`` to increase the log level
* ``-q`` to decrease the log level
* ``--color`` to enable color logging when available
* ``--no-color`` to disable color logging
The root logger is config... | [
"Configures",
"the",
"argparse",
".",
"ArgumentParser",
"with",
"arguments",
"to",
"configure",
"logging",
"."
] | 268c5936922b6b5e1f91acaf0390c1bf85d90dd9 | https://github.com/markpasc/arghlog/blob/268c5936922b6b5e1f91acaf0390c1bf85d90dd9/arghlog.py#L77-L133 |
246,813 | amcfague/webunit2 | webunit2/response.py | HttpResponse.assertHeader | def assertHeader(self, name, value=None, *args, **kwargs):
"""
Returns `True` if ``name`` was in the headers and, if ``value`` is
True, whether or not the values match, or `False` otherwise.
"""
return name in self.raw_headers and (
True if value is None else self.raw... | python | def assertHeader(self, name, value=None, *args, **kwargs):
"""
Returns `True` if ``name`` was in the headers and, if ``value`` is
True, whether or not the values match, or `False` otherwise.
"""
return name in self.raw_headers and (
True if value is None else self.raw... | [
"def",
"assertHeader",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"name",
"in",
"self",
".",
"raw_headers",
"and",
"(",
"True",
"if",
"value",
"is",
"None",
"else",
"self",
".... | Returns `True` if ``name`` was in the headers and, if ``value`` is
True, whether or not the values match, or `False` otherwise. | [
"Returns",
"True",
"if",
"name",
"was",
"in",
"the",
"headers",
"and",
"if",
"value",
"is",
"True",
"whether",
"or",
"not",
"the",
"values",
"match",
"or",
"False",
"otherwise",
"."
] | 3157e5837aad0810800628c1383f1fe11ee3e513 | https://github.com/amcfague/webunit2/blob/3157e5837aad0810800628c1383f1fe11ee3e513/webunit2/response.py#L59-L65 |
246,814 | cirruscluster/cirruscluster | cirruscluster/cluster/mapr.py | MaprCluster.ConfigureLazyWorkers | def ConfigureLazyWorkers(self):
""" Lazy workers are instances that are running and reachable but failed to
register with the cldb to join the mapr cluster. This trys to find these
missing workers and add them to the cluster. """
lazy_worker_instances = self.__GetMissingWorkers()
if not lazy_worke... | python | def ConfigureLazyWorkers(self):
""" Lazy workers are instances that are running and reachable but failed to
register with the cldb to join the mapr cluster. This trys to find these
missing workers and add them to the cluster. """
lazy_worker_instances = self.__GetMissingWorkers()
if not lazy_worke... | [
"def",
"ConfigureLazyWorkers",
"(",
"self",
")",
":",
"lazy_worker_instances",
"=",
"self",
".",
"__GetMissingWorkers",
"(",
")",
"if",
"not",
"lazy_worker_instances",
":",
"return",
"reachable_states",
"=",
"self",
".",
"__AreInstancesReachable",
"(",
"lazy_worker_in... | Lazy workers are instances that are running and reachable but failed to
register with the cldb to join the mapr cluster. This trys to find these
missing workers and add them to the cluster. | [
"Lazy",
"workers",
"are",
"instances",
"that",
"are",
"running",
"and",
"reachable",
"but",
"failed",
"to",
"register",
"with",
"the",
"cldb",
"to",
"join",
"the",
"mapr",
"cluster",
".",
"This",
"trys",
"to",
"find",
"these",
"missing",
"workers",
"and",
... | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/cluster/mapr.py#L289-L301 |
246,815 | cirruscluster/cirruscluster | cirruscluster/cluster/mapr.py | MaprCluster.__StartMaster | def __StartMaster(self):
""" Starts a master node, configures it, and starts services. """
num_masters = len(self.cluster.get_instances_in_role("master", "running"))
assert(num_masters < 1)
logging.info( "waiting for masters to start")
if self.config.master_on_spot_instances:
sel... | python | def __StartMaster(self):
""" Starts a master node, configures it, and starts services. """
num_masters = len(self.cluster.get_instances_in_role("master", "running"))
assert(num_masters < 1)
logging.info( "waiting for masters to start")
if self.config.master_on_spot_instances:
sel... | [
"def",
"__StartMaster",
"(",
"self",
")",
":",
"num_masters",
"=",
"len",
"(",
"self",
".",
"cluster",
".",
"get_instances_in_role",
"(",
"\"master\"",
",",
"\"running\"",
")",
")",
"assert",
"(",
"num_masters",
"<",
"1",
")",
"logging",
".",
"info",
"(",
... | Starts a master node, configures it, and starts services. | [
"Starts",
"a",
"master",
"node",
"configures",
"it",
"and",
"starts",
"services",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/cluster/mapr.py#L365-L376 |
246,816 | cirruscluster/cirruscluster | cirruscluster/cluster/mapr.py | MaprCluster.__AddWorkers | def __AddWorkers(self, num_to_add):
""" Adds workers evenly across all enabled zones."""
# Check preconditions
assert(self.__IsWebUiReady())
zone_to_ips = self.__GetZoneToWorkerIpsTable()
zone_old_new = []
for zone, ips in zone_to_ips.iteritems():
num_nodes_in_zone = le... | python | def __AddWorkers(self, num_to_add):
""" Adds workers evenly across all enabled zones."""
# Check preconditions
assert(self.__IsWebUiReady())
zone_to_ips = self.__GetZoneToWorkerIpsTable()
zone_old_new = []
for zone, ips in zone_to_ips.iteritems():
num_nodes_in_zone = le... | [
"def",
"__AddWorkers",
"(",
"self",
",",
"num_to_add",
")",
":",
"# Check preconditions",
"assert",
"(",
"self",
".",
"__IsWebUiReady",
"(",
")",
")",
"zone_to_ips",
"=",
"self",
".",
"__GetZoneToWorkerIpsTable",
"(",
")",
"zone_old_new",
"=",
"[",
"]",
"for",... | Adds workers evenly across all enabled zones. | [
"Adds",
"workers",
"evenly",
"across",
"all",
"enabled",
"zones",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/cluster/mapr.py#L536-L560 |
246,817 | cirruscluster/cirruscluster | cirruscluster/cluster/mapr.py | MaprCluster.__IpsToServerIds | def __IpsToServerIds(self):
""" Get list of mapping of ip address into a server id"""
master_instance = self.__GetMasterInstance()
assert(master_instance)
retval, response = self.__RunMaprCli('node list -columns id')
ip_to_id = {}
for line_num, line in enumerate(response.split('\n')):
toke... | python | def __IpsToServerIds(self):
""" Get list of mapping of ip address into a server id"""
master_instance = self.__GetMasterInstance()
assert(master_instance)
retval, response = self.__RunMaprCli('node list -columns id')
ip_to_id = {}
for line_num, line in enumerate(response.split('\n')):
toke... | [
"def",
"__IpsToServerIds",
"(",
"self",
")",
":",
"master_instance",
"=",
"self",
".",
"__GetMasterInstance",
"(",
")",
"assert",
"(",
"master_instance",
")",
"retval",
",",
"response",
"=",
"self",
".",
"__RunMaprCli",
"(",
"'node list -columns id'",
")",
"ip_t... | Get list of mapping of ip address into a server id | [
"Get",
"list",
"of",
"mapping",
"of",
"ip",
"address",
"into",
"a",
"server",
"id"
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/cluster/mapr.py#L995-L1007 |
246,818 | mrallen1/pygett | pygett/files.py | GettFile.contents | def contents(self):
"""
This method downloads the contents of the file represented by a `GettFile` object's metadata.
Input:
* None
Output:
* A byte stream
**NOTE**: You are responsible for handling any encoding/decoding which may be necessary.
... | python | def contents(self):
"""
This method downloads the contents of the file represented by a `GettFile` object's metadata.
Input:
* None
Output:
* A byte stream
**NOTE**: You are responsible for handling any encoding/decoding which may be necessary.
... | [
"def",
"contents",
"(",
"self",
")",
":",
"response",
"=",
"GettRequest",
"(",
")",
".",
"get",
"(",
"\"/files/%s/%s/blob\"",
"%",
"(",
"self",
".",
"sharename",
",",
"self",
".",
"fileid",
")",
")",
"return",
"response",
".",
"response"
] | This method downloads the contents of the file represented by a `GettFile` object's metadata.
Input:
* None
Output:
* A byte stream
**NOTE**: You are responsible for handling any encoding/decoding which may be necessary.
Example::
file = client.ge... | [
"This",
"method",
"downloads",
"the",
"contents",
"of",
"the",
"file",
"represented",
"by",
"a",
"GettFile",
"object",
"s",
"metadata",
"."
] | 1e21f8674a3634a901af054226670174b5ce2d87 | https://github.com/mrallen1/pygett/blob/1e21f8674a3634a901af054226670174b5ce2d87/pygett/files.py#L48-L67 |
246,819 | mrallen1/pygett | pygett/files.py | GettFile.thumbnail | def thumbnail(self):
"""
This method returns a thumbnail representation of the file if the data is a supported graphics format.
Input:
* None
Output:
* A byte stream representing a thumbnail of a support graphics file
Example::
file = clien... | python | def thumbnail(self):
"""
This method returns a thumbnail representation of the file if the data is a supported graphics format.
Input:
* None
Output:
* A byte stream representing a thumbnail of a support graphics file
Example::
file = clien... | [
"def",
"thumbnail",
"(",
"self",
")",
":",
"response",
"=",
"GettRequest",
"(",
")",
".",
"get",
"(",
"\"/files/%s/%s/blob/thumb\"",
"%",
"(",
"self",
".",
"sharename",
",",
"self",
".",
"fileid",
")",
")",
"return",
"response",
".",
"response"
] | This method returns a thumbnail representation of the file if the data is a supported graphics format.
Input:
* None
Output:
* A byte stream representing a thumbnail of a support graphics file
Example::
file = client.get_file("4ddfds", 0)
open(... | [
"This",
"method",
"returns",
"a",
"thumbnail",
"representation",
"of",
"the",
"file",
"if",
"the",
"data",
"is",
"a",
"supported",
"graphics",
"format",
"."
] | 1e21f8674a3634a901af054226670174b5ce2d87 | https://github.com/mrallen1/pygett/blob/1e21f8674a3634a901af054226670174b5ce2d87/pygett/files.py#L69-L86 |
246,820 | mrallen1/pygett | pygett/files.py | GettFile.send_data | def send_data(self, **kwargs):
"""
This method transmits data to the Gett service.
Input:
* ``put_url`` A PUT url to use when transmitting the data (required)
* ``data`` A byte stream (required)
Output:
* ``True``
Example::
if f... | python | def send_data(self, **kwargs):
"""
This method transmits data to the Gett service.
Input:
* ``put_url`` A PUT url to use when transmitting the data (required)
* ``data`` A byte stream (required)
Output:
* ``True``
Example::
if f... | [
"def",
"send_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"put_url",
"=",
"None",
"if",
"'put_url'",
"in",
"kwargs",
":",
"put_url",
"=",
"kwargs",
"[",
"'put_url'",
"]",
"else",
":",
"put_url",
"=",
"self",
".",
"put_upload_url",
"if",
"'dat... | This method transmits data to the Gett service.
Input:
* ``put_url`` A PUT url to use when transmitting the data (required)
* ``data`` A byte stream (required)
Output:
* ``True``
Example::
if file.send_data(put_url=file.upload_url, data=open("e... | [
"This",
"method",
"transmits",
"data",
"to",
"the",
"Gett",
"service",
"."
] | 1e21f8674a3634a901af054226670174b5ce2d87 | https://github.com/mrallen1/pygett/blob/1e21f8674a3634a901af054226670174b5ce2d87/pygett/files.py#L155-L189 |
246,821 | spookey/photon | photon/tools/signal.py | Signal.__signal | def __signal(self, sig, verbose=None):
'''
Helper class preventing code duplication..
:param sig:
Signal to use (e.g. "HUP", "ALRM")
:param verbose:
Overwrite :func:`photon.Photon.m`'s `verbose`
:returns:
|kill_return| with specified `pid`
... | python | def __signal(self, sig, verbose=None):
'''
Helper class preventing code duplication..
:param sig:
Signal to use (e.g. "HUP", "ALRM")
:param verbose:
Overwrite :func:`photon.Photon.m`'s `verbose`
:returns:
|kill_return| with specified `pid`
... | [
"def",
"__signal",
"(",
"self",
",",
"sig",
",",
"verbose",
"=",
"None",
")",
":",
"return",
"self",
".",
"m",
"(",
"'killing process %s with \"%s\"'",
"%",
"(",
"self",
".",
"__pid",
",",
"sig",
")",
",",
"cmdd",
"=",
"dict",
"(",
"cmd",
"=",
"'%s k... | Helper class preventing code duplication..
:param sig:
Signal to use (e.g. "HUP", "ALRM")
:param verbose:
Overwrite :func:`photon.Photon.m`'s `verbose`
:returns:
|kill_return| with specified `pid`
.. |kill_return| replace::
:func:`photon.... | [
"Helper",
"class",
"preventing",
"code",
"duplication",
".."
] | 57212a26ce713ab7723910ee49e3d0ba1697799f | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/tools/signal.py#L56-L75 |
246,822 | ulf1/oxyba | oxyba/linreg_mle.py | linreg_mle | def linreg_mle(y, X, algorithm='Nelder-Mead', debug=False):
"""MLE for Linear Regression Model
Parameters:
-----------
y : ndarray
target variable with N observations
X : ndarray
The <N x C> design matrix with C independent
variables, features, factors, etc.
algorithm ... | python | def linreg_mle(y, X, algorithm='Nelder-Mead', debug=False):
"""MLE for Linear Regression Model
Parameters:
-----------
y : ndarray
target variable with N observations
X : ndarray
The <N x C> design matrix with C independent
variables, features, factors, etc.
algorithm ... | [
"def",
"linreg_mle",
"(",
"y",
",",
"X",
",",
"algorithm",
"=",
"'Nelder-Mead'",
",",
"debug",
"=",
"False",
")",
":",
"import",
"numpy",
"as",
"np",
"import",
"scipy",
".",
"stats",
"as",
"sstat",
"import",
"scipy",
".",
"optimize",
"as",
"sopt",
"def... | MLE for Linear Regression Model
Parameters:
-----------
y : ndarray
target variable with N observations
X : ndarray
The <N x C> design matrix with C independent
variables, features, factors, etc.
algorithm : str
Optional. Default 'Nelder-Mead' (Simplex).
Th... | [
"MLE",
"for",
"Linear",
"Regression",
"Model"
] | b3043116050de275124365cb11e7df91fb40169d | https://github.com/ulf1/oxyba/blob/b3043116050de275124365cb11e7df91fb40169d/oxyba/linreg_mle.py#L2-L59 |
246,823 | delfick/gitmit | gitmit/prefix_tree.py | PrefixTree.fill | def fill(self, paths):
"""
Initialise the tree.
paths is a list of strings where each string is the relative path to some
file.
"""
for path in paths:
tree = self.tree
parts = tuple(path.split('/'))
dir_parts = parts[:-1]
b... | python | def fill(self, paths):
"""
Initialise the tree.
paths is a list of strings where each string is the relative path to some
file.
"""
for path in paths:
tree = self.tree
parts = tuple(path.split('/'))
dir_parts = parts[:-1]
b... | [
"def",
"fill",
"(",
"self",
",",
"paths",
")",
":",
"for",
"path",
"in",
"paths",
":",
"tree",
"=",
"self",
".",
"tree",
"parts",
"=",
"tuple",
"(",
"path",
".",
"split",
"(",
"'/'",
")",
")",
"dir_parts",
"=",
"parts",
"[",
":",
"-",
"1",
"]",... | Initialise the tree.
paths is a list of strings where each string is the relative path to some
file. | [
"Initialise",
"the",
"tree",
"."
] | ae0aef14a06b25ad2811f8f47cc97e68a0910eae | https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/prefix_tree.py#L59-L80 |
246,824 | delfick/gitmit | gitmit/prefix_tree.py | PrefixTree.remove | def remove(self, prefix, name):
"""
Remove a path from the tree
prefix is a tuple of the parts in the dirpath
name is a string representing the name of the file itself.
Any empty folders from the point of the file backwards to the root of
the tree is removed.
"... | python | def remove(self, prefix, name):
"""
Remove a path from the tree
prefix is a tuple of the parts in the dirpath
name is a string representing the name of the file itself.
Any empty folders from the point of the file backwards to the root of
the tree is removed.
"... | [
"def",
"remove",
"(",
"self",
",",
"prefix",
",",
"name",
")",
":",
"tree",
"=",
"self",
".",
"cache",
".",
"get",
"(",
"prefix",
",",
"empty",
")",
"if",
"tree",
"is",
"empty",
":",
"return",
"False",
"if",
"name",
"not",
"in",
"tree",
".",
"fil... | Remove a path from the tree
prefix is a tuple of the parts in the dirpath
name is a string representing the name of the file itself.
Any empty folders from the point of the file backwards to the root of
the tree is removed. | [
"Remove",
"a",
"path",
"from",
"the",
"tree"
] | ae0aef14a06b25ad2811f8f47cc97e68a0910eae | https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/prefix_tree.py#L82-L103 |
246,825 | delfick/gitmit | gitmit/prefix_tree.py | PrefixTree.remove_folder | def remove_folder(self, tree, prefix):
"""
Used to remove any empty folders
If this folder is empty then it is removed. If the parent is empty as a
result, then the parent is also removed, and so on.
"""
while True:
child = tree
tree = tree.parent... | python | def remove_folder(self, tree, prefix):
"""
Used to remove any empty folders
If this folder is empty then it is removed. If the parent is empty as a
result, then the parent is also removed, and so on.
"""
while True:
child = tree
tree = tree.parent... | [
"def",
"remove_folder",
"(",
"self",
",",
"tree",
",",
"prefix",
")",
":",
"while",
"True",
":",
"child",
"=",
"tree",
"tree",
"=",
"tree",
".",
"parent",
"if",
"not",
"child",
".",
"folders",
"and",
"not",
"child",
".",
"files",
":",
"del",
"self",
... | Used to remove any empty folders
If this folder is empty then it is removed. If the parent is empty as a
result, then the parent is also removed, and so on. | [
"Used",
"to",
"remove",
"any",
"empty",
"folders"
] | ae0aef14a06b25ad2811f8f47cc97e68a0910eae | https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/prefix_tree.py#L105-L122 |
246,826 | knagra/farnsworth | workshift/utils.py | can_manage | def can_manage(user, semester=None, pool=None, any_pool=False):
"""
Whether a user is allowed to manage a workshift semester. This includes the
current workshift managers, that semester's workshift managers, and site
superusers.
"""
if semester and user in semester.workshift_managers.all():
... | python | def can_manage(user, semester=None, pool=None, any_pool=False):
"""
Whether a user is allowed to manage a workshift semester. This includes the
current workshift managers, that semester's workshift managers, and site
superusers.
"""
if semester and user in semester.workshift_managers.all():
... | [
"def",
"can_manage",
"(",
"user",
",",
"semester",
"=",
"None",
",",
"pool",
"=",
"None",
",",
"any_pool",
"=",
"False",
")",
":",
"if",
"semester",
"and",
"user",
"in",
"semester",
".",
"workshift_managers",
".",
"all",
"(",
")",
":",
"return",
"True"... | Whether a user is allowed to manage a workshift semester. This includes the
current workshift managers, that semester's workshift managers, and site
superusers. | [
"Whether",
"a",
"user",
"is",
"allowed",
"to",
"manage",
"a",
"workshift",
"semester",
".",
"This",
"includes",
"the",
"current",
"workshift",
"managers",
"that",
"semester",
"s",
"workshift",
"managers",
"and",
"site",
"superusers",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/utils.py#L25-L47 |
246,827 | knagra/farnsworth | workshift/utils.py | get_year_season | def get_year_season(day=None):
"""
Returns a guess of the year and season of the current semester.
"""
if day is None:
day = date.today()
year = day.year
if day.month > 3 and day.month <= 7:
season = Semester.SUMMER
elif day.month > 7 and day.month <= 10:
season = Se... | python | def get_year_season(day=None):
"""
Returns a guess of the year and season of the current semester.
"""
if day is None:
day = date.today()
year = day.year
if day.month > 3 and day.month <= 7:
season = Semester.SUMMER
elif day.month > 7 and day.month <= 10:
season = Se... | [
"def",
"get_year_season",
"(",
"day",
"=",
"None",
")",
":",
"if",
"day",
"is",
"None",
":",
"day",
"=",
"date",
".",
"today",
"(",
")",
"year",
"=",
"day",
".",
"year",
"if",
"day",
".",
"month",
">",
"3",
"and",
"day",
".",
"month",
"<=",
"7"... | Returns a guess of the year and season of the current semester. | [
"Returns",
"a",
"guess",
"of",
"the",
"year",
"and",
"season",
"of",
"the",
"current",
"semester",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/utils.py#L50-L66 |
246,828 | knagra/farnsworth | workshift/utils.py | get_semester_start_end | def get_semester_start_end(year, season):
"""
Returns a guess of the start and end dates for given semester.
"""
if season == Semester.SPRING:
start_month, start_day = 1, 20
end_month, end_day = 5, 17
elif season == Semester.SUMMER:
start_month, start_day = 5, 25
end_... | python | def get_semester_start_end(year, season):
"""
Returns a guess of the start and end dates for given semester.
"""
if season == Semester.SPRING:
start_month, start_day = 1, 20
end_month, end_day = 5, 17
elif season == Semester.SUMMER:
start_month, start_day = 5, 25
end_... | [
"def",
"get_semester_start_end",
"(",
"year",
",",
"season",
")",
":",
"if",
"season",
"==",
"Semester",
".",
"SPRING",
":",
"start_month",
",",
"start_day",
"=",
"1",
",",
"20",
"end_month",
",",
"end_day",
"=",
"5",
",",
"17",
"elif",
"season",
"==",
... | Returns a guess of the start and end dates for given semester. | [
"Returns",
"a",
"guess",
"of",
"the",
"start",
"and",
"end",
"dates",
"for",
"given",
"semester",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/utils.py#L69-L83 |
246,829 | knagra/farnsworth | workshift/utils.py | randomly_assign_instances | def randomly_assign_instances(semester, pool, profiles=None, instances=None):
"""
Randomly assigns workshift instances to profiles.
Returns
-------
list of workshift.WorkshiftProfile
list of workshift.WorkshiftInstance
"""
if profiles is None:
profiles = WorkshiftProfile.objects... | python | def randomly_assign_instances(semester, pool, profiles=None, instances=None):
"""
Randomly assigns workshift instances to profiles.
Returns
-------
list of workshift.WorkshiftProfile
list of workshift.WorkshiftInstance
"""
if profiles is None:
profiles = WorkshiftProfile.objects... | [
"def",
"randomly_assign_instances",
"(",
"semester",
",",
"pool",
",",
"profiles",
"=",
"None",
",",
"instances",
"=",
"None",
")",
":",
"if",
"profiles",
"is",
"None",
":",
"profiles",
"=",
"WorkshiftProfile",
".",
"objects",
".",
"filter",
"(",
"semester",... | Randomly assigns workshift instances to profiles.
Returns
-------
list of workshift.WorkshiftProfile
list of workshift.WorkshiftInstance | [
"Randomly",
"assigns",
"workshift",
"instances",
"to",
"profiles",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/utils.py#L563-L629 |
246,830 | knagra/farnsworth | workshift/utils.py | clear_all_assignments | def clear_all_assignments(semester=None, pool=None, shifts=None):
"""
Clears all regular workshift assignments.
Parameters
----------
semester : workshift.models.Semester, optional
pool : workshift.models.WorkshiftPool, optional
If set, grab workshifts from a specific pool. Otherwise, t... | python | def clear_all_assignments(semester=None, pool=None, shifts=None):
"""
Clears all regular workshift assignments.
Parameters
----------
semester : workshift.models.Semester, optional
pool : workshift.models.WorkshiftPool, optional
If set, grab workshifts from a specific pool. Otherwise, t... | [
"def",
"clear_all_assignments",
"(",
"semester",
"=",
"None",
",",
"pool",
"=",
"None",
",",
"shifts",
"=",
"None",
")",
":",
"if",
"semester",
"is",
"None",
":",
"try",
":",
"semester",
"=",
"Semester",
".",
"objects",
".",
"get",
"(",
"current",
"=",... | Clears all regular workshift assignments.
Parameters
----------
semester : workshift.models.Semester, optional
pool : workshift.models.WorkshiftPool, optional
If set, grab workshifts from a specific pool. Otherwise, the primary
workshift pool will be used.
shifts : list of workshift... | [
"Clears",
"all",
"regular",
"workshift",
"assignments",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/utils.py#L632-L662 |
246,831 | knagra/farnsworth | workshift/utils.py | update_standings | def update_standings(semester=None, pool_hours=None, moment=None):
"""
This function acts to update a list of PoolHours objects to adjust their
current standing based on the time in the semester.
Parameters
----------
semester : workshift.models.Semester, optional
pool_hours : list of works... | python | def update_standings(semester=None, pool_hours=None, moment=None):
"""
This function acts to update a list of PoolHours objects to adjust their
current standing based on the time in the semester.
Parameters
----------
semester : workshift.models.Semester, optional
pool_hours : list of works... | [
"def",
"update_standings",
"(",
"semester",
"=",
"None",
",",
"pool_hours",
"=",
"None",
",",
"moment",
"=",
"None",
")",
":",
"if",
"semester",
"is",
"None",
":",
"try",
":",
"semester",
"=",
"Semester",
".",
"objects",
".",
"get",
"(",
"current",
"="... | This function acts to update a list of PoolHours objects to adjust their
current standing based on the time in the semester.
Parameters
----------
semester : workshift.models.Semester, optional
pool_hours : list of workshift.models.PoolHours, optional
If None, runs on all pool hours for sem... | [
"This",
"function",
"acts",
"to",
"update",
"a",
"list",
"of",
"PoolHours",
"objects",
"to",
"adjust",
"their",
"current",
"standing",
"based",
"on",
"the",
"time",
"in",
"the",
"semester",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/utils.py#L665-L703 |
246,832 | knagra/farnsworth | workshift/utils.py | reset_standings | def reset_standings(semester=None, pool_hours=None):
"""
Utility function to recalculate workshift standings. This function is meant
to only be called from the manager shell, it is not referenced anywhere
else in the workshift module.
Parameters
----------
semester : workshift.models.Semest... | python | def reset_standings(semester=None, pool_hours=None):
"""
Utility function to recalculate workshift standings. This function is meant
to only be called from the manager shell, it is not referenced anywhere
else in the workshift module.
Parameters
----------
semester : workshift.models.Semest... | [
"def",
"reset_standings",
"(",
"semester",
"=",
"None",
",",
"pool_hours",
"=",
"None",
")",
":",
"if",
"semester",
"is",
"None",
":",
"try",
":",
"semester",
"=",
"Semester",
".",
"objects",
".",
"get",
"(",
"current",
"=",
"True",
")",
"except",
"(",... | Utility function to recalculate workshift standings. This function is meant
to only be called from the manager shell, it is not referenced anywhere
else in the workshift module.
Parameters
----------
semester : workshift.models.Semester, optional
pool_hours : list of workshift.models.PoolHours,... | [
"Utility",
"function",
"to",
"recalculate",
"workshift",
"standings",
".",
"This",
"function",
"is",
"meant",
"to",
"only",
"be",
"called",
"from",
"the",
"manager",
"shell",
"it",
"is",
"not",
"referenced",
"anywhere",
"else",
"in",
"the",
"workshift",
"modul... | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/utils.py#L706-L748 |
246,833 | knagra/farnsworth | workshift/utils.py | calculate_assigned_hours | def calculate_assigned_hours(semester=None, profiles=None):
"""
Utility function to recalculate the assigned workshift hours. This function
is meant to only be called from the manager shell, it is not referenced
anywhere else in the workshift module.
Parameters
----------
semester : workshi... | python | def calculate_assigned_hours(semester=None, profiles=None):
"""
Utility function to recalculate the assigned workshift hours. This function
is meant to only be called from the manager shell, it is not referenced
anywhere else in the workshift module.
Parameters
----------
semester : workshi... | [
"def",
"calculate_assigned_hours",
"(",
"semester",
"=",
"None",
",",
"profiles",
"=",
"None",
")",
":",
"if",
"semester",
"is",
"None",
":",
"try",
":",
"semester",
"=",
"Semester",
".",
"objects",
".",
"get",
"(",
"current",
"=",
"True",
")",
"except",... | Utility function to recalculate the assigned workshift hours. This function
is meant to only be called from the manager shell, it is not referenced
anywhere else in the workshift module.
Parameters
----------
semester : workshift.models.Semester, optional
profiles : list of workshift.models.Wor... | [
"Utility",
"function",
"to",
"recalculate",
"the",
"assigned",
"workshift",
"hours",
".",
"This",
"function",
"is",
"meant",
"to",
"only",
"be",
"called",
"from",
"the",
"manager",
"shell",
"it",
"is",
"not",
"referenced",
"anywhere",
"else",
"in",
"the",
"w... | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/utils.py#L751-L778 |
246,834 | knagra/farnsworth | workshift/utils.py | reset_instance_assignments | def reset_instance_assignments(semester=None, shifts=None):
"""
Utility function to reset instance assignments. This function is meant to
only be called from the manager shell, it is not referenced anywhere else
in the workshift module.
Parameters
----------
semester : workshift.models.Seme... | python | def reset_instance_assignments(semester=None, shifts=None):
"""
Utility function to reset instance assignments. This function is meant to
only be called from the manager shell, it is not referenced anywhere else
in the workshift module.
Parameters
----------
semester : workshift.models.Seme... | [
"def",
"reset_instance_assignments",
"(",
"semester",
"=",
"None",
",",
"shifts",
"=",
"None",
")",
":",
"if",
"semester",
"is",
"None",
":",
"try",
":",
"semester",
"=",
"Semester",
".",
"objects",
".",
"get",
"(",
"current",
"=",
"True",
")",
"except",... | Utility function to reset instance assignments. This function is meant to
only be called from the manager shell, it is not referenced anywhere else
in the workshift module.
Parameters
----------
semester : workshift.models.Semester, optional
shifts : list of workshift.models.RegularWorkshift, o... | [
"Utility",
"function",
"to",
"reset",
"instance",
"assignments",
".",
"This",
"function",
"is",
"meant",
"to",
"only",
"be",
"called",
"from",
"the",
"manager",
"shell",
"it",
"is",
"not",
"referenced",
"anywhere",
"else",
"in",
"the",
"workshift",
"module",
... | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/utils.py#L781-L829 |
246,835 | xtrementl/focus | focus/daemon.py | pid_exists | def pid_exists(pid):
""" Determines if a system process identifer exists in process table.
"""
try:
os.kill(pid, 0)
except OSError as exc:
return exc.errno == errno.EPERM
else:
return True | python | def pid_exists(pid):
""" Determines if a system process identifer exists in process table.
"""
try:
os.kill(pid, 0)
except OSError as exc:
return exc.errno == errno.EPERM
else:
return True | [
"def",
"pid_exists",
"(",
"pid",
")",
":",
"try",
":",
"os",
".",
"kill",
"(",
"pid",
",",
"0",
")",
"except",
"OSError",
"as",
"exc",
":",
"return",
"exc",
".",
"errno",
"==",
"errno",
".",
"EPERM",
"else",
":",
"return",
"True"
] | Determines if a system process identifer exists in process table. | [
"Determines",
"if",
"a",
"system",
"process",
"identifer",
"exists",
"in",
"process",
"table",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/daemon.py#L54-L62 |
246,836 | xtrementl/focus | focus/daemon.py | daemonize | def daemonize(pid_file, working_dir, func):
""" Turns the current process into a daemon.
`pid_file`
File path to use as pid lock file for daemon.
`working_dir`
Working directory to switch to when daemon starts.
`func`
Callable to run after daemon is forke... | python | def daemonize(pid_file, working_dir, func):
""" Turns the current process into a daemon.
`pid_file`
File path to use as pid lock file for daemon.
`working_dir`
Working directory to switch to when daemon starts.
`func`
Callable to run after daemon is forke... | [
"def",
"daemonize",
"(",
"pid_file",
",",
"working_dir",
",",
"func",
")",
":",
"def",
"_fork",
"(",
")",
":",
"\"\"\" Fork a child process.\n\n Returns ``False`` if fork failed; otherwise,\n we are inside the new child process.\n \"\"\"",
"try",
":... | Turns the current process into a daemon.
`pid_file`
File path to use as pid lock file for daemon.
`working_dir`
Working directory to switch to when daemon starts.
`func`
Callable to run after daemon is forked. | [
"Turns",
"the",
"current",
"process",
"into",
"a",
"daemon",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/daemon.py#L65-L141 |
246,837 | xtrementl/focus | focus/daemon.py | shell_focusd | def shell_focusd(data_dir):
""" Shells a new instance of a focusd daemon process.
`data_dir`
Home directory for focusd data.
Returns boolean.
* Raises ``ValueError`` if sudo used and all passwords tries failed.
"""
command = 'focusd {0}'.format(data_dir)
# se... | python | def shell_focusd(data_dir):
""" Shells a new instance of a focusd daemon process.
`data_dir`
Home directory for focusd data.
Returns boolean.
* Raises ``ValueError`` if sudo used and all passwords tries failed.
"""
command = 'focusd {0}'.format(data_dir)
# se... | [
"def",
"shell_focusd",
"(",
"data_dir",
")",
":",
"command",
"=",
"'focusd {0}'",
".",
"format",
"(",
"data_dir",
")",
"# see what event hook plugins are registered",
"plugins",
"=",
"registration",
".",
"get_registered",
"(",
"event_hooks",
"=",
"True",
")",
"if",
... | Shells a new instance of a focusd daemon process.
`data_dir`
Home directory for focusd data.
Returns boolean.
* Raises ``ValueError`` if sudo used and all passwords tries failed. | [
"Shells",
"a",
"new",
"instance",
"of",
"a",
"focusd",
"daemon",
"process",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/daemon.py#L144-L178 |
246,838 | xtrementl/focus | focus/daemon.py | focusd | def focusd(task):
""" Forks the current process as a daemon to run a task.
`task`
``Task`` instance for the task to run.
"""
# determine if command server should be started
if registration.get_registered(event_hooks=True, root_access=True):
# root event plugins availabl... | python | def focusd(task):
""" Forks the current process as a daemon to run a task.
`task`
``Task`` instance for the task to run.
"""
# determine if command server should be started
if registration.get_registered(event_hooks=True, root_access=True):
# root event plugins availabl... | [
"def",
"focusd",
"(",
"task",
")",
":",
"# determine if command server should be started",
"if",
"registration",
".",
"get_registered",
"(",
"event_hooks",
"=",
"True",
",",
"root_access",
"=",
"True",
")",
":",
"# root event plugins available",
"start_cmd_srv",
"=",
... | Forks the current process as a daemon to run a task.
`task`
``Task`` instance for the task to run. | [
"Forks",
"the",
"current",
"process",
"as",
"a",
"daemon",
"to",
"run",
"a",
"task",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/daemon.py#L181-L197 |
246,839 | xtrementl/focus | focus/daemon.py | Focusd._reg_sighandlers | def _reg_sighandlers(self):
""" Registers signal handlers to this class.
"""
# SIGCHLD, so we shutdown when any of the child processes exit
_handler = lambda signo, frame: self.shutdown()
signal.signal(signal.SIGCHLD, _handler)
signal.signal(signal.SIGTERM, _handler) | python | def _reg_sighandlers(self):
""" Registers signal handlers to this class.
"""
# SIGCHLD, so we shutdown when any of the child processes exit
_handler = lambda signo, frame: self.shutdown()
signal.signal(signal.SIGCHLD, _handler)
signal.signal(signal.SIGTERM, _handler) | [
"def",
"_reg_sighandlers",
"(",
"self",
")",
":",
"# SIGCHLD, so we shutdown when any of the child processes exit",
"_handler",
"=",
"lambda",
"signo",
",",
"frame",
":",
"self",
".",
"shutdown",
"(",
")",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGCHLD",
",... | Registers signal handlers to this class. | [
"Registers",
"signal",
"handlers",
"to",
"this",
"class",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/daemon.py#L219-L226 |
246,840 | xtrementl/focus | focus/daemon.py | Focusd._drop_privs | def _drop_privs(self):
""" Reduces effective privileges for this process to that of the task
owner. The umask and environment variables are also modified to
recreate the environment of the user.
"""
uid = self._task.owner
# get pwd database info for task own... | python | def _drop_privs(self):
""" Reduces effective privileges for this process to that of the task
owner. The umask and environment variables are also modified to
recreate the environment of the user.
"""
uid = self._task.owner
# get pwd database info for task own... | [
"def",
"_drop_privs",
"(",
"self",
")",
":",
"uid",
"=",
"self",
".",
"_task",
".",
"owner",
"# get pwd database info for task owner",
"try",
":",
"pwd_info",
"=",
"pwd",
".",
"getpwuid",
"(",
"uid",
")",
"except",
"OSError",
":",
"pwd_info",
"=",
"None",
... | Reduces effective privileges for this process to that of the task
owner. The umask and environment variables are also modified to
recreate the environment of the user. | [
"Reduces",
"effective",
"privileges",
"for",
"this",
"process",
"to",
"that",
"of",
"the",
"task",
"owner",
".",
"The",
"umask",
"and",
"environment",
"variables",
"are",
"also",
"modified",
"to",
"recreate",
"the",
"environment",
"of",
"the",
"user",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/daemon.py#L228-L295 |
246,841 | xtrementl/focus | focus/daemon.py | Focusd.shutdown | def shutdown(self):
""" Shuts down the daemon process.
"""
if not self._exited:
self._exited = True
# signal task runner to terminate via SIGTERM
if self._task_runner.is_alive():
self._task_runner.terminate()
# if command... | python | def shutdown(self):
""" Shuts down the daemon process.
"""
if not self._exited:
self._exited = True
# signal task runner to terminate via SIGTERM
if self._task_runner.is_alive():
self._task_runner.terminate()
# if command... | [
"def",
"shutdown",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_exited",
":",
"self",
".",
"_exited",
"=",
"True",
"# signal task runner to terminate via SIGTERM",
"if",
"self",
".",
"_task_runner",
".",
"is_alive",
"(",
")",
":",
"self",
".",
"_task_r... | Shuts down the daemon process. | [
"Shuts",
"down",
"the",
"daemon",
"process",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/daemon.py#L297-L316 |
246,842 | xtrementl/focus | focus/daemon.py | Focusd.run | def run(self, start_command_srv):
""" Setup daemon process, start child forks, and sleep until
events are signalled.
`start_command_srv`
Set to ``True`` if command server should be started.
"""
if start_command_srv:
# note, this must be e... | python | def run(self, start_command_srv):
""" Setup daemon process, start child forks, and sleep until
events are signalled.
`start_command_srv`
Set to ``True`` if command server should be started.
"""
if start_command_srv:
# note, this must be e... | [
"def",
"run",
"(",
"self",
",",
"start_command_srv",
")",
":",
"if",
"start_command_srv",
":",
"# note, this must be established *before* the task runner is forked",
"# so the task runner can communicate with the command server.",
"# fork the command server",
"self",
".",
"_command_s... | Setup daemon process, start child forks, and sleep until
events are signalled.
`start_command_srv`
Set to ``True`` if command server should be started. | [
"Setup",
"daemon",
"process",
"start",
"child",
"forks",
"and",
"sleep",
"until",
"events",
"are",
"signalled",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/daemon.py#L318-L348 |
246,843 | xtrementl/focus | focus/daemon.py | Focusd.running | def running(self):
""" Determines if daemon is active.
Returns boolean.
"""
# check if task is active and pid file exists
return (not self._exited and os.path.isfile(self._pidfile)
and self._task.active) | python | def running(self):
""" Determines if daemon is active.
Returns boolean.
"""
# check if task is active and pid file exists
return (not self._exited and os.path.isfile(self._pidfile)
and self._task.active) | [
"def",
"running",
"(",
"self",
")",
":",
"# check if task is active and pid file exists",
"return",
"(",
"not",
"self",
".",
"_exited",
"and",
"os",
".",
"path",
".",
"isfile",
"(",
"self",
".",
"_pidfile",
")",
"and",
"self",
".",
"_task",
".",
"active",
... | Determines if daemon is active.
Returns boolean. | [
"Determines",
"if",
"daemon",
"is",
"active",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/daemon.py#L351-L359 |
246,844 | xtrementl/focus | focus/daemon.py | TaskProcess._register_sigterm | def _register_sigterm(self):
""" Registers SIGTERM signal handler.
"""
_handler = lambda signo, frame: self.shutdown()
signal.signal(signal.SIGTERM, _handler) | python | def _register_sigterm(self):
""" Registers SIGTERM signal handler.
"""
_handler = lambda signo, frame: self.shutdown()
signal.signal(signal.SIGTERM, _handler) | [
"def",
"_register_sigterm",
"(",
"self",
")",
":",
"_handler",
"=",
"lambda",
"signo",
",",
"frame",
":",
"self",
".",
"shutdown",
"(",
")",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGTERM",
",",
"_handler",
")"
] | Registers SIGTERM signal handler. | [
"Registers",
"SIGTERM",
"signal",
"handler",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/daemon.py#L382-L387 |
246,845 | xtrementl/focus | focus/daemon.py | TaskProcess.run | def run(self):
""" Main process loop.
"""
self._prepare()
while self.running:
if self._run() is False:
break
time.sleep(self._sleep_period)
self.shutdown() | python | def run(self):
""" Main process loop.
"""
self._prepare()
while self.running:
if self._run() is False:
break
time.sleep(self._sleep_period)
self.shutdown() | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"_prepare",
"(",
")",
"while",
"self",
".",
"running",
":",
"if",
"self",
".",
"_run",
"(",
")",
"is",
"False",
":",
"break",
"time",
".",
"sleep",
"(",
"self",
".",
"_sleep_period",
")",
"self",
... | Main process loop. | [
"Main",
"process",
"loop",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/daemon.py#L401-L412 |
246,846 | xtrementl/focus | focus/daemon.py | TaskRunner._setup_root_plugins | def _setup_root_plugins(self):
""" Injects a `run_root` method into the registered root event plugins.
"""
def run_root(_self, command):
""" Executes a shell command as root.
`command`
Shell command string.
Returns boolean.
... | python | def _setup_root_plugins(self):
""" Injects a `run_root` method into the registered root event plugins.
"""
def run_root(_self, command):
""" Executes a shell command as root.
`command`
Shell command string.
Returns boolean.
... | [
"def",
"_setup_root_plugins",
"(",
"self",
")",
":",
"def",
"run_root",
"(",
"_self",
",",
"command",
")",
":",
"\"\"\" Executes a shell command as root.\n\n `command`\n Shell command string.\n\n Returns boolean.\n \"\"\"",
... | Injects a `run_root` method into the registered root event plugins. | [
"Injects",
"a",
"run_root",
"method",
"into",
"the",
"registered",
"root",
"event",
"plugins",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/daemon.py#L447-L483 |
246,847 | xtrementl/focus | focus/daemon.py | TaskRunner._run_events | def _run_events(self, shutdown=False):
""" Runs event hooks for registered event plugins.
`shutdown`
Set to ``True`` to run task_end events;
otherwise, run task_run events.
"""
# run task_start events, if not ran already
if not self._ran_... | python | def _run_events(self, shutdown=False):
""" Runs event hooks for registered event plugins.
`shutdown`
Set to ``True`` to run task_end events;
otherwise, run task_run events.
"""
# run task_start events, if not ran already
if not self._ran_... | [
"def",
"_run_events",
"(",
"self",
",",
"shutdown",
"=",
"False",
")",
":",
"# run task_start events, if not ran already",
"if",
"not",
"self",
".",
"_ran_taskstart",
":",
"self",
".",
"_ran_taskstart",
"=",
"True",
"registration",
".",
"run_event_hooks",
"(",
"'t... | Runs event hooks for registered event plugins.
`shutdown`
Set to ``True`` to run task_end events;
otherwise, run task_run events. | [
"Runs",
"event",
"hooks",
"for",
"registered",
"event",
"plugins",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/daemon.py#L485-L506 |
246,848 | xtrementl/focus | focus/daemon.py | CommandServer._process_commands | def _process_commands(self):
""" Processes commands received and executes them accordingly.
Returns ``True`` if successful, ``False`` if connection closed or
server terminated.
"""
try:
# poll for data, so we don't block forever
if self._cmd_p... | python | def _process_commands(self):
""" Processes commands received and executes them accordingly.
Returns ``True`` if successful, ``False`` if connection closed or
server terminated.
"""
try:
# poll for data, so we don't block forever
if self._cmd_p... | [
"def",
"_process_commands",
"(",
"self",
")",
":",
"try",
":",
"# poll for data, so we don't block forever",
"if",
"self",
".",
"_cmd_pipe",
".",
"poll",
"(",
"1",
")",
":",
"# 1 sec timeout",
"payload",
"=",
"self",
".",
"_cmd_pipe",
".",
"recv_bytes",
"(",
"... | Processes commands received and executes them accordingly.
Returns ``True`` if successful, ``False`` if connection closed or
server terminated. | [
"Processes",
"commands",
"received",
"and",
"executes",
"them",
"accordingly",
".",
"Returns",
"True",
"if",
"successful",
"False",
"if",
"connection",
"closed",
"or",
"server",
"terminated",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/daemon.py#L557-L596 |
246,849 | fotonauts/fwissr-python | fwissr/source/mongodb.py | Mongodb.from_settings | def from_settings(cls, settings):
"""Read Mongodb Source configuration from the provided settings"""
if not 'mongodb' in settings or not 'collection' in settings or \
settings['mongodb'] == '' or settings['collection'] == '':
raise Exception(
"Erroneous mongod... | python | def from_settings(cls, settings):
"""Read Mongodb Source configuration from the provided settings"""
if not 'mongodb' in settings or not 'collection' in settings or \
settings['mongodb'] == '' or settings['collection'] == '':
raise Exception(
"Erroneous mongod... | [
"def",
"from_settings",
"(",
"cls",
",",
"settings",
")",
":",
"if",
"not",
"'mongodb'",
"in",
"settings",
"or",
"not",
"'collection'",
"in",
"settings",
"or",
"settings",
"[",
"'mongodb'",
"]",
"==",
"''",
"or",
"settings",
"[",
"'collection'",
"]",
"==",... | Read Mongodb Source configuration from the provided settings | [
"Read",
"Mongodb",
"Source",
"configuration",
"from",
"the",
"provided",
"settings"
] | 4314aa53ca45b4534cd312f6343a88596b4416d4 | https://github.com/fotonauts/fwissr-python/blob/4314aa53ca45b4534cd312f6343a88596b4416d4/fwissr/source/mongodb.py#L14-L44 |
246,850 | fred49/linshare-api | linshareapi/cache.py | compute_key | def compute_key(cli, familly, discriminant=None):
"""This function is used to compute a unique key from all connection parametters."""
hash_key = hashlib.sha256()
hash_key.update(familly)
hash_key.update(cli.host)
hash_key.update(cli.user)
hash_key.update(cli.password)
if discriminant:
... | python | def compute_key(cli, familly, discriminant=None):
"""This function is used to compute a unique key from all connection parametters."""
hash_key = hashlib.sha256()
hash_key.update(familly)
hash_key.update(cli.host)
hash_key.update(cli.user)
hash_key.update(cli.password)
if discriminant:
... | [
"def",
"compute_key",
"(",
"cli",
",",
"familly",
",",
"discriminant",
"=",
"None",
")",
":",
"hash_key",
"=",
"hashlib",
".",
"sha256",
"(",
")",
"hash_key",
".",
"update",
"(",
"familly",
")",
"hash_key",
".",
"update",
"(",
"cli",
".",
"host",
")",
... | This function is used to compute a unique key from all connection parametters. | [
"This",
"function",
"is",
"used",
"to",
"compute",
"a",
"unique",
"key",
"from",
"all",
"connection",
"parametters",
"."
] | be646c25aa8ba3718abb6869c620b157d53d6e41 | https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/cache.py#L18-L38 |
246,851 | fred49/linshare-api | linshareapi/cache.py | Invalid.override_familly | def override_familly(self, args):
"""Look in the current wrapped object to find a cache configuration to
override the current default configuration."""
resourceapi = args[0]
cache_cfg = resourceapi.cache
if cache_cfg.has_key('familly'):
self.familly = cache_cfg['famil... | python | def override_familly(self, args):
"""Look in the current wrapped object to find a cache configuration to
override the current default configuration."""
resourceapi = args[0]
cache_cfg = resourceapi.cache
if cache_cfg.has_key('familly'):
self.familly = cache_cfg['famil... | [
"def",
"override_familly",
"(",
"self",
",",
"args",
")",
":",
"resourceapi",
"=",
"args",
"[",
"0",
"]",
"cache_cfg",
"=",
"resourceapi",
".",
"cache",
"if",
"cache_cfg",
".",
"has_key",
"(",
"'familly'",
")",
":",
"self",
".",
"familly",
"=",
"cache_cf... | Look in the current wrapped object to find a cache configuration to
override the current default configuration. | [
"Look",
"in",
"the",
"current",
"wrapped",
"object",
"to",
"find",
"a",
"cache",
"configuration",
"to",
"override",
"the",
"current",
"default",
"configuration",
"."
] | be646c25aa8ba3718abb6869c620b157d53d6e41 | https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/cache.py#L117-L127 |
246,852 | etcher-be/elib_config | elib_config/_utils.py | friendly_type_name | def friendly_type_name(raw_type: typing.Type) -> str:
"""
Returns a user-friendly type name
:param raw_type: raw type (str, int, ...)
:return: user friendly type as string
"""
try:
return _TRANSLATE_TYPE[raw_type]
except KeyError:
LOGGER.error('unmanaged value type: %s', raw... | python | def friendly_type_name(raw_type: typing.Type) -> str:
"""
Returns a user-friendly type name
:param raw_type: raw type (str, int, ...)
:return: user friendly type as string
"""
try:
return _TRANSLATE_TYPE[raw_type]
except KeyError:
LOGGER.error('unmanaged value type: %s', raw... | [
"def",
"friendly_type_name",
"(",
"raw_type",
":",
"typing",
".",
"Type",
")",
"->",
"str",
":",
"try",
":",
"return",
"_TRANSLATE_TYPE",
"[",
"raw_type",
"]",
"except",
"KeyError",
":",
"LOGGER",
".",
"error",
"(",
"'unmanaged value type: %s'",
",",
"raw_type... | Returns a user-friendly type name
:param raw_type: raw type (str, int, ...)
:return: user friendly type as string | [
"Returns",
"a",
"user",
"-",
"friendly",
"type",
"name"
] | 5d8c839e84d70126620ab0186dc1f717e5868bd0 | https://github.com/etcher-be/elib_config/blob/5d8c839e84d70126620ab0186dc1f717e5868bd0/elib_config/_utils.py#L28-L39 |
246,853 | smartmob-project/dotenvfile | dotenvfile/__init__.py | loads | def loads(content):
"""Loads variable definitions from a string."""
lines = _group_lines(line for line in content.split('\n'))
lines = [
(i, _parse_envfile_line(line))
for i, line in lines if line.strip()
]
errors = []
# Reject files with duplicate variables (no sane default).
... | python | def loads(content):
"""Loads variable definitions from a string."""
lines = _group_lines(line for line in content.split('\n'))
lines = [
(i, _parse_envfile_line(line))
for i, line in lines if line.strip()
]
errors = []
# Reject files with duplicate variables (no sane default).
... | [
"def",
"loads",
"(",
"content",
")",
":",
"lines",
"=",
"_group_lines",
"(",
"line",
"for",
"line",
"in",
"content",
".",
"split",
"(",
"'\\n'",
")",
")",
"lines",
"=",
"[",
"(",
"i",
",",
"_parse_envfile_line",
"(",
"line",
")",
")",
"for",
"i",
"... | Loads variable definitions from a string. | [
"Loads",
"variable",
"definitions",
"from",
"a",
"string",
"."
] | 8a71eddfe73669c8fcd97a0062845257753ad85a | https://github.com/smartmob-project/dotenvfile/blob/8a71eddfe73669c8fcd97a0062845257753ad85a/dotenvfile/__init__.py#L73-L92 |
246,854 | Vesuvium/aratrum | aratrum/Aratrum.py | Aratrum.get | def get(self):
"""
Loads the configuration and returns it as a dictionary
"""
with open(self.filename, 'r') as f:
self.config = ujson.load(f)
return self.config | python | def get(self):
"""
Loads the configuration and returns it as a dictionary
"""
with open(self.filename, 'r') as f:
self.config = ujson.load(f)
return self.config | [
"def",
"get",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"filename",
",",
"'r'",
")",
"as",
"f",
":",
"self",
".",
"config",
"=",
"ujson",
".",
"load",
"(",
"f",
")",
"return",
"self",
".",
"config"
] | Loads the configuration and returns it as a dictionary | [
"Loads",
"the",
"configuration",
"and",
"returns",
"it",
"as",
"a",
"dictionary"
] | 7d237fe0c2afd615cf758a2a6485e93fa879b7e1 | https://github.com/Vesuvium/aratrum/blob/7d237fe0c2afd615cf758a2a6485e93fa879b7e1/aratrum/Aratrum.py#L17-L23 |
246,855 | Vesuvium/aratrum | aratrum/Aratrum.py | Aratrum.set | def set(self, option, value):
"""
Sets an option to a value.
"""
if self.config is None:
self.config = {}
self.config[option] = value | python | def set(self, option, value):
"""
Sets an option to a value.
"""
if self.config is None:
self.config = {}
self.config[option] = value | [
"def",
"set",
"(",
"self",
",",
"option",
",",
"value",
")",
":",
"if",
"self",
".",
"config",
"is",
"None",
":",
"self",
".",
"config",
"=",
"{",
"}",
"self",
".",
"config",
"[",
"option",
"]",
"=",
"value"
] | Sets an option to a value. | [
"Sets",
"an",
"option",
"to",
"a",
"value",
"."
] | 7d237fe0c2afd615cf758a2a6485e93fa879b7e1 | https://github.com/Vesuvium/aratrum/blob/7d237fe0c2afd615cf758a2a6485e93fa879b7e1/aratrum/Aratrum.py#L31-L37 |
246,856 | Vesuvium/aratrum | aratrum/Aratrum.py | Aratrum.delete | def delete(self, option):
"""
Deletes an option if exists
"""
if self.config is not None:
if option in self.config:
del self.config[option] | python | def delete(self, option):
"""
Deletes an option if exists
"""
if self.config is not None:
if option in self.config:
del self.config[option] | [
"def",
"delete",
"(",
"self",
",",
"option",
")",
":",
"if",
"self",
".",
"config",
"is",
"not",
"None",
":",
"if",
"option",
"in",
"self",
".",
"config",
":",
"del",
"self",
".",
"config",
"[",
"option",
"]"
] | Deletes an option if exists | [
"Deletes",
"an",
"option",
"if",
"exists"
] | 7d237fe0c2afd615cf758a2a6485e93fa879b7e1 | https://github.com/Vesuvium/aratrum/blob/7d237fe0c2afd615cf758a2a6485e93fa879b7e1/aratrum/Aratrum.py#L39-L45 |
246,857 | Vesuvium/aratrum | aratrum/Aratrum.py | Aratrum.save | def save(self):
"""
Saves the configuration
"""
with open(self.filename, 'w') as f:
ujson.dump(self.config, f, indent=4) | python | def save(self):
"""
Saves the configuration
"""
with open(self.filename, 'w') as f:
ujson.dump(self.config, f, indent=4) | [
"def",
"save",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"filename",
",",
"'w'",
")",
"as",
"f",
":",
"ujson",
".",
"dump",
"(",
"self",
".",
"config",
",",
"f",
",",
"indent",
"=",
"4",
")"
] | Saves the configuration | [
"Saves",
"the",
"configuration"
] | 7d237fe0c2afd615cf758a2a6485e93fa879b7e1 | https://github.com/Vesuvium/aratrum/blob/7d237fe0c2afd615cf758a2a6485e93fa879b7e1/aratrum/Aratrum.py#L47-L52 |
246,858 | bmweiner/skillful | skillful/validate.py | timestamp | def timestamp(stamp, tolerance=150):
"""Validate timestamp specified by request.
See `validate.request` for additional info.
Args:
stamp: str. Time request was made as ISO 8601 timestamp.
tolerance: int. Number of seconds request remains valid from timestamp.
Returns
bool: Tru... | python | def timestamp(stamp, tolerance=150):
"""Validate timestamp specified by request.
See `validate.request` for additional info.
Args:
stamp: str. Time request was made as ISO 8601 timestamp.
tolerance: int. Number of seconds request remains valid from timestamp.
Returns
bool: Tru... | [
"def",
"timestamp",
"(",
"stamp",
",",
"tolerance",
"=",
"150",
")",
":",
"try",
":",
"tolerance",
"=",
"datetime",
".",
"timedelta",
"(",
"0",
",",
"tolerance",
")",
"timestamp_low",
"=",
"dateutil",
".",
"parser",
".",
"parse",
"(",
"stamp",
")",
"ti... | Validate timestamp specified by request.
See `validate.request` for additional info.
Args:
stamp: str. Time request was made as ISO 8601 timestamp.
tolerance: int. Number of seconds request remains valid from timestamp.
Returns
bool: True if valid, False otherwise. | [
"Validate",
"timestamp",
"specified",
"by",
"request",
"."
] | 8646f54faf62cb63f165f7699b8ace5b4a08233c | https://github.com/bmweiner/skillful/blob/8646f54faf62cb63f165f7699b8ace5b4a08233c/skillful/validate.py#L21-L41 |
246,859 | bmweiner/skillful | skillful/validate.py | signature_cert_chain_url | def signature_cert_chain_url(url):
"""Validate URL specified by SignatureCertChainUrl.
See `validate.request` for additional info.
Args:
url: str. SignatureCertChainUrl header value sent by request.
Returns:
bool: True if valid, False otherwise.
"""
r = urlparse(url)
if no... | python | def signature_cert_chain_url(url):
"""Validate URL specified by SignatureCertChainUrl.
See `validate.request` for additional info.
Args:
url: str. SignatureCertChainUrl header value sent by request.
Returns:
bool: True if valid, False otherwise.
"""
r = urlparse(url)
if no... | [
"def",
"signature_cert_chain_url",
"(",
"url",
")",
":",
"r",
"=",
"urlparse",
"(",
"url",
")",
"if",
"not",
"r",
".",
"scheme",
".",
"lower",
"(",
")",
"==",
"'https'",
":",
"warnings",
".",
"warn",
"(",
"'Certificate URL scheme is invalid.'",
")",
"retur... | Validate URL specified by SignatureCertChainUrl.
See `validate.request` for additional info.
Args:
url: str. SignatureCertChainUrl header value sent by request.
Returns:
bool: True if valid, False otherwise. | [
"Validate",
"URL",
"specified",
"by",
"SignatureCertChainUrl",
"."
] | 8646f54faf62cb63f165f7699b8ace5b4a08233c | https://github.com/bmweiner/skillful/blob/8646f54faf62cb63f165f7699b8ace5b4a08233c/skillful/validate.py#L43-L67 |
246,860 | bmweiner/skillful | skillful/validate.py | retrieve | def retrieve(url):
"""Retrieve and parse PEM-encoded X.509 certificate chain.
See `validate.request` for additional info.
Args:
url: str. SignatureCertChainUrl header value sent by request.
Returns:
list or bool: If url is valid, returns the certificate chain as a list
of ... | python | def retrieve(url):
"""Retrieve and parse PEM-encoded X.509 certificate chain.
See `validate.request` for additional info.
Args:
url: str. SignatureCertChainUrl header value sent by request.
Returns:
list or bool: If url is valid, returns the certificate chain as a list
of ... | [
"def",
"retrieve",
"(",
"url",
")",
":",
"try",
":",
"pem_data",
"=",
"urlopen",
"(",
"url",
")",
".",
"read",
"(",
")",
"except",
"(",
"ValueError",
",",
"HTTPError",
")",
":",
"warnings",
".",
"warn",
"(",
"'Certificate URL is invalid.'",
")",
"return"... | Retrieve and parse PEM-encoded X.509 certificate chain.
See `validate.request` for additional info.
Args:
url: str. SignatureCertChainUrl header value sent by request.
Returns:
list or bool: If url is valid, returns the certificate chain as a list
of cryptography.hazmat.backen... | [
"Retrieve",
"and",
"parse",
"PEM",
"-",
"encoded",
"X",
".",
"509",
"certificate",
"chain",
"."
] | 8646f54faf62cb63f165f7699b8ace5b4a08233c | https://github.com/bmweiner/skillful/blob/8646f54faf62cb63f165f7699b8ace5b4a08233c/skillful/validate.py#L69-L96 |
246,861 | bmweiner/skillful | skillful/validate.py | _parse_pem_data | def _parse_pem_data(pem_data):
"""Parse PEM-encoded X.509 certificate chain.
Args:
pem_data: str. PEM file retrieved from SignatureCertChainUrl.
Returns:
list or bool: If url is valid, returns the certificate chain as a list
of cryptography.hazmat.backends.openssl.x509._Certifi... | python | def _parse_pem_data(pem_data):
"""Parse PEM-encoded X.509 certificate chain.
Args:
pem_data: str. PEM file retrieved from SignatureCertChainUrl.
Returns:
list or bool: If url is valid, returns the certificate chain as a list
of cryptography.hazmat.backends.openssl.x509._Certifi... | [
"def",
"_parse_pem_data",
"(",
"pem_data",
")",
":",
"sep",
"=",
"'-----BEGIN CERTIFICATE-----'",
"cert_chain",
"=",
"[",
"six",
".",
"b",
"(",
"sep",
"+",
"s",
")",
"for",
"s",
"in",
"pem_data",
".",
"split",
"(",
"sep",
")",
"[",
"1",
":",
"]",
"]"... | Parse PEM-encoded X.509 certificate chain.
Args:
pem_data: str. PEM file retrieved from SignatureCertChainUrl.
Returns:
list or bool: If url is valid, returns the certificate chain as a list
of cryptography.hazmat.backends.openssl.x509._Certificate
certificates where ce... | [
"Parse",
"PEM",
"-",
"encoded",
"X",
".",
"509",
"certificate",
"chain",
"."
] | 8646f54faf62cb63f165f7699b8ace5b4a08233c | https://github.com/bmweiner/skillful/blob/8646f54faf62cb63f165f7699b8ace5b4a08233c/skillful/validate.py#L98-L121 |
246,862 | bmweiner/skillful | skillful/validate.py | cert_chain | def cert_chain(certs):
"""Validate PEM-encoded X.509 certificate chain.
See `validate.request` for additional info.
Args:
certs: list. The certificate chain as a list of
cryptography.hazmat.backends.openssl.x509._Certificate certificates.
See `validate.retrieve` to create c... | python | def cert_chain(certs):
"""Validate PEM-encoded X.509 certificate chain.
See `validate.request` for additional info.
Args:
certs: list. The certificate chain as a list of
cryptography.hazmat.backends.openssl.x509._Certificate certificates.
See `validate.retrieve` to create c... | [
"def",
"cert_chain",
"(",
"certs",
")",
":",
"if",
"len",
"(",
"certs",
")",
"<",
"2",
":",
"warnings",
".",
"warn",
"(",
"'Certificate chain contains < 3 certificates.'",
")",
"return",
"False",
"cert",
"=",
"certs",
"[",
"0",
"]",
"today",
"=",
"datetime... | Validate PEM-encoded X.509 certificate chain.
See `validate.request` for additional info.
Args:
certs: list. The certificate chain as a list of
cryptography.hazmat.backends.openssl.x509._Certificate certificates.
See `validate.retrieve` to create certs obj.
Returns:
... | [
"Validate",
"PEM",
"-",
"encoded",
"X",
".",
"509",
"certificate",
"chain",
"."
] | 8646f54faf62cb63f165f7699b8ace5b4a08233c | https://github.com/bmweiner/skillful/blob/8646f54faf62cb63f165f7699b8ace5b4a08233c/skillful/validate.py#L123-L159 |
246,863 | bmweiner/skillful | skillful/validate.py | signature | def signature(cert, sig, body):
"""Validate data request signature.
See `validate.request` for additional info.
Args:
cert: cryptography.hazmat.backends.openssl.x509._Certificate. The Amazon
signing certificate.
sig: str. Signature header value sent by request.
body: st... | python | def signature(cert, sig, body):
"""Validate data request signature.
See `validate.request` for additional info.
Args:
cert: cryptography.hazmat.backends.openssl.x509._Certificate. The Amazon
signing certificate.
sig: str. Signature header value sent by request.
body: st... | [
"def",
"signature",
"(",
"cert",
",",
"sig",
",",
"body",
")",
":",
"body",
"=",
"six",
".",
"b",
"(",
"body",
")",
"sig",
"=",
"base64",
".",
"decodestring",
"(",
"sig",
")",
"padder",
"=",
"padding",
".",
"PKCS1v15",
"(",
")",
"public_key",
"=",
... | Validate data request signature.
See `validate.request` for additional info.
Args:
cert: cryptography.hazmat.backends.openssl.x509._Certificate. The Amazon
signing certificate.
sig: str. Signature header value sent by request.
body: str. HTTPS request body.
Returns:
... | [
"Validate",
"data",
"request",
"signature",
"."
] | 8646f54faf62cb63f165f7699b8ace5b4a08233c | https://github.com/bmweiner/skillful/blob/8646f54faf62cb63f165f7699b8ace5b4a08233c/skillful/validate.py#L161-L185 |
246,864 | bmweiner/skillful | skillful/validate.py | Valid.application_id | def application_id(self, app_id):
"""Validate request application id matches true application id.
Verifying the Application ID matches: https://goo.gl/qAdqe4.
Args:
app_id: str. Request application_id.
Returns:
bool: True if valid, False otherwise.
"""
... | python | def application_id(self, app_id):
"""Validate request application id matches true application id.
Verifying the Application ID matches: https://goo.gl/qAdqe4.
Args:
app_id: str. Request application_id.
Returns:
bool: True if valid, False otherwise.
"""
... | [
"def",
"application_id",
"(",
"self",
",",
"app_id",
")",
":",
"if",
"self",
".",
"app_id",
"!=",
"app_id",
":",
"warnings",
".",
"warn",
"(",
"'Application ID is invalid.'",
")",
"return",
"False",
"return",
"True"
] | Validate request application id matches true application id.
Verifying the Application ID matches: https://goo.gl/qAdqe4.
Args:
app_id: str. Request application_id.
Returns:
bool: True if valid, False otherwise. | [
"Validate",
"request",
"application",
"id",
"matches",
"true",
"application",
"id",
"."
] | 8646f54faf62cb63f165f7699b8ace5b4a08233c | https://github.com/bmweiner/skillful/blob/8646f54faf62cb63f165f7699b8ace5b4a08233c/skillful/validate.py#L204-L218 |
246,865 | bmweiner/skillful | skillful/validate.py | Valid.sender | def sender(self, body, stamp, url, sig):
"""Validate request is from Alexa.
Verifying that the Request was Sent by Alexa: https://goo.gl/AcrzB5.
Checking the Signature of the Request: https://goo.gl/FDkjBN.
Checking the Timestamp of the Request: https://goo.gl/Z5JhqZ
Args:
... | python | def sender(self, body, stamp, url, sig):
"""Validate request is from Alexa.
Verifying that the Request was Sent by Alexa: https://goo.gl/AcrzB5.
Checking the Signature of the Request: https://goo.gl/FDkjBN.
Checking the Timestamp of the Request: https://goo.gl/Z5JhqZ
Args:
... | [
"def",
"sender",
"(",
"self",
",",
"body",
",",
"stamp",
",",
"url",
",",
"sig",
")",
":",
"if",
"not",
"timestamp",
"(",
"stamp",
")",
":",
"return",
"False",
"if",
"self",
".",
"url",
"!=",
"url",
":",
"if",
"not",
"signature_cert_chain_url",
"(",
... | Validate request is from Alexa.
Verifying that the Request was Sent by Alexa: https://goo.gl/AcrzB5.
Checking the Signature of the Request: https://goo.gl/FDkjBN.
Checking the Timestamp of the Request: https://goo.gl/Z5JhqZ
Args:
body: str. HTTPS request body.
s... | [
"Validate",
"request",
"is",
"from",
"Alexa",
"."
] | 8646f54faf62cb63f165f7699b8ace5b4a08233c | https://github.com/bmweiner/skillful/blob/8646f54faf62cb63f165f7699b8ace5b4a08233c/skillful/validate.py#L220-L258 |
246,866 | bmweiner/skillful | skillful/validate.py | Valid.request | def request(self, app_id=None, body=None, stamp=None, url=None, sig=None):
"""Validate application ID and request is from Alexa."""
if self.app_id:
if not self.application_id(app_id):
return False
if (url or sig):
if not (body and stamp and url and sig):
... | python | def request(self, app_id=None, body=None, stamp=None, url=None, sig=None):
"""Validate application ID and request is from Alexa."""
if self.app_id:
if not self.application_id(app_id):
return False
if (url or sig):
if not (body and stamp and url and sig):
... | [
"def",
"request",
"(",
"self",
",",
"app_id",
"=",
"None",
",",
"body",
"=",
"None",
",",
"stamp",
"=",
"None",
",",
"url",
"=",
"None",
",",
"sig",
"=",
"None",
")",
":",
"if",
"self",
".",
"app_id",
":",
"if",
"not",
"self",
".",
"application_i... | Validate application ID and request is from Alexa. | [
"Validate",
"application",
"ID",
"and",
"request",
"is",
"from",
"Alexa",
"."
] | 8646f54faf62cb63f165f7699b8ace5b4a08233c | https://github.com/bmweiner/skillful/blob/8646f54faf62cb63f165f7699b8ace5b4a08233c/skillful/validate.py#L260-L273 |
246,867 | evetrivia/thanatos | thanatos/database/db_utils.py | load_tables_from_files | def load_tables_from_files(db_connection):
""" Looks in the current working directory for all required tables. """
_log.info('Loading tables from disk to DB.')
sde_dir_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'sde')
for sde_file_name in os.listdir(sde_dir_path):
_log.i... | python | def load_tables_from_files(db_connection):
""" Looks in the current working directory for all required tables. """
_log.info('Loading tables from disk to DB.')
sde_dir_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'sde')
for sde_file_name in os.listdir(sde_dir_path):
_log.i... | [
"def",
"load_tables_from_files",
"(",
"db_connection",
")",
":",
"_log",
".",
"info",
"(",
"'Loading tables from disk to DB.'",
")",
"sde_dir_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"... | Looks in the current working directory for all required tables. | [
"Looks",
"in",
"the",
"current",
"working",
"directory",
"for",
"all",
"required",
"tables",
"."
] | 664c12a8ccf4d27ab0e06e0969bbb6381f74789c | https://github.com/evetrivia/thanatos/blob/664c12a8ccf4d27ab0e06e0969bbb6381f74789c/thanatos/database/db_utils.py#L84-L100 |
246,868 | evetrivia/thanatos | thanatos/database/db_utils.py | get_connection | def get_connection(connection_details=None):
""" Creates a connection to the MySQL DB. """
if connection_details is None:
connection_details = get_default_connection_details()
return MySQLdb.connect(
connection_details['host'],
connection_details['user'],
connection_details... | python | def get_connection(connection_details=None):
""" Creates a connection to the MySQL DB. """
if connection_details is None:
connection_details = get_default_connection_details()
return MySQLdb.connect(
connection_details['host'],
connection_details['user'],
connection_details... | [
"def",
"get_connection",
"(",
"connection_details",
"=",
"None",
")",
":",
"if",
"connection_details",
"is",
"None",
":",
"connection_details",
"=",
"get_default_connection_details",
"(",
")",
"return",
"MySQLdb",
".",
"connect",
"(",
"connection_details",
"[",
"'ho... | Creates a connection to the MySQL DB. | [
"Creates",
"a",
"connection",
"to",
"the",
"MySQL",
"DB",
"."
] | 664c12a8ccf4d27ab0e06e0969bbb6381f74789c | https://github.com/evetrivia/thanatos/blob/664c12a8ccf4d27ab0e06e0969bbb6381f74789c/thanatos/database/db_utils.py#L103-L114 |
246,869 | evetrivia/thanatos | thanatos/database/db_utils.py | get_default_connection_details | def get_default_connection_details():
""" Gets the connection details based on environment vars or Thanatos default settings.
:return: Returns a dictionary of connection details.
:rtype: dict
"""
return {
'host': os.environ.get('MYSQL_HOST', '127.0.0.1'),
'user': os.environ.get('MY... | python | def get_default_connection_details():
""" Gets the connection details based on environment vars or Thanatos default settings.
:return: Returns a dictionary of connection details.
:rtype: dict
"""
return {
'host': os.environ.get('MYSQL_HOST', '127.0.0.1'),
'user': os.environ.get('MY... | [
"def",
"get_default_connection_details",
"(",
")",
":",
"return",
"{",
"'host'",
":",
"os",
".",
"environ",
".",
"get",
"(",
"'MYSQL_HOST'",
",",
"'127.0.0.1'",
")",
",",
"'user'",
":",
"os",
".",
"environ",
".",
"get",
"(",
"'MYSQL_USER'",
",",
"'vagrant'... | Gets the connection details based on environment vars or Thanatos default settings.
:return: Returns a dictionary of connection details.
:rtype: dict | [
"Gets",
"the",
"connection",
"details",
"based",
"on",
"environment",
"vars",
"or",
"Thanatos",
"default",
"settings",
"."
] | 664c12a8ccf4d27ab0e06e0969bbb6381f74789c | https://github.com/evetrivia/thanatos/blob/664c12a8ccf4d27ab0e06e0969bbb6381f74789c/thanatos/database/db_utils.py#L117-L129 |
246,870 | MaT1g3R/option | option/option_.py | Option.unwrap_or | def unwrap_or(self, default: U) -> Union[T, U]:
"""
Returns the contained value or ``default``.
Args:
default: The default value.
Returns:
The contained value if the :py:class:`Option` is ``Some``,
otherwise ``default``.
Notes:
I... | python | def unwrap_or(self, default: U) -> Union[T, U]:
"""
Returns the contained value or ``default``.
Args:
default: The default value.
Returns:
The contained value if the :py:class:`Option` is ``Some``,
otherwise ``default``.
Notes:
I... | [
"def",
"unwrap_or",
"(",
"self",
",",
"default",
":",
"U",
")",
"->",
"Union",
"[",
"T",
",",
"U",
"]",
":",
"return",
"self",
".",
"unwrap_or_else",
"(",
"lambda",
":",
"default",
")"
] | Returns the contained value or ``default``.
Args:
default: The default value.
Returns:
The contained value if the :py:class:`Option` is ``Some``,
otherwise ``default``.
Notes:
If you wish to use a result of a function call as the default,
... | [
"Returns",
"the",
"contained",
"value",
"or",
"default",
"."
] | 37c954e6e74273d48649b3236bc881a1286107d6 | https://github.com/MaT1g3R/option/blob/37c954e6e74273d48649b3236bc881a1286107d6/option/option_.py#L198-L219 |
246,871 | MaT1g3R/option | option/option_.py | Option.unwrap_or_else | def unwrap_or_else(self, callback: Callable[[], U]) -> Union[T, U]:
"""
Returns the contained value or computes it from ``callback``.
Args:
callback: The the default callback.
Returns:
The contained value if the :py:class:`Option` is ``Some``,
otherw... | python | def unwrap_or_else(self, callback: Callable[[], U]) -> Union[T, U]:
"""
Returns the contained value or computes it from ``callback``.
Args:
callback: The the default callback.
Returns:
The contained value if the :py:class:`Option` is ``Some``,
otherw... | [
"def",
"unwrap_or_else",
"(",
"self",
",",
"callback",
":",
"Callable",
"[",
"[",
"]",
",",
"U",
"]",
")",
"->",
"Union",
"[",
"T",
",",
"U",
"]",
":",
"return",
"self",
".",
"_val",
"if",
"self",
".",
"_is_some",
"else",
"callback",
"(",
")"
] | Returns the contained value or computes it from ``callback``.
Args:
callback: The the default callback.
Returns:
The contained value if the :py:class:`Option` is ``Some``,
otherwise ``callback()``.
Examples:
>>> Some(0).unwrap_or_else(lambda: 11... | [
"Returns",
"the",
"contained",
"value",
"or",
"computes",
"it",
"from",
"callback",
"."
] | 37c954e6e74273d48649b3236bc881a1286107d6 | https://github.com/MaT1g3R/option/blob/37c954e6e74273d48649b3236bc881a1286107d6/option/option_.py#L221-L238 |
246,872 | MaT1g3R/option | option/option_.py | Option.map_or | def map_or(self, callback: Callable[[T], U], default: A) -> Union[U, A]:
"""
Applies the ``callback`` to the contained value or returns ``default``.
Args:
callback: The callback to apply to the contained value.
default: The default value.
Returns:
Th... | python | def map_or(self, callback: Callable[[T], U], default: A) -> Union[U, A]:
"""
Applies the ``callback`` to the contained value or returns ``default``.
Args:
callback: The callback to apply to the contained value.
default: The default value.
Returns:
Th... | [
"def",
"map_or",
"(",
"self",
",",
"callback",
":",
"Callable",
"[",
"[",
"T",
"]",
",",
"U",
"]",
",",
"default",
":",
"A",
")",
"->",
"Union",
"[",
"U",
",",
"A",
"]",
":",
"return",
"callback",
"(",
"self",
".",
"_val",
")",
"if",
"self",
... | Applies the ``callback`` to the contained value or returns ``default``.
Args:
callback: The callback to apply to the contained value.
default: The default value.
Returns:
The ``callback`` result if the contained value is ``Some``,
otherwise ``default``.
... | [
"Applies",
"the",
"callback",
"to",
"the",
"contained",
"value",
"or",
"returns",
"default",
"."
] | 37c954e6e74273d48649b3236bc881a1286107d6 | https://github.com/MaT1g3R/option/blob/37c954e6e74273d48649b3236bc881a1286107d6/option/option_.py#L260-L282 |
246,873 | MaT1g3R/option | option/option_.py | Option.get | def get(
self: 'Option[Mapping[K,V]]',
key: K,
default=None
) -> 'Option[V]':
"""
Gets a mapping value by key in the contained value or returns
``default`` if the key doesn't exist.
Args:
key: The mapping key.
default: The ... | python | def get(
self: 'Option[Mapping[K,V]]',
key: K,
default=None
) -> 'Option[V]':
"""
Gets a mapping value by key in the contained value or returns
``default`` if the key doesn't exist.
Args:
key: The mapping key.
default: The ... | [
"def",
"get",
"(",
"self",
":",
"'Option[Mapping[K,V]]'",
",",
"key",
":",
"K",
",",
"default",
"=",
"None",
")",
"->",
"'Option[V]'",
":",
"if",
"self",
".",
"_is_some",
":",
"return",
"self",
".",
"_type",
".",
"maybe",
"(",
"self",
".",
"_val",
".... | Gets a mapping value by key in the contained value or returns
``default`` if the key doesn't exist.
Args:
key: The mapping key.
default: The defauilt value.
Returns:
* ``Some`` variant of the mapping value if the key exists
and the value is no... | [
"Gets",
"a",
"mapping",
"value",
"by",
"key",
"in",
"the",
"contained",
"value",
"or",
"returns",
"default",
"if",
"the",
"key",
"doesn",
"t",
"exist",
"."
] | 37c954e6e74273d48649b3236bc881a1286107d6 | https://github.com/MaT1g3R/option/blob/37c954e6e74273d48649b3236bc881a1286107d6/option/option_.py#L361-L392 |
246,874 | joar/mig | mig/__init__.py | assure_migrations_table_setup | def assure_migrations_table_setup(db):
"""
Make sure the migrations table is set up in the database.
"""
from mig.models import MigrationData
if not MigrationData.__table__.exists(db.bind):
MigrationData.metadata.create_all(
db.bind, tables=[MigrationData.__table__]) | python | def assure_migrations_table_setup(db):
"""
Make sure the migrations table is set up in the database.
"""
from mig.models import MigrationData
if not MigrationData.__table__.exists(db.bind):
MigrationData.metadata.create_all(
db.bind, tables=[MigrationData.__table__]) | [
"def",
"assure_migrations_table_setup",
"(",
"db",
")",
":",
"from",
"mig",
".",
"models",
"import",
"MigrationData",
"if",
"not",
"MigrationData",
".",
"__table__",
".",
"exists",
"(",
"db",
".",
"bind",
")",
":",
"MigrationData",
".",
"metadata",
".",
"cre... | Make sure the migrations table is set up in the database. | [
"Make",
"sure",
"the",
"migrations",
"table",
"is",
"set",
"up",
"in",
"the",
"database",
"."
] | e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5 | https://github.com/joar/mig/blob/e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5/mig/__init__.py#L280-L288 |
246,875 | joar/mig | mig/__init__.py | MigrationManager.sorted_migrations | def sorted_migrations(self):
"""
Sort migrations if necessary and store in self._sorted_migrations
"""
if not self._sorted_migrations:
self._sorted_migrations = sorted(
self.migration_registry.items(),
# sort on the key... the migration number
... | python | def sorted_migrations(self):
"""
Sort migrations if necessary and store in self._sorted_migrations
"""
if not self._sorted_migrations:
self._sorted_migrations = sorted(
self.migration_registry.items(),
# sort on the key... the migration number
... | [
"def",
"sorted_migrations",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_sorted_migrations",
":",
"self",
".",
"_sorted_migrations",
"=",
"sorted",
"(",
"self",
".",
"migration_registry",
".",
"items",
"(",
")",
",",
"# sort on the key... the migration numbe... | Sort migrations if necessary and store in self._sorted_migrations | [
"Sort",
"migrations",
"if",
"necessary",
"and",
"store",
"in",
"self",
".",
"_sorted_migrations"
] | e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5 | https://github.com/joar/mig/blob/e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5/mig/__init__.py#L75-L85 |
246,876 | joar/mig | mig/__init__.py | MigrationManager.migration_data | def migration_data(self):
"""
Get the migration row associated with this object, if any.
"""
return self.session.query(
self.migration_model).filter_by(name=self.name).first() | python | def migration_data(self):
"""
Get the migration row associated with this object, if any.
"""
return self.session.query(
self.migration_model).filter_by(name=self.name).first() | [
"def",
"migration_data",
"(",
"self",
")",
":",
"return",
"self",
".",
"session",
".",
"query",
"(",
"self",
".",
"migration_model",
")",
".",
"filter_by",
"(",
"name",
"=",
"self",
".",
"name",
")",
".",
"first",
"(",
")"
] | Get the migration row associated with this object, if any. | [
"Get",
"the",
"migration",
"row",
"associated",
"with",
"this",
"object",
"if",
"any",
"."
] | e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5 | https://github.com/joar/mig/blob/e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5/mig/__init__.py#L88-L93 |
246,877 | joar/mig | mig/__init__.py | MigrationManager.database_current_migration | def database_current_migration(self):
"""
Return the current migration in the database.
"""
# If the table doesn't even exist, return None.
if not self.migration_table.exists(self.session.bind):
return None
# Also return None if self.migration_data is None.
... | python | def database_current_migration(self):
"""
Return the current migration in the database.
"""
# If the table doesn't even exist, return None.
if not self.migration_table.exists(self.session.bind):
return None
# Also return None if self.migration_data is None.
... | [
"def",
"database_current_migration",
"(",
"self",
")",
":",
"# If the table doesn't even exist, return None.",
"if",
"not",
"self",
".",
"migration_table",
".",
"exists",
"(",
"self",
".",
"session",
".",
"bind",
")",
":",
"return",
"None",
"# Also return None if self... | Return the current migration in the database. | [
"Return",
"the",
"current",
"migration",
"in",
"the",
"database",
"."
] | e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5 | https://github.com/joar/mig/blob/e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5/mig/__init__.py#L108-L120 |
246,878 | joar/mig | mig/__init__.py | MigrationManager.migrations_to_run | def migrations_to_run(self):
"""
Get a list of migrations to run still, if any.
Note that this will fail if there's no migration record for
this class!
"""
assert self.database_current_migration is not None
db_current_migration = self.database_current_migration
... | python | def migrations_to_run(self):
"""
Get a list of migrations to run still, if any.
Note that this will fail if there's no migration record for
this class!
"""
assert self.database_current_migration is not None
db_current_migration = self.database_current_migration
... | [
"def",
"migrations_to_run",
"(",
"self",
")",
":",
"assert",
"self",
".",
"database_current_migration",
"is",
"not",
"None",
"db_current_migration",
"=",
"self",
".",
"database_current_migration",
"return",
"[",
"(",
"migration_number",
",",
"migration_func",
")",
"... | Get a list of migrations to run still, if any.
Note that this will fail if there's no migration record for
this class! | [
"Get",
"a",
"list",
"of",
"migrations",
"to",
"run",
"still",
"if",
"any",
"."
] | e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5 | https://github.com/joar/mig/blob/e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5/mig/__init__.py#L130-L144 |
246,879 | joar/mig | mig/__init__.py | MigrationManager.init_tables | def init_tables(self):
"""
Create all tables relative to this package
"""
# sanity check before we proceed, none of these should be created
for model in self.models:
# Maybe in the future just print out a "Yikes!" or something?
_log.debug('Checking for tab... | python | def init_tables(self):
"""
Create all tables relative to this package
"""
# sanity check before we proceed, none of these should be created
for model in self.models:
# Maybe in the future just print out a "Yikes!" or something?
_log.debug('Checking for tab... | [
"def",
"init_tables",
"(",
"self",
")",
":",
"# sanity check before we proceed, none of these should be created",
"for",
"model",
"in",
"self",
".",
"models",
":",
"# Maybe in the future just print out a \"Yikes!\" or something?",
"_log",
".",
"debug",
"(",
"'Checking for table... | Create all tables relative to this package | [
"Create",
"all",
"tables",
"relative",
"to",
"this",
"package"
] | e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5 | https://github.com/joar/mig/blob/e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5/mig/__init__.py#L146-L159 |
246,880 | joar/mig | mig/__init__.py | MigrationManager.create_new_migration_record | def create_new_migration_record(self):
"""
Create a new migration record for this migration set
"""
migration_record = self.migration_model(
name=self.name,
version=self.latest_migration)
self.session.add(migration_record)
self.session.commit() | python | def create_new_migration_record(self):
"""
Create a new migration record for this migration set
"""
migration_record = self.migration_model(
name=self.name,
version=self.latest_migration)
self.session.add(migration_record)
self.session.commit() | [
"def",
"create_new_migration_record",
"(",
"self",
")",
":",
"migration_record",
"=",
"self",
".",
"migration_model",
"(",
"name",
"=",
"self",
".",
"name",
",",
"version",
"=",
"self",
".",
"latest_migration",
")",
"self",
".",
"session",
".",
"add",
"(",
... | Create a new migration record for this migration set | [
"Create",
"a",
"new",
"migration",
"record",
"for",
"this",
"migration",
"set"
] | e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5 | https://github.com/joar/mig/blob/e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5/mig/__init__.py#L161-L169 |
246,881 | joar/mig | mig/__init__.py | MigrationManager.dry_run | def dry_run(self):
"""
Print out a dry run of what we would have upgraded.
"""
if self.database_current_migration is None:
self.printer(
u'~> Woulda initialized: %s\n' % self.name_for_printing())
return u'inited'
migrations_to_run = se... | python | def dry_run(self):
"""
Print out a dry run of what we would have upgraded.
"""
if self.database_current_migration is None:
self.printer(
u'~> Woulda initialized: %s\n' % self.name_for_printing())
return u'inited'
migrations_to_run = se... | [
"def",
"dry_run",
"(",
"self",
")",
":",
"if",
"self",
".",
"database_current_migration",
"is",
"None",
":",
"self",
".",
"printer",
"(",
"u'~> Woulda initialized: %s\\n'",
"%",
"self",
".",
"name_for_printing",
"(",
")",
")",
"return",
"u'inited'",
"migrations_... | Print out a dry run of what we would have upgraded. | [
"Print",
"out",
"a",
"dry",
"run",
"of",
"what",
"we",
"would",
"have",
"upgraded",
"."
] | e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5 | https://github.com/joar/mig/blob/e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5/mig/__init__.py#L171-L190 |
246,882 | joar/mig | mig/__init__.py | MigrationManager.init_or_migrate | def init_or_migrate(self):
"""
Initialize the database or migrate if appropriate.
Returns information about whether or not we initialized
('inited'), migrated ('migrated'), or did nothing (None)
"""
assure_migrations_table_setup(self.session)
# Find out what mig... | python | def init_or_migrate(self):
"""
Initialize the database or migrate if appropriate.
Returns information about whether or not we initialized
('inited'), migrated ('migrated'), or did nothing (None)
"""
assure_migrations_table_setup(self.session)
# Find out what mig... | [
"def",
"init_or_migrate",
"(",
"self",
")",
":",
"assure_migrations_table_setup",
"(",
"self",
".",
"session",
")",
"# Find out what migration number, if any, this database data is at,",
"# and what the latest is.",
"migration_number",
"=",
"self",
".",
"database_current_migratio... | Initialize the database or migrate if appropriate.
Returns information about whether or not we initialized
('inited'), migrated ('migrated'), or did nothing (None) | [
"Initialize",
"the",
"database",
"or",
"migrate",
"if",
"appropriate",
"."
] | e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5 | https://github.com/joar/mig/blob/e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5/mig/__init__.py#L199-L247 |
246,883 | jmgilman/Neolib | neolib/pyamf/remoting/amf0.py | RequestProcessor.authenticateRequest | def authenticateRequest(self, request, service_request, *args, **kwargs):
"""
Authenticates the request against the service.
@param request: The AMF request
@type request: L{Request<pyamf.remoting.Request>}
"""
username = password = None
if 'Credentials' in requ... | python | def authenticateRequest(self, request, service_request, *args, **kwargs):
"""
Authenticates the request against the service.
@param request: The AMF request
@type request: L{Request<pyamf.remoting.Request>}
"""
username = password = None
if 'Credentials' in requ... | [
"def",
"authenticateRequest",
"(",
"self",
",",
"request",
",",
"service_request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"username",
"=",
"password",
"=",
"None",
"if",
"'Credentials'",
"in",
"request",
".",
"headers",
":",
"cred",
"=",
"r... | Authenticates the request against the service.
@param request: The AMF request
@type request: L{Request<pyamf.remoting.Request>} | [
"Authenticates",
"the",
"request",
"against",
"the",
"service",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/amf0.py#L21-L37 |
246,884 | KnowledgeLinks/rdfframework | rdfframework/utilities/debug.py | dumpable_obj | def dumpable_obj(obj):
''' takes an object that fails with json.dumps and converts it to
a json.dumps dumpable object. This is useful for debuging code when
you want to dump an object for easy reading'''
if isinstance(obj, list):
_return_list = []
for item in obj:
if isinsta... | python | def dumpable_obj(obj):
''' takes an object that fails with json.dumps and converts it to
a json.dumps dumpable object. This is useful for debuging code when
you want to dump an object for easy reading'''
if isinstance(obj, list):
_return_list = []
for item in obj:
if isinsta... | [
"def",
"dumpable_obj",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"list",
")",
":",
"_return_list",
"=",
"[",
"]",
"for",
"item",
"in",
"obj",
":",
"if",
"isinstance",
"(",
"item",
",",
"list",
")",
":",
"_return_list",
".",
"append",... | takes an object that fails with json.dumps and converts it to
a json.dumps dumpable object. This is useful for debuging code when
you want to dump an object for easy reading | [
"takes",
"an",
"object",
"that",
"fails",
"with",
"json",
".",
"dumps",
"and",
"converts",
"it",
"to",
"a",
"json",
".",
"dumps",
"dumpable",
"object",
".",
"This",
"is",
"useful",
"for",
"debuging",
"code",
"when",
"you",
"want",
"to",
"dump",
"an",
"... | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/debug.py#L13-L57 |
246,885 | svasilev94/GraphLibrary | graphlibrary/paths.py | find_all_paths | def find_all_paths(G, start, end, path=[]):
"""
Find all paths between vertices start and end in graph.
"""
path = path + [start]
if start == end:
return [path]
if start not in G.vertices:
raise GraphInsertError("Vertex %s doesn't exist." % (start,))
if end not in G.... | python | def find_all_paths(G, start, end, path=[]):
"""
Find all paths between vertices start and end in graph.
"""
path = path + [start]
if start == end:
return [path]
if start not in G.vertices:
raise GraphInsertError("Vertex %s doesn't exist." % (start,))
if end not in G.... | [
"def",
"find_all_paths",
"(",
"G",
",",
"start",
",",
"end",
",",
"path",
"=",
"[",
"]",
")",
":",
"path",
"=",
"path",
"+",
"[",
"start",
"]",
"if",
"start",
"==",
"end",
":",
"return",
"[",
"path",
"]",
"if",
"start",
"not",
"in",
"G",
".",
... | Find all paths between vertices start and end in graph. | [
"Find",
"all",
"paths",
"between",
"vertices",
"start",
"and",
"end",
"in",
"graph",
"."
] | bf979a80bdea17eeb25955f0c119ca8f711ef62b | https://github.com/svasilev94/GraphLibrary/blob/bf979a80bdea17eeb25955f0c119ca8f711ef62b/graphlibrary/paths.py#L6-L23 |
246,886 | unixorn/haze | setup.py | system_call | def system_call(command):
"""Run a command and return stdout.
Would be better to use subprocess.check_output, but this works on 2.6,
which is still the system Python on CentOS 7."""
p = subprocess.Popen([command], stdout=subprocess.PIPE, shell=True)
return p.stdout.read() | python | def system_call(command):
"""Run a command and return stdout.
Would be better to use subprocess.check_output, but this works on 2.6,
which is still the system Python on CentOS 7."""
p = subprocess.Popen([command], stdout=subprocess.PIPE, shell=True)
return p.stdout.read() | [
"def",
"system_call",
"(",
"command",
")",
":",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"command",
"]",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"shell",
"=",
"True",
")",
"return",
"p",
".",
"stdout",
".",
"read",
"(",
")"
] | Run a command and return stdout.
Would be better to use subprocess.check_output, but this works on 2.6,
which is still the system Python on CentOS 7. | [
"Run",
"a",
"command",
"and",
"return",
"stdout",
"."
] | 77692b18e6574ac356e3e16659b96505c733afff | https://github.com/unixorn/haze/blob/77692b18e6574ac356e3e16659b96505c733afff/setup.py#L30-L36 |
246,887 | lduchesne/python-openstacksdk-hubic | hubic/hubic.py | HubiCAuthenticator.get_headers | def get_headers(self, session, **kwargs):
"""Get the authentication header.
If the current session has not been authenticated, this will trigger a
new authentication to the HubiC OAuth service.
:param keystoneclient.Session session: The session object to use for
... | python | def get_headers(self, session, **kwargs):
"""Get the authentication header.
If the current session has not been authenticated, this will trigger a
new authentication to the HubiC OAuth service.
:param keystoneclient.Session session: The session object to use for
... | [
"def",
"get_headers",
"(",
"self",
",",
"session",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"auth_token",
"is",
"None",
":",
"try",
":",
"self",
".",
"_refresh_tokens",
"(",
"session",
")",
"self",
".",
"_fetch_credentials",
"(",
"session",
... | Get the authentication header.
If the current session has not been authenticated, this will trigger a
new authentication to the HubiC OAuth service.
:param keystoneclient.Session session: The session object to use for
queries.
:raises key... | [
"Get",
"the",
"authentication",
"header",
"."
] | 25e752f847613bb7e068c05e094a8abadaa7925a | https://github.com/lduchesne/python-openstacksdk-hubic/blob/25e752f847613bb7e068c05e094a8abadaa7925a/hubic/hubic.py#L66-L91 |
246,888 | lduchesne/python-openstacksdk-hubic | hubic/hubic.py | HubiCAuthenticator.get_endpoint | def get_endpoint(self, session, **kwargs):
"""Get the HubiC storage endpoint uri.
If the current session has not been authenticated, this will trigger a
new authentication to the HubiC OAuth service.
:param keystoneclient.Session session: The session object to use for
... | python | def get_endpoint(self, session, **kwargs):
"""Get the HubiC storage endpoint uri.
If the current session has not been authenticated, this will trigger a
new authentication to the HubiC OAuth service.
:param keystoneclient.Session session: The session object to use for
... | [
"def",
"get_endpoint",
"(",
"self",
",",
"session",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"endpoint",
"is",
"None",
":",
"try",
":",
"self",
".",
"_refresh_tokens",
"(",
"session",
")",
"self",
".",
"_fetch_credentials",
"(",
"session",
... | Get the HubiC storage endpoint uri.
If the current session has not been authenticated, this will trigger a
new authentication to the HubiC OAuth service.
:param keystoneclient.Session session: The session object to use for
queries.
:raise... | [
"Get",
"the",
"HubiC",
"storage",
"endpoint",
"uri",
"."
] | 25e752f847613bb7e068c05e094a8abadaa7925a | https://github.com/lduchesne/python-openstacksdk-hubic/blob/25e752f847613bb7e068c05e094a8abadaa7925a/hubic/hubic.py#L94-L117 |
246,889 | lduchesne/python-openstacksdk-hubic | hubic/hubic.py | HubiCAuthenticator._refresh_tokens | def _refresh_tokens(self, session):
"""Request an access and a refresh token from the HubiC API.
Those tokens are mandatory and will be used for subsequent file
operations. They are not returned and will be stored internaly.
:param keystoneclient.Session session: The session object to ... | python | def _refresh_tokens(self, session):
"""Request an access and a refresh token from the HubiC API.
Those tokens are mandatory and will be used for subsequent file
operations. They are not returned and will be stored internaly.
:param keystoneclient.Session session: The session object to ... | [
"def",
"_refresh_tokens",
"(",
"self",
",",
"session",
")",
":",
"params",
"=",
"{",
"'client_id'",
":",
"self",
".",
"client_id",
",",
"'client_secret'",
":",
"self",
".",
"client_secret",
",",
"}",
"payload",
"=",
"{",
"'client_id'",
":",
"self",
".",
... | Request an access and a refresh token from the HubiC API.
Those tokens are mandatory and will be used for subsequent file
operations. They are not returned and will be stored internaly.
:param keystoneclient.Session session: The session object to use for
... | [
"Request",
"an",
"access",
"and",
"a",
"refresh",
"token",
"from",
"the",
"HubiC",
"API",
"."
] | 25e752f847613bb7e068c05e094a8abadaa7925a | https://github.com/lduchesne/python-openstacksdk-hubic/blob/25e752f847613bb7e068c05e094a8abadaa7925a/hubic/hubic.py#L141-L203 |
246,890 | lduchesne/python-openstacksdk-hubic | hubic/hubic.py | HubiCAuthenticator._fetch_credentials | def _fetch_credentials(self, session):
"""Fetch the endpoint URI and authorization token for this session.
Those two information are the basis for all future calls to the Swift
(OpenStack) API for the storage container.
:param keystoneclient.Session session: The session object to use f... | python | def _fetch_credentials(self, session):
"""Fetch the endpoint URI and authorization token for this session.
Those two information are the basis for all future calls to the Swift
(OpenStack) API for the storage container.
:param keystoneclient.Session session: The session object to use f... | [
"def",
"_fetch_credentials",
"(",
"self",
",",
"session",
")",
":",
"headers",
"=",
"{",
"'Authorization'",
":",
"'Bearer {0}'",
".",
"format",
"(",
"self",
".",
"access_token",
")",
",",
"}",
"r",
"=",
"session",
".",
"get",
"(",
"\"https://api.hubic.com/1.... | Fetch the endpoint URI and authorization token for this session.
Those two information are the basis for all future calls to the Swift
(OpenStack) API for the storage container.
:param keystoneclient.Session session: The session object to use for
... | [
"Fetch",
"the",
"endpoint",
"URI",
"and",
"authorization",
"token",
"for",
"this",
"session",
"."
] | 25e752f847613bb7e068c05e094a8abadaa7925a | https://github.com/lduchesne/python-openstacksdk-hubic/blob/25e752f847613bb7e068c05e094a8abadaa7925a/hubic/hubic.py#L206-L234 |
246,891 | lduchesne/python-openstacksdk-hubic | hubic/hubic.py | HubiCAuthenticator._get_authorization_token | def _get_authorization_token(self, session):
"""Load the HubiC form, submit it and return an authorization token.
This will load the HTML form to accept if the application can access
the user account and submit the form using the user's credentials.
:raises keystoneclient.exceptions.Au... | python | def _get_authorization_token(self, session):
"""Load the HubiC form, submit it and return an authorization token.
This will load the HTML form to accept if the application can access
the user account and submit the form using the user's credentials.
:raises keystoneclient.exceptions.Au... | [
"def",
"_get_authorization_token",
"(",
"self",
",",
"session",
")",
":",
"request_scope",
"=",
"'account.r,credentials.r'",
"params",
"=",
"{",
"'client_id'",
":",
"self",
".",
"client_id",
",",
"'redirect_uri'",
":",
"self",
".",
"redirect_uri",
",",
"'response_... | Load the HubiC form, submit it and return an authorization token.
This will load the HTML form to accept if the application can access
the user account and submit the form using the user's credentials.
:raises keystoneclient.exceptions.AuthorizationFailure: if something
... | [
"Load",
"the",
"HubiC",
"form",
"submit",
"it",
"and",
"return",
"an",
"authorization",
"token",
"."
] | 25e752f847613bb7e068c05e094a8abadaa7925a | https://github.com/lduchesne/python-openstacksdk-hubic/blob/25e752f847613bb7e068c05e094a8abadaa7925a/hubic/hubic.py#L237-L314 |
246,892 | jmgilman/Neolib | neolib/pyamf/codec.py | Context.getStringForBytes | def getStringForBytes(self, s):
"""
Returns the corresponding string for the supplied utf-8 encoded bytes.
If there is no string object, one is created.
@since: 0.6
"""
h = hash(s)
u = self._unicodes.get(h, None)
if u is not None:
return u
... | python | def getStringForBytes(self, s):
"""
Returns the corresponding string for the supplied utf-8 encoded bytes.
If there is no string object, one is created.
@since: 0.6
"""
h = hash(s)
u = self._unicodes.get(h, None)
if u is not None:
return u
... | [
"def",
"getStringForBytes",
"(",
"self",
",",
"s",
")",
":",
"h",
"=",
"hash",
"(",
"s",
")",
"u",
"=",
"self",
".",
"_unicodes",
".",
"get",
"(",
"h",
",",
"None",
")",
"if",
"u",
"is",
"not",
"None",
":",
"return",
"u",
"u",
"=",
"self",
".... | Returns the corresponding string for the supplied utf-8 encoded bytes.
If there is no string object, one is created.
@since: 0.6 | [
"Returns",
"the",
"corresponding",
"string",
"for",
"the",
"supplied",
"utf",
"-",
"8",
"encoded",
"bytes",
".",
"If",
"there",
"is",
"no",
"string",
"object",
"one",
"is",
"created",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/codec.py#L211-L226 |
246,893 | jmgilman/Neolib | neolib/pyamf/codec.py | Context.getBytesForString | def getBytesForString(self, u):
"""
Returns the corresponding utf-8 encoded string for a given unicode
object. If there is no string, one is encoded.
@since: 0.6
"""
h = hash(u)
s = self._unicodes.get(h, None)
if s is not None:
return s
... | python | def getBytesForString(self, u):
"""
Returns the corresponding utf-8 encoded string for a given unicode
object. If there is no string, one is encoded.
@since: 0.6
"""
h = hash(u)
s = self._unicodes.get(h, None)
if s is not None:
return s
... | [
"def",
"getBytesForString",
"(",
"self",
",",
"u",
")",
":",
"h",
"=",
"hash",
"(",
"u",
")",
"s",
"=",
"self",
".",
"_unicodes",
".",
"get",
"(",
"h",
",",
"None",
")",
"if",
"s",
"is",
"not",
"None",
":",
"return",
"s",
"s",
"=",
"self",
".... | Returns the corresponding utf-8 encoded string for a given unicode
object. If there is no string, one is encoded.
@since: 0.6 | [
"Returns",
"the",
"corresponding",
"utf",
"-",
"8",
"encoded",
"string",
"for",
"a",
"given",
"unicode",
"object",
".",
"If",
"there",
"is",
"no",
"string",
"one",
"is",
"encoded",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/codec.py#L228-L243 |
246,894 | jmgilman/Neolib | neolib/pyamf/codec.py | Decoder.readElement | def readElement(self):
"""
Reads an AMF3 element from the data stream.
@raise DecodeError: The ActionScript type is unsupported.
@raise EOStream: No more data left to decode.
"""
pos = self.stream.tell()
try:
t = self.stream.read(1)
except IO... | python | def readElement(self):
"""
Reads an AMF3 element from the data stream.
@raise DecodeError: The ActionScript type is unsupported.
@raise EOStream: No more data left to decode.
"""
pos = self.stream.tell()
try:
t = self.stream.read(1)
except IO... | [
"def",
"readElement",
"(",
"self",
")",
":",
"pos",
"=",
"self",
".",
"stream",
".",
"tell",
"(",
")",
"try",
":",
"t",
"=",
"self",
".",
"stream",
".",
"read",
"(",
"1",
")",
"except",
"IOError",
":",
"raise",
"pyamf",
".",
"EOStream",
"try",
":... | Reads an AMF3 element from the data stream.
@raise DecodeError: The ActionScript type is unsupported.
@raise EOStream: No more data left to decode. | [
"Reads",
"an",
"AMF3",
"element",
"from",
"the",
"data",
"stream",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/codec.py#L312-L342 |
246,895 | jmgilman/Neolib | neolib/pyamf/codec.py | Encoder.writeSequence | def writeSequence(self, iterable):
"""
Encodes an iterable. The default is to write If the iterable has an al
"""
try:
alias = self.context.getClassAlias(iterable.__class__)
except (AttributeError, pyamf.UnknownClassAlias):
self.writeList(iterable)
... | python | def writeSequence(self, iterable):
"""
Encodes an iterable. The default is to write If the iterable has an al
"""
try:
alias = self.context.getClassAlias(iterable.__class__)
except (AttributeError, pyamf.UnknownClassAlias):
self.writeList(iterable)
... | [
"def",
"writeSequence",
"(",
"self",
",",
"iterable",
")",
":",
"try",
":",
"alias",
"=",
"self",
".",
"context",
".",
"getClassAlias",
"(",
"iterable",
".",
"__class__",
")",
"except",
"(",
"AttributeError",
",",
"pyamf",
".",
"UnknownClassAlias",
")",
":... | Encodes an iterable. The default is to write If the iterable has an al | [
"Encodes",
"an",
"iterable",
".",
"The",
"default",
"is",
"to",
"write",
"If",
"the",
"iterable",
"has",
"an",
"al"
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/codec.py#L391-L409 |
246,896 | jmgilman/Neolib | neolib/pyamf/codec.py | Encoder.writeGenerator | def writeGenerator(self, gen):
"""
Iterates over a generator object and encodes all that is returned.
"""
n = getattr(gen, 'next')
while True:
try:
self.writeElement(n())
except StopIteration:
break | python | def writeGenerator(self, gen):
"""
Iterates over a generator object and encodes all that is returned.
"""
n = getattr(gen, 'next')
while True:
try:
self.writeElement(n())
except StopIteration:
break | [
"def",
"writeGenerator",
"(",
"self",
",",
"gen",
")",
":",
"n",
"=",
"getattr",
"(",
"gen",
",",
"'next'",
")",
"while",
"True",
":",
"try",
":",
"self",
".",
"writeElement",
"(",
"n",
"(",
")",
")",
"except",
"StopIteration",
":",
"break"
] | Iterates over a generator object and encodes all that is returned. | [
"Iterates",
"over",
"a",
"generator",
"object",
"and",
"encodes",
"all",
"that",
"is",
"returned",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/codec.py#L411-L421 |
246,897 | SmartDeveloperHub/agora-service-provider | agora/provider/jobs/collect.py | collect_fragment | def collect_fragment(event, agora_host):
"""
Execute a search plan for the declared graph pattern and sends all obtained triples to the corresponding
collector functions (config
"""
agora = Agora(agora_host)
graph_pattern = ""
for tp in __triple_patterns:
graph_pattern += '{} . '.for... | python | def collect_fragment(event, agora_host):
"""
Execute a search plan for the declared graph pattern and sends all obtained triples to the corresponding
collector functions (config
"""
agora = Agora(agora_host)
graph_pattern = ""
for tp in __triple_patterns:
graph_pattern += '{} . '.for... | [
"def",
"collect_fragment",
"(",
"event",
",",
"agora_host",
")",
":",
"agora",
"=",
"Agora",
"(",
"agora_host",
")",
"graph_pattern",
"=",
"\"\"",
"for",
"tp",
"in",
"__triple_patterns",
":",
"graph_pattern",
"+=",
"'{} . '",
".",
"format",
"(",
"tp",
")",
... | Execute a search plan for the declared graph pattern and sends all obtained triples to the corresponding
collector functions (config | [
"Execute",
"a",
"search",
"plan",
"for",
"the",
"declared",
"graph",
"pattern",
"and",
"sends",
"all",
"obtained",
"triples",
"to",
"the",
"corresponding",
"collector",
"functions",
"(",
"config"
] | 3962207e5701c659c74c8cfffcbc4b0a63eac4b4 | https://github.com/SmartDeveloperHub/agora-service-provider/blob/3962207e5701c659c74c8cfffcbc4b0a63eac4b4/agora/provider/jobs/collect.py#L88-L108 |
246,898 | opinkerfi/nago | nago/extensions/settings.py | get | def get(key, section='main'):
""" Get a single option from """
return nago.settings.get_option(option_name=key, section_name=section) | python | def get(key, section='main'):
""" Get a single option from """
return nago.settings.get_option(option_name=key, section_name=section) | [
"def",
"get",
"(",
"key",
",",
"section",
"=",
"'main'",
")",
":",
"return",
"nago",
".",
"settings",
".",
"get_option",
"(",
"option_name",
"=",
"key",
",",
"section_name",
"=",
"section",
")"
] | Get a single option from | [
"Get",
"a",
"single",
"option",
"from"
] | 85e1bdd1de0122f56868a483e7599e1b36a439b0 | https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/extensions/settings.py#L16-L18 |
246,899 | nicktgr15/sac | sac/methods/vad.py | Vad._frame_generator | def _frame_generator(self, frame_duration_ms, audio, sample_rate):
"""Generates audio frames from PCM audio data.
Takes the desired frame duration in milliseconds, the PCM data, and
the sample rate.
Yields Frames of the requested duration.
"""
n = int(sample_rate * (frame... | python | def _frame_generator(self, frame_duration_ms, audio, sample_rate):
"""Generates audio frames from PCM audio data.
Takes the desired frame duration in milliseconds, the PCM data, and
the sample rate.
Yields Frames of the requested duration.
"""
n = int(sample_rate * (frame... | [
"def",
"_frame_generator",
"(",
"self",
",",
"frame_duration_ms",
",",
"audio",
",",
"sample_rate",
")",
":",
"n",
"=",
"int",
"(",
"sample_rate",
"*",
"(",
"frame_duration_ms",
"/",
"1000.0",
")",
"*",
"2",
")",
"offset",
"=",
"0",
"timestamp",
"=",
"0.... | Generates audio frames from PCM audio data.
Takes the desired frame duration in milliseconds, the PCM data, and
the sample rate.
Yields Frames of the requested duration. | [
"Generates",
"audio",
"frames",
"from",
"PCM",
"audio",
"data",
".",
"Takes",
"the",
"desired",
"frame",
"duration",
"in",
"milliseconds",
"the",
"PCM",
"data",
"and",
"the",
"sample",
"rate",
".",
"Yields",
"Frames",
"of",
"the",
"requested",
"duration",
".... | 4b1d5d8e6ca2c437972db34ddc72990860865159 | https://github.com/nicktgr15/sac/blob/4b1d5d8e6ca2c437972db34ddc72990860865159/sac/methods/vad.py#L32-L45 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.