partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | QuotaField.get_aggregator_quotas | Fetch ancestors quotas that have the same name and are registered as aggregator quotas. | waldur_core/quotas/fields.py | def get_aggregator_quotas(self, quota):
""" Fetch ancestors quotas that have the same name and are registered as aggregator quotas. """
ancestors = quota.scope.get_quota_ancestors()
aggregator_quotas = []
for ancestor in ancestors:
for ancestor_quota_field in ancestor.get_quo... | def get_aggregator_quotas(self, quota):
""" Fetch ancestors quotas that have the same name and are registered as aggregator quotas. """
ancestors = quota.scope.get_quota_ancestors()
aggregator_quotas = []
for ancestor in ancestors:
for ancestor_quota_field in ancestor.get_quo... | [
"Fetch",
"ancestors",
"quotas",
"that",
"have",
"the",
"same",
"name",
"and",
"are",
"registered",
"as",
"aggregator",
"quotas",
"."
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/quotas/fields.py#L122-L130 | [
"def",
"get_aggregator_quotas",
"(",
"self",
",",
"quota",
")",
":",
"ancestors",
"=",
"quota",
".",
"scope",
".",
"get_quota_ancestors",
"(",
")",
"aggregator_quotas",
"=",
"[",
"]",
"for",
"ancestor",
"in",
"ancestors",
":",
"for",
"ancestor_quota_field",
"i... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | EventHook.subscribe | Adds a new event handler. | qcore/events.py | def subscribe(self, handler):
"""Adds a new event handler."""
assert callable(handler), "Invalid handler %s" % handler
self.handlers.append(handler) | def subscribe(self, handler):
"""Adds a new event handler."""
assert callable(handler), "Invalid handler %s" % handler
self.handlers.append(handler) | [
"Adds",
"a",
"new",
"event",
"handler",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/events.py#L46-L49 | [
"def",
"subscribe",
"(",
"self",
",",
"handler",
")",
":",
"assert",
"callable",
"(",
"handler",
")",
",",
"\"Invalid handler %s\"",
"%",
"handler",
"self",
".",
"handlers",
".",
"append",
"(",
"handler",
")"
] | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | EventHook.safe_trigger | *Safely* triggers the event by invoking all its
handlers, even if few of them raise an exception.
If a set of exceptions is raised during handler
invocation sequence, this method rethrows the first one.
:param args: the arguments to invoke event handlers with. | qcore/events.py | def safe_trigger(self, *args):
"""*Safely* triggers the event by invoking all its
handlers, even if few of them raise an exception.
If a set of exceptions is raised during handler
invocation sequence, this method rethrows the first one.
:param args: the arguments to invoke even... | def safe_trigger(self, *args):
"""*Safely* triggers the event by invoking all its
handlers, even if few of them raise an exception.
If a set of exceptions is raised during handler
invocation sequence, this method rethrows the first one.
:param args: the arguments to invoke even... | [
"*",
"Safely",
"*",
"triggers",
"the",
"event",
"by",
"invoking",
"all",
"its",
"handlers",
"even",
"if",
"few",
"of",
"them",
"raise",
"an",
"exception",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/events.py#L55-L76 | [
"def",
"safe_trigger",
"(",
"self",
",",
"*",
"args",
")",
":",
"error",
"=",
"None",
"# iterate over a copy of the original list because some event handlers",
"# may mutate the list",
"for",
"handler",
"in",
"list",
"(",
"self",
".",
"handlers",
")",
":",
"try",
":... | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | EventHub.on | Attaches the handler to the specified event.
@param event: event to attach the handler to. Any object can be passed
as event, but string is preferable. If qcore.EnumBase
instance is passed, its name is used as event key.
@param handler: event handler.
... | qcore/events.py | def on(self, event, handler):
"""Attaches the handler to the specified event.
@param event: event to attach the handler to. Any object can be passed
as event, but string is preferable. If qcore.EnumBase
instance is passed, its name is used as event key.
... | def on(self, event, handler):
"""Attaches the handler to the specified event.
@param event: event to attach the handler to. Any object can be passed
as event, but string is preferable. If qcore.EnumBase
instance is passed, its name is used as event key.
... | [
"Attaches",
"the",
"handler",
"to",
"the",
"specified",
"event",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/events.py#L217-L229 | [
"def",
"on",
"(",
"self",
",",
"event",
",",
"handler",
")",
":",
"event_hook",
"=",
"self",
".",
"get_or_create",
"(",
"event",
")",
"event_hook",
".",
"subscribe",
"(",
"handler",
")",
"return",
"self"
] | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | EventHub.off | Detaches the handler from the specified event.
@param event: event to detach the handler to. Any object can be passed
as event, but string is preferable. If qcore.EnumBase
instance is passed, its name is used as event key.
@param handler: event handler.
... | qcore/events.py | def off(self, event, handler):
"""Detaches the handler from the specified event.
@param event: event to detach the handler to. Any object can be passed
as event, but string is preferable. If qcore.EnumBase
instance is passed, its name is used as event key.
... | def off(self, event, handler):
"""Detaches the handler from the specified event.
@param event: event to detach the handler to. Any object can be passed
as event, but string is preferable. If qcore.EnumBase
instance is passed, its name is used as event key.
... | [
"Detaches",
"the",
"handler",
"from",
"the",
"specified",
"event",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/events.py#L231-L243 | [
"def",
"off",
"(",
"self",
",",
"event",
",",
"handler",
")",
":",
"event_hook",
"=",
"self",
".",
"get_or_create",
"(",
"event",
")",
"event_hook",
".",
"unsubscribe",
"(",
"handler",
")",
"return",
"self"
] | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | EventHub.trigger | Triggers the specified event by invoking EventHook.trigger under the hood.
@param event: event to trigger. Any object can be passed
as event, but string is preferable. If qcore.EnumBase
instance is passed, its name is used as event key.
@param args: event arg... | qcore/events.py | def trigger(self, event, *args):
"""Triggers the specified event by invoking EventHook.trigger under the hood.
@param event: event to trigger. Any object can be passed
as event, but string is preferable. If qcore.EnumBase
instance is passed, its name is used ... | def trigger(self, event, *args):
"""Triggers the specified event by invoking EventHook.trigger under the hood.
@param event: event to trigger. Any object can be passed
as event, but string is preferable. If qcore.EnumBase
instance is passed, its name is used ... | [
"Triggers",
"the",
"specified",
"event",
"by",
"invoking",
"EventHook",
".",
"trigger",
"under",
"the",
"hood",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/events.py#L245-L257 | [
"def",
"trigger",
"(",
"self",
",",
"event",
",",
"*",
"args",
")",
":",
"event_hook",
"=",
"self",
".",
"get_or_create",
"(",
"event",
")",
"event_hook",
".",
"trigger",
"(",
"*",
"args",
")",
"return",
"self"
] | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | EventHub.safe_trigger | Safely triggers the specified event by invoking
EventHook.safe_trigger under the hood.
@param event: event to trigger. Any object can be passed
as event, but string is preferable. If qcore.EnumBase
instance is passed, its name is used as event key.
@p... | qcore/events.py | def safe_trigger(self, event, *args):
"""Safely triggers the specified event by invoking
EventHook.safe_trigger under the hood.
@param event: event to trigger. Any object can be passed
as event, but string is preferable. If qcore.EnumBase
instance is ... | def safe_trigger(self, event, *args):
"""Safely triggers the specified event by invoking
EventHook.safe_trigger under the hood.
@param event: event to trigger. Any object can be passed
as event, but string is preferable. If qcore.EnumBase
instance is ... | [
"Safely",
"triggers",
"the",
"specified",
"event",
"by",
"invoking",
"EventHook",
".",
"safe_trigger",
"under",
"the",
"hood",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/events.py#L259-L272 | [
"def",
"safe_trigger",
"(",
"self",
",",
"event",
",",
"*",
"args",
")",
":",
"event_hook",
"=",
"self",
".",
"get_or_create",
"(",
"event",
")",
"event_hook",
".",
"safe_trigger",
"(",
"*",
"args",
")",
"return",
"self"
] | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | EventHub.get_or_create | Gets or creates a new event hook for the specified event (key).
This method treats qcore.EnumBase-typed event keys specially:
enum_member.name is used as key instead of enum instance
in case such a key is passed.
Note that on/off/trigger/safe_trigger methods rely on this method,
... | qcore/events.py | def get_or_create(self, event):
"""Gets or creates a new event hook for the specified event (key).
This method treats qcore.EnumBase-typed event keys specially:
enum_member.name is used as key instead of enum instance
in case such a key is passed.
Note that on/off/trigger/safe_... | def get_or_create(self, event):
"""Gets or creates a new event hook for the specified event (key).
This method treats qcore.EnumBase-typed event keys specially:
enum_member.name is used as key instead of enum instance
in case such a key is passed.
Note that on/off/trigger/safe_... | [
"Gets",
"or",
"creates",
"a",
"new",
"event",
"hook",
"for",
"the",
"specified",
"event",
"(",
"key",
")",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/events.py#L274-L287 | [
"def",
"get_or_create",
"(",
"self",
",",
"event",
")",
":",
"if",
"isinstance",
"(",
"event",
",",
"EnumBase",
")",
":",
"event",
"=",
"event",
".",
"short_name",
"return",
"self",
".",
"__dict__",
".",
"setdefault",
"(",
"event",
",",
"EventHook",
"(",... | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | cancel_expired_invitations | Invitation lifetime must be specified in Waldur Core settings with parameter
"INVITATION_LIFETIME". If invitation creation time is less than expiration time, the invitation will set as expired. | waldur_core/users/tasks.py | def cancel_expired_invitations(invitations=None):
"""
Invitation lifetime must be specified in Waldur Core settings with parameter
"INVITATION_LIFETIME". If invitation creation time is less than expiration time, the invitation will set as expired.
"""
expiration_date = timezone.now() - settings.WALD... | def cancel_expired_invitations(invitations=None):
"""
Invitation lifetime must be specified in Waldur Core settings with parameter
"INVITATION_LIFETIME". If invitation creation time is less than expiration time, the invitation will set as expired.
"""
expiration_date = timezone.now() - settings.WALD... | [
"Invitation",
"lifetime",
"must",
"be",
"specified",
"in",
"Waldur",
"Core",
"settings",
"with",
"parameter",
"INVITATION_LIFETIME",
".",
"If",
"invitation",
"creation",
"time",
"is",
"less",
"than",
"expiration",
"time",
"the",
"invitation",
"will",
"set",
"as",
... | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/users/tasks.py#L19-L28 | [
"def",
"cancel_expired_invitations",
"(",
"invitations",
"=",
"None",
")",
":",
"expiration_date",
"=",
"timezone",
".",
"now",
"(",
")",
"-",
"settings",
".",
"WALDUR_CORE",
"[",
"'INVITATION_LIFETIME'",
"]",
"if",
"not",
"invitations",
":",
"invitations",
"=",... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | FourByteDirectory.get_pseudo_abi_for_input | Lookup sighash from 4bytes.directory, create a pseudo api and try to decode it with the parsed abi.
May return multiple results as sighashes may collide.
:param s: bytes input
:return: pseudo abi for method | ethereum_input_decoder/decoder.py | def get_pseudo_abi_for_input(s, timeout=None, proxies=None):
"""
Lookup sighash from 4bytes.directory, create a pseudo api and try to decode it with the parsed abi.
May return multiple results as sighashes may collide.
:param s: bytes input
:return: pseudo abi for method
... | def get_pseudo_abi_for_input(s, timeout=None, proxies=None):
"""
Lookup sighash from 4bytes.directory, create a pseudo api and try to decode it with the parsed abi.
May return multiple results as sighashes may collide.
:param s: bytes input
:return: pseudo abi for method
... | [
"Lookup",
"sighash",
"from",
"4bytes",
".",
"directory",
"create",
"a",
"pseudo",
"api",
"and",
"try",
"to",
"decode",
"it",
"with",
"the",
"parsed",
"abi",
".",
"May",
"return",
"multiple",
"results",
"as",
"sighashes",
"may",
"collide",
".",
":",
"param"... | tintinweb/ethereum-input-decoder | python | https://github.com/tintinweb/ethereum-input-decoder/blob/aa96623e352fe096b6679cc3ea10ef62a260a711/ethereum_input_decoder/decoder.py#L70-L85 | [
"def",
"get_pseudo_abi_for_input",
"(",
"s",
",",
"timeout",
"=",
"None",
",",
"proxies",
"=",
"None",
")",
":",
"sighash",
"=",
"Utils",
".",
"bytes_to_str",
"(",
"s",
"[",
":",
"4",
"]",
")",
"for",
"pseudo_abi",
"in",
"FourByteDirectory",
".",
"get_ps... | aa96623e352fe096b6679cc3ea10ef62a260a711 |
train | ContractAbi._prepare_abi | Prepare the contract json abi for sighash lookups and fast access
:param jsonabi: contracts abi in json format
:return: | ethereum_input_decoder/decoder.py | def _prepare_abi(self, jsonabi):
"""
Prepare the contract json abi for sighash lookups and fast access
:param jsonabi: contracts abi in json format
:return:
"""
self.signatures = {}
for element_description in jsonabi:
abi_e = AbiMethod(element_descrip... | def _prepare_abi(self, jsonabi):
"""
Prepare the contract json abi for sighash lookups and fast access
:param jsonabi: contracts abi in json format
:return:
"""
self.signatures = {}
for element_description in jsonabi:
abi_e = AbiMethod(element_descrip... | [
"Prepare",
"the",
"contract",
"json",
"abi",
"for",
"sighash",
"lookups",
"and",
"fast",
"access"
] | tintinweb/ethereum-input-decoder | python | https://github.com/tintinweb/ethereum-input-decoder/blob/aa96623e352fe096b6679cc3ea10ef62a260a711/ethereum_input_decoder/decoder.py#L101-L125 | [
"def",
"_prepare_abi",
"(",
"self",
",",
"jsonabi",
")",
":",
"self",
".",
"signatures",
"=",
"{",
"}",
"for",
"element_description",
"in",
"jsonabi",
":",
"abi_e",
"=",
"AbiMethod",
"(",
"element_description",
")",
"if",
"abi_e",
"[",
"\"type\"",
"]",
"==... | aa96623e352fe096b6679cc3ea10ef62a260a711 |
train | ContractAbi.describe_constructor | Describe the input bytesequence (constructor arguments) s based on the loaded contract
abi definition
:param s: bytes constructor arguments
:return: AbiMethod instance | ethereum_input_decoder/decoder.py | def describe_constructor(self, s):
"""
Describe the input bytesequence (constructor arguments) s based on the loaded contract
abi definition
:param s: bytes constructor arguments
:return: AbiMethod instance
"""
method = self.signatures.get(b"__constructor__")
... | def describe_constructor(self, s):
"""
Describe the input bytesequence (constructor arguments) s based on the loaded contract
abi definition
:param s: bytes constructor arguments
:return: AbiMethod instance
"""
method = self.signatures.get(b"__constructor__")
... | [
"Describe",
"the",
"input",
"bytesequence",
"(",
"constructor",
"arguments",
")",
"s",
"based",
"on",
"the",
"loaded",
"contract",
"abi",
"definition"
] | tintinweb/ethereum-input-decoder | python | https://github.com/tintinweb/ethereum-input-decoder/blob/aa96623e352fe096b6679cc3ea10ef62a260a711/ethereum_input_decoder/decoder.py#L127-L153 | [
"def",
"describe_constructor",
"(",
"self",
",",
"s",
")",
":",
"method",
"=",
"self",
".",
"signatures",
".",
"get",
"(",
"b\"__constructor__\"",
")",
"if",
"not",
"method",
":",
"# constructor not available",
"m",
"=",
"AbiMethod",
"(",
"{",
"\"type\"",
":... | aa96623e352fe096b6679cc3ea10ef62a260a711 |
train | ContractAbi.describe_input | Describe the input bytesequence s based on the loaded contract abi definition
:param s: bytes input
:return: AbiMethod instance | ethereum_input_decoder/decoder.py | def describe_input(self, s):
"""
Describe the input bytesequence s based on the loaded contract abi definition
:param s: bytes input
:return: AbiMethod instance
"""
signatures = self.signatures.items()
for sighash, method in signatures:
if sighash is... | def describe_input(self, s):
"""
Describe the input bytesequence s based on the loaded contract abi definition
:param s: bytes input
:return: AbiMethod instance
"""
signatures = self.signatures.items()
for sighash, method in signatures:
if sighash is... | [
"Describe",
"the",
"input",
"bytesequence",
"s",
"based",
"on",
"the",
"loaded",
"contract",
"abi",
"definition"
] | tintinweb/ethereum-input-decoder | python | https://github.com/tintinweb/ethereum-input-decoder/blob/aa96623e352fe096b6679cc3ea10ef62a260a711/ethereum_input_decoder/decoder.py#L155-L197 | [
"def",
"describe_input",
"(",
"self",
",",
"s",
")",
":",
"signatures",
"=",
"self",
".",
"signatures",
".",
"items",
"(",
")",
"for",
"sighash",
",",
"method",
"in",
"signatures",
":",
"if",
"sighash",
"is",
"None",
"or",
"sighash",
".",
"startswith",
... | aa96623e352fe096b6679cc3ea10ef62a260a711 |
train | AbiMethod.from_input_lookup | Return a new AbiMethod object from an input stream
:param s: binary input
:return: new AbiMethod object matching the provided input stream | ethereum_input_decoder/decoder.py | def from_input_lookup(s):
"""
Return a new AbiMethod object from an input stream
:param s: binary input
:return: new AbiMethod object matching the provided input stream
"""
for pseudo_abi in FourByteDirectory.get_pseudo_abi_for_input(s):
method = AbiMethod(pse... | def from_input_lookup(s):
"""
Return a new AbiMethod object from an input stream
:param s: binary input
:return: new AbiMethod object matching the provided input stream
"""
for pseudo_abi in FourByteDirectory.get_pseudo_abi_for_input(s):
method = AbiMethod(pse... | [
"Return",
"a",
"new",
"AbiMethod",
"object",
"from",
"an",
"input",
"stream",
":",
"param",
"s",
":",
"binary",
"input",
":",
"return",
":",
"new",
"AbiMethod",
"object",
"matching",
"the",
"provided",
"input",
"stream"
] | tintinweb/ethereum-input-decoder | python | https://github.com/tintinweb/ethereum-input-decoder/blob/aa96623e352fe096b6679cc3ea10ef62a260a711/ethereum_input_decoder/decoder.py#L213-L230 | [
"def",
"from_input_lookup",
"(",
"s",
")",
":",
"for",
"pseudo_abi",
"in",
"FourByteDirectory",
".",
"get_pseudo_abi_for_input",
"(",
"s",
")",
":",
"method",
"=",
"AbiMethod",
"(",
"pseudo_abi",
")",
"types_def",
"=",
"pseudo_abi",
"[",
"\"inputs\"",
"]",
"ty... | aa96623e352fe096b6679cc3ea10ef62a260a711 |
train | assert_is | Raises an AssertionError if expected is not actual. | qcore/asserts.py | def assert_is(expected, actual, message=None, extra=None):
"""Raises an AssertionError if expected is not actual."""
assert expected is actual, _assert_fail_message(
message, expected, actual, "is not", extra
) | def assert_is(expected, actual, message=None, extra=None):
"""Raises an AssertionError if expected is not actual."""
assert expected is actual, _assert_fail_message(
message, expected, actual, "is not", extra
) | [
"Raises",
"an",
"AssertionError",
"if",
"expected",
"is",
"not",
"actual",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L83-L87 | [
"def",
"assert_is",
"(",
"expected",
",",
"actual",
",",
"message",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"assert",
"expected",
"is",
"actual",
",",
"_assert_fail_message",
"(",
"message",
",",
"expected",
",",
"actual",
",",
"\"is not\"",
",",... | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | assert_is_not | Raises an AssertionError if expected is actual. | qcore/asserts.py | def assert_is_not(expected, actual, message=None, extra=None):
"""Raises an AssertionError if expected is actual."""
assert expected is not actual, _assert_fail_message(
message, expected, actual, "is", extra
) | def assert_is_not(expected, actual, message=None, extra=None):
"""Raises an AssertionError if expected is actual."""
assert expected is not actual, _assert_fail_message(
message, expected, actual, "is", extra
) | [
"Raises",
"an",
"AssertionError",
"if",
"expected",
"is",
"actual",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L90-L94 | [
"def",
"assert_is_not",
"(",
"expected",
",",
"actual",
",",
"message",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"assert",
"expected",
"is",
"not",
"actual",
",",
"_assert_fail_message",
"(",
"message",
",",
"expected",
",",
"actual",
",",
"\"is\"... | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | assert_is_instance | Raises an AssertionError if value is not an instance of type(s). | qcore/asserts.py | def assert_is_instance(value, types, message=None, extra=None):
"""Raises an AssertionError if value is not an instance of type(s)."""
assert isinstance(value, types), _assert_fail_message(
message, value, types, "is not an instance of", extra
) | def assert_is_instance(value, types, message=None, extra=None):
"""Raises an AssertionError if value is not an instance of type(s)."""
assert isinstance(value, types), _assert_fail_message(
message, value, types, "is not an instance of", extra
) | [
"Raises",
"an",
"AssertionError",
"if",
"value",
"is",
"not",
"an",
"instance",
"of",
"type",
"(",
"s",
")",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L97-L101 | [
"def",
"assert_is_instance",
"(",
"value",
",",
"types",
",",
"message",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"value",
",",
"types",
")",
",",
"_assert_fail_message",
"(",
"message",
",",
"value",
",",
"types",
"... | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | assert_eq | Raises an AssertionError if expected != actual.
If tolerance is specified, raises an AssertionError if either
- expected or actual isn't a number, or
- the difference between expected and actual is larger than the tolerance. | qcore/asserts.py | def assert_eq(expected, actual, message=None, tolerance=None, extra=None):
"""Raises an AssertionError if expected != actual.
If tolerance is specified, raises an AssertionError if either
- expected or actual isn't a number, or
- the difference between expected and actual is larger than the tolerance.
... | def assert_eq(expected, actual, message=None, tolerance=None, extra=None):
"""Raises an AssertionError if expected != actual.
If tolerance is specified, raises an AssertionError if either
- expected or actual isn't a number, or
- the difference between expected and actual is larger than the tolerance.
... | [
"Raises",
"an",
"AssertionError",
"if",
"expected",
"!",
"=",
"actual",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L104-L130 | [
"def",
"assert_eq",
"(",
"expected",
",",
"actual",
",",
"message",
"=",
"None",
",",
"tolerance",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"if",
"tolerance",
"is",
"None",
":",
"assert",
"expected",
"==",
"actual",
",",
"_assert_fail_message",
... | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | assert_dict_eq | Asserts that two dictionaries are equal, producing a custom message if they are not. | qcore/asserts.py | def assert_dict_eq(expected, actual, number_tolerance=None, dict_path=[]):
"""Asserts that two dictionaries are equal, producing a custom message if they are not."""
assert_is_instance(expected, dict)
assert_is_instance(actual, dict)
expected_keys = set(expected.keys())
actual_keys = set(actual.key... | def assert_dict_eq(expected, actual, number_tolerance=None, dict_path=[]):
"""Asserts that two dictionaries are equal, producing a custom message if they are not."""
assert_is_instance(expected, dict)
assert_is_instance(actual, dict)
expected_keys = set(expected.keys())
actual_keys = set(actual.key... | [
"Asserts",
"that",
"two",
"dictionaries",
"are",
"equal",
"producing",
"a",
"custom",
"message",
"if",
"they",
"are",
"not",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L139-L187 | [
"def",
"assert_dict_eq",
"(",
"expected",
",",
"actual",
",",
"number_tolerance",
"=",
"None",
",",
"dict_path",
"=",
"[",
"]",
")",
":",
"assert_is_instance",
"(",
"expected",
",",
"dict",
")",
"assert_is_instance",
"(",
"actual",
",",
"dict",
")",
"expecte... | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | assert_gt | Raises an AssertionError if left_hand <= right_hand. | qcore/asserts.py | def assert_gt(left, right, message=None, extra=None):
"""Raises an AssertionError if left_hand <= right_hand."""
assert left > right, _assert_fail_message(message, left, right, "<=", extra) | def assert_gt(left, right, message=None, extra=None):
"""Raises an AssertionError if left_hand <= right_hand."""
assert left > right, _assert_fail_message(message, left, right, "<=", extra) | [
"Raises",
"an",
"AssertionError",
"if",
"left_hand",
"<",
"=",
"right_hand",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L219-L221 | [
"def",
"assert_gt",
"(",
"left",
",",
"right",
",",
"message",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"assert",
"left",
">",
"right",
",",
"_assert_fail_message",
"(",
"message",
",",
"left",
",",
"right",
",",
"\"<=\"",
",",
"extra",
")"
] | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | assert_ge | Raises an AssertionError if left_hand < right_hand. | qcore/asserts.py | def assert_ge(left, right, message=None, extra=None):
"""Raises an AssertionError if left_hand < right_hand."""
assert left >= right, _assert_fail_message(message, left, right, "<", extra) | def assert_ge(left, right, message=None, extra=None):
"""Raises an AssertionError if left_hand < right_hand."""
assert left >= right, _assert_fail_message(message, left, right, "<", extra) | [
"Raises",
"an",
"AssertionError",
"if",
"left_hand",
"<",
"right_hand",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L224-L226 | [
"def",
"assert_ge",
"(",
"left",
",",
"right",
",",
"message",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"assert",
"left",
">=",
"right",
",",
"_assert_fail_message",
"(",
"message",
",",
"left",
",",
"right",
",",
"\"<\"",
",",
"extra",
")"
] | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | assert_lt | Raises an AssertionError if left_hand >= right_hand. | qcore/asserts.py | def assert_lt(left, right, message=None, extra=None):
"""Raises an AssertionError if left_hand >= right_hand."""
assert left < right, _assert_fail_message(message, left, right, ">=", extra) | def assert_lt(left, right, message=None, extra=None):
"""Raises an AssertionError if left_hand >= right_hand."""
assert left < right, _assert_fail_message(message, left, right, ">=", extra) | [
"Raises",
"an",
"AssertionError",
"if",
"left_hand",
">",
"=",
"right_hand",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L229-L231 | [
"def",
"assert_lt",
"(",
"left",
",",
"right",
",",
"message",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"assert",
"left",
"<",
"right",
",",
"_assert_fail_message",
"(",
"message",
",",
"left",
",",
"right",
",",
"\">=\"",
",",
"extra",
")"
] | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | assert_le | Raises an AssertionError if left_hand > right_hand. | qcore/asserts.py | def assert_le(left, right, message=None, extra=None):
"""Raises an AssertionError if left_hand > right_hand."""
assert left <= right, _assert_fail_message(message, left, right, ">", extra) | def assert_le(left, right, message=None, extra=None):
"""Raises an AssertionError if left_hand > right_hand."""
assert left <= right, _assert_fail_message(message, left, right, ">", extra) | [
"Raises",
"an",
"AssertionError",
"if",
"left_hand",
">",
"right_hand",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L234-L236 | [
"def",
"assert_le",
"(",
"left",
",",
"right",
",",
"message",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"assert",
"left",
"<=",
"right",
",",
"_assert_fail_message",
"(",
"message",
",",
"left",
",",
"right",
",",
"\">\"",
",",
"extra",
")"
] | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | assert_in | Raises an AssertionError if obj is not in seq. | qcore/asserts.py | def assert_in(obj, seq, message=None, extra=None):
"""Raises an AssertionError if obj is not in seq."""
assert obj in seq, _assert_fail_message(message, obj, seq, "is not in", extra) | def assert_in(obj, seq, message=None, extra=None):
"""Raises an AssertionError if obj is not in seq."""
assert obj in seq, _assert_fail_message(message, obj, seq, "is not in", extra) | [
"Raises",
"an",
"AssertionError",
"if",
"obj",
"is",
"not",
"in",
"seq",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L239-L241 | [
"def",
"assert_in",
"(",
"obj",
",",
"seq",
",",
"message",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"assert",
"obj",
"in",
"seq",
",",
"_assert_fail_message",
"(",
"message",
",",
"obj",
",",
"seq",
",",
"\"is not in\"",
",",
"extra",
")"
] | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | assert_not_in | Raises an AssertionError if obj is in iter. | qcore/asserts.py | def assert_not_in(obj, seq, message=None, extra=None):
"""Raises an AssertionError if obj is in iter."""
# for very long strings, provide a truncated error
if isinstance(seq, six.string_types) and obj in seq and len(seq) > 200:
index = seq.find(obj)
start_index = index - 50
if start_... | def assert_not_in(obj, seq, message=None, extra=None):
"""Raises an AssertionError if obj is in iter."""
# for very long strings, provide a truncated error
if isinstance(seq, six.string_types) and obj in seq and len(seq) > 200:
index = seq.find(obj)
start_index = index - 50
if start_... | [
"Raises",
"an",
"AssertionError",
"if",
"obj",
"is",
"in",
"iter",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L244-L260 | [
"def",
"assert_not_in",
"(",
"obj",
",",
"seq",
",",
"message",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"# for very long strings, provide a truncated error",
"if",
"isinstance",
"(",
"seq",
",",
"six",
".",
"string_types",
")",
"and",
"obj",
"in",
... | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | assert_in_with_tolerance | Raises an AssertionError if obj is not in seq using assert_eq cmp. | qcore/asserts.py | def assert_in_with_tolerance(obj, seq, tolerance, message=None, extra=None):
"""Raises an AssertionError if obj is not in seq using assert_eq cmp."""
for i in seq:
try:
assert_eq(obj, i, tolerance=tolerance, message=message, extra=extra)
return
except AssertionError:
... | def assert_in_with_tolerance(obj, seq, tolerance, message=None, extra=None):
"""Raises an AssertionError if obj is not in seq using assert_eq cmp."""
for i in seq:
try:
assert_eq(obj, i, tolerance=tolerance, message=message, extra=extra)
return
except AssertionError:
... | [
"Raises",
"an",
"AssertionError",
"if",
"obj",
"is",
"not",
"in",
"seq",
"using",
"assert_eq",
"cmp",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L263-L271 | [
"def",
"assert_in_with_tolerance",
"(",
"obj",
",",
"seq",
",",
"tolerance",
",",
"message",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"for",
"i",
"in",
"seq",
":",
"try",
":",
"assert_eq",
"(",
"obj",
",",
"i",
",",
"tolerance",
"=",
"tolera... | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | assert_is_substring | Raises an AssertionError if substring is not a substring of subject. | qcore/asserts.py | def assert_is_substring(substring, subject, message=None, extra=None):
"""Raises an AssertionError if substring is not a substring of subject."""
assert (
(subject is not None)
and (substring is not None)
and (subject.find(substring) != -1)
), _assert_fail_message(message, substring,... | def assert_is_substring(substring, subject, message=None, extra=None):
"""Raises an AssertionError if substring is not a substring of subject."""
assert (
(subject is not None)
and (substring is not None)
and (subject.find(substring) != -1)
), _assert_fail_message(message, substring,... | [
"Raises",
"an",
"AssertionError",
"if",
"substring",
"is",
"not",
"a",
"substring",
"of",
"subject",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L274-L280 | [
"def",
"assert_is_substring",
"(",
"substring",
",",
"subject",
",",
"message",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"assert",
"(",
"(",
"subject",
"is",
"not",
"None",
")",
"and",
"(",
"substring",
"is",
"not",
"None",
")",
"and",
"(",
... | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | assert_is_not_substring | Raises an AssertionError if substring is a substring of subject. | qcore/asserts.py | def assert_is_not_substring(substring, subject, message=None, extra=None):
"""Raises an AssertionError if substring is a substring of subject."""
assert (
(subject is not None)
and (substring is not None)
and (subject.find(substring) == -1)
), _assert_fail_message(message, substring,... | def assert_is_not_substring(substring, subject, message=None, extra=None):
"""Raises an AssertionError if substring is a substring of subject."""
assert (
(subject is not None)
and (substring is not None)
and (subject.find(substring) == -1)
), _assert_fail_message(message, substring,... | [
"Raises",
"an",
"AssertionError",
"if",
"substring",
"is",
"a",
"substring",
"of",
"subject",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L283-L289 | [
"def",
"assert_is_not_substring",
"(",
"substring",
",",
"subject",
",",
"message",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"assert",
"(",
"(",
"subject",
"is",
"not",
"None",
")",
"and",
"(",
"substring",
"is",
"not",
"None",
")",
"and",
"("... | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | assert_unordered_list_eq | Raises an AssertionError if the objects contained
in expected are not equal to the objects contained
in actual without regard to their order.
This takes quadratic time in the umber of elements in actual; don't use it for very long lists. | qcore/asserts.py | def assert_unordered_list_eq(expected, actual, message=None):
"""Raises an AssertionError if the objects contained
in expected are not equal to the objects contained
in actual without regard to their order.
This takes quadratic time in the umber of elements in actual; don't use it for very long lists.... | def assert_unordered_list_eq(expected, actual, message=None):
"""Raises an AssertionError if the objects contained
in expected are not equal to the objects contained
in actual without regard to their order.
This takes quadratic time in the umber of elements in actual; don't use it for very long lists.... | [
"Raises",
"an",
"AssertionError",
"if",
"the",
"objects",
"contained",
"in",
"expected",
"are",
"not",
"equal",
"to",
"the",
"objects",
"contained",
"in",
"actual",
"without",
"regard",
"to",
"their",
"order",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L292-L314 | [
"def",
"assert_unordered_list_eq",
"(",
"expected",
",",
"actual",
",",
"message",
"=",
"None",
")",
":",
"missing_in_actual",
"=",
"[",
"]",
"missing_in_expected",
"=",
"list",
"(",
"actual",
")",
"for",
"x",
"in",
"expected",
":",
"try",
":",
"missing_in_e... | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | _execute_if_not_empty | Execute function only if one of input parameters is not empty | waldur_core/logging/elasticsearch_client.py | def _execute_if_not_empty(func):
""" Execute function only if one of input parameters is not empty """
def wrapper(*args, **kwargs):
if any(args[1:]) or any(kwargs.items()):
return func(*args, **kwargs)
return wrapper | def _execute_if_not_empty(func):
""" Execute function only if one of input parameters is not empty """
def wrapper(*args, **kwargs):
if any(args[1:]) or any(kwargs.items()):
return func(*args, **kwargs)
return wrapper | [
"Execute",
"function",
"only",
"if",
"one",
"of",
"input",
"parameters",
"is",
"not",
"empty"
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/elasticsearch_client.py#L89-L94 | [
"def",
"_execute_if_not_empty",
"(",
"func",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"any",
"(",
"args",
"[",
"1",
":",
"]",
")",
"or",
"any",
"(",
"kwargs",
".",
"items",
"(",
")",
")",
":",
"retu... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | ElasticsearchClient.prepare_search_body | Prepare body for elasticsearch query
Search parameters
^^^^^^^^^^^^^^^^^
These parameters are dictionaries and have format: <term>: [<value 1>, <value 2> ...]
should_terms: it resembles logical OR
must_terms: it resembles logical AND
must_not_terms: it resembles logical... | waldur_core/logging/elasticsearch_client.py | def prepare_search_body(self, should_terms=None, must_terms=None, must_not_terms=None, search_text='', start=None, end=None):
"""
Prepare body for elasticsearch query
Search parameters
^^^^^^^^^^^^^^^^^
These parameters are dictionaries and have format: <term>: [<value 1>, <val... | def prepare_search_body(self, should_terms=None, must_terms=None, must_not_terms=None, search_text='', start=None, end=None):
"""
Prepare body for elasticsearch query
Search parameters
^^^^^^^^^^^^^^^^^
These parameters are dictionaries and have format: <term>: [<value 1>, <val... | [
"Prepare",
"body",
"for",
"elasticsearch",
"query"
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/elasticsearch_client.py#L227-L249 | [
"def",
"prepare_search_body",
"(",
"self",
",",
"should_terms",
"=",
"None",
",",
"must_terms",
"=",
"None",
",",
"must_not_terms",
"=",
"None",
",",
"search_text",
"=",
"''",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"self",
".",
"... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | BaseExecutor.execute | Execute high level-operation | waldur_core/core/executors.py | def execute(cls, instance, async=True, countdown=2, is_heavy_task=False, **kwargs):
""" Execute high level-operation """
cls.pre_apply(instance, async=async, **kwargs)
result = cls.apply_signature(instance, async=async, countdown=countdown,
is_heavy_task=is_h... | def execute(cls, instance, async=True, countdown=2, is_heavy_task=False, **kwargs):
""" Execute high level-operation """
cls.pre_apply(instance, async=async, **kwargs)
result = cls.apply_signature(instance, async=async, countdown=countdown,
is_heavy_task=is_h... | [
"Execute",
"high",
"level",
"-",
"operation"
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/executors.py#L40-L46 | [
"def",
"execute",
"(",
"cls",
",",
"instance",
",",
"async",
"=",
"True",
",",
"countdown",
"=",
"2",
",",
"is_heavy_task",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"cls",
".",
"pre_apply",
"(",
"instance",
",",
"async",
"=",
"async",
",",
... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | BaseExecutor.apply_signature | Serialize input data and apply signature | waldur_core/core/executors.py | def apply_signature(cls, instance, async=True, countdown=None, is_heavy_task=False, **kwargs):
""" Serialize input data and apply signature """
serialized_instance = utils.serialize_instance(instance)
signature = cls.get_task_signature(instance, serialized_instance, **kwargs)
link = cls... | def apply_signature(cls, instance, async=True, countdown=None, is_heavy_task=False, **kwargs):
""" Serialize input data and apply signature """
serialized_instance = utils.serialize_instance(instance)
signature = cls.get_task_signature(instance, serialized_instance, **kwargs)
link = cls... | [
"Serialize",
"input",
"data",
"and",
"apply",
"signature"
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/executors.py#L59-L76 | [
"def",
"apply_signature",
"(",
"cls",
",",
"instance",
",",
"async",
"=",
"True",
",",
"countdown",
"=",
"None",
",",
"is_heavy_task",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"serialized_instance",
"=",
"utils",
".",
"serialize_instance",
"(",
"in... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | BaseExecutor._apply_callback | Synchronously execute callback | waldur_core/core/executors.py | def _apply_callback(cls, callback, result):
""" Synchronously execute callback """
if not callback.immutable:
callback.args = (result.id, ) + callback.args
callback.apply() | def _apply_callback(cls, callback, result):
""" Synchronously execute callback """
if not callback.immutable:
callback.args = (result.id, ) + callback.args
callback.apply() | [
"Synchronously",
"execute",
"callback"
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/executors.py#L79-L83 | [
"def",
"_apply_callback",
"(",
"cls",
",",
"callback",
",",
"result",
")",
":",
"if",
"not",
"callback",
".",
"immutable",
":",
"callback",
".",
"args",
"=",
"(",
"result",
".",
"id",
",",
")",
"+",
"callback",
".",
"args",
"callback",
".",
"apply",
... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | get_entity_description | Returns description in format:
* entity human readable name
* docstring | waldur_core/core/schemas.py | def get_entity_description(entity):
"""
Returns description in format:
* entity human readable name
* docstring
"""
try:
entity_name = entity.__name__.strip('_')
except AttributeError:
# entity is a class instance
entity_name = entity.__class__.__name__
label =... | def get_entity_description(entity):
"""
Returns description in format:
* entity human readable name
* docstring
"""
try:
entity_name = entity.__name__.strip('_')
except AttributeError:
# entity is a class instance
entity_name = entity.__class__.__name__
label =... | [
"Returns",
"description",
"in",
"format",
":",
"*",
"entity",
"human",
"readable",
"name",
"*",
"docstring"
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L37-L55 | [
"def",
"get_entity_description",
"(",
"entity",
")",
":",
"try",
":",
"entity_name",
"=",
"entity",
".",
"__name__",
".",
"strip",
"(",
"'_'",
")",
"except",
"AttributeError",
":",
"# entity is a class instance",
"entity_name",
"=",
"entity",
".",
"__class__",
"... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | get_validators_description | Returns validators description in format:
### Validators:
* validator1 name
* validator1 docstring
* validator2 name
* validator2 docstring | waldur_core/core/schemas.py | def get_validators_description(view):
"""
Returns validators description in format:
### Validators:
* validator1 name
* validator1 docstring
* validator2 name
* validator2 docstring
"""
action = getattr(view, 'action', None)
if action is None:
return ''
description... | def get_validators_description(view):
"""
Returns validators description in format:
### Validators:
* validator1 name
* validator1 docstring
* validator2 name
* validator2 docstring
"""
action = getattr(view, 'action', None)
if action is None:
return ''
description... | [
"Returns",
"validators",
"description",
"in",
"format",
":",
"###",
"Validators",
":",
"*",
"validator1",
"name",
"*",
"validator1",
"docstring",
"*",
"validator2",
"name",
"*",
"validator2",
"docstring"
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L58-L77 | [
"def",
"get_validators_description",
"(",
"view",
")",
":",
"action",
"=",
"getattr",
"(",
"view",
",",
"'action'",
",",
"None",
")",
"if",
"action",
"is",
"None",
":",
"return",
"''",
"description",
"=",
"''",
"validators",
"=",
"getattr",
"(",
"view",
... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | get_actions_permission_description | Returns actions permissions description in format:
* permission1 name
* permission1 docstring
* permission2 name
* permission2 docstring | waldur_core/core/schemas.py | def get_actions_permission_description(view, method):
"""
Returns actions permissions description in format:
* permission1 name
* permission1 docstring
* permission2 name
* permission2 docstring
"""
action = getattr(view, 'action', None)
if action is None:
return ''
if... | def get_actions_permission_description(view, method):
"""
Returns actions permissions description in format:
* permission1 name
* permission1 docstring
* permission2 name
* permission2 docstring
"""
action = getattr(view, 'action', None)
if action is None:
return ''
if... | [
"Returns",
"actions",
"permissions",
"description",
"in",
"format",
":",
"*",
"permission1",
"name",
"*",
"permission1",
"docstring",
"*",
"permission2",
"name",
"*",
"permission2",
"docstring"
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L80-L106 | [
"def",
"get_actions_permission_description",
"(",
"view",
",",
"method",
")",
":",
"action",
"=",
"getattr",
"(",
"view",
",",
"'action'",
",",
"None",
")",
"if",
"action",
"is",
"None",
":",
"return",
"''",
"if",
"hasattr",
"(",
"view",
",",
"action",
"... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | get_permissions_description | Returns permissions description in format:
### Permissions:
* permission1 name
* permission1 docstring
* permission2 name
* permission2 docstring | waldur_core/core/schemas.py | def get_permissions_description(view, method):
"""
Returns permissions description in format:
### Permissions:
* permission1 name
* permission1 docstring
* permission2 name
* permission2 docstring
"""
if not hasattr(view, 'permission_classes'):
return ''
description = ... | def get_permissions_description(view, method):
"""
Returns permissions description in format:
### Permissions:
* permission1 name
* permission1 docstring
* permission2 name
* permission2 docstring
"""
if not hasattr(view, 'permission_classes'):
return ''
description = ... | [
"Returns",
"permissions",
"description",
"in",
"format",
":",
"###",
"Permissions",
":",
"*",
"permission1",
"name",
"*",
"permission1",
"docstring",
"*",
"permission2",
"name",
"*",
"permission2",
"docstring"
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L109-L131 | [
"def",
"get_permissions_description",
"(",
"view",
",",
"method",
")",
":",
"if",
"not",
"hasattr",
"(",
"view",
",",
"'permission_classes'",
")",
":",
"return",
"''",
"description",
"=",
"''",
"for",
"permission_class",
"in",
"view",
".",
"permission_classes",
... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | get_validation_description | Returns validation description in format:
### Validation:
validate method docstring
* field1 name
* field1 validation docstring
* field2 name
* field2 validation docstring | waldur_core/core/schemas.py | def get_validation_description(view, method):
"""
Returns validation description in format:
### Validation:
validate method docstring
* field1 name
* field1 validation docstring
* field2 name
* field2 validation docstring
"""
if method not in ('PUT', 'PATCH', 'POST') or not has... | def get_validation_description(view, method):
"""
Returns validation description in format:
### Validation:
validate method docstring
* field1 name
* field1 validation docstring
* field2 name
* field2 validation docstring
"""
if method not in ('PUT', 'PATCH', 'POST') or not has... | [
"Returns",
"validation",
"description",
"in",
"format",
":",
"###",
"Validation",
":",
"validate",
"method",
"docstring",
"*",
"field1",
"name",
"*",
"field1",
"validation",
"docstring",
"*",
"field2",
"name",
"*",
"field2",
"validation",
"docstring"
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L134-L163 | [
"def",
"get_validation_description",
"(",
"view",
",",
"method",
")",
":",
"if",
"method",
"not",
"in",
"(",
"'PUT'",
",",
"'PATCH'",
",",
"'POST'",
")",
"or",
"not",
"hasattr",
"(",
"view",
",",
"'get_serializer'",
")",
":",
"return",
"''",
"serializer",
... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | get_field_type | Returns field type/possible values. | waldur_core/core/schemas.py | def get_field_type(field):
"""
Returns field type/possible values.
"""
if isinstance(field, core_filters.MappedMultipleChoiceFilter):
return ' | '.join(['"%s"' % f for f in sorted(field.mapped_to_model)])
if isinstance(field, OrderingFilter) or isinstance(field, ChoiceFilter):
return... | def get_field_type(field):
"""
Returns field type/possible values.
"""
if isinstance(field, core_filters.MappedMultipleChoiceFilter):
return ' | '.join(['"%s"' % f for f in sorted(field.mapped_to_model)])
if isinstance(field, OrderingFilter) or isinstance(field, ChoiceFilter):
return... | [
"Returns",
"field",
"type",
"/",
"possible",
"values",
"."
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L185-L233 | [
"def",
"get_field_type",
"(",
"field",
")",
":",
"if",
"isinstance",
"(",
"field",
",",
"core_filters",
".",
"MappedMultipleChoiceFilter",
")",
":",
"return",
"' | '",
".",
"join",
"(",
"[",
"'\"%s\"'",
"%",
"f",
"for",
"f",
"in",
"sorted",
"(",
"field",
... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | is_disabled_action | Checks whether Link action is disabled. | waldur_core/core/schemas.py | def is_disabled_action(view):
"""
Checks whether Link action is disabled.
"""
if not isinstance(view, core_views.ActionsViewSet):
return False
action = getattr(view, 'action', None)
return action in view.disabled_actions if action is not None else False | def is_disabled_action(view):
"""
Checks whether Link action is disabled.
"""
if not isinstance(view, core_views.ActionsViewSet):
return False
action = getattr(view, 'action', None)
return action in view.disabled_actions if action is not None else False | [
"Checks",
"whether",
"Link",
"action",
"is",
"disabled",
"."
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L236-L244 | [
"def",
"is_disabled_action",
"(",
"view",
")",
":",
"if",
"not",
"isinstance",
"(",
"view",
",",
"core_views",
".",
"ActionsViewSet",
")",
":",
"return",
"False",
"action",
"=",
"getattr",
"(",
"view",
",",
"'action'",
",",
"None",
")",
"return",
"action",... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | WaldurEndpointInspector.get_allowed_methods | Return a list of the valid HTTP methods for this endpoint. | waldur_core/core/schemas.py | def get_allowed_methods(self, callback):
"""
Return a list of the valid HTTP methods for this endpoint.
"""
if hasattr(callback, 'actions'):
return [method.upper() for method in callback.actions.keys() if method != 'head']
return [
method for method in
... | def get_allowed_methods(self, callback):
"""
Return a list of the valid HTTP methods for this endpoint.
"""
if hasattr(callback, 'actions'):
return [method.upper() for method in callback.actions.keys() if method != 'head']
return [
method for method in
... | [
"Return",
"a",
"list",
"of",
"the",
"valid",
"HTTP",
"methods",
"for",
"this",
"endpoint",
"."
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L24-L34 | [
"def",
"get_allowed_methods",
"(",
"self",
",",
"callback",
")",
":",
"if",
"hasattr",
"(",
"callback",
",",
"'actions'",
")",
":",
"return",
"[",
"method",
".",
"upper",
"(",
")",
"for",
"method",
"in",
"callback",
".",
"actions",
".",
"keys",
"(",
")... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | WaldurSchemaGenerator.create_view | Given a callback, return an actual view instance. | waldur_core/core/schemas.py | def create_view(self, callback, method, request=None):
"""
Given a callback, return an actual view instance.
"""
view = super(WaldurSchemaGenerator, self).create_view(callback, method, request)
if is_disabled_action(view):
view.exclude_from_schema = True
retu... | def create_view(self, callback, method, request=None):
"""
Given a callback, return an actual view instance.
"""
view = super(WaldurSchemaGenerator, self).create_view(callback, method, request)
if is_disabled_action(view):
view.exclude_from_schema = True
retu... | [
"Given",
"a",
"callback",
"return",
"an",
"actual",
"view",
"instance",
"."
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L250-L258 | [
"def",
"create_view",
"(",
"self",
",",
"callback",
",",
"method",
",",
"request",
"=",
"None",
")",
":",
"view",
"=",
"super",
"(",
"WaldurSchemaGenerator",
",",
"self",
")",
".",
"create_view",
"(",
"callback",
",",
"method",
",",
"request",
")",
"if",... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | WaldurSchemaGenerator.get_description | Determine a link description.
This will be based on the method docstring if one exists,
or else the class docstring. | waldur_core/core/schemas.py | def get_description(self, path, method, view):
"""
Determine a link description.
This will be based on the method docstring if one exists,
or else the class docstring.
"""
description = super(WaldurSchemaGenerator, self).get_description(path, method, view)
permi... | def get_description(self, path, method, view):
"""
Determine a link description.
This will be based on the method docstring if one exists,
or else the class docstring.
"""
description = super(WaldurSchemaGenerator, self).get_description(path, method, view)
permi... | [
"Determine",
"a",
"link",
"description",
"."
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L260-L282 | [
"def",
"get_description",
"(",
"self",
",",
"path",
",",
"method",
",",
"view",
")",
":",
"description",
"=",
"super",
"(",
"WaldurSchemaGenerator",
",",
"self",
")",
".",
"get_description",
"(",
"path",
",",
"method",
",",
"view",
")",
"permissions_descript... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | WaldurSchemaGenerator.get_serializer_fields | Return a list of `coreapi.Field` instances corresponding to any
request body input, as determined by the serializer class. | waldur_core/core/schemas.py | def get_serializer_fields(self, path, method, view):
"""
Return a list of `coreapi.Field` instances corresponding to any
request body input, as determined by the serializer class.
"""
if method not in ('PUT', 'PATCH', 'POST'):
return []
if not hasattr(view, '... | def get_serializer_fields(self, path, method, view):
"""
Return a list of `coreapi.Field` instances corresponding to any
request body input, as determined by the serializer class.
"""
if method not in ('PUT', 'PATCH', 'POST'):
return []
if not hasattr(view, '... | [
"Return",
"a",
"list",
"of",
"coreapi",
".",
"Field",
"instances",
"corresponding",
"to",
"any",
"request",
"body",
"input",
"as",
"determined",
"by",
"the",
"serializer",
"class",
"."
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L315-L348 | [
"def",
"get_serializer_fields",
"(",
"self",
",",
"path",
",",
"method",
",",
"view",
")",
":",
"if",
"method",
"not",
"in",
"(",
"'PUT'",
",",
"'PATCH'",
",",
"'POST'",
")",
":",
"return",
"[",
"]",
"if",
"not",
"hasattr",
"(",
"view",
",",
"'get_se... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | delete_error_message | Delete error message if instance state changed from erred | waldur_core/core/handlers.py | def delete_error_message(sender, instance, name, source, target, **kwargs):
""" Delete error message if instance state changed from erred """
if source != StateMixin.States.ERRED:
return
instance.error_message = ''
instance.save(update_fields=['error_message']) | def delete_error_message(sender, instance, name, source, target, **kwargs):
""" Delete error message if instance state changed from erred """
if source != StateMixin.States.ERRED:
return
instance.error_message = ''
instance.save(update_fields=['error_message']) | [
"Delete",
"error",
"message",
"if",
"instance",
"state",
"changed",
"from",
"erred"
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/handlers.py#L31-L36 | [
"def",
"delete_error_message",
"(",
"sender",
",",
"instance",
",",
"name",
",",
"source",
",",
"target",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"source",
"!=",
"StateMixin",
".",
"States",
".",
"ERRED",
":",
"return",
"instance",
".",
"error_message",
... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | find_version | read __init__.py | setup.py | def find_version(*file_paths):
"""
read __init__.py
"""
file_path = os.path.join(*file_paths)
with open(file_path, 'r') as version_file:
line = version_file.readline()
while line:
if line.startswith('__version__'):
version_match = re.search(
... | def find_version(*file_paths):
"""
read __init__.py
"""
file_path = os.path.join(*file_paths)
with open(file_path, 'r') as version_file:
line = version_file.readline()
while line:
if line.startswith('__version__'):
version_match = re.search(
... | [
"read",
"__init__",
".",
"py"
] | zeromake/aiosqlite3 | python | https://github.com/zeromake/aiosqlite3/blob/1a74a062507e2df8f833a70885e69dca0ab3e7e7/setup.py#L25-L42 | [
"def",
"find_version",
"(",
"*",
"file_paths",
")",
":",
"file_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"*",
"file_paths",
")",
"with",
"open",
"(",
"file_path",
",",
"'r'",
")",
"as",
"version_file",
":",
"line",
"=",
"version_file",
".",
"rea... | 1a74a062507e2df8f833a70885e69dca0ab3e7e7 |
train | trace | This decorator prints entry and exit message when
the decorated method is called, as well as call
arguments, result and thrown exception (if any).
:param enter: indicates whether entry message should be printed.
:param exit: indicates whether exit message should be printed.
:return: decorated funct... | qcore/debug.py | def trace(enter=False, exit=True):
"""
This decorator prints entry and exit message when
the decorated method is called, as well as call
arguments, result and thrown exception (if any).
:param enter: indicates whether entry message should be printed.
:param exit: indicates whether exit message ... | def trace(enter=False, exit=True):
"""
This decorator prints entry and exit message when
the decorated method is called, as well as call
arguments, result and thrown exception (if any).
:param enter: indicates whether entry message should be printed.
:param exit: indicates whether exit message ... | [
"This",
"decorator",
"prints",
"entry",
"and",
"exit",
"message",
"when",
"the",
"decorated",
"method",
"is",
"called",
"as",
"well",
"as",
"call",
"arguments",
"result",
"and",
"thrown",
"exception",
"(",
"if",
"any",
")",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/debug.py#L33-L71 | [
"def",
"trace",
"(",
"enter",
"=",
"False",
",",
"exit",
"=",
"True",
")",
":",
"def",
"decorate",
"(",
"fn",
")",
":",
"@",
"inspection",
".",
"wraps",
"(",
"fn",
")",
"def",
"new_fn",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"name... | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | EnumType._make_value | Instantiates an enum with an arbitrary value. | qcore/enum.py | def _make_value(self, value):
"""Instantiates an enum with an arbitrary value."""
member = self.__new__(self, value)
member.__init__(value)
return member | def _make_value(self, value):
"""Instantiates an enum with an arbitrary value."""
member = self.__new__(self, value)
member.__init__(value)
return member | [
"Instantiates",
"an",
"enum",
"with",
"an",
"arbitrary",
"value",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/enum.py#L89-L93 | [
"def",
"_make_value",
"(",
"self",
",",
"value",
")",
":",
"member",
"=",
"self",
".",
"__new__",
"(",
"self",
",",
"value",
")",
"member",
".",
"__init__",
"(",
"value",
")",
"return",
"member"
] | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | EnumBase.create | Creates a new enum type based on this one (cls) and adds newly
passed members to the newly created subclass of cls.
This method helps to create enums having the same member values as
values of other enum(s).
:param name: name of the newly created type
:param members: 1) a dict ... | qcore/enum.py | def create(cls, name, members):
"""Creates a new enum type based on this one (cls) and adds newly
passed members to the newly created subclass of cls.
This method helps to create enums having the same member values as
values of other enum(s).
:param name: name of the newly crea... | def create(cls, name, members):
"""Creates a new enum type based on this one (cls) and adds newly
passed members to the newly created subclass of cls.
This method helps to create enums having the same member values as
values of other enum(s).
:param name: name of the newly crea... | [
"Creates",
"a",
"new",
"enum",
"type",
"based",
"on",
"this",
"one",
"(",
"cls",
")",
"and",
"adds",
"newly",
"passed",
"members",
"to",
"the",
"newly",
"created",
"subclass",
"of",
"cls",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/enum.py#L175-L214 | [
"def",
"create",
"(",
"cls",
",",
"name",
",",
"members",
")",
":",
"NewEnum",
"=",
"type",
"(",
"name",
",",
"(",
"cls",
",",
")",
",",
"{",
"}",
")",
"if",
"isinstance",
"(",
"members",
",",
"dict",
")",
":",
"members",
"=",
"members",
".",
"... | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | Enum.parse | Parses an enum member name or value into an enum member.
Accepts the following types:
- Members of this enum class. These are returned directly.
- Integers. If there is an enum member with the integer as a value, that member is returned.
- Strings. If there is an enum member with the st... | qcore/enum.py | def parse(cls, value, default=_no_default):
"""Parses an enum member name or value into an enum member.
Accepts the following types:
- Members of this enum class. These are returned directly.
- Integers. If there is an enum member with the integer as a value, that member is returned.
... | def parse(cls, value, default=_no_default):
"""Parses an enum member name or value into an enum member.
Accepts the following types:
- Members of this enum class. These are returned directly.
- Integers. If there is an enum member with the integer as a value, that member is returned.
... | [
"Parses",
"an",
"enum",
"member",
"name",
"or",
"value",
"into",
"an",
"enum",
"member",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/enum.py#L239-L272 | [
"def",
"parse",
"(",
"cls",
",",
"value",
",",
"default",
"=",
"_no_default",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"cls",
")",
":",
"return",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"six",
".",
"integer_types",
")",
"and",
"not",
... | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | Flags.parse | Parses a flag integer or string into a Flags instance.
Accepts the following types:
- Members of this enum class. These are returned directly.
- Integers. These are converted directly into a Flags instance with the given name.
- Strings. The function accepts a comma-delimited list of fl... | qcore/enum.py | def parse(cls, value, default=_no_default):
"""Parses a flag integer or string into a Flags instance.
Accepts the following types:
- Members of this enum class. These are returned directly.
- Integers. These are converted directly into a Flags instance with the given name.
- Str... | def parse(cls, value, default=_no_default):
"""Parses a flag integer or string into a Flags instance.
Accepts the following types:
- Members of this enum class. These are returned directly.
- Integers. These are converted directly into a Flags instance with the given name.
- Str... | [
"Parses",
"a",
"flag",
"integer",
"or",
"string",
"into",
"a",
"Flags",
"instance",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/enum.py#L300-L344 | [
"def",
"parse",
"(",
"cls",
",",
"value",
",",
"default",
"=",
"_no_default",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"cls",
")",
":",
"return",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"int",
")",
":",
"e",
"=",
"cls",
".",
"_mak... | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | PriceEstimateViewSet.list | To get a list of price estimates, run **GET** against */api/price-estimates/* as authenticated user.
You can filter price estimates by scope type, scope URL, customer UUID.
`scope_type` is generic type of object for which price estimate is calculated.
Currently there are following types: custom... | waldur_core/cost_tracking/views.py | def list(self, request, *args, **kwargs):
"""
To get a list of price estimates, run **GET** against */api/price-estimates/* as authenticated user.
You can filter price estimates by scope type, scope URL, customer UUID.
`scope_type` is generic type of object for which price estimate is c... | def list(self, request, *args, **kwargs):
"""
To get a list of price estimates, run **GET** against */api/price-estimates/* as authenticated user.
You can filter price estimates by scope type, scope URL, customer UUID.
`scope_type` is generic type of object for which price estimate is c... | [
"To",
"get",
"a",
"list",
"of",
"price",
"estimates",
"run",
"**",
"GET",
"**",
"against",
"*",
"/",
"api",
"/",
"price",
"-",
"estimates",
"/",
"*",
"as",
"authenticated",
"user",
".",
"You",
"can",
"filter",
"price",
"estimates",
"by",
"scope",
"type... | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/views.py#L40-L54 | [
"def",
"list",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"PriceEstimateViewSet",
",",
"self",
")",
".",
"list",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | PriceListItemViewSet.list | To get a list of price list items, run **GET** against */api/price-list-items/* as an authenticated user. | waldur_core/cost_tracking/views.py | def list(self, request, *args, **kwargs):
"""
To get a list of price list items, run **GET** against */api/price-list-items/* as an authenticated user.
"""
return super(PriceListItemViewSet, self).list(request, *args, **kwargs) | def list(self, request, *args, **kwargs):
"""
To get a list of price list items, run **GET** against */api/price-list-items/* as an authenticated user.
"""
return super(PriceListItemViewSet, self).list(request, *args, **kwargs) | [
"To",
"get",
"a",
"list",
"of",
"price",
"list",
"items",
"run",
"**",
"GET",
"**",
"against",
"*",
"/",
"api",
"/",
"price",
"-",
"list",
"-",
"items",
"/",
"*",
"as",
"an",
"authenticated",
"user",
"."
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/views.py#L73-L77 | [
"def",
"list",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"PriceListItemViewSet",
",",
"self",
")",
".",
"list",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | PriceListItemViewSet.create | Run **POST** request against */api/price-list-items/* to create new price list item.
Customer owner and staff can create price items.
Example of request:
.. code-block:: http
POST /api/price-list-items/ HTTP/1.1
Content-Type: application/json
Accept: applic... | waldur_core/cost_tracking/views.py | def create(self, request, *args, **kwargs):
"""
Run **POST** request against */api/price-list-items/* to create new price list item.
Customer owner and staff can create price items.
Example of request:
.. code-block:: http
POST /api/price-list-items/ HTTP/1.1
... | def create(self, request, *args, **kwargs):
"""
Run **POST** request against */api/price-list-items/* to create new price list item.
Customer owner and staff can create price items.
Example of request:
.. code-block:: http
POST /api/price-list-items/ HTTP/1.1
... | [
"Run",
"**",
"POST",
"**",
"request",
"against",
"*",
"/",
"api",
"/",
"price",
"-",
"list",
"-",
"items",
"/",
"*",
"to",
"create",
"new",
"price",
"list",
"item",
".",
"Customer",
"owner",
"and",
"staff",
"can",
"create",
"price",
"items",
"."
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/views.py#L79-L101 | [
"def",
"create",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"PriceListItemViewSet",
",",
"self",
")",
".",
"create",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | PriceListItemViewSet.update | Run **PATCH** request against */api/price-list-items/<uuid>/* to update price list item.
Only item_type, key value and units can be updated.
Only customer owner and staff can update price items. | waldur_core/cost_tracking/views.py | def update(self, request, *args, **kwargs):
"""
Run **PATCH** request against */api/price-list-items/<uuid>/* to update price list item.
Only item_type, key value and units can be updated.
Only customer owner and staff can update price items.
"""
return super(PriceListIte... | def update(self, request, *args, **kwargs):
"""
Run **PATCH** request against */api/price-list-items/<uuid>/* to update price list item.
Only item_type, key value and units can be updated.
Only customer owner and staff can update price items.
"""
return super(PriceListIte... | [
"Run",
"**",
"PATCH",
"**",
"request",
"against",
"*",
"/",
"api",
"/",
"price",
"-",
"list",
"-",
"items",
"/",
"<uuid",
">",
"/",
"*",
"to",
"update",
"price",
"list",
"item",
".",
"Only",
"item_type",
"key",
"value",
"and",
"units",
"can",
"be",
... | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/views.py#L103-L109 | [
"def",
"update",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"PriceListItemViewSet",
",",
"self",
")",
".",
"update",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | PriceListItemViewSet.destroy | Run **DELETE** request against */api/price-list-items/<uuid>/* to delete price list item.
Only customer owner and staff can delete price items. | waldur_core/cost_tracking/views.py | def destroy(self, request, *args, **kwargs):
"""
Run **DELETE** request against */api/price-list-items/<uuid>/* to delete price list item.
Only customer owner and staff can delete price items.
"""
return super(PriceListItemViewSet, self).destroy(request, *args, **kwargs) | def destroy(self, request, *args, **kwargs):
"""
Run **DELETE** request against */api/price-list-items/<uuid>/* to delete price list item.
Only customer owner and staff can delete price items.
"""
return super(PriceListItemViewSet, self).destroy(request, *args, **kwargs) | [
"Run",
"**",
"DELETE",
"**",
"request",
"against",
"*",
"/",
"api",
"/",
"price",
"-",
"list",
"-",
"items",
"/",
"<uuid",
">",
"/",
"*",
"to",
"delete",
"price",
"list",
"item",
".",
"Only",
"customer",
"owner",
"and",
"staff",
"can",
"delete",
"pri... | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/views.py#L111-L116 | [
"def",
"destroy",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"PriceListItemViewSet",
",",
"self",
")",
".",
"destroy",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | DefaultPriceListItemViewSet.list | To get a list of default price list items, run **GET** against */api/default-price-list-items/*
as authenticated user.
Price lists can be filtered by:
- ?key=<string>
- ?item_type=<string> has to be from list of available item_types
(available options: 'flavor', 'storage', ... | waldur_core/cost_tracking/views.py | def list(self, request, *args, **kwargs):
"""
To get a list of default price list items, run **GET** against */api/default-price-list-items/*
as authenticated user.
Price lists can be filtered by:
- ?key=<string>
- ?item_type=<string> has to be from list of available i... | def list(self, request, *args, **kwargs):
"""
To get a list of default price list items, run **GET** against */api/default-price-list-items/*
as authenticated user.
Price lists can be filtered by:
- ?key=<string>
- ?item_type=<string> has to be from list of available i... | [
"To",
"get",
"a",
"list",
"of",
"default",
"price",
"list",
"items",
"run",
"**",
"GET",
"**",
"against",
"*",
"/",
"api",
"/",
"default",
"-",
"price",
"-",
"list",
"-",
"items",
"/",
"*",
"as",
"authenticated",
"user",
"."
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/views.py#L139-L150 | [
"def",
"list",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"DefaultPriceListItemViewSet",
",",
"self",
")",
".",
"list",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | MergedPriceListItemViewSet.list | To get a list of price list items, run **GET** against */api/merged-price-list-items/*
as authenticated user.
If service is not specified default price list items are displayed.
Otherwise service specific price list items are displayed.
In this case rendered object contains {"is_manuall... | waldur_core/cost_tracking/views.py | def list(self, request, *args, **kwargs):
"""
To get a list of price list items, run **GET** against */api/merged-price-list-items/*
as authenticated user.
If service is not specified default price list items are displayed.
Otherwise service specific price list items are display... | def list(self, request, *args, **kwargs):
"""
To get a list of price list items, run **GET** against */api/merged-price-list-items/*
as authenticated user.
If service is not specified default price list items are displayed.
Otherwise service specific price list items are display... | [
"To",
"get",
"a",
"list",
"of",
"price",
"list",
"items",
"run",
"**",
"GET",
"**",
"against",
"*",
"/",
"api",
"/",
"merged",
"-",
"price",
"-",
"list",
"-",
"items",
"/",
"*",
"as",
"authenticated",
"user",
"."
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/views.py#L158-L173 | [
"def",
"list",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"MergedPriceListItemViewSet",
",",
"self",
")",
".",
"list",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | Remote | A remote notebook finder. Place a `*` into a url
to generalize the finder. It returns a context manager | src/importnb/remote.py | def Remote(path=None, loader=Notebook, **globals):
"""A remote notebook finder. Place a `*` into a url
to generalize the finder. It returns a context manager
"""
class Remote(RemoteMixin, loader):
...
return Remote(path=path, **globals) | def Remote(path=None, loader=Notebook, **globals):
"""A remote notebook finder. Place a `*` into a url
to generalize the finder. It returns a context manager
"""
class Remote(RemoteMixin, loader):
...
return Remote(path=path, **globals) | [
"A",
"remote",
"notebook",
"finder",
".",
"Place",
"a",
"*",
"into",
"a",
"url",
"to",
"generalize",
"the",
"finder",
".",
"It",
"returns",
"a",
"context",
"manager"
] | deathbeds/importnb | python | https://github.com/deathbeds/importnb/blob/ec870d1f8ab99fd5b363267f89787a3e442a779f/src/importnb/remote.py#L88-L96 | [
"def",
"Remote",
"(",
"path",
"=",
"None",
",",
"loader",
"=",
"Notebook",
",",
"*",
"*",
"globals",
")",
":",
"class",
"Remote",
"(",
"RemoteMixin",
",",
"loader",
")",
":",
"...",
"return",
"Remote",
"(",
"path",
"=",
"path",
",",
"*",
"*",
"glob... | ec870d1f8ab99fd5b363267f89787a3e442a779f |
train | ActionsPermission.get_permission_checks | Get permission checks that will be executed for current action. | waldur_core/core/permissions.py | def get_permission_checks(self, request, view):
"""
Get permission checks that will be executed for current action.
"""
if view.action is None:
return []
# if permissions are defined for view directly - use them.
if hasattr(view, view.action + '_permissions'):... | def get_permission_checks(self, request, view):
"""
Get permission checks that will be executed for current action.
"""
if view.action is None:
return []
# if permissions are defined for view directly - use them.
if hasattr(view, view.action + '_permissions'):... | [
"Get",
"permission",
"checks",
"that",
"will",
"be",
"executed",
"for",
"current",
"action",
"."
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/permissions.py#L61-L75 | [
"def",
"get_permission_checks",
"(",
"self",
",",
"request",
",",
"view",
")",
":",
"if",
"view",
".",
"action",
"is",
"None",
":",
"return",
"[",
"]",
"# if permissions are defined for view directly - use them.",
"if",
"hasattr",
"(",
"view",
",",
"view",
".",
... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | Server.add_function | Registers the function to the server's default fixed function manager. | src/pyws/server.py | def add_function(self, function):
"""
Registers the function to the server's default fixed function manager.
"""
#noinspection PyTypeChecker
if not len(self.settings.FUNCTION_MANAGERS):
raise ConfigurationError(
'Where have the default function manager... | def add_function(self, function):
"""
Registers the function to the server's default fixed function manager.
"""
#noinspection PyTypeChecker
if not len(self.settings.FUNCTION_MANAGERS):
raise ConfigurationError(
'Where have the default function manager... | [
"Registers",
"the",
"function",
"to",
"the",
"server",
"s",
"default",
"fixed",
"function",
"manager",
"."
] | stepank/pyws | python | https://github.com/stepank/pyws/blob/ff39133aabeb56bbb08d66286ac0cc8731eda7dd/src/pyws/server.py#L117-L125 | [
"def",
"add_function",
"(",
"self",
",",
"function",
")",
":",
"#noinspection PyTypeChecker",
"if",
"not",
"len",
"(",
"self",
".",
"settings",
".",
"FUNCTION_MANAGERS",
")",
":",
"raise",
"ConfigurationError",
"(",
"'Where have the default function manager gone?!'",
... | ff39133aabeb56bbb08d66286ac0cc8731eda7dd |
train | format_raw_field | When ElasticSearch analyzes string, it breaks it into parts.
In order make query for not-analyzed exact string values, we should use subfield instead.
The index template for Elasticsearch 5.0 has been changed.
The subfield for string multi-fields has changed from .raw to .keyword
Thus workaround for b... | waldur_core/logging/filters.py | def format_raw_field(key):
"""
When ElasticSearch analyzes string, it breaks it into parts.
In order make query for not-analyzed exact string values, we should use subfield instead.
The index template for Elasticsearch 5.0 has been changed.
The subfield for string multi-fields has changed from .raw... | def format_raw_field(key):
"""
When ElasticSearch analyzes string, it breaks it into parts.
In order make query for not-analyzed exact string values, we should use subfield instead.
The index template for Elasticsearch 5.0 has been changed.
The subfield for string multi-fields has changed from .raw... | [
"When",
"ElasticSearch",
"analyzes",
"string",
"it",
"breaks",
"it",
"into",
"parts",
".",
"In",
"order",
"make",
"query",
"for",
"not",
"-",
"analyzed",
"exact",
"string",
"values",
"we",
"should",
"use",
"subfield",
"instead",
"."
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/filters.py#L20-L32 | [
"def",
"format_raw_field",
"(",
"key",
")",
":",
"subfield",
"=",
"django_settings",
".",
"WALDUR_CORE",
".",
"get",
"(",
"'ELASTICSEARCH'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'raw_subfield'",
",",
"'keyword'",
")",
"return",
"'%s.%s'",
"%",
"(",
"camel... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | decorate | Creates a decorator function that applies the decorator_cls that was passed in. | qcore/decorators.py | def decorate(decorator_cls, *args, **kwargs):
"""Creates a decorator function that applies the decorator_cls that was passed in."""
global _wrappers
wrapper_cls = _wrappers.get(decorator_cls, None)
if wrapper_cls is None:
class PythonWrapper(decorator_cls):
pass
wrapper_cl... | def decorate(decorator_cls, *args, **kwargs):
"""Creates a decorator function that applies the decorator_cls that was passed in."""
global _wrappers
wrapper_cls = _wrappers.get(decorator_cls, None)
if wrapper_cls is None:
class PythonWrapper(decorator_cls):
pass
wrapper_cl... | [
"Creates",
"a",
"decorator",
"function",
"that",
"applies",
"the",
"decorator_cls",
"that",
"was",
"passed",
"in",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/decorators.py#L160-L179 | [
"def",
"decorate",
"(",
"decorator_cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"global",
"_wrappers",
"wrapper_cls",
"=",
"_wrappers",
".",
"get",
"(",
"decorator_cls",
",",
"None",
")",
"if",
"wrapper_cls",
"is",
"None",
":",
"class",
"Py... | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | deprecated | States that method is deprecated.
:param replacement_description: Describes what must be used instead.
:return: the original method with modified docstring. | qcore/decorators.py | def deprecated(replacement_description):
"""States that method is deprecated.
:param replacement_description: Describes what must be used instead.
:return: the original method with modified docstring.
"""
def decorate(fn_or_class):
if isinstance(fn_or_class, type):
pass # Can... | def deprecated(replacement_description):
"""States that method is deprecated.
:param replacement_description: Describes what must be used instead.
:return: the original method with modified docstring.
"""
def decorate(fn_or_class):
if isinstance(fn_or_class, type):
pass # Can... | [
"States",
"that",
"method",
"is",
"deprecated",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/decorators.py#L182-L203 | [
"def",
"deprecated",
"(",
"replacement_description",
")",
":",
"def",
"decorate",
"(",
"fn_or_class",
")",
":",
"if",
"isinstance",
"(",
"fn_or_class",
",",
"type",
")",
":",
"pass",
"# Can't change __doc__ of type objects",
"else",
":",
"try",
":",
"fn_or_class",... | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | convert_result | Decorator that can convert the result of a function call. | qcore/decorators.py | def convert_result(converter):
"""Decorator that can convert the result of a function call."""
def decorate(fn):
@inspection.wraps(fn)
def new_fn(*args, **kwargs):
return converter(fn(*args, **kwargs))
return new_fn
return decorate | def convert_result(converter):
"""Decorator that can convert the result of a function call."""
def decorate(fn):
@inspection.wraps(fn)
def new_fn(*args, **kwargs):
return converter(fn(*args, **kwargs))
return new_fn
return decorate | [
"Decorator",
"that",
"can",
"convert",
"the",
"result",
"of",
"a",
"function",
"call",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/decorators.py#L206-L216 | [
"def",
"convert_result",
"(",
"converter",
")",
":",
"def",
"decorate",
"(",
"fn",
")",
":",
"@",
"inspection",
".",
"wraps",
"(",
"fn",
")",
"def",
"new_fn",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"converter",
"(",
"fn",
"(... | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | retry | Decorator for retrying a function if it throws an exception.
:param exception_cls: an exception type or a parenthesized tuple of exception types
:param max_tries: maximum number of times this function can be executed. Must be at least 1.
:param sleep: number of seconds to sleep between function retries | qcore/decorators.py | def retry(exception_cls, max_tries=10, sleep=0.05):
"""Decorator for retrying a function if it throws an exception.
:param exception_cls: an exception type or a parenthesized tuple of exception types
:param max_tries: maximum number of times this function can be executed. Must be at least 1.
:param sle... | def retry(exception_cls, max_tries=10, sleep=0.05):
"""Decorator for retrying a function if it throws an exception.
:param exception_cls: an exception type or a parenthesized tuple of exception types
:param max_tries: maximum number of times this function can be executed. Must be at least 1.
:param sle... | [
"Decorator",
"for",
"retrying",
"a",
"function",
"if",
"it",
"throws",
"an",
"exception",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/decorators.py#L219-L274 | [
"def",
"retry",
"(",
"exception_cls",
",",
"max_tries",
"=",
"10",
",",
"sleep",
"=",
"0.05",
")",
":",
"assert",
"max_tries",
">",
"0",
"def",
"with_max_retries_call",
"(",
"delegate",
")",
":",
"for",
"i",
"in",
"xrange",
"(",
"0",
",",
"max_tries",
... | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | decorator_of_context_manager | Converts a context manager into a decorator.
This decorator will run the decorated function in the context of the
manager.
:param ctxt: Context to run the function in.
:return: Wrapper around the original function. | qcore/decorators.py | def decorator_of_context_manager(ctxt):
"""Converts a context manager into a decorator.
This decorator will run the decorated function in the context of the
manager.
:param ctxt: Context to run the function in.
:return: Wrapper around the original function.
"""
def decorator_fn(*outer_ar... | def decorator_of_context_manager(ctxt):
"""Converts a context manager into a decorator.
This decorator will run the decorated function in the context of the
manager.
:param ctxt: Context to run the function in.
:return: Wrapper around the original function.
"""
def decorator_fn(*outer_ar... | [
"Converts",
"a",
"context",
"manager",
"into",
"a",
"decorator",
"."
] | quora/qcore | python | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/decorators.py#L277-L304 | [
"def",
"decorator_of_context_manager",
"(",
"ctxt",
")",
":",
"def",
"decorator_fn",
"(",
"*",
"outer_args",
",",
"*",
"*",
"outer_kwargs",
")",
":",
"def",
"decorator",
"(",
"fn",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"fn",
")",
"def",
"wrapper... | fa5cd438eea554db35fd29cbc8dfbde69f09961c |
train | Protocol.get_error | A helper function, gets standard information from the error. | src/pyws/protocols/base.py | def get_error(self, error):
"""
A helper function, gets standard information from the error.
"""
error_type = type(error)
if error.error_type == ET_CLIENT:
error_type_name = 'Client'
else:
error_type_name = 'Server'
return {
'ty... | def get_error(self, error):
"""
A helper function, gets standard information from the error.
"""
error_type = type(error)
if error.error_type == ET_CLIENT:
error_type_name = 'Client'
else:
error_type_name = 'Server'
return {
'ty... | [
"A",
"helper",
"function",
"gets",
"standard",
"information",
"from",
"the",
"error",
"."
] | stepank/pyws | python | https://github.com/stepank/pyws/blob/ff39133aabeb56bbb08d66286ac0cc8731eda7dd/src/pyws/protocols/base.py#L66-L81 | [
"def",
"get_error",
"(",
"self",
",",
"error",
")",
":",
"error_type",
"=",
"type",
"(",
"error",
")",
"if",
"error",
".",
"error_type",
"==",
"ET_CLIENT",
":",
"error_type_name",
"=",
"'Client'",
"else",
":",
"error_type_name",
"=",
"'Server'",
"return",
... | ff39133aabeb56bbb08d66286ac0cc8731eda7dd |
train | QuotaModelMixin.validate_quota_change | Get error messages about object and his ancestor quotas that will be exceeded if quota_delta will be added.
raise_exception - if True QuotaExceededException will be raised if validation fails
quota_deltas - dictionary of quotas deltas, example:
{
'ram': 1024,
'storage': ... | waldur_core/quotas/models.py | def validate_quota_change(self, quota_deltas, raise_exception=False):
"""
Get error messages about object and his ancestor quotas that will be exceeded if quota_delta will be added.
raise_exception - if True QuotaExceededException will be raised if validation fails
quota_deltas - dictio... | def validate_quota_change(self, quota_deltas, raise_exception=False):
"""
Get error messages about object and his ancestor quotas that will be exceeded if quota_delta will be added.
raise_exception - if True QuotaExceededException will be raised if validation fails
quota_deltas - dictio... | [
"Get",
"error",
"messages",
"about",
"object",
"and",
"his",
"ancestor",
"quotas",
"that",
"will",
"be",
"exceeded",
"if",
"quota_delta",
"will",
"be",
"added",
"."
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/quotas/models.py#L186-L211 | [
"def",
"validate_quota_change",
"(",
"self",
",",
"quota_deltas",
",",
"raise_exception",
"=",
"False",
")",
":",
"errors",
"=",
"[",
"]",
"for",
"name",
",",
"delta",
"in",
"six",
".",
"iteritems",
"(",
"quota_deltas",
")",
":",
"quota",
"=",
"self",
".... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | QuotaModelMixin.get_sum_of_quotas_as_dict | Return dictionary with sum of all scopes' quotas.
Dictionary format:
{
'quota_name1': 'sum of limits for quotas with such quota_name1',
'quota_name1_usage': 'sum of usages for quotas with such quota_name1',
...
}
All `scopes` have to be instances of t... | waldur_core/quotas/models.py | def get_sum_of_quotas_as_dict(cls, scopes, quota_names=None, fields=['usage', 'limit']):
"""
Return dictionary with sum of all scopes' quotas.
Dictionary format:
{
'quota_name1': 'sum of limits for quotas with such quota_name1',
'quota_name1_usage': 'sum of usage... | def get_sum_of_quotas_as_dict(cls, scopes, quota_names=None, fields=['usage', 'limit']):
"""
Return dictionary with sum of all scopes' quotas.
Dictionary format:
{
'quota_name1': 'sum of limits for quotas with such quota_name1',
'quota_name1_usage': 'sum of usage... | [
"Return",
"dictionary",
"with",
"sum",
"of",
"all",
"scopes",
"quotas",
"."
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/quotas/models.py#L220-L270 | [
"def",
"get_sum_of_quotas_as_dict",
"(",
"cls",
",",
"scopes",
",",
"quota_names",
"=",
"None",
",",
"fields",
"=",
"[",
"'usage'",
",",
"'limit'",
"]",
")",
":",
"if",
"not",
"scopes",
":",
"return",
"{",
"}",
"if",
"quota_names",
"is",
"None",
":",
"... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | EventViewSet.list | To get a list of events - run **GET** against */api/events/* as authenticated user. Note that a user can
only see events connected to objects she is allowed to see.
Sorting is supported in ascending and descending order by specifying a field to an **?o=** parameter. By default
events are sorted... | waldur_core/logging/views.py | def list(self, request, *args, **kwargs):
"""
To get a list of events - run **GET** against */api/events/* as authenticated user. Note that a user can
only see events connected to objects she is allowed to see.
Sorting is supported in ascending and descending order by specifying a field... | def list(self, request, *args, **kwargs):
"""
To get a list of events - run **GET** against */api/events/* as authenticated user. Note that a user can
only see events connected to objects she is allowed to see.
Sorting is supported in ascending and descending order by specifying a field... | [
"To",
"get",
"a",
"list",
"of",
"events",
"-",
"run",
"**",
"GET",
"**",
"against",
"*",
"/",
"api",
"/",
"events",
"/",
"*",
"as",
"authenticated",
"user",
".",
"Note",
"that",
"a",
"user",
"can",
"only",
"see",
"events",
"connected",
"to",
"objects... | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L23-L60 | [
"def",
"list",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"queryset",
"=",
"self",
".",
"filter_queryset",
"(",
"self",
".",
"get_queryset",
"(",
")",
")",
"page",
"=",
"self",
".",
"paginate_querys... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | EventViewSet.count | To get a count of events - run **GET** against */api/events/count/* as authenticated user.
Endpoint support same filters as events list.
Response example:
.. code-block:: javascript
{"count": 12321} | waldur_core/logging/views.py | def count(self, request, *args, **kwargs):
"""
To get a count of events - run **GET** against */api/events/count/* as authenticated user.
Endpoint support same filters as events list.
Response example:
.. code-block:: javascript
{"count": 12321}
"""
... | def count(self, request, *args, **kwargs):
"""
To get a count of events - run **GET** against */api/events/count/* as authenticated user.
Endpoint support same filters as events list.
Response example:
.. code-block:: javascript
{"count": 12321}
"""
... | [
"To",
"get",
"a",
"count",
"of",
"events",
"-",
"run",
"**",
"GET",
"**",
"against",
"*",
"/",
"api",
"/",
"events",
"/",
"count",
"/",
"*",
"as",
"authenticated",
"user",
".",
"Endpoint",
"support",
"same",
"filters",
"as",
"events",
"list",
"."
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L78-L91 | [
"def",
"count",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"queryset",
"=",
"self",
".",
"filter_queryset",
"(",
"self",
".",
"get_queryset",
"(",
")",
")",
"return",
"response",
".",
"Response",
"(... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | EventViewSet.count_history | To get a historical data of events amount - run **GET** against */api/events/count/history/*.
Endpoint support same filters as events list.
More about historical data - read at section *Historical data*.
Response example:
.. code-block:: javascript
[
{
... | waldur_core/logging/views.py | def count_history(self, request, *args, **kwargs):
"""
To get a historical data of events amount - run **GET** against */api/events/count/history/*.
Endpoint support same filters as events list.
More about historical data - read at section *Historical data*.
Response example:
... | def count_history(self, request, *args, **kwargs):
"""
To get a historical data of events amount - run **GET** against */api/events/count/history/*.
Endpoint support same filters as events list.
More about historical data - read at section *Historical data*.
Response example:
... | [
"To",
"get",
"a",
"historical",
"data",
"of",
"events",
"amount",
"-",
"run",
"**",
"GET",
"**",
"against",
"*",
"/",
"api",
"/",
"events",
"/",
"count",
"/",
"history",
"/",
"*",
".",
"Endpoint",
"support",
"same",
"filters",
"as",
"events",
"list",
... | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L94-L129 | [
"def",
"count_history",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"queryset",
"=",
"self",
".",
"filter_queryset",
"(",
"self",
".",
"get_queryset",
"(",
")",
")",
"mapped",
"=",
"{",
"'start'",
":",
"request",
... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | EventViewSet.scope_types | Returns a list of scope types acceptable by events filter. | waldur_core/logging/views.py | def scope_types(self, request, *args, **kwargs):
""" Returns a list of scope types acceptable by events filter. """
return response.Response(utils.get_scope_types_mapping().keys()) | def scope_types(self, request, *args, **kwargs):
""" Returns a list of scope types acceptable by events filter. """
return response.Response(utils.get_scope_types_mapping().keys()) | [
"Returns",
"a",
"list",
"of",
"scope",
"types",
"acceptable",
"by",
"events",
"filter",
"."
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L132-L134 | [
"def",
"scope_types",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"response",
".",
"Response",
"(",
"utils",
".",
"get_scope_types_mapping",
"(",
")",
".",
"keys",
"(",
")",
")"
] | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | AlertViewSet.list | To get a list of alerts, run **GET** against */api/alerts/* as authenticated user.
Alert severity field can take one of this values: "Error", "Warning", "Info", "Debug".
Field scope will contain link to object that cause alert.
Context - dictionary that contains information about all related to... | waldur_core/logging/views.py | def list(self, request, *args, **kwargs):
"""
To get a list of alerts, run **GET** against */api/alerts/* as authenticated user.
Alert severity field can take one of this values: "Error", "Warning", "Info", "Debug".
Field scope will contain link to object that cause alert.
Conte... | def list(self, request, *args, **kwargs):
"""
To get a list of alerts, run **GET** against */api/alerts/* as authenticated user.
Alert severity field can take one of this values: "Error", "Warning", "Info", "Debug".
Field scope will contain link to object that cause alert.
Conte... | [
"To",
"get",
"a",
"list",
"of",
"alerts",
"run",
"**",
"GET",
"**",
"against",
"*",
"/",
"api",
"/",
"alerts",
"/",
"*",
"as",
"authenticated",
"user",
"."
] | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L161-L230 | [
"def",
"list",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"AlertViewSet",
",",
"self",
")",
".",
"list",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | AlertViewSet.create | Run **POST** against */api/alerts/* to create or update alert. If alert with posted scope and
alert_type already exists - it will be updated. Only users with staff privileges can create alerts.
Request example:
.. code-block:: javascript
POST /api/alerts/
Accept: appli... | waldur_core/logging/views.py | def create(self, request, *args, **kwargs):
"""
Run **POST** against */api/alerts/* to create or update alert. If alert with posted scope and
alert_type already exists - it will be updated. Only users with staff privileges can create alerts.
Request example:
.. code-block:: jav... | def create(self, request, *args, **kwargs):
"""
Run **POST** against */api/alerts/* to create or update alert. If alert with posted scope and
alert_type already exists - it will be updated. Only users with staff privileges can create alerts.
Request example:
.. code-block:: jav... | [
"Run",
"**",
"POST",
"**",
"against",
"*",
"/",
"api",
"/",
"alerts",
"/",
"*",
"to",
"create",
"or",
"update",
"alert",
".",
"If",
"alert",
"with",
"posted",
"scope",
"and",
"alert_type",
"already",
"exists",
"-",
"it",
"will",
"be",
"updated",
".",
... | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L232-L254 | [
"def",
"create",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"AlertViewSet",
",",
"self",
")",
".",
"create",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | AlertViewSet.close | To close alert - run **POST** against */api/alerts/<alert_uuid>/close/*. No data is required.
Only users with staff privileges can close alerts. | waldur_core/logging/views.py | def close(self, request, *args, **kwargs):
"""
To close alert - run **POST** against */api/alerts/<alert_uuid>/close/*. No data is required.
Only users with staff privileges can close alerts.
"""
if not request.user.is_staff:
raise PermissionDenied()
alert = s... | def close(self, request, *args, **kwargs):
"""
To close alert - run **POST** against */api/alerts/<alert_uuid>/close/*. No data is required.
Only users with staff privileges can close alerts.
"""
if not request.user.is_staff:
raise PermissionDenied()
alert = s... | [
"To",
"close",
"alert",
"-",
"run",
"**",
"POST",
"**",
"against",
"*",
"/",
"api",
"/",
"alerts",
"/",
"<alert_uuid",
">",
"/",
"close",
"/",
"*",
".",
"No",
"data",
"is",
"required",
".",
"Only",
"users",
"with",
"staff",
"privileges",
"can",
"clos... | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L257-L267 | [
"def",
"close",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"request",
".",
"user",
".",
"is_staff",
":",
"raise",
"PermissionDenied",
"(",
")",
"alert",
"=",
"self",
".",
"get_object",
"(",
")",
"... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | AlertViewSet.acknowledge | To acknowledge alert - run **POST** against */api/alerts/<alert_uuid>/acknowledge/*. No payload is required.
All users that can see alerts can also acknowledge it. If alert is already acknowledged endpoint
will return error with code 409(conflict). | waldur_core/logging/views.py | def acknowledge(self, request, *args, **kwargs):
"""
To acknowledge alert - run **POST** against */api/alerts/<alert_uuid>/acknowledge/*. No payload is required.
All users that can see alerts can also acknowledge it. If alert is already acknowledged endpoint
will return error with code 4... | def acknowledge(self, request, *args, **kwargs):
"""
To acknowledge alert - run **POST** against */api/alerts/<alert_uuid>/acknowledge/*. No payload is required.
All users that can see alerts can also acknowledge it. If alert is already acknowledged endpoint
will return error with code 4... | [
"To",
"acknowledge",
"alert",
"-",
"run",
"**",
"POST",
"**",
"against",
"*",
"/",
"api",
"/",
"alerts",
"/",
"<alert_uuid",
">",
"/",
"acknowledge",
"/",
"*",
".",
"No",
"payload",
"is",
"required",
".",
"All",
"users",
"that",
"can",
"see",
"alerts",... | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L270-L281 | [
"def",
"acknowledge",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"alert",
"=",
"self",
".",
"get_object",
"(",
")",
"if",
"not",
"alert",
".",
"acknowledged",
":",
"alert",
".",
"acknowledge",
"(",
")",
"return"... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | AlertViewSet.stats | To get count of alerts per severities - run **GET** request against */api/alerts/stats/*.
This endpoint supports all filters that are available for alerts list (*/api/alerts/*).
Response example:
.. code-block:: javascript
{
"debug": 2,
"error": 1,
... | waldur_core/logging/views.py | def stats(self, request, *args, **kwargs):
"""
To get count of alerts per severities - run **GET** request against */api/alerts/stats/*.
This endpoint supports all filters that are available for alerts list (*/api/alerts/*).
Response example:
.. code-block:: javascript
... | def stats(self, request, *args, **kwargs):
"""
To get count of alerts per severities - run **GET** request against */api/alerts/stats/*.
This endpoint supports all filters that are available for alerts list (*/api/alerts/*).
Response example:
.. code-block:: javascript
... | [
"To",
"get",
"count",
"of",
"alerts",
"per",
"severities",
"-",
"run",
"**",
"GET",
"**",
"request",
"against",
"*",
"/",
"api",
"/",
"alerts",
"/",
"stats",
"/",
"*",
".",
"This",
"endpoint",
"supports",
"all",
"filters",
"that",
"are",
"available",
"... | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L298-L325 | [
"def",
"stats",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"queryset",
"=",
"self",
".",
"filter_queryset",
"(",
"self",
".",
"get_queryset",
"(",
")",
")",
"alerts_severities_count",
"=",
"queryset",
".",
"values",... | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | WebHookViewSet.create | To create new web hook issue **POST** against */api/hooks-web/* as an authenticated user.
You should specify list of event_types or event_groups.
Example of a request:
.. code-block:: http
POST /api/hooks-web/ HTTP/1.1
Content-Type: application/json
Accept:... | waldur_core/logging/views.py | def create(self, request, *args, **kwargs):
"""
To create new web hook issue **POST** against */api/hooks-web/* as an authenticated user.
You should specify list of event_types or event_groups.
Example of a request:
.. code-block:: http
POST /api/hooks-web/ HTTP/1.... | def create(self, request, *args, **kwargs):
"""
To create new web hook issue **POST** against */api/hooks-web/* as an authenticated user.
You should specify list of event_types or event_groups.
Example of a request:
.. code-block:: http
POST /api/hooks-web/ HTTP/1.... | [
"To",
"create",
"new",
"web",
"hook",
"issue",
"**",
"POST",
"**",
"against",
"*",
"/",
"api",
"/",
"hooks",
"-",
"web",
"/",
"*",
"as",
"an",
"authenticated",
"user",
".",
"You",
"should",
"specify",
"list",
"of",
"event_types",
"or",
"event_groups",
... | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L356-L401 | [
"def",
"create",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"WebHookViewSet",
",",
"self",
")",
".",
"create",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | EmailHookViewSet.create | To create new email hook issue **POST** against */api/hooks-email/* as an authenticated user.
You should specify list of event_types or event_groups.
Example of a request:
.. code-block:: http
POST /api/hooks-email/ HTTP/1.1
Content-Type: application/json
A... | waldur_core/logging/views.py | def create(self, request, *args, **kwargs):
"""
To create new email hook issue **POST** against */api/hooks-email/* as an authenticated user.
You should specify list of event_types or event_groups.
Example of a request:
.. code-block:: http
POST /api/hooks-email/ H... | def create(self, request, *args, **kwargs):
"""
To create new email hook issue **POST** against */api/hooks-email/* as an authenticated user.
You should specify list of event_types or event_groups.
Example of a request:
.. code-block:: http
POST /api/hooks-email/ H... | [
"To",
"create",
"new",
"email",
"hook",
"issue",
"**",
"POST",
"**",
"against",
"*",
"/",
"api",
"/",
"hooks",
"-",
"email",
"/",
"*",
"as",
"an",
"authenticated",
"user",
".",
"You",
"should",
"specify",
"list",
"of",
"event_types",
"or",
"event_groups"... | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L409-L438 | [
"def",
"create",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"EmailHookViewSet",
",",
"self",
")",
".",
"create",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | PushHookViewSet.create | To create new push hook issue **POST** against */api/hooks-push/* as an authenticated user.
You should specify list of event_types or event_groups.
Example of a request:
.. code-block:: http
POST /api/hooks-push/ HTTP/1.1
Content-Type: application/json
Acce... | waldur_core/logging/views.py | def create(self, request, *args, **kwargs):
"""
To create new push hook issue **POST** against */api/hooks-push/* as an authenticated user.
You should specify list of event_types or event_groups.
Example of a request:
.. code-block:: http
POST /api/hooks-push/ HTTP... | def create(self, request, *args, **kwargs):
"""
To create new push hook issue **POST** against */api/hooks-push/* as an authenticated user.
You should specify list of event_types or event_groups.
Example of a request:
.. code-block:: http
POST /api/hooks-push/ HTTP... | [
"To",
"create",
"new",
"push",
"hook",
"issue",
"**",
"POST",
"**",
"against",
"*",
"/",
"api",
"/",
"hooks",
"-",
"push",
"/",
"*",
"as",
"an",
"authenticated",
"user",
".",
"You",
"should",
"specify",
"list",
"of",
"event_types",
"or",
"event_groups",
... | opennode/waldur-core | python | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L446-L475 | [
"def",
"create",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"PushHookViewSet",
",",
"self",
")",
".",
"create",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | d6c17a9592bb6c49c33567542eef8d099605a46a |
train | Instruments.import_from_file | Import this instrument's settings from the given file. Will
automatically add the instrument's synth and table to the song's
synths and tables if needed.
Note that this may invalidate existing instrument accessor objects.
:param index: the index into which to import
:param fil... | pylsdj/instruments.py | def import_from_file(self, index, filename):
"""Import this instrument's settings from the given file. Will
automatically add the instrument's synth and table to the song's
synths and tables if needed.
Note that this may invalidate existing instrument accessor objects.
:param i... | def import_from_file(self, index, filename):
"""Import this instrument's settings from the given file. Will
automatically add the instrument's synth and table to the song's
synths and tables if needed.
Note that this may invalidate existing instrument accessor objects.
:param i... | [
"Import",
"this",
"instrument",
"s",
"settings",
"from",
"the",
"given",
"file",
".",
"Will",
"automatically",
"add",
"the",
"instrument",
"s",
"synth",
"and",
"table",
"to",
"the",
"song",
"s",
"synths",
"and",
"tables",
"if",
"needed",
"."
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/instruments.py#L63-L80 | [
"def",
"import_from_file",
"(",
"self",
",",
"index",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'r'",
")",
"as",
"fp",
":",
"self",
".",
"_import_from_struct",
"(",
"index",
",",
"json",
".",
"load",
"(",
"fp",
")",
")"
] | 1c45a7919dd324e941f76b315558b9647892e4d5 |
train | load_lsdsng | Load a Project from a ``.lsdsng`` file.
:param filename: the name of the file from which to load
:rtype: :py:class:`pylsdj.Project` | pylsdj/project.py | def load_lsdsng(filename):
"""Load a Project from a ``.lsdsng`` file.
:param filename: the name of the file from which to load
:rtype: :py:class:`pylsdj.Project`
"""
# Load preamble data so that we know the name and version of the song
with open(filename, 'rb') as fp:
preamble_data = b... | def load_lsdsng(filename):
"""Load a Project from a ``.lsdsng`` file.
:param filename: the name of the file from which to load
:rtype: :py:class:`pylsdj.Project`
"""
# Load preamble data so that we know the name and version of the song
with open(filename, 'rb') as fp:
preamble_data = b... | [
"Load",
"a",
"Project",
"from",
"a",
".",
"lsdsng",
"file",
"."
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/project.py#L10-L52 | [
"def",
"load_lsdsng",
"(",
"filename",
")",
":",
"# Load preamble data so that we know the name and version of the song",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"fp",
":",
"preamble_data",
"=",
"bread",
".",
"parse",
"(",
"fp",
",",
"spec",
".",
... | 1c45a7919dd324e941f76b315558b9647892e4d5 |
train | load_srm | Load a Project from an ``.srm`` file.
:param filename: the name of the file from which to load
:rtype: :py:class:`pylsdj.Project` | pylsdj/project.py | def load_srm(filename):
"""Load a Project from an ``.srm`` file.
:param filename: the name of the file from which to load
:rtype: :py:class:`pylsdj.Project`
"""
# .srm files are just decompressed projects without headers
# In order to determine the file's size in compressed blocks, we have to... | def load_srm(filename):
"""Load a Project from an ``.srm`` file.
:param filename: the name of the file from which to load
:rtype: :py:class:`pylsdj.Project`
"""
# .srm files are just decompressed projects without headers
# In order to determine the file's size in compressed blocks, we have to... | [
"Load",
"a",
"Project",
"from",
"an",
".",
"srm",
"file",
"."
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/project.py#L55-L82 | [
"def",
"load_srm",
"(",
"filename",
")",
":",
"# .srm files are just decompressed projects without headers",
"# In order to determine the file's size in compressed blocks, we have to",
"# compress it first",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"fp",
":",
"r... | 1c45a7919dd324e941f76b315558b9647892e4d5 |
train | Project.song | the song associated with the project | pylsdj/project.py | def song(self):
"""the song associated with the project"""
if self._song is None:
self._song = Song(self._song_data)
return self._song | def song(self):
"""the song associated with the project"""
if self._song is None:
self._song = Song(self._song_data)
return self._song | [
"the",
"song",
"associated",
"with",
"the",
"project"
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/project.py#L119-L124 | [
"def",
"song",
"(",
"self",
")",
":",
"if",
"self",
".",
"_song",
"is",
"None",
":",
"self",
".",
"_song",
"=",
"Song",
"(",
"self",
".",
"_song_data",
")",
"return",
"self",
".",
"_song"
] | 1c45a7919dd324e941f76b315558b9647892e4d5 |
train | Project.save | Save a project in .lsdsng format to the target file.
:param filename: the name of the file to which to save
:deprecated: use ``save_lsdsng(filename)`` instead | pylsdj/project.py | def save(self, filename):
"""Save a project in .lsdsng format to the target file.
:param filename: the name of the file to which to save
:deprecated: use ``save_lsdsng(filename)`` instead
"""
with open(filename, 'wb') as fp:
writer = BlockWriter()
factor... | def save(self, filename):
"""Save a project in .lsdsng format to the target file.
:param filename: the name of the file to which to save
:deprecated: use ``save_lsdsng(filename)`` instead
"""
with open(filename, 'wb') as fp:
writer = BlockWriter()
factor... | [
"Save",
"a",
"project",
"in",
".",
"lsdsng",
"format",
"to",
"the",
"target",
"file",
"."
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/project.py#L133-L159 | [
"def",
"save",
"(",
"self",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'wb'",
")",
"as",
"fp",
":",
"writer",
"=",
"BlockWriter",
"(",
")",
"factory",
"=",
"BlockFactory",
"(",
")",
"preamble_dummy_bytes",
"=",
"bytearray",
"(",
... | 1c45a7919dd324e941f76b315558b9647892e4d5 |
train | Project.save_srm | Save a project in .srm format to the target file.
:param filename: the name of the file to which to save | pylsdj/project.py | def save_srm(self, filename):
"""Save a project in .srm format to the target file.
:param filename: the name of the file to which to save
"""
with open(filename, 'wb') as fp:
raw_data = bread.write(self._song_data, spec.song)
fp.write(raw_data) | def save_srm(self, filename):
"""Save a project in .srm format to the target file.
:param filename: the name of the file to which to save
"""
with open(filename, 'wb') as fp:
raw_data = bread.write(self._song_data, spec.song)
fp.write(raw_data) | [
"Save",
"a",
"project",
"in",
".",
"srm",
"format",
"to",
"the",
"target",
"file",
"."
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/project.py#L168-L175 | [
"def",
"save_srm",
"(",
"self",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'wb'",
")",
"as",
"fp",
":",
"raw_data",
"=",
"bread",
".",
"write",
"(",
"self",
".",
"_song_data",
",",
"spec",
".",
"song",
")",
"fp",
".",
"write"... | 1c45a7919dd324e941f76b315558b9647892e4d5 |
train | Synth.phase_type | compresses the waveform horizontally; one of
``"normal"``, ``"resync"``, ``"resync2"`` | pylsdj/synth.py | def phase_type(self, value):
'''compresses the waveform horizontally; one of
``"normal"``, ``"resync"``, ``"resync2"``'''
self._params.phase_type = value
self._overwrite_lock.disable() | def phase_type(self, value):
'''compresses the waveform horizontally; one of
``"normal"``, ``"resync"``, ``"resync2"``'''
self._params.phase_type = value
self._overwrite_lock.disable() | [
"compresses",
"the",
"waveform",
"horizontally",
";",
"one",
"of",
"normal",
"resync",
"resync2"
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/synth.py#L186-L190 | [
"def",
"phase_type",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_params",
".",
"phase_type",
"=",
"value",
"self",
".",
"_overwrite_lock",
".",
"disable",
"(",
")"
] | 1c45a7919dd324e941f76b315558b9647892e4d5 |
train | SAVFile.project_list | The list of :py:class:`pylsdj.Project` s that the
.sav file contains | pylsdj/savfile.py | def project_list(self):
"""The list of :py:class:`pylsdj.Project` s that the
.sav file contains"""
return [(i, self.projects[i]) for i in sorted(self.projects.keys())] | def project_list(self):
"""The list of :py:class:`pylsdj.Project` s that the
.sav file contains"""
return [(i, self.projects[i]) for i in sorted(self.projects.keys())] | [
"The",
"list",
"of",
":",
"py",
":",
"class",
":",
"pylsdj",
".",
"Project",
"s",
"that",
"the",
".",
"sav",
"file",
"contains"
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/savfile.py#L207-L210 | [
"def",
"project_list",
"(",
"self",
")",
":",
"return",
"[",
"(",
"i",
",",
"self",
".",
"projects",
"[",
"i",
"]",
")",
"for",
"i",
"in",
"sorted",
"(",
"self",
".",
"projects",
".",
"keys",
"(",
")",
")",
"]"
] | 1c45a7919dd324e941f76b315558b9647892e4d5 |
train | SAVFile.save | Save this file.
:param filename: the file to which to save the .sav file
:type filename: str
:param callback: a progress callback function
:type callback: function | pylsdj/savfile.py | def save(self, filename, callback=_noop_callback):
"""Save this file.
:param filename: the file to which to save the .sav file
:type filename: str
:param callback: a progress callback function
:type callback: function
"""
with open(filename, 'wb') as fp:
... | def save(self, filename, callback=_noop_callback):
"""Save this file.
:param filename: the file to which to save the .sav file
:type filename: str
:param callback: a progress callback function
:type callback: function
"""
with open(filename, 'wb') as fp:
... | [
"Save",
"this",
"file",
"."
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/savfile.py#L312-L321 | [
"def",
"save",
"(",
"self",
",",
"filename",
",",
"callback",
"=",
"_noop_callback",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'wb'",
")",
"as",
"fp",
":",
"self",
".",
"_save",
"(",
"fp",
",",
"callback",
")"
] | 1c45a7919dd324e941f76b315558b9647892e4d5 |
train | split | Splits compressed data into blocks.
:param compressed_data: the compressed data to split
:param segment_size: the size of a block in bytes
:param block_factory: a BlockFactory used to construct the blocks
:rtype: a list of block IDs of blocks that the block factory created while
splitting | pylsdj/filepack.py | def split(compressed_data, segment_size, block_factory):
"""Splits compressed data into blocks.
:param compressed_data: the compressed data to split
:param segment_size: the size of a block in bytes
:param block_factory: a BlockFactory used to construct the blocks
:rtype: a list of block IDs of bl... | def split(compressed_data, segment_size, block_factory):
"""Splits compressed data into blocks.
:param compressed_data: the compressed data to split
:param segment_size: the size of a block in bytes
:param block_factory: a BlockFactory used to construct the blocks
:rtype: a list of block IDs of bl... | [
"Splits",
"compressed",
"data",
"into",
"blocks",
"."
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/filepack.py#L46-L138 | [
"def",
"split",
"(",
"compressed_data",
",",
"segment_size",
",",
"block_factory",
")",
":",
"# Split compressed data into blocks",
"segments",
"=",
"[",
"]",
"current_segment_start",
"=",
"0",
"index",
"=",
"0",
"data_size",
"=",
"len",
"(",
"compressed_data",
")... | 1c45a7919dd324e941f76b315558b9647892e4d5 |
train | renumber_block_keys | Renumber a block map's indices so that tehy match the blocks' block
switch statements.
:param blocks a block map to renumber
:rtype: a renumbered copy of the block map | pylsdj/filepack.py | def renumber_block_keys(blocks):
"""Renumber a block map's indices so that tehy match the blocks' block
switch statements.
:param blocks a block map to renumber
:rtype: a renumbered copy of the block map
"""
# There is an implicit block switch to the 0th block at the start of the
# file
... | def renumber_block_keys(blocks):
"""Renumber a block map's indices so that tehy match the blocks' block
switch statements.
:param blocks a block map to renumber
:rtype: a renumbered copy of the block map
"""
# There is an implicit block switch to the 0th block at the start of the
# file
... | [
"Renumber",
"a",
"block",
"map",
"s",
"indices",
"so",
"that",
"tehy",
"match",
"the",
"blocks",
"block",
"switch",
"statements",
"."
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/filepack.py#L141-L201 | [
"def",
"renumber_block_keys",
"(",
"blocks",
")",
":",
"# There is an implicit block switch to the 0th block at the start of the",
"# file",
"byte_switch_keys",
"=",
"[",
"0",
"]",
"block_keys",
"=",
"list",
"(",
"blocks",
".",
"keys",
"(",
")",
")",
"# Scan the blocks,... | 1c45a7919dd324e941f76b315558b9647892e4d5 |
train | merge | Merge the given blocks into a contiguous block of compressed data.
:param blocks: the list of blocks
:rtype: a list of compressed bytes | pylsdj/filepack.py | def merge(blocks):
"""Merge the given blocks into a contiguous block of compressed data.
:param blocks: the list of blocks
:rtype: a list of compressed bytes
"""
current_block = blocks[sorted(blocks.keys())[0]]
compressed_data = []
eof = False
while not eof:
data_size_to_appe... | def merge(blocks):
"""Merge the given blocks into a contiguous block of compressed data.
:param blocks: the list of blocks
:rtype: a list of compressed bytes
"""
current_block = blocks[sorted(blocks.keys())[0]]
compressed_data = []
eof = False
while not eof:
data_size_to_appe... | [
"Merge",
"the",
"given",
"blocks",
"into",
"a",
"contiguous",
"block",
"of",
"compressed",
"data",
"."
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/filepack.py#L204-L259 | [
"def",
"merge",
"(",
"blocks",
")",
":",
"current_block",
"=",
"blocks",
"[",
"sorted",
"(",
"blocks",
".",
"keys",
"(",
")",
")",
"[",
"0",
"]",
"]",
"compressed_data",
"=",
"[",
"]",
"eof",
"=",
"False",
"while",
"not",
"eof",
":",
"data_size_to_ap... | 1c45a7919dd324e941f76b315558b9647892e4d5 |
train | pad | Add zeroes to a segment until it reaches a certain size.
:param segment: the segment to pad
:param size: the size to which to pad the segment | pylsdj/filepack.py | def pad(segment, size):
"""Add zeroes to a segment until it reaches a certain size.
:param segment: the segment to pad
:param size: the size to which to pad the segment
"""
for i in range(size - len(segment)):
segment.append(0)
assert len(segment) == size | def pad(segment, size):
"""Add zeroes to a segment until it reaches a certain size.
:param segment: the segment to pad
:param size: the size to which to pad the segment
"""
for i in range(size - len(segment)):
segment.append(0)
assert len(segment) == size | [
"Add",
"zeroes",
"to",
"a",
"segment",
"until",
"it",
"reaches",
"a",
"certain",
"size",
"."
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/filepack.py#L276-L285 | [
"def",
"pad",
"(",
"segment",
",",
"size",
")",
":",
"for",
"i",
"in",
"range",
"(",
"size",
"-",
"len",
"(",
"segment",
")",
")",
":",
"segment",
".",
"append",
"(",
"0",
")",
"assert",
"len",
"(",
"segment",
")",
"==",
"size"
] | 1c45a7919dd324e941f76b315558b9647892e4d5 |
train | decompress | Decompress data that has been compressed by the filepack algorithm.
:param compressed_data: an array of compressed data bytes to decompress
:rtype: an array of decompressed bytes | pylsdj/filepack.py | def decompress(compressed_data):
"""Decompress data that has been compressed by the filepack algorithm.
:param compressed_data: an array of compressed data bytes to decompress
:rtype: an array of decompressed bytes"""
raw_data = []
index = 0
while index < len(compressed_data):
curren... | def decompress(compressed_data):
"""Decompress data that has been compressed by the filepack algorithm.
:param compressed_data: an array of compressed data bytes to decompress
:rtype: an array of decompressed bytes"""
raw_data = []
index = 0
while index < len(compressed_data):
curren... | [
"Decompress",
"data",
"that",
"has",
"been",
"compressed",
"by",
"the",
"filepack",
"algorithm",
"."
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/filepack.py#L288-L338 | [
"def",
"decompress",
"(",
"compressed_data",
")",
":",
"raw_data",
"=",
"[",
"]",
"index",
"=",
"0",
"while",
"index",
"<",
"len",
"(",
"compressed_data",
")",
":",
"current",
"=",
"compressed_data",
"[",
"index",
"]",
"index",
"+=",
"1",
"if",
"current"... | 1c45a7919dd324e941f76b315558b9647892e4d5 |
train | compress | Compress raw bytes with the filepack algorithm.
:param raw_data: an array of raw data bytes to compress
:rtype: a list of compressed bytes | pylsdj/filepack.py | def compress(raw_data):
"""Compress raw bytes with the filepack algorithm.
:param raw_data: an array of raw data bytes to compress
:rtype: a list of compressed bytes
"""
raw_data = bytearray(raw_data)
compressed_data = []
data_size = len(raw_data)
index = 0
next_bytes = [-1, -1, ... | def compress(raw_data):
"""Compress raw bytes with the filepack algorithm.
:param raw_data: an array of raw data bytes to compress
:rtype: a list of compressed bytes
"""
raw_data = bytearray(raw_data)
compressed_data = []
data_size = len(raw_data)
index = 0
next_bytes = [-1, -1, ... | [
"Compress",
"raw",
"bytes",
"with",
"the",
"filepack",
"algorithm",
"."
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/filepack.py#L341-L433 | [
"def",
"compress",
"(",
"raw_data",
")",
":",
"raw_data",
"=",
"bytearray",
"(",
"raw_data",
")",
"compressed_data",
"=",
"[",
"]",
"data_size",
"=",
"len",
"(",
"raw_data",
")",
"index",
"=",
"0",
"next_bytes",
"=",
"[",
"-",
"1",
",",
"-",
"1",
","... | 1c45a7919dd324e941f76b315558b9647892e4d5 |
train | name_without_zeroes | Return a human-readable name without LSDJ's trailing zeroes.
:param name: the name from which to strip zeroes
:rtype: the name, without trailing zeroes | pylsdj/utils.py | def name_without_zeroes(name):
"""
Return a human-readable name without LSDJ's trailing zeroes.
:param name: the name from which to strip zeroes
:rtype: the name, without trailing zeroes
"""
first_zero = name.find(b'\0')
if first_zero == -1:
return name
else:
return str... | def name_without_zeroes(name):
"""
Return a human-readable name without LSDJ's trailing zeroes.
:param name: the name from which to strip zeroes
:rtype: the name, without trailing zeroes
"""
first_zero = name.find(b'\0')
if first_zero == -1:
return name
else:
return str... | [
"Return",
"a",
"human",
"-",
"readable",
"name",
"without",
"LSDJ",
"s",
"trailing",
"zeroes",
"."
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/utils.py#L32-L44 | [
"def",
"name_without_zeroes",
"(",
"name",
")",
":",
"first_zero",
"=",
"name",
".",
"find",
"(",
"b'\\0'",
")",
"if",
"first_zero",
"==",
"-",
"1",
":",
"return",
"name",
"else",
":",
"return",
"str",
"(",
"name",
"[",
":",
"first_zero",
"]",
")"
] | 1c45a7919dd324e941f76b315558b9647892e4d5 |
train | Instrument.name | the instrument's name (5 characters, zero-padded) | pylsdj/instrument.py | def name(self):
"""the instrument's name (5 characters, zero-padded)"""
instr_name = self.song.song_data.instrument_names[self.index]
if type(instr_name) == bytes:
instr_name = instr_name.decode('utf-8')
return instr_name | def name(self):
"""the instrument's name (5 characters, zero-padded)"""
instr_name = self.song.song_data.instrument_names[self.index]
if type(instr_name) == bytes:
instr_name = instr_name.decode('utf-8')
return instr_name | [
"the",
"instrument",
"s",
"name",
"(",
"5",
"characters",
"zero",
"-",
"padded",
")"
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/instrument.py#L21-L28 | [
"def",
"name",
"(",
"self",
")",
":",
"instr_name",
"=",
"self",
".",
"song",
".",
"song_data",
".",
"instrument_names",
"[",
"self",
".",
"index",
"]",
"if",
"type",
"(",
"instr_name",
")",
"==",
"bytes",
":",
"instr_name",
"=",
"instr_name",
".",
"de... | 1c45a7919dd324e941f76b315558b9647892e4d5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.