repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
opennode/waldur-core | waldur_core/cost_tracking/models.py | ConsumptionDetails.update_configuration | def update_configuration(self, new_configuration):
""" Save how much consumables were used and update current configuration.
Return True if configuration changed.
"""
if new_configuration == self.configuration:
return False
now = timezone.now()
if now.mon... | python | def update_configuration(self, new_configuration):
""" Save how much consumables were used and update current configuration.
Return True if configuration changed.
"""
if new_configuration == self.configuration:
return False
now = timezone.now()
if now.mon... | [
"def",
"update_configuration",
"(",
"self",
",",
"new_configuration",
")",
":",
"if",
"new_configuration",
"==",
"self",
".",
"configuration",
":",
"return",
"False",
"now",
"=",
"timezone",
".",
"now",
"(",
")",
"if",
"now",
".",
"month",
"!=",
"self",
".... | Save how much consumables were used and update current configuration.
Return True if configuration changed. | [
"Save",
"how",
"much",
"consumables",
"were",
"used",
"and",
"update",
"current",
"configuration",
"."
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/models.py#L288-L306 |
opennode/waldur-core | waldur_core/cost_tracking/models.py | ConsumptionDetails.consumed_in_month | def consumed_in_month(self):
""" How many resources were (or will be) consumed until end of the month """
month_end = core_utils.month_end(datetime.date(self.price_estimate.year, self.price_estimate.month, 1))
return self._get_consumed(month_end) | python | def consumed_in_month(self):
""" How many resources were (or will be) consumed until end of the month """
month_end = core_utils.month_end(datetime.date(self.price_estimate.year, self.price_estimate.month, 1))
return self._get_consumed(month_end) | [
"def",
"consumed_in_month",
"(",
"self",
")",
":",
"month_end",
"=",
"core_utils",
".",
"month_end",
"(",
"datetime",
".",
"date",
"(",
"self",
".",
"price_estimate",
".",
"year",
",",
"self",
".",
"price_estimate",
".",
"month",
",",
"1",
")",
")",
"ret... | How many resources were (or will be) consumed until end of the month | [
"How",
"many",
"resources",
"were",
"(",
"or",
"will",
"be",
")",
"consumed",
"until",
"end",
"of",
"the",
"month"
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/models.py#L309-L312 |
opennode/waldur-core | waldur_core/cost_tracking/models.py | ConsumptionDetails._get_consumed | def _get_consumed(self, time):
""" How many consumables were (or will be) used by resource until given time. """
minutes_from_last_update = self._get_minutes_from_last_update(time)
if minutes_from_last_update < 0:
raise ConsumptionDetailCalculateError('Cannot calculate consumption if... | python | def _get_consumed(self, time):
""" How many consumables were (or will be) used by resource until given time. """
minutes_from_last_update = self._get_minutes_from_last_update(time)
if minutes_from_last_update < 0:
raise ConsumptionDetailCalculateError('Cannot calculate consumption if... | [
"def",
"_get_consumed",
"(",
"self",
",",
"time",
")",
":",
"minutes_from_last_update",
"=",
"self",
".",
"_get_minutes_from_last_update",
"(",
"time",
")",
"if",
"minutes_from_last_update",
"<",
"0",
":",
"raise",
"ConsumptionDetailCalculateError",
"(",
"'Cannot calc... | How many consumables were (or will be) used by resource until given time. | [
"How",
"many",
"consumables",
"were",
"(",
"or",
"will",
"be",
")",
"used",
"by",
"resource",
"until",
"given",
"time",
"."
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/models.py#L319-L329 |
opennode/waldur-core | waldur_core/cost_tracking/models.py | ConsumptionDetails._get_minutes_from_last_update | def _get_minutes_from_last_update(self, time):
""" How much minutes passed from last update to given time """
time_from_last_update = time - self.last_update_time
return int(time_from_last_update.total_seconds() / 60) | python | def _get_minutes_from_last_update(self, time):
""" How much minutes passed from last update to given time """
time_from_last_update = time - self.last_update_time
return int(time_from_last_update.total_seconds() / 60) | [
"def",
"_get_minutes_from_last_update",
"(",
"self",
",",
"time",
")",
":",
"time_from_last_update",
"=",
"time",
"-",
"self",
".",
"last_update_time",
"return",
"int",
"(",
"time_from_last_update",
".",
"total_seconds",
"(",
")",
"/",
"60",
")"
] | How much minutes passed from last update to given time | [
"How",
"much",
"minutes",
"passed",
"from",
"last",
"update",
"to",
"given",
"time"
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/models.py#L331-L334 |
opennode/waldur-core | waldur_core/cost_tracking/models.py | PriceListItem.get_for_resource | def get_for_resource(resource):
""" Get list of all price list items that should be used for resource.
If price list item is defined for service - return it, otherwise -
return default price list item.
"""
resource_content_type = ContentType.objects.get_for_model(resourc... | python | def get_for_resource(resource):
""" Get list of all price list items that should be used for resource.
If price list item is defined for service - return it, otherwise -
return default price list item.
"""
resource_content_type = ContentType.objects.get_for_model(resourc... | [
"def",
"get_for_resource",
"(",
"resource",
")",
":",
"resource_content_type",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"resource",
")",
"default_items",
"=",
"set",
"(",
"DefaultPriceListItem",
".",
"objects",
".",
"filter",
"(",
"resource_c... | Get list of all price list items that should be used for resource.
If price list item is defined for service - return it, otherwise -
return default price list item. | [
"Get",
"list",
"of",
"all",
"price",
"list",
"items",
"that",
"should",
"be",
"used",
"for",
"resource",
"."
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/models.py#L457-L469 |
opennode/waldur-core | waldur_core/core/__init__.py | WaldurExtension.get_extensions | def get_extensions(cls):
""" Get a list of available extensions """
assemblies = []
for waldur_extension in pkg_resources.iter_entry_points('waldur_extensions'):
extension_module = waldur_extension.load()
if inspect.isclass(extension_module) and issubclass(extension_modul... | python | def get_extensions(cls):
""" Get a list of available extensions """
assemblies = []
for waldur_extension in pkg_resources.iter_entry_points('waldur_extensions'):
extension_module = waldur_extension.load()
if inspect.isclass(extension_module) and issubclass(extension_modul... | [
"def",
"get_extensions",
"(",
"cls",
")",
":",
"assemblies",
"=",
"[",
"]",
"for",
"waldur_extension",
"in",
"pkg_resources",
".",
"iter_entry_points",
"(",
"'waldur_extensions'",
")",
":",
"extension_module",
"=",
"waldur_extension",
".",
"load",
"(",
")",
"if"... | Get a list of available extensions | [
"Get",
"a",
"list",
"of",
"available",
"extensions"
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/__init__.py#L50-L61 |
quora/qcore | qcore/helpers.py | ellipsis | def ellipsis(source, max_length):
"""Truncates a string to be at most max_length long."""
if max_length == 0 or len(source) <= max_length:
return source
return source[: max(0, max_length - 3)] + "..." | python | def ellipsis(source, max_length):
"""Truncates a string to be at most max_length long."""
if max_length == 0 or len(source) <= max_length:
return source
return source[: max(0, max_length - 3)] + "..." | [
"def",
"ellipsis",
"(",
"source",
",",
"max_length",
")",
":",
"if",
"max_length",
"==",
"0",
"or",
"len",
"(",
"source",
")",
"<=",
"max_length",
":",
"return",
"source",
"return",
"source",
"[",
":",
"max",
"(",
"0",
",",
"max_length",
"-",
"3",
")... | Truncates a string to be at most max_length long. | [
"Truncates",
"a",
"string",
"to",
"be",
"at",
"most",
"max_length",
"long",
"."
] | train | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/helpers.py#L232-L236 |
quora/qcore | qcore/helpers.py | safe_str | def safe_str(source, max_length=0):
"""Wrapper for str() that catches exceptions."""
try:
return ellipsis(str(source), max_length)
except Exception as e:
return ellipsis("<n/a: str(...) raised %s>" % e, max_length) | python | def safe_str(source, max_length=0):
"""Wrapper for str() that catches exceptions."""
try:
return ellipsis(str(source), max_length)
except Exception as e:
return ellipsis("<n/a: str(...) raised %s>" % e, max_length) | [
"def",
"safe_str",
"(",
"source",
",",
"max_length",
"=",
"0",
")",
":",
"try",
":",
"return",
"ellipsis",
"(",
"str",
"(",
"source",
")",
",",
"max_length",
")",
"except",
"Exception",
"as",
"e",
":",
"return",
"ellipsis",
"(",
"\"<n/a: str(...) raised %s... | Wrapper for str() that catches exceptions. | [
"Wrapper",
"for",
"str",
"()",
"that",
"catches",
"exceptions",
"."
] | train | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/helpers.py#L239-L244 |
quora/qcore | qcore/helpers.py | safe_repr | def safe_repr(source, max_length=0):
"""Wrapper for repr() that catches exceptions."""
try:
return ellipsis(repr(source), max_length)
except Exception as e:
return ellipsis("<n/a: repr(...) raised %s>" % e, max_length) | python | def safe_repr(source, max_length=0):
"""Wrapper for repr() that catches exceptions."""
try:
return ellipsis(repr(source), max_length)
except Exception as e:
return ellipsis("<n/a: repr(...) raised %s>" % e, max_length) | [
"def",
"safe_repr",
"(",
"source",
",",
"max_length",
"=",
"0",
")",
":",
"try",
":",
"return",
"ellipsis",
"(",
"repr",
"(",
"source",
")",
",",
"max_length",
")",
"except",
"Exception",
"as",
"e",
":",
"return",
"ellipsis",
"(",
"\"<n/a: repr(...) raised... | Wrapper for repr() that catches exceptions. | [
"Wrapper",
"for",
"repr",
"()",
"that",
"catches",
"exceptions",
"."
] | train | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/helpers.py#L247-L252 |
quora/qcore | qcore/helpers.py | dict_to_object | def dict_to_object(source):
"""Returns an object with the key-value pairs in source as attributes."""
target = inspectable_class.InspectableClass()
for k, v in source.items():
setattr(target, k, v)
return target | python | def dict_to_object(source):
"""Returns an object with the key-value pairs in source as attributes."""
target = inspectable_class.InspectableClass()
for k, v in source.items():
setattr(target, k, v)
return target | [
"def",
"dict_to_object",
"(",
"source",
")",
":",
"target",
"=",
"inspectable_class",
".",
"InspectableClass",
"(",
")",
"for",
"k",
",",
"v",
"in",
"source",
".",
"items",
"(",
")",
":",
"setattr",
"(",
"target",
",",
"k",
",",
"v",
")",
"return",
"... | Returns an object with the key-value pairs in source as attributes. | [
"Returns",
"an",
"object",
"with",
"the",
"key",
"-",
"value",
"pairs",
"in",
"source",
"as",
"attributes",
"."
] | train | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/helpers.py#L255-L260 |
quora/qcore | qcore/helpers.py | copy_public_attrs | def copy_public_attrs(source_obj, dest_obj):
"""Shallow copies all public attributes from source_obj to dest_obj.
Overwrites them if they already exist.
"""
for name, value in inspect.getmembers(source_obj):
if not any(name.startswith(x) for x in ["_", "func", "im"]):
setattr(dest_... | python | def copy_public_attrs(source_obj, dest_obj):
"""Shallow copies all public attributes from source_obj to dest_obj.
Overwrites them if they already exist.
"""
for name, value in inspect.getmembers(source_obj):
if not any(name.startswith(x) for x in ["_", "func", "im"]):
setattr(dest_... | [
"def",
"copy_public_attrs",
"(",
"source_obj",
",",
"dest_obj",
")",
":",
"for",
"name",
",",
"value",
"in",
"inspect",
".",
"getmembers",
"(",
"source_obj",
")",
":",
"if",
"not",
"any",
"(",
"name",
".",
"startswith",
"(",
"x",
")",
"for",
"x",
"in",... | Shallow copies all public attributes from source_obj to dest_obj.
Overwrites them if they already exist. | [
"Shallow",
"copies",
"all",
"public",
"attributes",
"from",
"source_obj",
"to",
"dest_obj",
"."
] | train | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/helpers.py#L263-L271 |
quora/qcore | qcore/helpers.py | object_from_string | def object_from_string(name):
"""Creates a Python class or function from its fully qualified name.
:param name: A fully qualified name of a class or a function. In Python 3 this
is only allowed to be of text type (unicode). In Python 2, both bytes and unicode
are allowed.
:return: A functio... | python | def object_from_string(name):
"""Creates a Python class or function from its fully qualified name.
:param name: A fully qualified name of a class or a function. In Python 3 this
is only allowed to be of text type (unicode). In Python 2, both bytes and unicode
are allowed.
:return: A functio... | [
"def",
"object_from_string",
"(",
"name",
")",
":",
"if",
"six",
".",
"PY3",
":",
"if",
"not",
"isinstance",
"(",
"name",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"\"name must be str, not %r\"",
"%",
"type",
"(",
"name",
")",
")",
"else",
":",
... | Creates a Python class or function from its fully qualified name.
:param name: A fully qualified name of a class or a function. In Python 3 this
is only allowed to be of text type (unicode). In Python 2, both bytes and unicode
are allowed.
:return: A function or class object.
This method i... | [
"Creates",
"a",
"Python",
"class",
"or",
"function",
"from",
"its",
"fully",
"qualified",
"name",
"."
] | train | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/helpers.py#L274-L313 |
quora/qcore | qcore/helpers.py | catchable_exceptions | def catchable_exceptions(exceptions):
"""Returns True if exceptions can be caught in the except clause.
The exception can be caught if it is an Exception type or a tuple of
exception types.
"""
if isinstance(exceptions, type) and issubclass(exceptions, BaseException):
return True
if (... | python | def catchable_exceptions(exceptions):
"""Returns True if exceptions can be caught in the except clause.
The exception can be caught if it is an Exception type or a tuple of
exception types.
"""
if isinstance(exceptions, type) and issubclass(exceptions, BaseException):
return True
if (... | [
"def",
"catchable_exceptions",
"(",
"exceptions",
")",
":",
"if",
"isinstance",
"(",
"exceptions",
",",
"type",
")",
"and",
"issubclass",
"(",
"exceptions",
",",
"BaseException",
")",
":",
"return",
"True",
"if",
"(",
"isinstance",
"(",
"exceptions",
",",
"t... | Returns True if exceptions can be caught in the except clause.
The exception can be caught if it is an Exception type or a tuple of
exception types. | [
"Returns",
"True",
"if",
"exceptions",
"can",
"be",
"caught",
"in",
"the",
"except",
"clause",
"."
] | train | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/helpers.py#L316-L333 |
quora/qcore | qcore/helpers.py | ScopedValue.override | def override(self, value):
"""Temporarily overrides the old value with the new one."""
if self._value is not value:
return _ScopedValueOverrideContext(self, value)
else:
return empty_context | python | def override(self, value):
"""Temporarily overrides the old value with the new one."""
if self._value is not value:
return _ScopedValueOverrideContext(self, value)
else:
return empty_context | [
"def",
"override",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"_value",
"is",
"not",
"value",
":",
"return",
"_ScopedValueOverrideContext",
"(",
"self",
",",
"value",
")",
"else",
":",
"return",
"empty_context"
] | Temporarily overrides the old value with the new one. | [
"Temporarily",
"overrides",
"the",
"old",
"value",
"with",
"the",
"new",
"one",
"."
] | train | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/helpers.py#L181-L186 |
opennode/waldur-core | waldur_core/core/views.py | ActionsViewSet.validate_object_action | def validate_object_action(self, action_name, obj=None):
""" Execute validation for actions that are related to particular object """
action_method = getattr(self, action_name)
if not getattr(action_method, 'detail', False) and action_name not in ('update', 'partial_update', 'destroy'):
... | python | def validate_object_action(self, action_name, obj=None):
""" Execute validation for actions that are related to particular object """
action_method = getattr(self, action_name)
if not getattr(action_method, 'detail', False) and action_name not in ('update', 'partial_update', 'destroy'):
... | [
"def",
"validate_object_action",
"(",
"self",
",",
"action_name",
",",
"obj",
"=",
"None",
")",
":",
"action_method",
"=",
"getattr",
"(",
"self",
",",
"action_name",
")",
"if",
"not",
"getattr",
"(",
"action_method",
",",
"'detail'",
",",
"False",
")",
"a... | Execute validation for actions that are related to particular object | [
"Execute",
"validation",
"for",
"actions",
"that",
"are",
"related",
"to",
"particular",
"object"
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/views.py#L290-L299 |
mhjohnson/PyParse | PyParse.py | Parser.row_dict | def row_dict(self, row):
"""returns dictionary version of row using keys from self.field_map"""
d = {}
for field_name,index in self.field_map.items():
d[field_name] = self.field_value(row, field_name)
return d | python | def row_dict(self, row):
"""returns dictionary version of row using keys from self.field_map"""
d = {}
for field_name,index in self.field_map.items():
d[field_name] = self.field_value(row, field_name)
return d | [
"def",
"row_dict",
"(",
"self",
",",
"row",
")",
":",
"d",
"=",
"{",
"}",
"for",
"field_name",
",",
"index",
"in",
"self",
".",
"field_map",
".",
"items",
"(",
")",
":",
"d",
"[",
"field_name",
"]",
"=",
"self",
".",
"field_value",
"(",
"row",
",... | returns dictionary version of row using keys from self.field_map | [
"returns",
"dictionary",
"version",
"of",
"row",
"using",
"keys",
"from",
"self",
".",
"field_map"
] | train | https://github.com/mhjohnson/PyParse/blob/4a78160255d2d9ca95728ea655dd188ef74b5075/PyParse.py#L95-L100 |
mhjohnson/PyParse | PyParse.py | Parser._dialect | def _dialect(self, filepath):
"""returns detected dialect of filepath and sets self.has_header
if not passed in __init__ kwargs
Arguments:
filepath (str): filepath of target csv file
"""
with open(filepath, self.read_mode) as csvfile:
sample = csvfile.read... | python | def _dialect(self, filepath):
"""returns detected dialect of filepath and sets self.has_header
if not passed in __init__ kwargs
Arguments:
filepath (str): filepath of target csv file
"""
with open(filepath, self.read_mode) as csvfile:
sample = csvfile.read... | [
"def",
"_dialect",
"(",
"self",
",",
"filepath",
")",
":",
"with",
"open",
"(",
"filepath",
",",
"self",
".",
"read_mode",
")",
"as",
"csvfile",
":",
"sample",
"=",
"csvfile",
".",
"read",
"(",
"1024",
")",
"dialect",
"=",
"csv",
".",
"Sniffer",
"(",... | returns detected dialect of filepath and sets self.has_header
if not passed in __init__ kwargs
Arguments:
filepath (str): filepath of target csv file | [
"returns",
"detected",
"dialect",
"of",
"filepath",
"and",
"sets",
"self",
".",
"has_header",
"if",
"not",
"passed",
"in",
"__init__",
"kwargs",
"Arguments",
":",
"filepath",
"(",
"str",
")",
":",
"filepath",
"of",
"target",
"csv",
"file"
] | train | https://github.com/mhjohnson/PyParse/blob/4a78160255d2d9ca95728ea655dd188ef74b5075/PyParse.py#L102-L115 |
opennode/waldur-core | waldur_core/cost_tracking/admin.py | _get_content_type_queryset | def _get_content_type_queryset(models_list):
""" Get list of services content types """
content_type_ids = {c.id for c in ContentType.objects.get_for_models(*models_list).values()}
return ContentType.objects.filter(id__in=content_type_ids) | python | def _get_content_type_queryset(models_list):
""" Get list of services content types """
content_type_ids = {c.id for c in ContentType.objects.get_for_models(*models_list).values()}
return ContentType.objects.filter(id__in=content_type_ids) | [
"def",
"_get_content_type_queryset",
"(",
"models_list",
")",
":",
"content_type_ids",
"=",
"{",
"c",
".",
"id",
"for",
"c",
"in",
"ContentType",
".",
"objects",
".",
"get_for_models",
"(",
"*",
"models_list",
")",
".",
"values",
"(",
")",
"}",
"return",
"... | Get list of services content types | [
"Get",
"list",
"of",
"services",
"content",
"types"
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/admin.py#L15-L18 |
opennode/waldur-core | waldur_core/cost_tracking/admin.py | DefaultPriceListItemAdmin.init_registered | def init_registered(self, request):
""" Create default price list items for each registered resource. """
created_items = models.DefaultPriceListItem.init_from_registered_resources()
if created_items:
message = ungettext(
_('Price item was created: %s.') % created_it... | python | def init_registered(self, request):
""" Create default price list items for each registered resource. """
created_items = models.DefaultPriceListItem.init_from_registered_resources()
if created_items:
message = ungettext(
_('Price item was created: %s.') % created_it... | [
"def",
"init_registered",
"(",
"self",
",",
"request",
")",
":",
"created_items",
"=",
"models",
".",
"DefaultPriceListItem",
".",
"init_from_registered_resources",
"(",
")",
"if",
"created_items",
":",
"message",
"=",
"ungettext",
"(",
"_",
"(",
"'Price item was ... | Create default price list items for each registered resource. | [
"Create",
"default",
"price",
"list",
"items",
"for",
"each",
"registered",
"resource",
"."
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/admin.py#L60-L74 |
opennode/waldur-core | waldur_core/cost_tracking/admin.py | DefaultPriceListItemAdmin.reinit_configurations | def reinit_configurations(self, request):
""" Re-initialize configuration for resource if it has been changed.
This method should be called if resource consumption strategy was changed.
"""
now = timezone.now()
# Step 1. Collect all resources with changed configuration.
... | python | def reinit_configurations(self, request):
""" Re-initialize configuration for resource if it has been changed.
This method should be called if resource consumption strategy was changed.
"""
now = timezone.now()
# Step 1. Collect all resources with changed configuration.
... | [
"def",
"reinit_configurations",
"(",
"self",
",",
"request",
")",
":",
"now",
"=",
"timezone",
".",
"now",
"(",
")",
"# Step 1. Collect all resources with changed configuration.",
"changed_resources",
"=",
"[",
"]",
"for",
"resource_model",
"in",
"CostTrackingRegister",... | Re-initialize configuration for resource if it has been changed.
This method should be called if resource consumption strategy was changed. | [
"Re",
"-",
"initialize",
"configuration",
"for",
"resource",
"if",
"it",
"has",
"been",
"changed",
"."
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/admin.py#L106-L133 |
nuagenetworks/bambou | bambou/utils/sha1.py | Sha1.encrypt | def encrypt(self, message):
""" Encrypt the given message """
if not isinstance(message, (bytes, str)):
raise TypeError
return hashlib.sha1(message.encode('utf-8')).hexdigest() | python | def encrypt(self, message):
""" Encrypt the given message """
if not isinstance(message, (bytes, str)):
raise TypeError
return hashlib.sha1(message.encode('utf-8')).hexdigest() | [
"def",
"encrypt",
"(",
"self",
",",
"message",
")",
":",
"if",
"not",
"isinstance",
"(",
"message",
",",
"(",
"bytes",
",",
"str",
")",
")",
":",
"raise",
"TypeError",
"return",
"hashlib",
".",
"sha1",
"(",
"message",
".",
"encode",
"(",
"'utf-8'",
"... | Encrypt the given message | [
"Encrypt",
"the",
"given",
"message"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/utils/sha1.py#L37-L43 |
opennode/waldur-core | waldur_core/core/models.py | ScheduleMixin.save | def save(self, *args, **kwargs):
"""
Updates next_trigger_at field if:
- instance become active
- instance.schedule changed
- instance is new
"""
try:
prev_instance = self.__class__.objects.get(pk=self.pk)
except self.DoesNotExist:
... | python | def save(self, *args, **kwargs):
"""
Updates next_trigger_at field if:
- instance become active
- instance.schedule changed
- instance is new
"""
try:
prev_instance = self.__class__.objects.get(pk=self.pk)
except self.DoesNotExist:
... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"prev_instance",
"=",
"self",
".",
"__class__",
".",
"objects",
".",
"get",
"(",
"pk",
"=",
"self",
".",
"pk",
")",
"except",
"self",
".",
"DoesNotExist",
... | Updates next_trigger_at field if:
- instance become active
- instance.schedule changed
- instance is new | [
"Updates",
"next_trigger_at",
"field",
"if",
":",
"-",
"instance",
"become",
"active",
"-",
"instance",
".",
"schedule",
"changed",
"-",
"instance",
"is",
"new"
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/models.py#L115-L131 |
opennode/waldur-core | waldur_core/core/models.py | ReversionMixin.get_version_fields | def get_version_fields(self):
""" Get field that are tracked in object history versions. """
options = reversion._get_options(self)
return options.fields or [f.name for f in self._meta.fields if f not in options.exclude] | python | def get_version_fields(self):
""" Get field that are tracked in object history versions. """
options = reversion._get_options(self)
return options.fields or [f.name for f in self._meta.fields if f not in options.exclude] | [
"def",
"get_version_fields",
"(",
"self",
")",
":",
"options",
"=",
"reversion",
".",
"_get_options",
"(",
"self",
")",
"return",
"options",
".",
"fields",
"or",
"[",
"f",
".",
"name",
"for",
"f",
"in",
"self",
".",
"_meta",
".",
"fields",
"if",
"f",
... | Get field that are tracked in object history versions. | [
"Get",
"field",
"that",
"are",
"tracked",
"in",
"object",
"history",
"versions",
"."
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/models.py#L380-L383 |
opennode/waldur-core | waldur_core/core/models.py | ReversionMixin._is_version_duplicate | def _is_version_duplicate(self):
""" Define should new version be created for object or no.
Reasons to provide custom check instead of default `ignore_revision_duplicates`:
- no need to compare all revisions - it is OK if right object version exists in any revision;
- need... | python | def _is_version_duplicate(self):
""" Define should new version be created for object or no.
Reasons to provide custom check instead of default `ignore_revision_duplicates`:
- no need to compare all revisions - it is OK if right object version exists in any revision;
- need... | [
"def",
"_is_version_duplicate",
"(",
"self",
")",
":",
"if",
"self",
".",
"id",
"is",
"None",
":",
"return",
"False",
"try",
":",
"latest_version",
"=",
"Version",
".",
"objects",
".",
"get_for_object",
"(",
"self",
")",
".",
"latest",
"(",
"'revision__dat... | Define should new version be created for object or no.
Reasons to provide custom check instead of default `ignore_revision_duplicates`:
- no need to compare all revisions - it is OK if right object version exists in any revision;
- need to compare object attributes (not serialized... | [
"Define",
"should",
"new",
"version",
"be",
"created",
"for",
"object",
"or",
"no",
"."
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/models.py#L385-L401 |
opennode/waldur-core | waldur_core/core/models.py | DescendantMixin.get_ancestors | def get_ancestors(self):
""" Get all unique instance ancestors """
ancestors = list(self.get_parents())
ancestor_unique_attributes = set([(a.__class__, a.id) for a in ancestors])
ancestors_with_parents = [a for a in ancestors if isinstance(a, DescendantMixin)]
for ancestor in anc... | python | def get_ancestors(self):
""" Get all unique instance ancestors """
ancestors = list(self.get_parents())
ancestor_unique_attributes = set([(a.__class__, a.id) for a in ancestors])
ancestors_with_parents = [a for a in ancestors if isinstance(a, DescendantMixin)]
for ancestor in anc... | [
"def",
"get_ancestors",
"(",
"self",
")",
":",
"ancestors",
"=",
"list",
"(",
"self",
".",
"get_parents",
"(",
")",
")",
"ancestor_unique_attributes",
"=",
"set",
"(",
"[",
"(",
"a",
".",
"__class__",
",",
"a",
".",
"id",
")",
"for",
"a",
"in",
"ance... | Get all unique instance ancestors | [
"Get",
"all",
"unique",
"instance",
"ancestors"
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/models.py#L424-L433 |
nuagenetworks/bambou | bambou/nurest_connection.py | NURESTConnection.has_succeed | def has_succeed(self):
""" Check if the connection has succeed
Returns:
Returns True if connection has succeed.
False otherwise.
"""
status_code = self._response.status_code
if status_code in [HTTP_CODE_ZERO, HTTP_CODE_SUCCESS, HTTP_CODE_CRE... | python | def has_succeed(self):
""" Check if the connection has succeed
Returns:
Returns True if connection has succeed.
False otherwise.
"""
status_code = self._response.status_code
if status_code in [HTTP_CODE_ZERO, HTTP_CODE_SUCCESS, HTTP_CODE_CRE... | [
"def",
"has_succeed",
"(",
"self",
")",
":",
"status_code",
"=",
"self",
".",
"_response",
".",
"status_code",
"if",
"status_code",
"in",
"[",
"HTTP_CODE_ZERO",
",",
"HTTP_CODE_SUCCESS",
",",
"HTTP_CODE_CREATED",
",",
"HTTP_CODE_EMPTY",
",",
"HTTP_CODE_MULTIPLE_CHOI... | Check if the connection has succeed
Returns:
Returns True if connection has succeed.
False otherwise. | [
"Check",
"if",
"the",
"connection",
"has",
"succeed"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_connection.py#L233-L249 |
nuagenetworks/bambou | bambou/nurest_connection.py | NURESTConnection.handle_response_for_connection | def handle_response_for_connection(self, should_post=False):
""" Check if the response succeed or not.
In case of error, this method also print messages and set
an array of errors in the response object.
Returns:
Returns True if the response has succeed, Fal... | python | def handle_response_for_connection(self, should_post=False):
""" Check if the response succeed or not.
In case of error, this method also print messages and set
an array of errors in the response object.
Returns:
Returns True if the response has succeed, Fal... | [
"def",
"handle_response_for_connection",
"(",
"self",
",",
"should_post",
"=",
"False",
")",
":",
"status_code",
"=",
"self",
".",
"_response",
".",
"status_code",
"data",
"=",
"self",
".",
"_response",
".",
"data",
"# TODO : Get errors in response data after bug fix ... | Check if the response succeed or not.
In case of error, this method also print messages and set
an array of errors in the response object.
Returns:
Returns True if the response has succeed, False otherwise | [
"Check",
"if",
"the",
"response",
"succeed",
"or",
"not",
"."
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_connection.py#L260-L305 |
nuagenetworks/bambou | bambou/nurest_connection.py | NURESTConnection._did_receive_response | def _did_receive_response(self, response):
""" Called when a response is received """
try:
data = response.json()
except:
data = None
self._response = NURESTResponse(status_code=response.status_code, headers=response.headers, data=data, reason=response.reason)
... | python | def _did_receive_response(self, response):
""" Called when a response is received """
try:
data = response.json()
except:
data = None
self._response = NURESTResponse(status_code=response.status_code, headers=response.headers, data=data, reason=response.reason)
... | [
"def",
"_did_receive_response",
"(",
"self",
",",
"response",
")",
":",
"try",
":",
"data",
"=",
"response",
".",
"json",
"(",
")",
"except",
":",
"data",
"=",
"None",
"self",
".",
"_response",
"=",
"NURESTResponse",
"(",
"status_code",
"=",
"response",
... | Called when a response is received | [
"Called",
"when",
"a",
"response",
"is",
"received"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_connection.py#L309-L326 |
nuagenetworks/bambou | bambou/nurest_connection.py | NURESTConnection._did_timeout | def _did_timeout(self):
""" Called when a resquest has timeout """
bambou_logger.debug('Bambou %s on %s has timeout (timeout=%ss)..' % (self._request.method, self._request.url, self.timeout))
self._has_timeouted = True
if self.async:
self._callback(self)
else:
... | python | def _did_timeout(self):
""" Called when a resquest has timeout """
bambou_logger.debug('Bambou %s on %s has timeout (timeout=%ss)..' % (self._request.method, self._request.url, self.timeout))
self._has_timeouted = True
if self.async:
self._callback(self)
else:
... | [
"def",
"_did_timeout",
"(",
"self",
")",
":",
"bambou_logger",
".",
"debug",
"(",
"'Bambou %s on %s has timeout (timeout=%ss)..'",
"%",
"(",
"self",
".",
"_request",
".",
"method",
",",
"self",
".",
"_request",
".",
"url",
",",
"self",
".",
"timeout",
")",
"... | Called when a resquest has timeout | [
"Called",
"when",
"a",
"resquest",
"has",
"timeout"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_connection.py#L328-L337 |
nuagenetworks/bambou | bambou/nurest_connection.py | NURESTConnection._make_request | def _make_request(self, session=None):
""" Make a synchronous request """
if session is None:
session = NURESTSession.get_current_session()
self._has_timeouted = False
# Add specific headers
controller = session.login_controller
enterprise = controller.ent... | python | def _make_request(self, session=None):
""" Make a synchronous request """
if session is None:
session = NURESTSession.get_current_session()
self._has_timeouted = False
# Add specific headers
controller = session.login_controller
enterprise = controller.ent... | [
"def",
"_make_request",
"(",
"self",
",",
"session",
"=",
"None",
")",
":",
"if",
"session",
"is",
"None",
":",
"session",
"=",
"NURESTSession",
".",
"get_current_session",
"(",
")",
"self",
".",
"_has_timeouted",
"=",
"False",
"# Add specific headers",
"contr... | Make a synchronous request | [
"Make",
"a",
"synchronous",
"request"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_connection.py#L339-L392 |
nuagenetworks/bambou | bambou/nurest_connection.py | NURESTConnection.__make_request | def __make_request(self, requests_session, method, url, params, data, headers, certificate):
""" Encapsulate requests call
"""
verify = False
timeout = self.timeout
try: # TODO : Remove this ugly try/except after fixing Java issue: http://mvjira.mv.usa.alcatel.com/browse/VSD-54... | python | def __make_request(self, requests_session, method, url, params, data, headers, certificate):
""" Encapsulate requests call
"""
verify = False
timeout = self.timeout
try: # TODO : Remove this ugly try/except after fixing Java issue: http://mvjira.mv.usa.alcatel.com/browse/VSD-54... | [
"def",
"__make_request",
"(",
"self",
",",
"requests_session",
",",
"method",
",",
"url",
",",
"params",
",",
"data",
",",
"headers",
",",
"certificate",
")",
":",
"verify",
"=",
"False",
"timeout",
"=",
"self",
".",
"timeout",
"try",
":",
"# TODO : Remove... | Encapsulate requests call | [
"Encapsulate",
"requests",
"call"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_connection.py#L394-L425 |
nuagenetworks/bambou | bambou/nurest_connection.py | NURESTConnection.start | def start(self):
""" Make an HTTP request with a specific method """
# TODO : Use Timeout here and _ignore_request_idle
from .nurest_session import NURESTSession
session = NURESTSession.get_current_session()
if self.async:
thread = threading.Thread(target=self._make... | python | def start(self):
""" Make an HTTP request with a specific method """
# TODO : Use Timeout here and _ignore_request_idle
from .nurest_session import NURESTSession
session = NURESTSession.get_current_session()
if self.async:
thread = threading.Thread(target=self._make... | [
"def",
"start",
"(",
"self",
")",
":",
"# TODO : Use Timeout here and _ignore_request_idle",
"from",
".",
"nurest_session",
"import",
"NURESTSession",
"session",
"=",
"NURESTSession",
".",
"get_current_session",
"(",
")",
"if",
"self",
".",
"async",
":",
"thread",
"... | Make an HTTP request with a specific method | [
"Make",
"an",
"HTTP",
"request",
"with",
"a",
"specific",
"method"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_connection.py#L427-L440 |
nuagenetworks/bambou | bambou/nurest_connection.py | NURESTConnection.reset | def reset(self):
""" Reset the connection
"""
self._request = None
self._response = None
self._transaction_id = uuid.uuid4().hex | python | def reset(self):
""" Reset the connection
"""
self._request = None
self._response = None
self._transaction_id = uuid.uuid4().hex | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"_request",
"=",
"None",
"self",
".",
"_response",
"=",
"None",
"self",
".",
"_transaction_id",
"=",
"uuid",
".",
"uuid4",
"(",
")",
".",
"hex"
] | Reset the connection | [
"Reset",
"the",
"connection"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_connection.py#L442-L448 |
opennode/waldur-core | waldur_core/cost_tracking/managers.py | ConsumptionDetailsQuerySet.create | def create(self, price_estimate):
""" Take configuration from previous month, it it exists.
Set last_update_time equals to the beginning of the month.
"""
kwargs = {}
try:
previous_price_estimate = price_estimate.get_previous()
except ObjectDoesNotExist:
... | python | def create(self, price_estimate):
""" Take configuration from previous month, it it exists.
Set last_update_time equals to the beginning of the month.
"""
kwargs = {}
try:
previous_price_estimate = price_estimate.get_previous()
except ObjectDoesNotExist:
... | [
"def",
"create",
"(",
"self",
",",
"price_estimate",
")",
":",
"kwargs",
"=",
"{",
"}",
"try",
":",
"previous_price_estimate",
"=",
"price_estimate",
".",
"get_previous",
"(",
")",
"except",
"ObjectDoesNotExist",
":",
"pass",
"else",
":",
"configuration",
"=",... | Take configuration from previous month, it it exists.
Set last_update_time equals to the beginning of the month. | [
"Take",
"configuration",
"from",
"previous",
"month",
"it",
"it",
"exists",
".",
"Set",
"last_update_time",
"equals",
"to",
"the",
"beginning",
"of",
"the",
"month",
"."
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/managers.py#L59-L73 |
opennode/waldur-core | waldur_core/logging/serializers.py | BaseHookSerializer.get_fields | def get_fields(self):
"""
When static declaration is used, event type choices are fetched too early -
even before all apps are initialized. As a result, some event types are missing.
When dynamic declaration is used, all valid event types are available as choices.
"""
fie... | python | def get_fields(self):
"""
When static declaration is used, event type choices are fetched too early -
even before all apps are initialized. As a result, some event types are missing.
When dynamic declaration is used, all valid event types are available as choices.
"""
fie... | [
"def",
"get_fields",
"(",
"self",
")",
":",
"fields",
"=",
"super",
"(",
"BaseHookSerializer",
",",
"self",
")",
".",
"get_fields",
"(",
")",
"fields",
"[",
"'event_types'",
"]",
"=",
"serializers",
".",
"MultipleChoiceField",
"(",
"choices",
"=",
"loggers",... | When static declaration is used, event type choices are fetched too early -
even before all apps are initialized. As a result, some event types are missing.
When dynamic declaration is used, all valid event types are available as choices. | [
"When",
"static",
"declaration",
"is",
"used",
"event",
"type",
"choices",
"are",
"fetched",
"too",
"early",
"-",
"even",
"before",
"all",
"apps",
"are",
"initialized",
".",
"As",
"a",
"result",
"some",
"event",
"types",
"are",
"missing",
".",
"When",
"dyn... | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/serializers.py#L68-L79 |
opennode/waldur-core | waldur_core/cost_tracking/serializers.py | PriceEstimateSerializer.build_nested_field | def build_nested_field(self, field_name, relation_info, nested_depth):
""" Use PriceEstimateSerializer to serialize estimate children """
if field_name != 'children':
return super(PriceEstimateSerializer, self).build_nested_field(field_name, relation_info, nested_depth)
field_class =... | python | def build_nested_field(self, field_name, relation_info, nested_depth):
""" Use PriceEstimateSerializer to serialize estimate children """
if field_name != 'children':
return super(PriceEstimateSerializer, self).build_nested_field(field_name, relation_info, nested_depth)
field_class =... | [
"def",
"build_nested_field",
"(",
"self",
",",
"field_name",
",",
"relation_info",
",",
"nested_depth",
")",
":",
"if",
"field_name",
"!=",
"'children'",
":",
"return",
"super",
"(",
"PriceEstimateSerializer",
",",
"self",
")",
".",
"build_nested_field",
"(",
"f... | Use PriceEstimateSerializer to serialize estimate children | [
"Use",
"PriceEstimateSerializer",
"to",
"serialize",
"estimate",
"children"
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/serializers.py#L43-L49 |
quora/qcore | qcore/errors.py | prepare_for_reraise | def prepare_for_reraise(error, exc_info=None):
"""Prepares the exception for re-raising with reraise method.
This method attaches type and traceback info to the error object
so that reraise can properly reraise it using this info.
"""
if not hasattr(error, "_type_"):
if exc_info is None:
... | python | def prepare_for_reraise(error, exc_info=None):
"""Prepares the exception for re-raising with reraise method.
This method attaches type and traceback info to the error object
so that reraise can properly reraise it using this info.
"""
if not hasattr(error, "_type_"):
if exc_info is None:
... | [
"def",
"prepare_for_reraise",
"(",
"error",
",",
"exc_info",
"=",
"None",
")",
":",
"if",
"not",
"hasattr",
"(",
"error",
",",
"\"_type_\"",
")",
":",
"if",
"exc_info",
"is",
"None",
":",
"exc_info",
"=",
"sys",
".",
"exc_info",
"(",
")",
"error",
".",... | Prepares the exception for re-raising with reraise method.
This method attaches type and traceback info to the error object
so that reraise can properly reraise it using this info. | [
"Prepares",
"the",
"exception",
"for",
"re",
"-",
"raising",
"with",
"reraise",
"method",
"."
] | train | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/errors.py#L72-L84 |
quora/qcore | qcore/errors.py | reraise | def reraise(error):
"""Re-raises the error that was processed by prepare_for_reraise earlier."""
if hasattr(error, "_type_"):
six.reraise(type(error), error, error._traceback)
raise error | python | def reraise(error):
"""Re-raises the error that was processed by prepare_for_reraise earlier."""
if hasattr(error, "_type_"):
six.reraise(type(error), error, error._traceback)
raise error | [
"def",
"reraise",
"(",
"error",
")",
":",
"if",
"hasattr",
"(",
"error",
",",
"\"_type_\"",
")",
":",
"six",
".",
"reraise",
"(",
"type",
"(",
"error",
")",
",",
"error",
",",
"error",
".",
"_traceback",
")",
"raise",
"error"
] | Re-raises the error that was processed by prepare_for_reraise earlier. | [
"Re",
"-",
"raises",
"the",
"error",
"that",
"was",
"processed",
"by",
"prepare_for_reraise",
"earlier",
"."
] | train | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/errors.py#L90-L94 |
stepank/pyws | src/pyws/functions/register.py | register | def register(*args, **kwargs):
"""
Creates a registrator that, being called with a function as the only
argument, wraps a function with ``pyws.functions.NativeFunctionAdapter``
and registers it to the server. Arguments are exactly the same as for
``pyws.functions.NativeFunctionAdapter`` except that ... | python | def register(*args, **kwargs):
"""
Creates a registrator that, being called with a function as the only
argument, wraps a function with ``pyws.functions.NativeFunctionAdapter``
and registers it to the server. Arguments are exactly the same as for
``pyws.functions.NativeFunctionAdapter`` except that ... | [
"def",
"register",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"args",
"and",
"callable",
"(",
"args",
"[",
"0",
"]",
")",
":",
"raise",
"ConfigurationError",
"(",
"'You might have tried to decorate a function directly with '",
"'@register which is ... | Creates a registrator that, being called with a function as the only
argument, wraps a function with ``pyws.functions.NativeFunctionAdapter``
and registers it to the server. Arguments are exactly the same as for
``pyws.functions.NativeFunctionAdapter`` except that you can pass
an additional keyword argu... | [
"Creates",
"a",
"registrator",
"that",
"being",
"called",
"with",
"a",
"function",
"as",
"the",
"only",
"argument",
"wraps",
"a",
"function",
"with",
"pyws",
".",
"functions",
".",
"NativeFunctionAdapter",
"and",
"registers",
"it",
"to",
"the",
"server",
".",
... | train | https://github.com/stepank/pyws/blob/ff39133aabeb56bbb08d66286ac0cc8731eda7dd/src/pyws/functions/register.py#L9-L47 |
nuagenetworks/bambou | bambou/nurest_object.py | NUMetaRESTObject.rest_name | def rest_name(cls):
""" Represents a singular REST name
"""
if cls.__name__ == "NURESTRootObject" or cls.__name__ == "NURESTObject":
return "Not Implemented"
if cls.__rest_name__ is None:
raise NotImplementedError('%s has no defined name. Implement rest_name prop... | python | def rest_name(cls):
""" Represents a singular REST name
"""
if cls.__name__ == "NURESTRootObject" or cls.__name__ == "NURESTObject":
return "Not Implemented"
if cls.__rest_name__ is None:
raise NotImplementedError('%s has no defined name. Implement rest_name prop... | [
"def",
"rest_name",
"(",
"cls",
")",
":",
"if",
"cls",
".",
"__name__",
"==",
"\"NURESTRootObject\"",
"or",
"cls",
".",
"__name__",
"==",
"\"NURESTObject\"",
":",
"return",
"\"Not Implemented\"",
"if",
"cls",
".",
"__rest_name__",
"is",
"None",
":",
"raise",
... | Represents a singular REST name | [
"Represents",
"a",
"singular",
"REST",
"name"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L51-L60 |
nuagenetworks/bambou | bambou/nurest_object.py | NUMetaRESTObject.resource_name | def resource_name(cls):
""" Represents the resource name
"""
if cls.__name__ == "NURESTRootObject" or cls.__name__ == "NURESTObject":
return "Not Implemented"
if cls.__resource_name__ is None:
raise NotImplementedError('%s has no defined resource name. Implement ... | python | def resource_name(cls):
""" Represents the resource name
"""
if cls.__name__ == "NURESTRootObject" or cls.__name__ == "NURESTObject":
return "Not Implemented"
if cls.__resource_name__ is None:
raise NotImplementedError('%s has no defined resource name. Implement ... | [
"def",
"resource_name",
"(",
"cls",
")",
":",
"if",
"cls",
".",
"__name__",
"==",
"\"NURESTRootObject\"",
"or",
"cls",
".",
"__name__",
"==",
"\"NURESTObject\"",
":",
"return",
"\"Not Implemented\"",
"if",
"cls",
".",
"__resource_name__",
"is",
"None",
":",
"r... | Represents the resource name | [
"Represents",
"the",
"resource",
"name"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L63-L72 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject._compute_args | def _compute_args(self, data=dict(), **kwargs):
""" Compute the arguments
Try to import attributes from data.
Otherwise compute kwargs arguments.
Args:
data: a dict()
kwargs: a list of arguments
"""
for name, remote_attribute... | python | def _compute_args(self, data=dict(), **kwargs):
""" Compute the arguments
Try to import attributes from data.
Otherwise compute kwargs arguments.
Args:
data: a dict()
kwargs: a list of arguments
"""
for name, remote_attribute... | [
"def",
"_compute_args",
"(",
"self",
",",
"data",
"=",
"dict",
"(",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"name",
",",
"remote_attribute",
"in",
"self",
".",
"_attributes",
".",
"items",
"(",
")",
":",
"default_value",
"=",
"BambouConfig",
"."... | Compute the arguments
Try to import attributes from data.
Otherwise compute kwargs arguments.
Args:
data: a dict()
kwargs: a list of arguments | [
"Compute",
"the",
"arguments"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L116-L136 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.children_rest_names | def children_rest_names(self):
""" Gets the list of all possible children ReST names.
Returns:
list: list containing all possible rest names as string
Example:
>>> entity = NUEntity()
>>> entity.children_rest_names
["foo",... | python | def children_rest_names(self):
""" Gets the list of all possible children ReST names.
Returns:
list: list containing all possible rest names as string
Example:
>>> entity = NUEntity()
>>> entity.children_rest_names
["foo",... | [
"def",
"children_rest_names",
"(",
"self",
")",
":",
"names",
"=",
"[",
"]",
"for",
"fetcher",
"in",
"self",
".",
"fetchers",
":",
"names",
".",
"append",
"(",
"fetcher",
".",
"__class__",
".",
"managed_object_rest_name",
"(",
")",
")",
"return",
"names"
] | Gets the list of all possible children ReST names.
Returns:
list: list containing all possible rest names as string
Example:
>>> entity = NUEntity()
>>> entity.children_rest_names
["foo", "bar"] | [
"Gets",
"the",
"list",
"of",
"all",
"possible",
"children",
"ReST",
"names",
"."
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L266-L283 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.get_resource_url | def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name) | python | def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name) | [
"def",
"get_resource_url",
"(",
"self",
")",
":",
"name",
"=",
"self",
".",
"__class__",
".",
"resource_name",
"url",
"=",
"self",
".",
"__class__",
".",
"rest_base_url",
"(",
")",
"if",
"self",
".",
"id",
"is",
"not",
"None",
":",
"return",
"\"%s/%s/%s\... | Get resource complete url | [
"Get",
"resource",
"complete",
"url"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L309-L318 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.validate | def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
... | python | def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
... | [
"def",
"validate",
"(",
"self",
")",
":",
"self",
".",
"_attribute_errors",
"=",
"dict",
"(",
")",
"# Reset validation errors",
"for",
"local_name",
",",
"attribute",
"in",
"self",
".",
"_attributes",
".",
"items",
"(",
")",
":",
"value",
"=",
"getattr",
"... | Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict. | [
"Validate",
"the",
"current",
"object",
"attributes",
"."
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L330-L379 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.expose_attribute | def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False, ... | python | def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False, ... | [
"def",
"expose_attribute",
"(",
"self",
",",
"local_name",
",",
"attribute_type",
",",
"remote_name",
"=",
"None",
",",
"display_name",
"=",
"None",
",",
"is_required",
"=",
"False",
",",
"is_readonly",
"=",
"False",
",",
"max_length",
"=",
"None",
",",
"min... | Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name` | [
"Expose",
"local_name",
"as",
"remote_name"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L432-L464 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.is_owned_by_current_user | def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id | python | def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id | [
"def",
"is_owned_by_current_user",
"(",
"self",
")",
":",
"from",
"bambou",
".",
"nurest_root_object",
"import",
"NURESTRootObject",
"root_object",
"=",
"NURESTRootObject",
".",
"get_default_root_object",
"(",
")",
"return",
"self",
".",
"_owner",
"==",
"root_object",... | Check if the current user owns the object | [
"Check",
"if",
"the",
"current",
"user",
"owns",
"the",
"object"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L490-L495 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.parent_for_matching_rest_name | def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None | python | def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None | [
"def",
"parent_for_matching_rest_name",
"(",
"self",
",",
"rest_names",
")",
":",
"parent",
"=",
"self",
"while",
"parent",
":",
"if",
"parent",
".",
"rest_name",
"in",
"rest_names",
":",
"return",
"parent",
"parent",
"=",
"parent",
".",
"parent_object",
"retu... | Return parent that matches a rest name | [
"Return",
"parent",
"that",
"matches",
"a",
"rest",
"name"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L497-L508 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.genealogic_types | def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types | python | def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types | [
"def",
"genealogic_types",
"(",
"self",
")",
":",
"types",
"=",
"[",
"]",
"parent",
"=",
"self",
"while",
"parent",
":",
"types",
".",
"append",
"(",
"parent",
".",
"rest_name",
")",
"parent",
"=",
"parent",
".",
"parent_object",
"return",
"types"
] | Get genealogic types
Returns:
Returns a list of all parent types | [
"Get",
"genealogic",
"types"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L510-L524 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.genealogic_ids | def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids | python | def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids | [
"def",
"genealogic_ids",
"(",
"self",
")",
":",
"ids",
"=",
"[",
"]",
"parent",
"=",
"self",
"while",
"parent",
":",
"ids",
".",
"append",
"(",
"parent",
".",
"id",
")",
"parent",
"=",
"parent",
".",
"parent_object",
"return",
"ids"
] | Get all genealogic ids
Returns:
A list of all parent ids | [
"Get",
"all",
"genealogic",
"ids"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L526-L540 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.get_formated_creation_date | def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(for... | python | def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(for... | [
"def",
"get_formated_creation_date",
"(",
"self",
",",
"format",
"=",
"'%b %Y %d %H:%I:%S'",
")",
":",
"if",
"not",
"self",
".",
"_creation_date",
":",
"return",
"None",
"date",
"=",
"datetime",
".",
"datetime",
".",
"utcfromtimestamp",
"(",
"self",
".",
"_cre... | Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' | [
"Return",
"creation",
"date",
"with",
"a",
"given",
"format",
".",
"Default",
"is",
"%b",
"%Y",
"%d",
"%H",
":",
"%I",
":",
"%S"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L568-L575 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.add_child | def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
... | python | def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
... | [
"def",
"add_child",
"(",
"self",
",",
"child",
")",
":",
"rest_name",
"=",
"child",
".",
"rest_name",
"children",
"=",
"self",
".",
"fetcher_for_rest_name",
"(",
"rest_name",
")",
"if",
"children",
"is",
"None",
":",
"raise",
"InternalConsitencyError",
"(",
... | Add a child | [
"Add",
"a",
"child"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L605-L616 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.remove_child | def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
... | python | def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
... | [
"def",
"remove_child",
"(",
"self",
",",
"child",
")",
":",
"rest_name",
"=",
"child",
".",
"rest_name",
"children",
"=",
"self",
".",
"fetcher_for_rest_name",
"(",
"rest_name",
")",
"target_child",
"=",
"None",
"for",
"local_child",
"in",
"children",
":",
"... | Remove a child | [
"Remove",
"a",
"child"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L618-L633 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.update_child | def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
... | python | def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
... | [
"def",
"update_child",
"(",
"self",
",",
"child",
")",
":",
"rest_name",
"=",
"child",
".",
"rest_name",
"children",
"=",
"self",
".",
"fetcher_for_rest_name",
"(",
"rest_name",
")",
"index",
"=",
"None",
"for",
"local_child",
"in",
"children",
":",
"if",
... | Update child | [
"Update",
"child"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L635-L649 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.to_dict | def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name... | python | def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"dictionary",
"=",
"dict",
"(",
")",
"for",
"local_name",
",",
"attribute",
"in",
"self",
".",
"_attributes",
".",
"items",
"(",
")",
":",
"remote_name",
"=",
"attribute",
".",
"remote_name",
"if",
"hasattr",
"(",... | Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": ... | [
"Converts",
"the",
"current",
"object",
"into",
"a",
"Dictionary",
"using",
"all",
"exposed",
"ReST",
"attributes",
"."
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L667-L704 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.from_dict | def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
... | python | def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
... | [
"def",
"from_dict",
"(",
"self",
",",
"dictionary",
")",
":",
"for",
"remote_name",
",",
"remote_value",
"in",
"dictionary",
".",
"items",
"(",
")",
":",
"# Check if a local attribute is exposed with the remote_name",
"# if no attribute is exposed, return None",
"local_name... | Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
... | [
"Sets",
"all",
"the",
"exposed",
"ReST",
"attribues",
"from",
"the",
"given",
"dictionary"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L706-L729 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.delete | def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous cal... | python | def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous cal... | [
"def",
"delete",
"(",
"self",
",",
"response_choice",
"=",
"1",
",",
"async",
"=",
"False",
",",
"callback",
"=",
"None",
")",
":",
"return",
"self",
".",
"_manage_child_object",
"(",
"nurest_object",
"=",
"self",
",",
"method",
"=",
"HTTP_METHOD_DELETE",
... | Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that... | [
"Delete",
"object",
"and",
"call",
"given",
"callback",
"in",
"case",
"of",
"call",
"."
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L733-L744 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.save | def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in... | python | def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in... | [
"def",
"save",
"(",
"self",
",",
"response_choice",
"=",
"None",
",",
"async",
"=",
"False",
",",
"callback",
"=",
"None",
")",
":",
"return",
"self",
".",
"_manage_child_object",
"(",
"nurest_object",
"=",
"self",
",",
"method",
"=",
"HTTP_METHOD_PUT",
",... | Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.na... | [
"Update",
"object",
"and",
"call",
"given",
"callback",
"in",
"case",
"of",
"async",
"call"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L746-L757 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.send_request | def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that... | python | def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that... | [
"def",
"send_request",
"(",
"self",
",",
"request",
",",
"async",
"=",
"False",
",",
"local_callback",
"=",
"None",
",",
"remote_callback",
"=",
"None",
",",
"user_info",
"=",
"None",
")",
":",
"callbacks",
"=",
"dict",
"(",
")",
"if",
"local_callback",
... | Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in cas... | [
"Sends",
"a",
"request",
"calls",
"the",
"local",
"callback",
"then",
"the",
"remote",
"callback",
"in",
"case",
"of",
"async",
"call"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L789-L813 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject._manage_child_object | def _manage_child_object(self, nurest_object, method=HTTP_METHOD_GET, async=False, callback=None, handler=None, response_choice=None, commit=False):
""" Low level child management. Send given HTTP method with given nurest_object to given ressource of current object
Args:
nurest_obje... | python | def _manage_child_object(self, nurest_object, method=HTTP_METHOD_GET, async=False, callback=None, handler=None, response_choice=None, commit=False):
""" Low level child management. Send given HTTP method with given nurest_object to given ressource of current object
Args:
nurest_obje... | [
"def",
"_manage_child_object",
"(",
"self",
",",
"nurest_object",
",",
"method",
"=",
"HTTP_METHOD_GET",
",",
"async",
"=",
"False",
",",
"callback",
"=",
"None",
",",
"handler",
"=",
"None",
",",
"response_choice",
"=",
"None",
",",
"commit",
"=",
"False",
... | Low level child management. Send given HTTP method with given nurest_object to given ressource of current object
Args:
nurest_object: the NURESTObject object to manage
method: the HTTP method to use (GET, POST, PUT, DELETE)
callback: the callback to call at t... | [
"Low",
"level",
"child",
"management",
".",
"Send",
"given",
"HTTP",
"method",
"with",
"given",
"nurest_object",
"to",
"given",
"ressource",
"of",
"current",
"object"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L815-L849 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject._did_receive_response | def _did_receive_response(self, connection):
""" Receive a response from the connection """
if connection.has_timeouted:
bambou_logger.info("NURESTConnection has timeout.")
return
has_callbacks = connection.has_callbacks()
should_post = not has_callbacks
... | python | def _did_receive_response(self, connection):
""" Receive a response from the connection """
if connection.has_timeouted:
bambou_logger.info("NURESTConnection has timeout.")
return
has_callbacks = connection.has_callbacks()
should_post = not has_callbacks
... | [
"def",
"_did_receive_response",
"(",
"self",
",",
"connection",
")",
":",
"if",
"connection",
".",
"has_timeouted",
":",
"bambou_logger",
".",
"info",
"(",
"\"NURESTConnection has timeout.\"",
")",
"return",
"has_callbacks",
"=",
"connection",
".",
"has_callbacks",
... | Receive a response from the connection | [
"Receive",
"a",
"response",
"from",
"the",
"connection"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L853-L865 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject._did_retrieve | def _did_retrieve(self, connection):
""" Callback called after fetching the object """
response = connection.response
try:
self.from_dict(response.data[0])
except:
pass
return self._did_perform_standard_operation(connection) | python | def _did_retrieve(self, connection):
""" Callback called after fetching the object """
response = connection.response
try:
self.from_dict(response.data[0])
except:
pass
return self._did_perform_standard_operation(connection) | [
"def",
"_did_retrieve",
"(",
"self",
",",
"connection",
")",
":",
"response",
"=",
"connection",
".",
"response",
"try",
":",
"self",
".",
"from_dict",
"(",
"response",
".",
"data",
"[",
"0",
"]",
")",
"except",
":",
"pass",
"return",
"self",
".",
"_di... | Callback called after fetching the object | [
"Callback",
"called",
"after",
"fetching",
"the",
"object"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L867-L877 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject._did_perform_standard_operation | def _did_perform_standard_operation(self, connection):
""" Performs standard opertions """
if connection.async:
callback = connection.callbacks['remote']
if connection.user_info and 'nurest_object' in connection.user_info:
callback(connection.user_info['nurest_o... | python | def _did_perform_standard_operation(self, connection):
""" Performs standard opertions """
if connection.async:
callback = connection.callbacks['remote']
if connection.user_info and 'nurest_object' in connection.user_info:
callback(connection.user_info['nurest_o... | [
"def",
"_did_perform_standard_operation",
"(",
"self",
",",
"connection",
")",
":",
"if",
"connection",
".",
"async",
":",
"callback",
"=",
"connection",
".",
"callbacks",
"[",
"'remote'",
"]",
"if",
"connection",
".",
"user_info",
"and",
"'nurest_object'",
"in"... | Performs standard opertions | [
"Performs",
"standard",
"opertions"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L879-L908 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.create_child | def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nur... | python | def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nur... | [
"def",
"create_child",
"(",
"self",
",",
"nurest_object",
",",
"response_choice",
"=",
"None",
",",
"async",
"=",
"False",
",",
"callback",
"=",
"None",
",",
"commit",
"=",
"True",
")",
":",
"# if nurest_object.id:",
"# raise InternalConsitencyError(\"Cannot cre... | Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatica... | [
"Add",
"given",
"nurest_object",
"to",
"the",
"current",
"object"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L912-L941 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.instantiate_child | def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject templ... | python | def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject templ... | [
"def",
"instantiate_child",
"(",
"self",
",",
"nurest_object",
",",
"from_template",
",",
"response_choice",
"=",
"None",
",",
"async",
"=",
"False",
",",
"callback",
"=",
"None",
",",
"commit",
"=",
"True",
")",
":",
"# if nurest_object.id:",
"# raise Inter... | Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns t... | [
"Instantiate",
"an",
"nurest_object",
"from",
"a",
"template",
"object"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L943-L975 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject._did_create_child | def _did_create_child(self, connection):
""" Callback called after adding a new child nurest_object """
response = connection.response
try:
connection.user_info['nurest_object'].from_dict(response.data[0])
except Exception:
pass
return self._did_perform_... | python | def _did_create_child(self, connection):
""" Callback called after adding a new child nurest_object """
response = connection.response
try:
connection.user_info['nurest_object'].from_dict(response.data[0])
except Exception:
pass
return self._did_perform_... | [
"def",
"_did_create_child",
"(",
"self",
",",
"connection",
")",
":",
"response",
"=",
"connection",
".",
"response",
"try",
":",
"connection",
".",
"user_info",
"[",
"'nurest_object'",
"]",
".",
"from_dict",
"(",
"response",
".",
"data",
"[",
"0",
"]",
")... | Callback called after adding a new child nurest_object | [
"Callback",
"called",
"after",
"adding",
"a",
"new",
"child",
"nurest_object"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L977-L986 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.assign | def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
... | python | def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
... | [
"def",
"assign",
"(",
"self",
",",
"objects",
",",
"nurest_object_type",
",",
"async",
"=",
"False",
",",
"callback",
"=",
"None",
",",
"commit",
"=",
"True",
")",
":",
"ids",
"=",
"list",
"(",
")",
"for",
"nurest_object",
"in",
"objects",
":",
"ids",
... | Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
... | [
"Reference",
"a",
"list",
"of",
"objects",
"into",
"the",
"current",
"resource"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L988-L1022 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.rest_equals | def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict() | python | def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict() | [
"def",
"rest_equals",
"(",
"self",
",",
"rest_object",
")",
":",
"if",
"not",
"self",
".",
"equals",
"(",
"rest_object",
")",
":",
"return",
"False",
"return",
"self",
".",
"to_dict",
"(",
")",
"==",
"rest_object",
".",
"to_dict",
"(",
")"
] | Compare objects REST attributes | [
"Compare",
"objects",
"REST",
"attributes"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L1026-L1033 |
nuagenetworks/bambou | bambou/nurest_object.py | NURESTObject.equals | def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object... | python | def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object... | [
"def",
"equals",
"(",
"self",
",",
"rest_object",
")",
":",
"if",
"self",
".",
"_is_dirty",
":",
"return",
"False",
"if",
"rest_object",
"is",
"None",
":",
"return",
"False",
"if",
"not",
"isinstance",
"(",
"rest_object",
",",
"NURESTObject",
")",
":",
"... | Compare with another object | [
"Compare",
"with",
"another",
"object"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L1035-L1056 |
opennode/waldur-core | waldur_core/logging/middleware.py | get_ip_address | def get_ip_address(request):
"""
Correct IP address is expected as first element of HTTP_X_FORWARDED_FOR or REMOTE_ADDR
"""
if 'HTTP_X_FORWARDED_FOR' in request.META:
return request.META['HTTP_X_FORWARDED_FOR'].split(',')[0].strip()
else:
return request.META['REMOTE_ADDR'] | python | def get_ip_address(request):
"""
Correct IP address is expected as first element of HTTP_X_FORWARDED_FOR or REMOTE_ADDR
"""
if 'HTTP_X_FORWARDED_FOR' in request.META:
return request.META['HTTP_X_FORWARDED_FOR'].split(',')[0].strip()
else:
return request.META['REMOTE_ADDR'] | [
"def",
"get_ip_address",
"(",
"request",
")",
":",
"if",
"'HTTP_X_FORWARDED_FOR'",
"in",
"request",
".",
"META",
":",
"return",
"request",
".",
"META",
"[",
"'HTTP_X_FORWARDED_FOR'",
"]",
".",
"split",
"(",
"','",
")",
"[",
"0",
"]",
".",
"strip",
"(",
"... | Correct IP address is expected as first element of HTTP_X_FORWARDED_FOR or REMOTE_ADDR | [
"Correct",
"IP",
"address",
"is",
"expected",
"as",
"first",
"element",
"of",
"HTTP_X_FORWARDED_FOR",
"or",
"REMOTE_ADDR"
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/middleware.py#L29-L36 |
opennode/waldur-core | waldur_core/cost_tracking/management/commands/delete_invalid_price_estimates.py | Command.get_estimates_without_scope_in_month | def get_estimates_without_scope_in_month(self, customer):
"""
It is expected that valid row for each month contains at least one
price estimate for customer, service setting, service,
service project link, project and resource.
Otherwise all price estimates in the row should be d... | python | def get_estimates_without_scope_in_month(self, customer):
"""
It is expected that valid row for each month contains at least one
price estimate for customer, service setting, service,
service project link, project and resource.
Otherwise all price estimates in the row should be d... | [
"def",
"get_estimates_without_scope_in_month",
"(",
"self",
",",
"customer",
")",
":",
"estimates",
"=",
"self",
".",
"get_price_estimates_for_customer",
"(",
"customer",
")",
"if",
"not",
"estimates",
":",
"return",
"[",
"]",
"tables",
"=",
"{",
"model",
":",
... | It is expected that valid row for each month contains at least one
price estimate for customer, service setting, service,
service project link, project and resource.
Otherwise all price estimates in the row should be deleted. | [
"It",
"is",
"expected",
"that",
"valid",
"row",
"for",
"each",
"month",
"contains",
"at",
"least",
"one",
"price",
"estimate",
"for",
"customer",
"service",
"setting",
"service",
"service",
"project",
"link",
"project",
"and",
"resource",
".",
"Otherwise",
"al... | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/management/commands/delete_invalid_price_estimates.py#L78-L109 |
nuagenetworks/bambou | bambou/utils/nuremote_attribute.py | NURemoteAttribute.is_identifier | def is_identifier(self, is_identifier):
""" Setter for is_identifier """
if is_identifier:
self.is_editable = False
self._is_identifier = is_identifier | python | def is_identifier(self, is_identifier):
""" Setter for is_identifier """
if is_identifier:
self.is_editable = False
self._is_identifier = is_identifier | [
"def",
"is_identifier",
"(",
"self",
",",
"is_identifier",
")",
":",
"if",
"is_identifier",
":",
"self",
".",
"is_editable",
"=",
"False",
"self",
".",
"_is_identifier",
"=",
"is_identifier"
] | Setter for is_identifier | [
"Setter",
"for",
"is_identifier"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/utils/nuremote_attribute.py#L75-L81 |
nuagenetworks/bambou | bambou/utils/nuremote_attribute.py | NURemoteAttribute.is_password | def is_password(self, is_password):
""" Setter for is_identifier """
if is_password:
self.is_forgetable = True
self._is_password = is_password | python | def is_password(self, is_password):
""" Setter for is_identifier """
if is_password:
self.is_forgetable = True
self._is_password = is_password | [
"def",
"is_password",
"(",
"self",
",",
"is_password",
")",
":",
"if",
"is_password",
":",
"self",
".",
"is_forgetable",
"=",
"True",
"self",
".",
"_is_password",
"=",
"is_password"
] | Setter for is_identifier | [
"Setter",
"for",
"is_identifier"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/utils/nuremote_attribute.py#L90-L96 |
nuagenetworks/bambou | bambou/utils/nuremote_attribute.py | NURemoteAttribute.choices | def choices(self, choices):
""" Setter for is_identifier """
if choices is not None and len(choices) > 0:
self.has_choices = True
self._choices = choices | python | def choices(self, choices):
""" Setter for is_identifier """
if choices is not None and len(choices) > 0:
self.has_choices = True
self._choices = choices | [
"def",
"choices",
"(",
"self",
",",
"choices",
")",
":",
"if",
"choices",
"is",
"not",
"None",
"and",
"len",
"(",
"choices",
")",
">",
"0",
":",
"self",
".",
"has_choices",
"=",
"True",
"self",
".",
"_choices",
"=",
"choices"
] | Setter for is_identifier | [
"Setter",
"for",
"is_identifier"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/utils/nuremote_attribute.py#L105-L111 |
nuagenetworks/bambou | bambou/utils/nuremote_attribute.py | NURemoteAttribute.get_default_value | def get_default_value(self):
""" Get a default value of the attribute_type """
if self.choices:
return self.choices[0]
value = self.attribute_type()
if self.attribute_type is time:
value = int(value)
elif self.attribute_type is str:
value =... | python | def get_default_value(self):
""" Get a default value of the attribute_type """
if self.choices:
return self.choices[0]
value = self.attribute_type()
if self.attribute_type is time:
value = int(value)
elif self.attribute_type is str:
value =... | [
"def",
"get_default_value",
"(",
"self",
")",
":",
"if",
"self",
".",
"choices",
":",
"return",
"self",
".",
"choices",
"[",
"0",
"]",
"value",
"=",
"self",
".",
"attribute_type",
"(",
")",
"if",
"self",
".",
"attribute_type",
"is",
"time",
":",
"value... | Get a default value of the attribute_type | [
"Get",
"a",
"default",
"value",
"of",
"the",
"attribute_type"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/utils/nuremote_attribute.py#L115-L141 |
nuagenetworks/bambou | bambou/utils/nuremote_attribute.py | NURemoteAttribute.get_min_value | def get_min_value(self):
""" Get the minimum value """
value = self.get_default_value()
if self.attribute_type is str:
min_value = value[:self.min_length - 1]
elif self.attribute_type is int:
min_value = self.min_length - 1
else:
raise Type... | python | def get_min_value(self):
""" Get the minimum value """
value = self.get_default_value()
if self.attribute_type is str:
min_value = value[:self.min_length - 1]
elif self.attribute_type is int:
min_value = self.min_length - 1
else:
raise Type... | [
"def",
"get_min_value",
"(",
"self",
")",
":",
"value",
"=",
"self",
".",
"get_default_value",
"(",
")",
"if",
"self",
".",
"attribute_type",
"is",
"str",
":",
"min_value",
"=",
"value",
"[",
":",
"self",
".",
"min_length",
"-",
"1",
"]",
"elif",
"self... | Get the minimum value | [
"Get",
"the",
"minimum",
"value"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/utils/nuremote_attribute.py#L143-L157 |
nuagenetworks/bambou | bambou/utils/nuremote_attribute.py | NURemoteAttribute.get_max_value | def get_max_value(self):
""" Get the maximum value """
value = self.get_default_value()
if self.attribute_type is str:
max_value = value.ljust(self.max_length + 1, 'a')
elif self.attribute_type is int:
max_value = self.max_length + 1
else:
... | python | def get_max_value(self):
""" Get the maximum value """
value = self.get_default_value()
if self.attribute_type is str:
max_value = value.ljust(self.max_length + 1, 'a')
elif self.attribute_type is int:
max_value = self.max_length + 1
else:
... | [
"def",
"get_max_value",
"(",
"self",
")",
":",
"value",
"=",
"self",
".",
"get_default_value",
"(",
")",
"if",
"self",
".",
"attribute_type",
"is",
"str",
":",
"max_value",
"=",
"value",
".",
"ljust",
"(",
"self",
".",
"max_length",
"+",
"1",
",",
"'a'... | Get the maximum value | [
"Get",
"the",
"maximum",
"value"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/utils/nuremote_attribute.py#L159-L173 |
opennode/waldur-core | waldur_core/core/routers.py | SortedDefaultRouter.get_api_root_view | def get_api_root_view(self, api_urls=None):
"""
Return a basic root view.
"""
api_root_dict = OrderedDict()
list_name = self.routes[0].name
for prefix, viewset, basename in self.registry:
api_root_dict[prefix] = list_name.format(basename=basename)
cla... | python | def get_api_root_view(self, api_urls=None):
"""
Return a basic root view.
"""
api_root_dict = OrderedDict()
list_name = self.routes[0].name
for prefix, viewset, basename in self.registry:
api_root_dict[prefix] = list_name.format(basename=basename)
cla... | [
"def",
"get_api_root_view",
"(",
"self",
",",
"api_urls",
"=",
"None",
")",
":",
"api_root_dict",
"=",
"OrderedDict",
"(",
")",
"list_name",
"=",
"self",
".",
"routes",
"[",
"0",
"]",
".",
"name",
"for",
"prefix",
",",
"viewset",
",",
"basename",
"in",
... | Return a basic root view. | [
"Return",
"a",
"basic",
"root",
"view",
"."
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/routers.py#L13-L47 |
opennode/waldur-core | waldur_core/core/routers.py | SortedDefaultRouter.get_default_base_name | def get_default_base_name(self, viewset):
"""
Attempt to automatically determine base name using `get_url_name`.
"""
queryset = getattr(viewset, 'queryset', None)
if queryset is not None:
get_url_name = getattr(queryset.model, 'get_url_name', None)
if get... | python | def get_default_base_name(self, viewset):
"""
Attempt to automatically determine base name using `get_url_name`.
"""
queryset = getattr(viewset, 'queryset', None)
if queryset is not None:
get_url_name = getattr(queryset.model, 'get_url_name', None)
if get... | [
"def",
"get_default_base_name",
"(",
"self",
",",
"viewset",
")",
":",
"queryset",
"=",
"getattr",
"(",
"viewset",
",",
"'queryset'",
",",
"None",
")",
"if",
"queryset",
"is",
"not",
"None",
":",
"get_url_name",
"=",
"getattr",
"(",
"queryset",
".",
"model... | Attempt to automatically determine base name using `get_url_name`. | [
"Attempt",
"to",
"automatically",
"determine",
"base",
"name",
"using",
"get_url_name",
"."
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/routers.py#L49-L60 |
opennode/waldur-core | waldur_core/structure/handlers.py | change_customer_nc_users_quota | def change_customer_nc_users_quota(sender, structure, user, role, signal, **kwargs):
""" Modify nc_user_count quota usage on structure role grant or revoke """
assert signal in (signals.structure_role_granted, signals.structure_role_revoked), \
'Handler "change_customer_nc_users_quota" has to be used on... | python | def change_customer_nc_users_quota(sender, structure, user, role, signal, **kwargs):
""" Modify nc_user_count quota usage on structure role grant or revoke """
assert signal in (signals.structure_role_granted, signals.structure_role_revoked), \
'Handler "change_customer_nc_users_quota" has to be used on... | [
"def",
"change_customer_nc_users_quota",
"(",
"sender",
",",
"structure",
",",
"user",
",",
"role",
",",
"signal",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"signal",
"in",
"(",
"signals",
".",
"structure_role_granted",
",",
"signals",
".",
"structure_role_... | Modify nc_user_count quota usage on structure role grant or revoke | [
"Modify",
"nc_user_count",
"quota",
"usage",
"on",
"structure",
"role",
"grant",
"or",
"revoke"
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/handlers.py#L196-L209 |
opennode/waldur-core | waldur_core/structure/handlers.py | delete_service_settings_on_service_delete | def delete_service_settings_on_service_delete(sender, instance, **kwargs):
""" Delete not shared service settings without services """
service = instance
try:
service_settings = service.settings
except ServiceSettings.DoesNotExist:
# If this handler works together with delete_service_set... | python | def delete_service_settings_on_service_delete(sender, instance, **kwargs):
""" Delete not shared service settings without services """
service = instance
try:
service_settings = service.settings
except ServiceSettings.DoesNotExist:
# If this handler works together with delete_service_set... | [
"def",
"delete_service_settings_on_service_delete",
"(",
"sender",
",",
"instance",
",",
"*",
"*",
"kwargs",
")",
":",
"service",
"=",
"instance",
"try",
":",
"service_settings",
"=",
"service",
".",
"settings",
"except",
"ServiceSettings",
".",
"DoesNotExist",
":... | Delete not shared service settings without services | [
"Delete",
"not",
"shared",
"service",
"settings",
"without",
"services"
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/handlers.py#L312-L322 |
opennode/waldur-core | waldur_core/structure/handlers.py | delete_service_settings_on_scope_delete | def delete_service_settings_on_scope_delete(sender, instance, **kwargs):
""" If VM that contains service settings were deleted - all settings
resources could be safely deleted from NC.
"""
for service_settings in ServiceSettings.objects.filter(scope=instance):
service_settings.unlink_descend... | python | def delete_service_settings_on_scope_delete(sender, instance, **kwargs):
""" If VM that contains service settings were deleted - all settings
resources could be safely deleted from NC.
"""
for service_settings in ServiceSettings.objects.filter(scope=instance):
service_settings.unlink_descend... | [
"def",
"delete_service_settings_on_scope_delete",
"(",
"sender",
",",
"instance",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"service_settings",
"in",
"ServiceSettings",
".",
"objects",
".",
"filter",
"(",
"scope",
"=",
"instance",
")",
":",
"service_settings",
"... | If VM that contains service settings were deleted - all settings
resources could be safely deleted from NC. | [
"If",
"VM",
"that",
"contains",
"service",
"settings",
"were",
"deleted",
"-",
"all",
"settings",
"resources",
"could",
"be",
"safely",
"deleted",
"from",
"NC",
"."
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/handlers.py#L343-L349 |
nuagenetworks/bambou | bambou/nurest_login_controller.py | NURESTLoginController.url | def url(self, url):
""" Set API URL endpoint
Args:
url: the url of the API endpoint
"""
if url and url.endswith('/'):
url = url[:-1]
self._url = url | python | def url(self, url):
""" Set API URL endpoint
Args:
url: the url of the API endpoint
"""
if url and url.endswith('/'):
url = url[:-1]
self._url = url | [
"def",
"url",
"(",
"self",
",",
"url",
")",
":",
"if",
"url",
"and",
"url",
".",
"endswith",
"(",
"'/'",
")",
":",
"url",
"=",
"url",
"[",
":",
"-",
"1",
"]",
"self",
".",
"_url",
"=",
"url"
] | Set API URL endpoint
Args:
url: the url of the API endpoint | [
"Set",
"API",
"URL",
"endpoint"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_login_controller.py#L191-L200 |
nuagenetworks/bambou | bambou/nurest_login_controller.py | NURESTLoginController.get_authentication_header | def get_authentication_header(self, user=None, api_key=None, password=None, certificate=None):
""" Return authenication string to place in Authorization Header
If API Token is set, it'll be used. Otherwise, the clear
text password will be sent. Users of NURESTLoginController are respons... | python | def get_authentication_header(self, user=None, api_key=None, password=None, certificate=None):
""" Return authenication string to place in Authorization Header
If API Token is set, it'll be used. Otherwise, the clear
text password will be sent. Users of NURESTLoginController are respons... | [
"def",
"get_authentication_header",
"(",
"self",
",",
"user",
"=",
"None",
",",
"api_key",
"=",
"None",
",",
"password",
"=",
"None",
",",
"certificate",
"=",
"None",
")",
":",
"if",
"not",
"user",
":",
"user",
"=",
"self",
".",
"user",
"if",
"not",
... | Return authenication string to place in Authorization Header
If API Token is set, it'll be used. Otherwise, the clear
text password will be sent. Users of NURESTLoginController are responsible to
clean the password property.
Returns:
Returns the XREST Au... | [
"Return",
"authenication",
"string",
"to",
"place",
"in",
"Authorization",
"Header"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_login_controller.py#L223-L256 |
nuagenetworks/bambou | bambou/nurest_login_controller.py | NURESTLoginController.reset | def reset(self):
""" Reset controller
It removes all information about previous session
"""
self._is_impersonating = False
self._impersonation = None
self.user = None
self.password = None
self.api_key = None
self.enterprise = None
se... | python | def reset(self):
""" Reset controller
It removes all information about previous session
"""
self._is_impersonating = False
self._impersonation = None
self.user = None
self.password = None
self.api_key = None
self.enterprise = None
se... | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"_is_impersonating",
"=",
"False",
"self",
".",
"_impersonation",
"=",
"None",
"self",
".",
"user",
"=",
"None",
"self",
".",
"password",
"=",
"None",
"self",
".",
"api_key",
"=",
"None",
"self",
".",... | Reset controller
It removes all information about previous session | [
"Reset",
"controller"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_login_controller.py#L258-L271 |
nuagenetworks/bambou | bambou/nurest_login_controller.py | NURESTLoginController.impersonate | def impersonate(self, user, enterprise):
""" Impersonate a user in a enterprise
Args:
user: the name of the user to impersonate
enterprise: the name of the enterprise where to use impersonation
"""
if not user or not enterprise:
raise Val... | python | def impersonate(self, user, enterprise):
""" Impersonate a user in a enterprise
Args:
user: the name of the user to impersonate
enterprise: the name of the enterprise where to use impersonation
"""
if not user or not enterprise:
raise Val... | [
"def",
"impersonate",
"(",
"self",
",",
"user",
",",
"enterprise",
")",
":",
"if",
"not",
"user",
"or",
"not",
"enterprise",
":",
"raise",
"ValueError",
"(",
"'You must set a user name and an enterprise name to begin impersonification'",
")",
"self",
".",
"_is_imperso... | Impersonate a user in a enterprise
Args:
user: the name of the user to impersonate
enterprise: the name of the enterprise where to use impersonation | [
"Impersonate",
"a",
"user",
"in",
"a",
"enterprise"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_login_controller.py#L273-L285 |
nuagenetworks/bambou | bambou/nurest_login_controller.py | NURESTLoginController.equals | def equals(self, controller):
""" Verify if the controller corresponds
to the current one.
"""
if controller is None:
return False
return self.user == controller.user and self.enterprise == controller.enterprise and self.url == controller.url | python | def equals(self, controller):
""" Verify if the controller corresponds
to the current one.
"""
if controller is None:
return False
return self.user == controller.user and self.enterprise == controller.enterprise and self.url == controller.url | [
"def",
"equals",
"(",
"self",
",",
"controller",
")",
":",
"if",
"controller",
"is",
"None",
":",
"return",
"False",
"return",
"self",
".",
"user",
"==",
"controller",
".",
"user",
"and",
"self",
".",
"enterprise",
"==",
"controller",
".",
"enterprise",
... | Verify if the controller corresponds
to the current one. | [
"Verify",
"if",
"the",
"controller",
"corresponds",
"to",
"the",
"current",
"one",
"."
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_login_controller.py#L294-L302 |
stepank/pyws | src/pyws/adapters/_wsgi.py | create_application | def create_application(server, root_url):
"""
WSGI adapter. It creates a simple WSGI application, that can be used with
any WSGI server. The arguments are:
#. ``server`` is a pyws server object,
#. ``root_url`` is an URL to which the server will be bound.
An application created by the function... | python | def create_application(server, root_url):
"""
WSGI adapter. It creates a simple WSGI application, that can be used with
any WSGI server. The arguments are:
#. ``server`` is a pyws server object,
#. ``root_url`` is an URL to which the server will be bound.
An application created by the function... | [
"def",
"create_application",
"(",
"server",
",",
"root_url",
")",
":",
"def",
"serve",
"(",
"environ",
",",
"start_response",
")",
":",
"root",
"=",
"root_url",
".",
"lstrip",
"(",
"'/'",
")",
"tail",
",",
"get",
"=",
"(",
"util",
".",
"request_uri",
"... | WSGI adapter. It creates a simple WSGI application, that can be used with
any WSGI server. The arguments are:
#. ``server`` is a pyws server object,
#. ``root_url`` is an URL to which the server will be bound.
An application created by the function transforms WSGI environment into a
pyws request o... | [
"WSGI",
"adapter",
".",
"It",
"creates",
"a",
"simple",
"WSGI",
"application",
"that",
"can",
"be",
"used",
"with",
"any",
"WSGI",
"server",
".",
"The",
"arguments",
"are",
":"
] | train | https://github.com/stepank/pyws/blob/ff39133aabeb56bbb08d66286ac0cc8731eda7dd/src/pyws/adapters/_wsgi.py#L8-L58 |
zeromake/aiosqlite3 | aiosqlite3/sa/engine.py | compiler_dialect | def compiler_dialect(paramstyle='named'):
"""
构建dialect
"""
dialect = SQLiteDialect_pysqlite(
json_serializer=json.dumps,
json_deserializer=json_deserializer,
paramstyle=paramstyle
)
dialect.default_paramstyle = paramstyle
dialect.statement_compiler = ACompiler_sqlite... | python | def compiler_dialect(paramstyle='named'):
"""
构建dialect
"""
dialect = SQLiteDialect_pysqlite(
json_serializer=json.dumps,
json_deserializer=json_deserializer,
paramstyle=paramstyle
)
dialect.default_paramstyle = paramstyle
dialect.statement_compiler = ACompiler_sqlite... | [
"def",
"compiler_dialect",
"(",
"paramstyle",
"=",
"'named'",
")",
":",
"dialect",
"=",
"SQLiteDialect_pysqlite",
"(",
"json_serializer",
"=",
"json",
".",
"dumps",
",",
"json_deserializer",
"=",
"json_deserializer",
",",
"paramstyle",
"=",
"paramstyle",
")",
"dia... | 构建dialect | [
"构建dialect"
] | train | https://github.com/zeromake/aiosqlite3/blob/1a74a062507e2df8f833a70885e69dca0ab3e7e7/aiosqlite3/sa/engine.py#L58-L69 |
zeromake/aiosqlite3 | aiosqlite3/sa/engine.py | create_engine | def create_engine(
database,
minsize=1,
maxsize=10,
loop=None,
dialect=_dialect,
paramstyle=None,
**kwargs):
"""
A coroutine for Engine creation.
Returns Engine instance with embedded connection pool.
The pool has *minsize* opened connections to ... | python | def create_engine(
database,
minsize=1,
maxsize=10,
loop=None,
dialect=_dialect,
paramstyle=None,
**kwargs):
"""
A coroutine for Engine creation.
Returns Engine instance with embedded connection pool.
The pool has *minsize* opened connections to ... | [
"def",
"create_engine",
"(",
"database",
",",
"minsize",
"=",
"1",
",",
"maxsize",
"=",
"10",
",",
"loop",
"=",
"None",
",",
"dialect",
"=",
"_dialect",
",",
"paramstyle",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"coro",
"=",
"_create_engine",
... | A coroutine for Engine creation.
Returns Engine instance with embedded connection pool.
The pool has *minsize* opened connections to sqlite3. | [
"A",
"coroutine",
"for",
"Engine",
"creation",
"."
] | train | https://github.com/zeromake/aiosqlite3/blob/1a74a062507e2df8f833a70885e69dca0ab3e7e7/aiosqlite3/sa/engine.py#L75-L99 |
zeromake/aiosqlite3 | aiosqlite3/sa/engine.py | Engine.release | def release(self, conn):
"""Revert back connection to pool."""
if conn.in_transaction:
raise InvalidRequestError(
"Cannot release a connection with "
"not finished transaction"
)
raw = conn.connection
res = yield from self._pool.rel... | python | def release(self, conn):
"""Revert back connection to pool."""
if conn.in_transaction:
raise InvalidRequestError(
"Cannot release a connection with "
"not finished transaction"
)
raw = conn.connection
res = yield from self._pool.rel... | [
"def",
"release",
"(",
"self",
",",
"conn",
")",
":",
"if",
"conn",
".",
"in_transaction",
":",
"raise",
"InvalidRequestError",
"(",
"\"Cannot release a connection with \"",
"\"not finished transaction\"",
")",
"raw",
"=",
"conn",
".",
"connection",
"res",
"=",
"y... | Revert back connection to pool. | [
"Revert",
"back",
"connection",
"to",
"pool",
"."
] | train | https://github.com/zeromake/aiosqlite3/blob/1a74a062507e2df8f833a70885e69dca0ab3e7e7/aiosqlite3/sa/engine.py#L213-L222 |
opennode/waldur-core | waldur_core/cost_tracking/__init__.py | CostTrackingRegister.get_configuration | def get_configuration(cls, resource):
""" Return how much consumables are used by resource with current configuration.
Output example:
{
<ConsumableItem instance>: <usage>,
<ConsumableItem instance>: <usage>,
...
}
"""
... | python | def get_configuration(cls, resource):
""" Return how much consumables are used by resource with current configuration.
Output example:
{
<ConsumableItem instance>: <usage>,
<ConsumableItem instance>: <usage>,
...
}
"""
... | [
"def",
"get_configuration",
"(",
"cls",
",",
"resource",
")",
":",
"strategy",
"=",
"cls",
".",
"_get_strategy",
"(",
"resource",
".",
"__class__",
")",
"return",
"strategy",
".",
"get_configuration",
"(",
"resource",
")"
] | Return how much consumables are used by resource with current configuration.
Output example:
{
<ConsumableItem instance>: <usage>,
<ConsumableItem instance>: <usage>,
...
} | [
"Return",
"how",
"much",
"consumables",
"are",
"used",
"by",
"resource",
"with",
"current",
"configuration",
"."
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/__init__.py#L124-L135 |
zeromake/aiosqlite3 | aiosqlite3/sa/result.py | ResultProxy.close | def close(self):
"""Close this ResultProxy.
Closes the underlying DBAPI cursor corresponding to the execution.
Note that any data cached within this ResultProxy is still available.
For some types of results, this may include buffered rows.
If this ResultProxy was generated from a... | python | def close(self):
"""Close this ResultProxy.
Closes the underlying DBAPI cursor corresponding to the execution.
Note that any data cached within this ResultProxy is still available.
For some types of results, this may include buffered rows.
If this ResultProxy was generated from a... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_closed",
":",
"self",
".",
"_closed",
"=",
"True",
"yield",
"from",
"self",
".",
"_cursor",
".",
"close",
"(",
")",
"# allow consistent errors",
"self",
".",
"_cursor",
"=",
"None",
"se... | Close this ResultProxy.
Closes the underlying DBAPI cursor corresponding to the execution.
Note that any data cached within this ResultProxy is still available.
For some types of results, this may include buffered rows.
If this ResultProxy was generated from an implicit execution,
... | [
"Close",
"this",
"ResultProxy",
".",
"Closes",
"the",
"underlying",
"DBAPI",
"cursor",
"corresponding",
"to",
"the",
"execution",
".",
"Note",
"that",
"any",
"data",
"cached",
"within",
"this",
"ResultProxy",
"is",
"still",
"available",
".",
"For",
"some",
"ty... | train | https://github.com/zeromake/aiosqlite3/blob/1a74a062507e2df8f833a70885e69dca0ab3e7e7/aiosqlite3/sa/result.py#L315-L336 |
OpenDataScienceLab/skdata | setup.py | get_version | def get_version():
"""Obtain the version number"""
import imp
import os
mod = imp.load_source(
'version', os.path.join('skdata', '__init__.py')
)
return mod.__version__ | python | def get_version():
"""Obtain the version number"""
import imp
import os
mod = imp.load_source(
'version', os.path.join('skdata', '__init__.py')
)
return mod.__version__ | [
"def",
"get_version",
"(",
")",
":",
"import",
"imp",
"import",
"os",
"mod",
"=",
"imp",
".",
"load_source",
"(",
"'version'",
",",
"os",
".",
"path",
".",
"join",
"(",
"'skdata'",
",",
"'__init__.py'",
")",
")",
"return",
"mod",
".",
"__version__"
] | Obtain the version number | [
"Obtain",
"the",
"version",
"number"
] | train | https://github.com/OpenDataScienceLab/skdata/blob/34f06845a944ff4f048b55c7babdd8420f71a6b9/setup.py#L29-L36 |
opennode/waldur-core | waldur_core/users/views.py | InvitationViewSet.accept | def accept(self, request, uuid=None):
""" Accept invitation for current user.
To replace user's email with email from invitation - add parameter
'replace_email' to request POST body.
"""
invitation = self.get_object()
if invitation.state != models.Invitation.Sta... | python | def accept(self, request, uuid=None):
""" Accept invitation for current user.
To replace user's email with email from invitation - add parameter
'replace_email' to request POST body.
"""
invitation = self.get_object()
if invitation.state != models.Invitation.Sta... | [
"def",
"accept",
"(",
"self",
",",
"request",
",",
"uuid",
"=",
"None",
")",
":",
"invitation",
"=",
"self",
".",
"get_object",
"(",
")",
"if",
"invitation",
".",
"state",
"!=",
"models",
".",
"Invitation",
".",
"State",
".",
"PENDING",
":",
"raise",
... | Accept invitation for current user.
To replace user's email with email from invitation - add parameter
'replace_email' to request POST body. | [
"Accept",
"invitation",
"for",
"current",
"user",
"."
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/users/views.py#L94-L119 |
opennode/waldur-core | waldur_core/cost_tracking/handlers.py | scope_deletion | def scope_deletion(sender, instance, **kwargs):
""" Run different actions on price estimate scope deletion.
If scope is a customer - delete all customer estimates and their children.
If scope is a deleted resource - redefine consumption details, recalculate
... | python | def scope_deletion(sender, instance, **kwargs):
""" Run different actions on price estimate scope deletion.
If scope is a customer - delete all customer estimates and their children.
If scope is a deleted resource - redefine consumption details, recalculate
... | [
"def",
"scope_deletion",
"(",
"sender",
",",
"instance",
",",
"*",
"*",
"kwargs",
")",
":",
"is_resource",
"=",
"isinstance",
"(",
"instance",
",",
"structure_models",
".",
"ResourceMixin",
")",
"if",
"is_resource",
"and",
"getattr",
"(",
"instance",
",",
"'... | Run different actions on price estimate scope deletion.
If scope is a customer - delete all customer estimates and their children.
If scope is a deleted resource - redefine consumption details, recalculate
ancestors estimates and update estimate details.
... | [
"Run",
"different",
"actions",
"on",
"price",
"estimate",
"scope",
"deletion",
"."
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/handlers.py#L16-L35 |
opennode/waldur-core | waldur_core/cost_tracking/handlers.py | _resource_deletion | def _resource_deletion(resource):
""" Recalculate consumption details and save resource details """
if resource.__class__ not in CostTrackingRegister.registered_resources:
return
new_configuration = {}
price_estimate = models.PriceEstimate.update_resource_estimate(resource, new_configuration)
... | python | def _resource_deletion(resource):
""" Recalculate consumption details and save resource details """
if resource.__class__ not in CostTrackingRegister.registered_resources:
return
new_configuration = {}
price_estimate = models.PriceEstimate.update_resource_estimate(resource, new_configuration)
... | [
"def",
"_resource_deletion",
"(",
"resource",
")",
":",
"if",
"resource",
".",
"__class__",
"not",
"in",
"CostTrackingRegister",
".",
"registered_resources",
":",
"return",
"new_configuration",
"=",
"{",
"}",
"price_estimate",
"=",
"models",
".",
"PriceEstimate",
... | Recalculate consumption details and save resource details | [
"Recalculate",
"consumption",
"details",
"and",
"save",
"resource",
"details"
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/handlers.py#L52-L58 |
opennode/waldur-core | waldur_core/cost_tracking/handlers.py | resource_update | def resource_update(sender, instance, created=False, **kwargs):
""" Update resource consumption details and price estimate if its configuration has changed.
Create estimates for previous months if resource was created not in current month.
"""
resource = instance
try:
new_configuration =... | python | def resource_update(sender, instance, created=False, **kwargs):
""" Update resource consumption details and price estimate if its configuration has changed.
Create estimates for previous months if resource was created not in current month.
"""
resource = instance
try:
new_configuration =... | [
"def",
"resource_update",
"(",
"sender",
",",
"instance",
",",
"created",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"resource",
"=",
"instance",
"try",
":",
"new_configuration",
"=",
"CostTrackingRegister",
".",
"get_configuration",
"(",
"resource",
")"... | Update resource consumption details and price estimate if its configuration has changed.
Create estimates for previous months if resource was created not in current month. | [
"Update",
"resource",
"consumption",
"details",
"and",
"price",
"estimate",
"if",
"its",
"configuration",
"has",
"changed",
".",
"Create",
"estimates",
"for",
"previous",
"months",
"if",
"resource",
"was",
"created",
"not",
"in",
"current",
"month",
"."
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/handlers.py#L66-L79 |
opennode/waldur-core | waldur_core/cost_tracking/handlers.py | resource_quota_update | def resource_quota_update(sender, instance, **kwargs):
""" Update resource consumption details and price estimate if its configuration has changed """
quota = instance
resource = quota.scope
try:
new_configuration = CostTrackingRegister.get_configuration(resource)
except ResourceNotRegistere... | python | def resource_quota_update(sender, instance, **kwargs):
""" Update resource consumption details and price estimate if its configuration has changed """
quota = instance
resource = quota.scope
try:
new_configuration = CostTrackingRegister.get_configuration(resource)
except ResourceNotRegistere... | [
"def",
"resource_quota_update",
"(",
"sender",
",",
"instance",
",",
"*",
"*",
"kwargs",
")",
":",
"quota",
"=",
"instance",
"resource",
"=",
"quota",
".",
"scope",
"try",
":",
"new_configuration",
"=",
"CostTrackingRegister",
".",
"get_configuration",
"(",
"r... | Update resource consumption details and price estimate if its configuration has changed | [
"Update",
"resource",
"consumption",
"details",
"and",
"price",
"estimate",
"if",
"its",
"configuration",
"has",
"changed"
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/handlers.py#L82-L91 |
opennode/waldur-core | waldur_core/cost_tracking/handlers.py | _create_historical_estimates | def _create_historical_estimates(resource, configuration):
""" Create consumption details and price estimates for past months.
Usually we need to update historical values on resource import.
"""
today = timezone.now()
month_start = core_utils.month_start(today)
while month_start > resource.... | python | def _create_historical_estimates(resource, configuration):
""" Create consumption details and price estimates for past months.
Usually we need to update historical values on resource import.
"""
today = timezone.now()
month_start = core_utils.month_start(today)
while month_start > resource.... | [
"def",
"_create_historical_estimates",
"(",
"resource",
",",
"configuration",
")",
":",
"today",
"=",
"timezone",
".",
"now",
"(",
")",
"month_start",
"=",
"core_utils",
".",
"month_start",
"(",
"today",
")",
"while",
"month_start",
">",
"resource",
".",
"crea... | Create consumption details and price estimates for past months.
Usually we need to update historical values on resource import. | [
"Create",
"consumption",
"details",
"and",
"price",
"estimates",
"for",
"past",
"months",
"."
] | train | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/handlers.py#L94-L103 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.