repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
uber/doubles | doubles/call_count_accumulator.py | CallCountAccumulator.error_string | def error_string(self):
"""Returns a well formed error message
e.g at least 5 times but was called 4 times
:rtype string
"""
if self.has_correct_call_count():
return ''
return '{} instead of {} {} '.format(
self._restriction_string(),
... | python | def error_string(self):
"""Returns a well formed error message
e.g at least 5 times but was called 4 times
:rtype string
"""
if self.has_correct_call_count():
return ''
return '{} instead of {} {} '.format(
self._restriction_string(),
... | [
"def",
"error_string",
"(",
"self",
")",
":",
"if",
"self",
".",
"has_correct_call_count",
"(",
")",
":",
"return",
"''",
"return",
"'{} instead of {} {} '",
".",
"format",
"(",
"self",
".",
"_restriction_string",
"(",
")",
",",
"self",
".",
"count",
",",
... | Returns a well formed error message
e.g at least 5 times but was called 4 times
:rtype string | [
"Returns",
"a",
"well",
"formed",
"error",
"message"
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/call_count_accumulator.py#L146-L161 | train |
uber/doubles | doubles/space.py | Space.patch_for | def patch_for(self, path):
"""Returns the ``Patch`` for the target path, creating it if necessary.
:param str path: The absolute module path to the target.
:return: The mapped ``Patch``.
:rtype: Patch
"""
if path not in self._patches:
self._patches[path] = P... | python | def patch_for(self, path):
"""Returns the ``Patch`` for the target path, creating it if necessary.
:param str path: The absolute module path to the target.
:return: The mapped ``Patch``.
:rtype: Patch
"""
if path not in self._patches:
self._patches[path] = P... | [
"def",
"patch_for",
"(",
"self",
",",
"path",
")",
":",
"if",
"path",
"not",
"in",
"self",
".",
"_patches",
":",
"self",
".",
"_patches",
"[",
"path",
"]",
"=",
"Patch",
"(",
"path",
")",
"return",
"self",
".",
"_patches",
"[",
"path",
"]"
] | Returns the ``Patch`` for the target path, creating it if necessary.
:param str path: The absolute module path to the target.
:return: The mapped ``Patch``.
:rtype: Patch | [
"Returns",
"the",
"Patch",
"for",
"the",
"target",
"path",
"creating",
"it",
"if",
"necessary",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/space.py#L18-L29 | train |
uber/doubles | doubles/space.py | Space.proxy_for | def proxy_for(self, obj):
"""Returns the ``Proxy`` for the target object, creating it if necessary.
:param object obj: The object that will be doubled.
:return: The mapped ``Proxy``.
:rtype: Proxy
"""
obj_id = id(obj)
if obj_id not in self._proxies:
... | python | def proxy_for(self, obj):
"""Returns the ``Proxy`` for the target object, creating it if necessary.
:param object obj: The object that will be doubled.
:return: The mapped ``Proxy``.
:rtype: Proxy
"""
obj_id = id(obj)
if obj_id not in self._proxies:
... | [
"def",
"proxy_for",
"(",
"self",
",",
"obj",
")",
":",
"obj_id",
"=",
"id",
"(",
"obj",
")",
"if",
"obj_id",
"not",
"in",
"self",
".",
"_proxies",
":",
"self",
".",
"_proxies",
"[",
"obj_id",
"]",
"=",
"Proxy",
"(",
"obj",
")",
"return",
"self",
... | Returns the ``Proxy`` for the target object, creating it if necessary.
:param object obj: The object that will be doubled.
:return: The mapped ``Proxy``.
:rtype: Proxy | [
"Returns",
"the",
"Proxy",
"for",
"the",
"target",
"object",
"creating",
"it",
"if",
"necessary",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/space.py#L31-L44 | train |
uber/doubles | doubles/space.py | Space.teardown | def teardown(self):
"""Restores all doubled objects to their original state."""
for proxy in self._proxies.values():
proxy.restore_original_object()
for patch in self._patches.values():
patch.restore_original_object() | python | def teardown(self):
"""Restores all doubled objects to their original state."""
for proxy in self._proxies.values():
proxy.restore_original_object()
for patch in self._patches.values():
patch.restore_original_object() | [
"def",
"teardown",
"(",
"self",
")",
":",
"for",
"proxy",
"in",
"self",
".",
"_proxies",
".",
"values",
"(",
")",
":",
"proxy",
".",
"restore_original_object",
"(",
")",
"for",
"patch",
"in",
"self",
".",
"_patches",
".",
"values",
"(",
")",
":",
"pa... | Restores all doubled objects to their original state. | [
"Restores",
"all",
"doubled",
"objects",
"to",
"their",
"original",
"state",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/space.py#L46-L53 | train |
uber/doubles | doubles/space.py | Space.verify | def verify(self):
"""Verifies expectations on all doubled objects.
:raise: ``MockExpectationError`` on the first expectation that is not satisfied, if any.
"""
if self._is_verified:
return
for proxy in self._proxies.values():
proxy.verify()
sel... | python | def verify(self):
"""Verifies expectations on all doubled objects.
:raise: ``MockExpectationError`` on the first expectation that is not satisfied, if any.
"""
if self._is_verified:
return
for proxy in self._proxies.values():
proxy.verify()
sel... | [
"def",
"verify",
"(",
"self",
")",
":",
"if",
"self",
".",
"_is_verified",
":",
"return",
"for",
"proxy",
"in",
"self",
".",
"_proxies",
".",
"values",
"(",
")",
":",
"proxy",
".",
"verify",
"(",
")",
"self",
".",
"_is_verified",
"=",
"True"
] | Verifies expectations on all doubled objects.
:raise: ``MockExpectationError`` on the first expectation that is not satisfied, if any. | [
"Verifies",
"expectations",
"on",
"all",
"doubled",
"objects",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/space.py#L63-L75 | train |
uber/doubles | doubles/proxy_method.py | ProxyMethod.restore_original_method | def restore_original_method(self):
"""Replaces the proxy method on the target object with its original value."""
if self._target.is_class_or_module():
setattr(self._target.obj, self._method_name, self._original_method)
if self._method_name == '__new__' and sys.version_info >= (3... | python | def restore_original_method(self):
"""Replaces the proxy method on the target object with its original value."""
if self._target.is_class_or_module():
setattr(self._target.obj, self._method_name, self._original_method)
if self._method_name == '__new__' and sys.version_info >= (3... | [
"def",
"restore_original_method",
"(",
"self",
")",
":",
"if",
"self",
".",
"_target",
".",
"is_class_or_module",
"(",
")",
":",
"setattr",
"(",
"self",
".",
"_target",
".",
"obj",
",",
"self",
".",
"_method_name",
",",
"self",
".",
"_original_method",
")"... | Replaces the proxy method on the target object with its original value. | [
"Replaces",
"the",
"proxy",
"method",
"on",
"the",
"target",
"object",
"with",
"its",
"original",
"value",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/proxy_method.py#L105-L124 | train |
uber/doubles | doubles/proxy_method.py | ProxyMethod._hijack_target | def _hijack_target(self):
"""Replaces the target method on the target object with the proxy method."""
if self._target.is_class_or_module():
setattr(self._target.obj, self._method_name, self)
elif self._attr.kind == 'property':
proxy_property = ProxyProperty(
... | python | def _hijack_target(self):
"""Replaces the target method on the target object with the proxy method."""
if self._target.is_class_or_module():
setattr(self._target.obj, self._method_name, self)
elif self._attr.kind == 'property':
proxy_property = ProxyProperty(
... | [
"def",
"_hijack_target",
"(",
"self",
")",
":",
"if",
"self",
".",
"_target",
".",
"is_class_or_module",
"(",
")",
":",
"setattr",
"(",
"self",
".",
"_target",
".",
"obj",
",",
"self",
".",
"_method_name",
",",
"self",
")",
"elif",
"self",
".",
"_attr"... | Replaces the target method on the target object with the proxy method. | [
"Replaces",
"the",
"target",
"method",
"on",
"the",
"target",
"object",
"with",
"the",
"proxy",
"method",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/proxy_method.py#L131-L147 | train |
uber/doubles | doubles/proxy_method.py | ProxyMethod._raise_exception | def _raise_exception(self, args, kwargs):
""" Raises an ``UnallowedMethodCallError`` with a useful message.
:raise: ``UnallowedMethodCallError``
"""
error_message = (
"Received unexpected call to '{}' on {!r}. The supplied arguments "
"{} do not match any avail... | python | def _raise_exception(self, args, kwargs):
""" Raises an ``UnallowedMethodCallError`` with a useful message.
:raise: ``UnallowedMethodCallError``
"""
error_message = (
"Received unexpected call to '{}' on {!r}. The supplied arguments "
"{} do not match any avail... | [
"def",
"_raise_exception",
"(",
"self",
",",
"args",
",",
"kwargs",
")",
":",
"error_message",
"=",
"(",
"\"Received unexpected call to '{}' on {!r}. The supplied arguments \"",
"\"{} do not match any available allowances.\"",
")",
"raise",
"UnallowedMethodCallError",
"(",
"er... | Raises an ``UnallowedMethodCallError`` with a useful message.
:raise: ``UnallowedMethodCallError`` | [
"Raises",
"an",
"UnallowedMethodCallError",
"with",
"a",
"useful",
"message",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/proxy_method.py#L149-L166 | train |
uber/doubles | doubles/proxy.py | Proxy.method_double_for | def method_double_for(self, method_name):
"""Returns the method double for the provided method name, creating one if necessary.
:param str method_name: The name of the method to retrieve a method double for.
:return: The mapped ``MethodDouble``.
:rtype: MethodDouble
"""
... | python | def method_double_for(self, method_name):
"""Returns the method double for the provided method name, creating one if necessary.
:param str method_name: The name of the method to retrieve a method double for.
:return: The mapped ``MethodDouble``.
:rtype: MethodDouble
"""
... | [
"def",
"method_double_for",
"(",
"self",
",",
"method_name",
")",
":",
"if",
"method_name",
"not",
"in",
"self",
".",
"_method_doubles",
":",
"self",
".",
"_method_doubles",
"[",
"method_name",
"]",
"=",
"MethodDouble",
"(",
"method_name",
",",
"self",
".",
... | Returns the method double for the provided method name, creating one if necessary.
:param str method_name: The name of the method to retrieve a method double for.
:return: The mapped ``MethodDouble``.
:rtype: MethodDouble | [
"Returns",
"the",
"method",
"double",
"for",
"the",
"provided",
"method",
"name",
"creating",
"one",
"if",
"necessary",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/proxy.py#L58-L69 | train |
uber/doubles | doubles/instance_double.py | _get_doubles_target | def _get_doubles_target(module, class_name, path):
"""Validate and return the class to be doubled.
:param module module: The module that contains the class that will be doubled.
:param str class_name: The name of the class that will be doubled.
:param str path: The full path to the class that will be d... | python | def _get_doubles_target(module, class_name, path):
"""Validate and return the class to be doubled.
:param module module: The module that contains the class that will be doubled.
:param str class_name: The name of the class that will be doubled.
:param str path: The full path to the class that will be d... | [
"def",
"_get_doubles_target",
"(",
"module",
",",
"class_name",
",",
"path",
")",
":",
"try",
":",
"doubles_target",
"=",
"getattr",
"(",
"module",
",",
"class_name",
")",
"if",
"isinstance",
"(",
"doubles_target",
",",
"ObjectDouble",
")",
":",
"return",
"d... | Validate and return the class to be doubled.
:param module module: The module that contains the class that will be doubled.
:param str class_name: The name of the class that will be doubled.
:param str path: The full path to the class that will be doubled.
:return: The class that will be doubled.
:... | [
"Validate",
"and",
"return",
"the",
"class",
"to",
"be",
"doubled",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/instance_double.py#L8-L33 | train |
uber/doubles | doubles/allowance.py | Allowance.and_raise | def and_raise(self, exception, *args, **kwargs):
"""Causes the double to raise the provided exception when called.
If provided, additional arguments (positional and keyword) passed to
`and_raise` are used in the exception instantiation.
:param Exception exception: The exception to rais... | python | def and_raise(self, exception, *args, **kwargs):
"""Causes the double to raise the provided exception when called.
If provided, additional arguments (positional and keyword) passed to
`and_raise` are used in the exception instantiation.
:param Exception exception: The exception to rais... | [
"def",
"and_raise",
"(",
"self",
",",
"exception",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"proxy_exception",
"(",
"*",
"proxy_args",
",",
"*",
"*",
"proxy_kwargs",
")",
":",
"raise",
"exception",
"self",
".",
"_return_value",
"=",
... | Causes the double to raise the provided exception when called.
If provided, additional arguments (positional and keyword) passed to
`and_raise` are used in the exception instantiation.
:param Exception exception: The exception to raise. | [
"Causes",
"the",
"double",
"to",
"raise",
"the",
"provided",
"exception",
"when",
"called",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/allowance.py#L71-L83 | train |
uber/doubles | doubles/allowance.py | Allowance.and_raise_future | def and_raise_future(self, exception):
"""Similar to `and_raise` but the doubled method returns a future.
:param Exception exception: The exception to raise.
"""
future = _get_future()
future.set_exception(exception)
return self.and_return(future) | python | def and_raise_future(self, exception):
"""Similar to `and_raise` but the doubled method returns a future.
:param Exception exception: The exception to raise.
"""
future = _get_future()
future.set_exception(exception)
return self.and_return(future) | [
"def",
"and_raise_future",
"(",
"self",
",",
"exception",
")",
":",
"future",
"=",
"_get_future",
"(",
")",
"future",
".",
"set_exception",
"(",
"exception",
")",
"return",
"self",
".",
"and_return",
"(",
"future",
")"
] | Similar to `and_raise` but the doubled method returns a future.
:param Exception exception: The exception to raise. | [
"Similar",
"to",
"and_raise",
"but",
"the",
"doubled",
"method",
"returns",
"a",
"future",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/allowance.py#L85-L92 | train |
uber/doubles | doubles/allowance.py | Allowance.and_return_future | def and_return_future(self, *return_values):
"""Similar to `and_return` but the doubled method returns a future.
:param object return_values: The values the double will return when called,
"""
futures = []
for value in return_values:
future = _get_future()
... | python | def and_return_future(self, *return_values):
"""Similar to `and_return` but the doubled method returns a future.
:param object return_values: The values the double will return when called,
"""
futures = []
for value in return_values:
future = _get_future()
... | [
"def",
"and_return_future",
"(",
"self",
",",
"*",
"return_values",
")",
":",
"futures",
"=",
"[",
"]",
"for",
"value",
"in",
"return_values",
":",
"future",
"=",
"_get_future",
"(",
")",
"future",
".",
"set_result",
"(",
"value",
")",
"futures",
".",
"a... | Similar to `and_return` but the doubled method returns a future.
:param object return_values: The values the double will return when called, | [
"Similar",
"to",
"and_return",
"but",
"the",
"doubled",
"method",
"returns",
"a",
"future",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/allowance.py#L94-L104 | train |
uber/doubles | doubles/allowance.py | Allowance.and_return | def and_return(self, *return_values):
"""Set a return value for an allowance
Causes the double to return the provided values in order. If multiple
values are provided, they are returned one at a time in sequence as the double is called.
If the double is called more times than there are... | python | def and_return(self, *return_values):
"""Set a return value for an allowance
Causes the double to return the provided values in order. If multiple
values are provided, they are returned one at a time in sequence as the double is called.
If the double is called more times than there are... | [
"def",
"and_return",
"(",
"self",
",",
"*",
"return_values",
")",
":",
"if",
"not",
"return_values",
":",
"raise",
"TypeError",
"(",
"'and_return() expected at least 1 return value'",
")",
"return_values",
"=",
"list",
"(",
"return_values",
")",
"final_value",
"=",
... | Set a return value for an allowance
Causes the double to return the provided values in order. If multiple
values are provided, they are returned one at a time in sequence as the double is called.
If the double is called more times than there are return values, it should continue to
ret... | [
"Set",
"a",
"return",
"value",
"for",
"an",
"allowance"
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/allowance.py#L106-L127 | train |
uber/doubles | doubles/allowance.py | Allowance.and_return_result_of | def and_return_result_of(self, return_value):
""" Causes the double to return the result of calling the provided value.
:param return_value: A callable that will be invoked to determine the double's return value.
:type return_value: any callable object
"""
if not check_func_take... | python | def and_return_result_of(self, return_value):
""" Causes the double to return the result of calling the provided value.
:param return_value: A callable that will be invoked to determine the double's return value.
:type return_value: any callable object
"""
if not check_func_take... | [
"def",
"and_return_result_of",
"(",
"self",
",",
"return_value",
")",
":",
"if",
"not",
"check_func_takes_args",
"(",
"return_value",
")",
":",
"self",
".",
"_return_value",
"=",
"lambda",
"*",
"args",
",",
"*",
"*",
"kwargs",
":",
"return_value",
"(",
")",
... | Causes the double to return the result of calling the provided value.
:param return_value: A callable that will be invoked to determine the double's return value.
:type return_value: any callable object | [
"Causes",
"the",
"double",
"to",
"return",
"the",
"result",
"of",
"calling",
"the",
"provided",
"value",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/allowance.py#L129-L140 | train |
uber/doubles | doubles/allowance.py | Allowance.with_args | def with_args(self, *args, **kwargs):
"""Declares that the double can only be called with the provided arguments.
:param args: Any positional arguments required for invocation.
:param kwargs: Any keyword arguments required for invocation.
"""
self.args = args
self.kwarg... | python | def with_args(self, *args, **kwargs):
"""Declares that the double can only be called with the provided arguments.
:param args: Any positional arguments required for invocation.
:param kwargs: Any keyword arguments required for invocation.
"""
self.args = args
self.kwarg... | [
"def",
"with_args",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"args",
"=",
"args",
"self",
".",
"kwargs",
"=",
"kwargs",
"self",
".",
"verify_arguments",
"(",
")",
"return",
"self"
] | Declares that the double can only be called with the provided arguments.
:param args: Any positional arguments required for invocation.
:param kwargs: Any keyword arguments required for invocation. | [
"Declares",
"that",
"the",
"double",
"can",
"only",
"be",
"called",
"with",
"the",
"provided",
"arguments",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/allowance.py#L153-L163 | train |
uber/doubles | doubles/allowance.py | Allowance.with_args_validator | def with_args_validator(self, matching_function):
"""Define a custom function for testing arguments
:param func matching_function: The function used to test arguments passed to the stub.
"""
self.args = None
self.kwargs = None
self._custom_matcher = matching_function
... | python | def with_args_validator(self, matching_function):
"""Define a custom function for testing arguments
:param func matching_function: The function used to test arguments passed to the stub.
"""
self.args = None
self.kwargs = None
self._custom_matcher = matching_function
... | [
"def",
"with_args_validator",
"(",
"self",
",",
"matching_function",
")",
":",
"self",
".",
"args",
"=",
"None",
"self",
".",
"kwargs",
"=",
"None",
"self",
".",
"_custom_matcher",
"=",
"matching_function",
"return",
"self"
] | Define a custom function for testing arguments
:param func matching_function: The function used to test arguments passed to the stub. | [
"Define",
"a",
"custom",
"function",
"for",
"testing",
"arguments"
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/allowance.py#L165-L173 | train |
uber/doubles | doubles/allowance.py | Allowance.satisfy_exact_match | def satisfy_exact_match(self, args, kwargs):
"""Returns a boolean indicating whether or not the stub will accept the provided arguments.
:return: Whether or not the stub accepts the provided arguments.
:rtype: bool
"""
if self.args is None and self.kwargs is None:
r... | python | def satisfy_exact_match(self, args, kwargs):
"""Returns a boolean indicating whether or not the stub will accept the provided arguments.
:return: Whether or not the stub accepts the provided arguments.
:rtype: bool
"""
if self.args is None and self.kwargs is None:
r... | [
"def",
"satisfy_exact_match",
"(",
"self",
",",
"args",
",",
"kwargs",
")",
":",
"if",
"self",
".",
"args",
"is",
"None",
"and",
"self",
".",
"kwargs",
"is",
"None",
":",
"return",
"False",
"elif",
"self",
".",
"args",
"is",
"_any",
"and",
"self",
".... | Returns a boolean indicating whether or not the stub will accept the provided arguments.
:return: Whether or not the stub accepts the provided arguments.
:rtype: bool | [
"Returns",
"a",
"boolean",
"indicating",
"whether",
"or",
"not",
"the",
"stub",
"will",
"accept",
"the",
"provided",
"arguments",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/allowance.py#L208-L233 | train |
uber/doubles | doubles/allowance.py | Allowance.satisfy_custom_matcher | def satisfy_custom_matcher(self, args, kwargs):
"""Return a boolean indicating if the args satisfy the stub
:return: Whether or not the stub accepts the provided arguments.
:rtype: bool
"""
if not self._custom_matcher:
return False
try:
return sel... | python | def satisfy_custom_matcher(self, args, kwargs):
"""Return a boolean indicating if the args satisfy the stub
:return: Whether or not the stub accepts the provided arguments.
:rtype: bool
"""
if not self._custom_matcher:
return False
try:
return sel... | [
"def",
"satisfy_custom_matcher",
"(",
"self",
",",
"args",
",",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"_custom_matcher",
":",
"return",
"False",
"try",
":",
"return",
"self",
".",
"_custom_matcher",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",... | Return a boolean indicating if the args satisfy the stub
:return: Whether or not the stub accepts the provided arguments.
:rtype: bool | [
"Return",
"a",
"boolean",
"indicating",
"if",
"the",
"args",
"satisfy",
"the",
"stub"
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/allowance.py#L235-L246 | train |
uber/doubles | doubles/allowance.py | Allowance.return_value | def return_value(self, *args, **kwargs):
"""Extracts the real value to be returned from the wrapping callable.
:return: The value the double should return when called.
"""
self._called()
return self._return_value(*args, **kwargs) | python | def return_value(self, *args, **kwargs):
"""Extracts the real value to be returned from the wrapping callable.
:return: The value the double should return when called.
"""
self._called()
return self._return_value(*args, **kwargs) | [
"def",
"return_value",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_called",
"(",
")",
"return",
"self",
".",
"_return_value",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Extracts the real value to be returned from the wrapping callable.
:return: The value the double should return when called. | [
"Extracts",
"the",
"real",
"value",
"to",
"be",
"returned",
"from",
"the",
"wrapping",
"callable",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/allowance.py#L248-L255 | train |
uber/doubles | doubles/allowance.py | Allowance.verify_arguments | def verify_arguments(self, args=None, kwargs=None):
"""Ensures that the arguments specified match the signature of the real method.
:raise: ``VerifyingDoubleError`` if the arguments do not match.
"""
args = self.args if args is None else args
kwargs = self.kwargs if kwargs is N... | python | def verify_arguments(self, args=None, kwargs=None):
"""Ensures that the arguments specified match the signature of the real method.
:raise: ``VerifyingDoubleError`` if the arguments do not match.
"""
args = self.args if args is None else args
kwargs = self.kwargs if kwargs is N... | [
"def",
"verify_arguments",
"(",
"self",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
")",
":",
"args",
"=",
"self",
".",
"args",
"if",
"args",
"is",
"None",
"else",
"args",
"kwargs",
"=",
"self",
".",
"kwargs",
"if",
"kwargs",
"is",
"None",
... | Ensures that the arguments specified match the signature of the real method.
:raise: ``VerifyingDoubleError`` if the arguments do not match. | [
"Ensures",
"that",
"the",
"arguments",
"specified",
"match",
"the",
"signature",
"of",
"the",
"real",
"method",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/allowance.py#L257-L270 | train |
uber/doubles | doubles/allowance.py | Allowance.raise_failure_exception | def raise_failure_exception(self, expect_or_allow='Allowed'):
"""Raises a ``MockExpectationError`` with a useful message.
:raise: ``MockExpectationError``
"""
raise MockExpectationError(
"{} '{}' to be called {}on {!r} with {}, but was not. ({}:{})".format(
... | python | def raise_failure_exception(self, expect_or_allow='Allowed'):
"""Raises a ``MockExpectationError`` with a useful message.
:raise: ``MockExpectationError``
"""
raise MockExpectationError(
"{} '{}' to be called {}on {!r} with {}, but was not. ({}:{})".format(
... | [
"def",
"raise_failure_exception",
"(",
"self",
",",
"expect_or_allow",
"=",
"'Allowed'",
")",
":",
"raise",
"MockExpectationError",
"(",
"\"{} '{}' to be called {}on {!r} with {}, but was not. ({}:{})\"",
".",
"format",
"(",
"expect_or_allow",
",",
"self",
".",
"_method_nam... | Raises a ``MockExpectationError`` with a useful message.
:raise: ``MockExpectationError`` | [
"Raises",
"a",
"MockExpectationError",
"with",
"a",
"useful",
"message",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/allowance.py#L334-L350 | train |
uber/doubles | doubles/allowance.py | Allowance._expected_argument_string | def _expected_argument_string(self):
"""Generates a string describing what arguments the double expected.
:return: A string describing expected arguments.
:rtype: str
"""
if self.args is _any and self.kwargs is _any:
return 'any args'
elif self._custom_match... | python | def _expected_argument_string(self):
"""Generates a string describing what arguments the double expected.
:return: A string describing expected arguments.
:rtype: str
"""
if self.args is _any and self.kwargs is _any:
return 'any args'
elif self._custom_match... | [
"def",
"_expected_argument_string",
"(",
"self",
")",
":",
"if",
"self",
".",
"args",
"is",
"_any",
"and",
"self",
".",
"kwargs",
"is",
"_any",
":",
"return",
"'any args'",
"elif",
"self",
".",
"_custom_matcher",
":",
"return",
"\"custom matcher: '{}'\"",
".",... | Generates a string describing what arguments the double expected.
:return: A string describing expected arguments.
:rtype: str | [
"Generates",
"a",
"string",
"describing",
"what",
"arguments",
"the",
"double",
"expected",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/allowance.py#L352-L364 | train |
uber/doubles | doubles/target.py | Target.is_class_or_module | def is_class_or_module(self):
"""Determines if the object is a class or a module
:return: True if the object is a class or a module, False otherwise.
:rtype: bool
"""
if isinstance(self.obj, ObjectDouble):
return self.obj.is_class
return isclass(self.double... | python | def is_class_or_module(self):
"""Determines if the object is a class or a module
:return: True if the object is a class or a module, False otherwise.
:rtype: bool
"""
if isinstance(self.obj, ObjectDouble):
return self.obj.is_class
return isclass(self.double... | [
"def",
"is_class_or_module",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"obj",
",",
"ObjectDouble",
")",
":",
"return",
"self",
".",
"obj",
".",
"is_class",
"return",
"isclass",
"(",
"self",
".",
"doubled_obj",
")",
"or",
"ismodule",
"(... | Determines if the object is a class or a module
:return: True if the object is a class or a module, False otherwise.
:rtype: bool | [
"Determines",
"if",
"the",
"object",
"is",
"a",
"class",
"or",
"a",
"module"
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/target.py#L36-L46 | train |
uber/doubles | doubles/target.py | Target._determine_doubled_obj | def _determine_doubled_obj(self):
"""Return the target object.
Returns the object that should be treated as the target object. For partial doubles, this
will be the same as ``self.obj``, but for pure doubles, it's pulled from the special
``_doubles_target`` attribute.
:return: ... | python | def _determine_doubled_obj(self):
"""Return the target object.
Returns the object that should be treated as the target object. For partial doubles, this
will be the same as ``self.obj``, but for pure doubles, it's pulled from the special
``_doubles_target`` attribute.
:return: ... | [
"def",
"_determine_doubled_obj",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"obj",
",",
"ObjectDouble",
")",
":",
"return",
"self",
".",
"obj",
".",
"_doubles_target",
"else",
":",
"return",
"self",
".",
"obj"
] | Return the target object.
Returns the object that should be treated as the target object. For partial doubles, this
will be the same as ``self.obj``, but for pure doubles, it's pulled from the special
``_doubles_target`` attribute.
:return: The object to be doubled.
:rtype: obj... | [
"Return",
"the",
"target",
"object",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/target.py#L48-L62 | train |
uber/doubles | doubles/target.py | Target._generate_attrs | def _generate_attrs(self):
"""Get detailed info about target object.
Uses ``inspect.classify_class_attrs`` to get several important details about each attribute
on the target object.
:return: The attribute details dict.
:rtype: dict
"""
attrs = {}
if is... | python | def _generate_attrs(self):
"""Get detailed info about target object.
Uses ``inspect.classify_class_attrs`` to get several important details about each attribute
on the target object.
:return: The attribute details dict.
:rtype: dict
"""
attrs = {}
if is... | [
"def",
"_generate_attrs",
"(",
"self",
")",
":",
"attrs",
"=",
"{",
"}",
"if",
"ismodule",
"(",
"self",
".",
"doubled_obj",
")",
":",
"for",
"name",
",",
"func",
"in",
"getmembers",
"(",
"self",
".",
"doubled_obj",
",",
"is_callable",
")",
":",
"attrs"... | Get detailed info about target object.
Uses ``inspect.classify_class_attrs`` to get several important details about each attribute
on the target object.
:return: The attribute details dict.
:rtype: dict | [
"Get",
"detailed",
"info",
"about",
"target",
"object",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/target.py#L76-L94 | train |
uber/doubles | doubles/target.py | Target.hijack_attr | def hijack_attr(self, attr_name):
"""Hijack an attribute on the target object.
Updates the underlying class and delegating the call to the instance.
This allows specially-handled attributes like __call__, __enter__,
and __exit__ to be mocked on a per-instance basis.
:param str ... | python | def hijack_attr(self, attr_name):
"""Hijack an attribute on the target object.
Updates the underlying class and delegating the call to the instance.
This allows specially-handled attributes like __call__, __enter__,
and __exit__ to be mocked on a per-instance basis.
:param str ... | [
"def",
"hijack_attr",
"(",
"self",
",",
"attr_name",
")",
":",
"if",
"not",
"self",
".",
"_original_attr",
"(",
"attr_name",
")",
":",
"setattr",
"(",
"self",
".",
"obj",
".",
"__class__",
",",
"attr_name",
",",
"_proxy_class_method_to_instance",
"(",
"getat... | Hijack an attribute on the target object.
Updates the underlying class and delegating the call to the instance.
This allows specially-handled attributes like __call__, __enter__,
and __exit__ to be mocked on a per-instance basis.
:param str attr_name: the name of the attribute to hijac... | [
"Hijack",
"an",
"attribute",
"on",
"the",
"target",
"object",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/target.py#L96-L112 | train |
uber/doubles | doubles/target.py | Target.restore_attr | def restore_attr(self, attr_name):
"""Restore an attribute back onto the target object.
:param str attr_name: the name of the attribute to restore
"""
original_attr = self._original_attr(attr_name)
if self._original_attr(attr_name):
setattr(self.obj.__class__, attr_n... | python | def restore_attr(self, attr_name):
"""Restore an attribute back onto the target object.
:param str attr_name: the name of the attribute to restore
"""
original_attr = self._original_attr(attr_name)
if self._original_attr(attr_name):
setattr(self.obj.__class__, attr_n... | [
"def",
"restore_attr",
"(",
"self",
",",
"attr_name",
")",
":",
"original_attr",
"=",
"self",
".",
"_original_attr",
"(",
"attr_name",
")",
"if",
"self",
".",
"_original_attr",
"(",
"attr_name",
")",
":",
"setattr",
"(",
"self",
".",
"obj",
".",
"__class__... | Restore an attribute back onto the target object.
:param str attr_name: the name of the attribute to restore | [
"Restore",
"an",
"attribute",
"back",
"onto",
"the",
"target",
"object",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/target.py#L114-L121 | train |
uber/doubles | doubles/target.py | Target._original_attr | def _original_attr(self, attr_name):
"""Return the original attribute off of the proxy on the target object.
:param str attr_name: the name of the original attribute to return
:return: Func or None.
:rtype: func
"""
try:
return getattr(
getatt... | python | def _original_attr(self, attr_name):
"""Return the original attribute off of the proxy on the target object.
:param str attr_name: the name of the original attribute to return
:return: Func or None.
:rtype: func
"""
try:
return getattr(
getatt... | [
"def",
"_original_attr",
"(",
"self",
",",
"attr_name",
")",
":",
"try",
":",
"return",
"getattr",
"(",
"getattr",
"(",
"self",
".",
"obj",
".",
"__class__",
",",
"attr_name",
")",
",",
"'_doubles_target_method'",
",",
"None",
")",
"except",
"AttributeError"... | Return the original attribute off of the proxy on the target object.
:param str attr_name: the name of the original attribute to return
:return: Func or None.
:rtype: func | [
"Return",
"the",
"original",
"attribute",
"off",
"of",
"the",
"proxy",
"on",
"the",
"target",
"object",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/target.py#L123-L135 | train |
uber/doubles | doubles/target.py | Target.get_callable_attr | def get_callable_attr(self, attr_name):
"""Used to double methods added to an object after creation
:param str attr_name: the name of the original attribute to return
:return: Attribute or None.
:rtype: func
"""
if not hasattr(self.doubled_obj, attr_name):
r... | python | def get_callable_attr(self, attr_name):
"""Used to double methods added to an object after creation
:param str attr_name: the name of the original attribute to return
:return: Attribute or None.
:rtype: func
"""
if not hasattr(self.doubled_obj, attr_name):
r... | [
"def",
"get_callable_attr",
"(",
"self",
",",
"attr_name",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
".",
"doubled_obj",
",",
"attr_name",
")",
":",
"return",
"None",
"func",
"=",
"getattr",
"(",
"self",
".",
"doubled_obj",
",",
"attr_name",
")",
"i... | Used to double methods added to an object after creation
:param str attr_name: the name of the original attribute to return
:return: Attribute or None.
:rtype: func | [
"Used",
"to",
"double",
"methods",
"added",
"to",
"an",
"object",
"after",
"creation"
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/target.py#L137-L158 | train |
uber/doubles | doubles/target.py | Target.get_attr | def get_attr(self, method_name):
"""Get attribute from the target object"""
return self.attrs.get(method_name) or self.get_callable_attr(method_name) | python | def get_attr(self, method_name):
"""Get attribute from the target object"""
return self.attrs.get(method_name) or self.get_callable_attr(method_name) | [
"def",
"get_attr",
"(",
"self",
",",
"method_name",
")",
":",
"return",
"self",
".",
"attrs",
".",
"get",
"(",
"method_name",
")",
"or",
"self",
".",
"get_callable_attr",
"(",
"method_name",
")"
] | Get attribute from the target object | [
"Get",
"attribute",
"from",
"the",
"target",
"object"
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/target.py#L160-L162 | train |
uber/doubles | doubles/method_double.py | MethodDouble.add_allowance | def add_allowance(self, caller):
"""Adds a new allowance for the method.
:param: tuple caller: A tuple indicating where the method was called
:return: The new ``Allowance``.
:rtype: Allowance
"""
allowance = Allowance(self._target, self._method_name, caller)
sel... | python | def add_allowance(self, caller):
"""Adds a new allowance for the method.
:param: tuple caller: A tuple indicating where the method was called
:return: The new ``Allowance``.
:rtype: Allowance
"""
allowance = Allowance(self._target, self._method_name, caller)
sel... | [
"def",
"add_allowance",
"(",
"self",
",",
"caller",
")",
":",
"allowance",
"=",
"Allowance",
"(",
"self",
".",
"_target",
",",
"self",
".",
"_method_name",
",",
"caller",
")",
"self",
".",
"_allowances",
".",
"insert",
"(",
"0",
",",
"allowance",
")",
... | Adds a new allowance for the method.
:param: tuple caller: A tuple indicating where the method was called
:return: The new ``Allowance``.
:rtype: Allowance | [
"Adds",
"a",
"new",
"allowance",
"for",
"the",
"method",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/method_double.py#L30-L40 | train |
uber/doubles | doubles/method_double.py | MethodDouble.add_expectation | def add_expectation(self, caller):
"""Adds a new expectation for the method.
:return: The new ``Expectation``.
:rtype: Expectation
"""
expectation = Expectation(self._target, self._method_name, caller)
self._expectations.insert(0, expectation)
return expectation | python | def add_expectation(self, caller):
"""Adds a new expectation for the method.
:return: The new ``Expectation``.
:rtype: Expectation
"""
expectation = Expectation(self._target, self._method_name, caller)
self._expectations.insert(0, expectation)
return expectation | [
"def",
"add_expectation",
"(",
"self",
",",
"caller",
")",
":",
"expectation",
"=",
"Expectation",
"(",
"self",
".",
"_target",
",",
"self",
".",
"_method_name",
",",
"caller",
")",
"self",
".",
"_expectations",
".",
"insert",
"(",
"0",
",",
"expectation",... | Adds a new expectation for the method.
:return: The new ``Expectation``.
:rtype: Expectation | [
"Adds",
"a",
"new",
"expectation",
"for",
"the",
"method",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/method_double.py#L42-L51 | train |
uber/doubles | doubles/method_double.py | MethodDouble._find_matching_allowance | def _find_matching_allowance(self, args, kwargs):
"""Return a matching allowance.
Returns the first allowance that matches the ones declared. Tries one with specific
arguments first, then falls back to an allowance that allows arbitrary arguments.
:return: The matching ``Allowance``, i... | python | def _find_matching_allowance(self, args, kwargs):
"""Return a matching allowance.
Returns the first allowance that matches the ones declared. Tries one with specific
arguments first, then falls back to an allowance that allows arbitrary arguments.
:return: The matching ``Allowance``, i... | [
"def",
"_find_matching_allowance",
"(",
"self",
",",
"args",
",",
"kwargs",
")",
":",
"for",
"allowance",
"in",
"self",
".",
"_allowances",
":",
"if",
"allowance",
".",
"satisfy_exact_match",
"(",
"args",
",",
"kwargs",
")",
":",
"return",
"allowance",
"for"... | Return a matching allowance.
Returns the first allowance that matches the ones declared. Tries one with specific
arguments first, then falls back to an allowance that allows arbitrary arguments.
:return: The matching ``Allowance``, if one was found.
:rtype: Allowance, None | [
"Return",
"a",
"matching",
"allowance",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/method_double.py#L68-L88 | train |
uber/doubles | doubles/method_double.py | MethodDouble._find_matching_double | def _find_matching_double(self, args, kwargs):
"""Returns the first matching expectation or allowance.
Returns the first allowance or expectation that matches the ones declared. Tries one
with specific arguments first, then falls back to an expectation that allows arbitrary
arguments.
... | python | def _find_matching_double(self, args, kwargs):
"""Returns the first matching expectation or allowance.
Returns the first allowance or expectation that matches the ones declared. Tries one
with specific arguments first, then falls back to an expectation that allows arbitrary
arguments.
... | [
"def",
"_find_matching_double",
"(",
"self",
",",
"args",
",",
"kwargs",
")",
":",
"expectation",
"=",
"self",
".",
"_find_matching_expectation",
"(",
"args",
",",
"kwargs",
")",
"if",
"expectation",
":",
"return",
"expectation",
"allowance",
"=",
"self",
".",... | Returns the first matching expectation or allowance.
Returns the first allowance or expectation that matches the ones declared. Tries one
with specific arguments first, then falls back to an expectation that allows arbitrary
arguments.
:return: The matching ``Allowance`` or ``Expectati... | [
"Returns",
"the",
"first",
"matching",
"expectation",
"or",
"allowance",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/method_double.py#L90-L109 | train |
uber/doubles | doubles/method_double.py | MethodDouble._find_matching_expectation | def _find_matching_expectation(self, args, kwargs):
"""Return a matching expectation.
Returns the first expectation that matches the ones declared. Tries one with specific
arguments first, then falls back to an expectation that allows arbitrary arguments.
:return: The matching ``Expect... | python | def _find_matching_expectation(self, args, kwargs):
"""Return a matching expectation.
Returns the first expectation that matches the ones declared. Tries one with specific
arguments first, then falls back to an expectation that allows arbitrary arguments.
:return: The matching ``Expect... | [
"def",
"_find_matching_expectation",
"(",
"self",
",",
"args",
",",
"kwargs",
")",
":",
"for",
"expectation",
"in",
"self",
".",
"_expectations",
":",
"if",
"expectation",
".",
"satisfy_exact_match",
"(",
"args",
",",
"kwargs",
")",
":",
"return",
"expectation... | Return a matching expectation.
Returns the first expectation that matches the ones declared. Tries one with specific
arguments first, then falls back to an expectation that allows arbitrary arguments.
:return: The matching ``Expectation``, if one was found.
:rtype: Expectation, None | [
"Return",
"a",
"matching",
"expectation",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/method_double.py#L111-L131 | train |
uber/doubles | doubles/method_double.py | MethodDouble._verify_method | def _verify_method(self):
"""Verify that a method may be doubled.
Verifies that the target object has a method matching the name the user is attempting to
double.
:raise: ``VerifyingDoubleError`` if no matching method is found.
"""
class_level = self._target.is_class_o... | python | def _verify_method(self):
"""Verify that a method may be doubled.
Verifies that the target object has a method matching the name the user is attempting to
double.
:raise: ``VerifyingDoubleError`` if no matching method is found.
"""
class_level = self._target.is_class_o... | [
"def",
"_verify_method",
"(",
"self",
")",
":",
"class_level",
"=",
"self",
".",
"_target",
".",
"is_class_or_module",
"(",
")",
"verify_method",
"(",
"self",
".",
"_target",
",",
"self",
".",
"_method_name",
",",
"class_level",
"=",
"class_level",
")"
] | Verify that a method may be doubled.
Verifies that the target object has a method matching the name the user is attempting to
double.
:raise: ``VerifyingDoubleError`` if no matching method is found. | [
"Verify",
"that",
"a",
"method",
"may",
"be",
"doubled",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/method_double.py#L133-L144 | train |
uber/doubles | doubles/verification.py | verify_method | def verify_method(target, method_name, class_level=False):
"""Verifies that the provided method exists on the target object.
:param Target target: A ``Target`` object containing the object with the method to double.
:param str method_name: The name of the method to double.
:raise: ``VerifyingDoubleErro... | python | def verify_method(target, method_name, class_level=False):
"""Verifies that the provided method exists on the target object.
:param Target target: A ``Target`` object containing the object with the method to double.
:param str method_name: The name of the method to double.
:raise: ``VerifyingDoubleErro... | [
"def",
"verify_method",
"(",
"target",
",",
"method_name",
",",
"class_level",
"=",
"False",
")",
":",
"attr",
"=",
"target",
".",
"get_attr",
"(",
"method_name",
")",
"if",
"not",
"attr",
":",
"raise",
"VerifyingDoubleError",
"(",
"method_name",
",",
"targe... | Verifies that the provided method exists on the target object.
:param Target target: A ``Target`` object containing the object with the method to double.
:param str method_name: The name of the method to double.
:raise: ``VerifyingDoubleError`` if the attribute doesn't exist, if it's not a callable object,... | [
"Verifies",
"that",
"the",
"provided",
"method",
"exists",
"on",
"the",
"target",
"object",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/verification.py#L76-L94 | train |
uber/doubles | doubles/verification.py | verify_arguments | def verify_arguments(target, method_name, args, kwargs):
"""Verifies that the provided arguments match the signature of the provided method.
:param Target target: A ``Target`` object containing the object with the method to double.
:param str method_name: The name of the method to double.
:param tuple ... | python | def verify_arguments(target, method_name, args, kwargs):
"""Verifies that the provided arguments match the signature of the provided method.
:param Target target: A ``Target`` object containing the object with the method to double.
:param str method_name: The name of the method to double.
:param tuple ... | [
"def",
"verify_arguments",
"(",
"target",
",",
"method_name",
",",
"args",
",",
"kwargs",
")",
":",
"if",
"method_name",
"==",
"'_doubles__new__'",
":",
"return",
"_verify_arguments_of_doubles__new__",
"(",
"target",
",",
"args",
",",
"kwargs",
")",
"attr",
"=",... | Verifies that the provided arguments match the signature of the provided method.
:param Target target: A ``Target`` object containing the object with the method to double.
:param str method_name: The name of the method to double.
:param tuple args: The positional arguments the method should be called with.... | [
"Verifies",
"that",
"the",
"provided",
"arguments",
"match",
"the",
"signature",
"of",
"the",
"provided",
"method",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/verification.py#L97-L125 | train |
uber/doubles | doubles/targets/allowance_target.py | allow_constructor | def allow_constructor(target):
"""
Set an allowance on a ``ClassDouble`` constructor
This allows the caller to control what a ClassDouble returns when a new instance is created.
:param ClassDouble target: The ClassDouble to set the allowance on.
:return: an ``Allowance`` for the __new__ method.
... | python | def allow_constructor(target):
"""
Set an allowance on a ``ClassDouble`` constructor
This allows the caller to control what a ClassDouble returns when a new instance is created.
:param ClassDouble target: The ClassDouble to set the allowance on.
:return: an ``Allowance`` for the __new__ method.
... | [
"def",
"allow_constructor",
"(",
"target",
")",
":",
"if",
"not",
"isinstance",
"(",
"target",
",",
"ClassDouble",
")",
":",
"raise",
"ConstructorDoubleError",
"(",
"'Cannot allow_constructor of {} since it is not a ClassDouble.'",
".",
"format",
"(",
"target",
")",
"... | Set an allowance on a ``ClassDouble`` constructor
This allows the caller to control what a ClassDouble returns when a new instance is created.
:param ClassDouble target: The ClassDouble to set the allowance on.
:return: an ``Allowance`` for the __new__ method.
:raise: ``ConstructorDoubleError`` if ta... | [
"Set",
"an",
"allowance",
"on",
"a",
"ClassDouble",
"constructor"
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/targets/allowance_target.py#L25-L40 | train |
uber/doubles | doubles/targets/patch_target.py | patch | def patch(target, value):
"""
Replace the specified object
:param str target: A string pointing to the target to patch.
:param object value: The value to replace the target with.
:return: A ``Patch`` object.
"""
patch = current_space().patch_for(target)
patch.set_value(value)
return... | python | def patch(target, value):
"""
Replace the specified object
:param str target: A string pointing to the target to patch.
:param object value: The value to replace the target with.
:return: A ``Patch`` object.
"""
patch = current_space().patch_for(target)
patch.set_value(value)
return... | [
"def",
"patch",
"(",
"target",
",",
"value",
")",
":",
"patch",
"=",
"current_space",
"(",
")",
".",
"patch_for",
"(",
"target",
")",
"patch",
".",
"set_value",
"(",
"value",
")",
"return",
"patch"
] | Replace the specified object
:param str target: A string pointing to the target to patch.
:param object value: The value to replace the target with.
:return: A ``Patch`` object. | [
"Replace",
"the",
"specified",
"object"
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/targets/patch_target.py#L18-L28 | train |
uber/doubles | doubles/utils.py | get_path_components | def get_path_components(path):
"""Extract the module name and class name out of the fully qualified path to the class.
:param str path: The full path to the class.
:return: The module path and the class name.
:rtype: str, str
:raise: ``VerifyingDoubleImportError`` if the path is to a top-level modu... | python | def get_path_components(path):
"""Extract the module name and class name out of the fully qualified path to the class.
:param str path: The full path to the class.
:return: The module path and the class name.
:rtype: str, str
:raise: ``VerifyingDoubleImportError`` if the path is to a top-level modu... | [
"def",
"get_path_components",
"(",
"path",
")",
":",
"path_segments",
"=",
"path",
".",
"split",
"(",
"'.'",
")",
"module_path",
"=",
"'.'",
".",
"join",
"(",
"path_segments",
"[",
":",
"-",
"1",
"]",
")",
"if",
"module_path",
"==",
"''",
":",
"raise",... | Extract the module name and class name out of the fully qualified path to the class.
:param str path: The full path to the class.
:return: The module path and the class name.
:rtype: str, str
:raise: ``VerifyingDoubleImportError`` if the path is to a top-level module. | [
"Extract",
"the",
"module",
"name",
"and",
"class",
"name",
"out",
"of",
"the",
"fully",
"qualified",
"path",
"to",
"the",
"class",
"."
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/utils.py#L22-L39 | train |
uber/doubles | doubles/targets/expectation_target.py | expect_constructor | def expect_constructor(target):
"""
Set an expectation on a ``ClassDouble`` constructor
:param ClassDouble target: The ClassDouble to set the expectation on.
:return: an ``Expectation`` for the __new__ method.
:raise: ``ConstructorDoubleError`` if target is not a ClassDouble.
"""
if not is... | python | def expect_constructor(target):
"""
Set an expectation on a ``ClassDouble`` constructor
:param ClassDouble target: The ClassDouble to set the expectation on.
:return: an ``Expectation`` for the __new__ method.
:raise: ``ConstructorDoubleError`` if target is not a ClassDouble.
"""
if not is... | [
"def",
"expect_constructor",
"(",
"target",
")",
":",
"if",
"not",
"isinstance",
"(",
"target",
",",
"ClassDouble",
")",
":",
"raise",
"ConstructorDoubleError",
"(",
"'Cannot allow_constructor of {} since it is not a ClassDouble.'",
".",
"format",
"(",
"target",
")",
... | Set an expectation on a ``ClassDouble`` constructor
:param ClassDouble target: The ClassDouble to set the expectation on.
:return: an ``Expectation`` for the __new__ method.
:raise: ``ConstructorDoubleError`` if target is not a ClassDouble. | [
"Set",
"an",
"expectation",
"on",
"a",
"ClassDouble",
"constructor"
] | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/targets/expectation_target.py#L25-L38 | train |
thombashi/pytablewriter | pytablewriter/writer/text/_markdown.py | MarkdownTableWriter.write_table | def write_table(self):
"""
|write_table| with Markdown table format.
:raises pytablewriter.EmptyHeaderError: If the |headers| is empty.
:Example:
:ref:`example-markdown-table-writer`
.. note::
- |None| values are written as an empty string
- ... | python | def write_table(self):
"""
|write_table| with Markdown table format.
:raises pytablewriter.EmptyHeaderError: If the |headers| is empty.
:Example:
:ref:`example-markdown-table-writer`
.. note::
- |None| values are written as an empty string
- ... | [
"def",
"write_table",
"(",
"self",
")",
":",
"with",
"self",
".",
"_logger",
":",
"self",
".",
"_verify_property",
"(",
")",
"self",
".",
"__write_chapter",
"(",
")",
"self",
".",
"_write_table",
"(",
")",
"if",
"self",
".",
"is_write_null_line_after_table",... | |write_table| with Markdown table format.
:raises pytablewriter.EmptyHeaderError: If the |headers| is empty.
:Example:
:ref:`example-markdown-table-writer`
.. note::
- |None| values are written as an empty string
- Vertical bar characters (``'|'``) in table ... | [
"|write_table|",
"with",
"Markdown",
"table",
"format",
"."
] | 52ea85ed8e89097afa64f137c6a1b3acdfefdbda | https://github.com/thombashi/pytablewriter/blob/52ea85ed8e89097afa64f137c6a1b3acdfefdbda/pytablewriter/writer/text/_markdown.py#L86-L104 | train |
thombashi/pytablewriter | pytablewriter/writer/text/_html.py | HtmlTableWriter.write_table | def write_table(self):
"""
|write_table| with HTML table format.
:Example:
:ref:`example-html-table-writer`
.. note::
- |None| is not written
"""
tags = _get_tags_module()
with self._logger:
self._verify_property()
... | python | def write_table(self):
"""
|write_table| with HTML table format.
:Example:
:ref:`example-html-table-writer`
.. note::
- |None| is not written
"""
tags = _get_tags_module()
with self._logger:
self._verify_property()
... | [
"def",
"write_table",
"(",
"self",
")",
":",
"tags",
"=",
"_get_tags_module",
"(",
")",
"with",
"self",
".",
"_logger",
":",
"self",
".",
"_verify_property",
"(",
")",
"self",
".",
"_preprocess",
"(",
")",
"if",
"typepy",
".",
"is_not_null_string",
"(",
... | |write_table| with HTML table format.
:Example:
:ref:`example-html-table-writer`
.. note::
- |None| is not written | [
"|write_table|",
"with",
"HTML",
"table",
"format",
"."
] | 52ea85ed8e89097afa64f137c6a1b3acdfefdbda | https://github.com/thombashi/pytablewriter/blob/52ea85ed8e89097afa64f137c6a1b3acdfefdbda/pytablewriter/writer/text/_html.py#L57-L85 | train |
thombashi/pytablewriter | pytablewriter/writer/text/_text_writer.py | TextTableWriter.dump | def dump(self, output, close_after_write=True):
"""Write data to the output with tabular format.
Args:
output (file descriptor or str):
file descriptor or path to the output file.
close_after_write (bool, optional):
Close the output after write.
... | python | def dump(self, output, close_after_write=True):
"""Write data to the output with tabular format.
Args:
output (file descriptor or str):
file descriptor or path to the output file.
close_after_write (bool, optional):
Close the output after write.
... | [
"def",
"dump",
"(",
"self",
",",
"output",
",",
"close_after_write",
"=",
"True",
")",
":",
"try",
":",
"output",
".",
"write",
"self",
".",
"stream",
"=",
"output",
"except",
"AttributeError",
":",
"self",
".",
"stream",
"=",
"io",
".",
"open",
"(",
... | Write data to the output with tabular format.
Args:
output (file descriptor or str):
file descriptor or path to the output file.
close_after_write (bool, optional):
Close the output after write.
Defaults to |True|. | [
"Write",
"data",
"to",
"the",
"output",
"with",
"tabular",
"format",
"."
] | 52ea85ed8e89097afa64f137c6a1b3acdfefdbda | https://github.com/thombashi/pytablewriter/blob/52ea85ed8e89097afa64f137c6a1b3acdfefdbda/pytablewriter/writer/text/_text_writer.py#L179-L201 | train |
thombashi/pytablewriter | pytablewriter/writer/text/_text_writer.py | TextTableWriter.dumps | def dumps(self):
"""Get rendered tabular text from the table data.
Only available for text format table writers.
Returns:
str: Rendered tabular text.
"""
old_stream = self.stream
try:
self.stream = six.StringIO()
self.write_table()
... | python | def dumps(self):
"""Get rendered tabular text from the table data.
Only available for text format table writers.
Returns:
str: Rendered tabular text.
"""
old_stream = self.stream
try:
self.stream = six.StringIO()
self.write_table()
... | [
"def",
"dumps",
"(",
"self",
")",
":",
"old_stream",
"=",
"self",
".",
"stream",
"try",
":",
"self",
".",
"stream",
"=",
"six",
".",
"StringIO",
"(",
")",
"self",
".",
"write_table",
"(",
")",
"tabular_text",
"=",
"self",
".",
"stream",
".",
"getvalu... | Get rendered tabular text from the table data.
Only available for text format table writers.
Returns:
str: Rendered tabular text. | [
"Get",
"rendered",
"tabular",
"text",
"from",
"the",
"table",
"data",
"."
] | 52ea85ed8e89097afa64f137c6a1b3acdfefdbda | https://github.com/thombashi/pytablewriter/blob/52ea85ed8e89097afa64f137c6a1b3acdfefdbda/pytablewriter/writer/text/_text_writer.py#L203-L221 | train |
thombashi/pytablewriter | pytablewriter/writer/binary/_excel.py | ExcelTableWriter.open | def open(self, file_path):
"""
Open an Excel workbook file.
:param str file_path: Excel workbook file path to open.
"""
if self.is_opened() and self.workbook.file_path == file_path:
self._logger.logger.debug("workbook already opened: {}".format(self.workbook.file_pa... | python | def open(self, file_path):
"""
Open an Excel workbook file.
:param str file_path: Excel workbook file path to open.
"""
if self.is_opened() and self.workbook.file_path == file_path:
self._logger.logger.debug("workbook already opened: {}".format(self.workbook.file_pa... | [
"def",
"open",
"(",
"self",
",",
"file_path",
")",
":",
"if",
"self",
".",
"is_opened",
"(",
")",
"and",
"self",
".",
"workbook",
".",
"file_path",
"==",
"file_path",
":",
"self",
".",
"_logger",
".",
"logger",
".",
"debug",
"(",
"\"workbook already open... | Open an Excel workbook file.
:param str file_path: Excel workbook file path to open. | [
"Open",
"an",
"Excel",
"workbook",
"file",
"."
] | 52ea85ed8e89097afa64f137c6a1b3acdfefdbda | https://github.com/thombashi/pytablewriter/blob/52ea85ed8e89097afa64f137c6a1b3acdfefdbda/pytablewriter/writer/binary/_excel.py#L129-L141 | train |
thombashi/pytablewriter | pytablewriter/writer/binary/_excel.py | ExcelTableWriter.from_tabledata | def from_tabledata(self, value, is_overwrite_table_name=True):
"""
Set following attributes from |TableData|
- :py:attr:`~.table_name`.
- :py:attr:`~.headers`.
- :py:attr:`~.value_matrix`.
And create worksheet named from :py:attr:`~.table_name` ABC
if not existe... | python | def from_tabledata(self, value, is_overwrite_table_name=True):
"""
Set following attributes from |TableData|
- :py:attr:`~.table_name`.
- :py:attr:`~.headers`.
- :py:attr:`~.value_matrix`.
And create worksheet named from :py:attr:`~.table_name` ABC
if not existe... | [
"def",
"from_tabledata",
"(",
"self",
",",
"value",
",",
"is_overwrite_table_name",
"=",
"True",
")",
":",
"super",
"(",
"ExcelTableWriter",
",",
"self",
")",
".",
"from_tabledata",
"(",
"value",
")",
"if",
"self",
".",
"is_opened",
"(",
")",
":",
"self",
... | Set following attributes from |TableData|
- :py:attr:`~.table_name`.
- :py:attr:`~.headers`.
- :py:attr:`~.value_matrix`.
And create worksheet named from :py:attr:`~.table_name` ABC
if not existed yet.
:param tabledata.TableData value: Input table data. | [
"Set",
"following",
"attributes",
"from",
"|TableData|"
] | 52ea85ed8e89097afa64f137c6a1b3acdfefdbda | https://github.com/thombashi/pytablewriter/blob/52ea85ed8e89097afa64f137c6a1b3acdfefdbda/pytablewriter/writer/binary/_excel.py#L166-L183 | train |
thombashi/pytablewriter | pytablewriter/writer/binary/_excel.py | ExcelTableWriter.make_worksheet | def make_worksheet(self, sheet_name=None):
"""Make a worksheet to the current workbook.
Args:
sheet_name (str):
Name of the worksheet to create. The name will be automatically generated
(like ``"Sheet1"``) if the ``sheet_name`` is empty.
"""
... | python | def make_worksheet(self, sheet_name=None):
"""Make a worksheet to the current workbook.
Args:
sheet_name (str):
Name of the worksheet to create. The name will be automatically generated
(like ``"Sheet1"``) if the ``sheet_name`` is empty.
"""
... | [
"def",
"make_worksheet",
"(",
"self",
",",
"sheet_name",
"=",
"None",
")",
":",
"if",
"sheet_name",
"is",
"None",
":",
"sheet_name",
"=",
"self",
".",
"table_name",
"if",
"not",
"sheet_name",
":",
"sheet_name",
"=",
"\"\"",
"self",
".",
"_stream",
"=",
"... | Make a worksheet to the current workbook.
Args:
sheet_name (str):
Name of the worksheet to create. The name will be automatically generated
(like ``"Sheet1"``) if the ``sheet_name`` is empty. | [
"Make",
"a",
"worksheet",
"to",
"the",
"current",
"workbook",
"."
] | 52ea85ed8e89097afa64f137c6a1b3acdfefdbda | https://github.com/thombashi/pytablewriter/blob/52ea85ed8e89097afa64f137c6a1b3acdfefdbda/pytablewriter/writer/binary/_excel.py#L185-L200 | train |
thombashi/pytablewriter | pytablewriter/writer/binary/_excel.py | ExcelTableWriter.dump | def dump(self, output, close_after_write=True):
"""Write a worksheet to the current workbook.
Args:
output (str):
Path to the workbook file to write.
close_after_write (bool, optional):
Close the workbook after write.
Defaults to |... | python | def dump(self, output, close_after_write=True):
"""Write a worksheet to the current workbook.
Args:
output (str):
Path to the workbook file to write.
close_after_write (bool, optional):
Close the workbook after write.
Defaults to |... | [
"def",
"dump",
"(",
"self",
",",
"output",
",",
"close_after_write",
"=",
"True",
")",
":",
"self",
".",
"open",
"(",
"output",
")",
"try",
":",
"self",
".",
"make_worksheet",
"(",
"self",
".",
"table_name",
")",
"self",
".",
"write_table",
"(",
")",
... | Write a worksheet to the current workbook.
Args:
output (str):
Path to the workbook file to write.
close_after_write (bool, optional):
Close the workbook after write.
Defaults to |True|. | [
"Write",
"a",
"worksheet",
"to",
"the",
"current",
"workbook",
"."
] | 52ea85ed8e89097afa64f137c6a1b3acdfefdbda | https://github.com/thombashi/pytablewriter/blob/52ea85ed8e89097afa64f137c6a1b3acdfefdbda/pytablewriter/writer/binary/_excel.py#L202-L219 | train |
thombashi/pytablewriter | pytablewriter/writer/binary/_sqlite.py | SqliteTableWriter.open | def open(self, file_path):
"""
Open a SQLite database file.
:param str file_path: SQLite database file path to open.
"""
from simplesqlite import SimpleSQLite
if self.is_opened():
if self.stream.database_path == abspath(file_path):
self._log... | python | def open(self, file_path):
"""
Open a SQLite database file.
:param str file_path: SQLite database file path to open.
"""
from simplesqlite import SimpleSQLite
if self.is_opened():
if self.stream.database_path == abspath(file_path):
self._log... | [
"def",
"open",
"(",
"self",
",",
"file_path",
")",
":",
"from",
"simplesqlite",
"import",
"SimpleSQLite",
"if",
"self",
".",
"is_opened",
"(",
")",
":",
"if",
"self",
".",
"stream",
".",
"database_path",
"==",
"abspath",
"(",
"file_path",
")",
":",
"self... | Open a SQLite database file.
:param str file_path: SQLite database file path to open. | [
"Open",
"a",
"SQLite",
"database",
"file",
"."
] | 52ea85ed8e89097afa64f137c6a1b3acdfefdbda | https://github.com/thombashi/pytablewriter/blob/52ea85ed8e89097afa64f137c6a1b3acdfefdbda/pytablewriter/writer/binary/_sqlite.py#L61-L79 | train |
thombashi/pytablewriter | pytablewriter/writer/_table_writer.py | AbstractTableWriter.set_style | def set_style(self, column, style):
"""Set |Style| for a specific column.
Args:
column (|int| or |str|):
Column specifier. column index or header name correlated with the column.
style (|Style|):
Style value to be set to the column.
Raise... | python | def set_style(self, column, style):
"""Set |Style| for a specific column.
Args:
column (|int| or |str|):
Column specifier. column index or header name correlated with the column.
style (|Style|):
Style value to be set to the column.
Raise... | [
"def",
"set_style",
"(",
"self",
",",
"column",
",",
"style",
")",
":",
"column_idx",
"=",
"None",
"while",
"len",
"(",
"self",
".",
"headers",
")",
">",
"len",
"(",
"self",
".",
"__style_list",
")",
":",
"self",
".",
"__style_list",
".",
"append",
"... | Set |Style| for a specific column.
Args:
column (|int| or |str|):
Column specifier. column index or header name correlated with the column.
style (|Style|):
Style value to be set to the column.
Raises:
ValueError: If the column specif... | [
"Set",
"|Style|",
"for",
"a",
"specific",
"column",
"."
] | 52ea85ed8e89097afa64f137c6a1b3acdfefdbda | https://github.com/thombashi/pytablewriter/blob/52ea85ed8e89097afa64f137c6a1b3acdfefdbda/pytablewriter/writer/_table_writer.py#L458-L493 | train |
thombashi/pytablewriter | pytablewriter/writer/_table_writer.py | AbstractTableWriter.close | def close(self):
"""
Close the current |stream|.
"""
if self.stream is None:
return
try:
self.stream.isatty()
if self.stream.name in ["<stdin>", "<stdout>", "<stderr>"]:
return
except AttributeError:
pass
... | python | def close(self):
"""
Close the current |stream|.
"""
if self.stream is None:
return
try:
self.stream.isatty()
if self.stream.name in ["<stdin>", "<stdout>", "<stderr>"]:
return
except AttributeError:
pass
... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"stream",
"is",
"None",
":",
"return",
"try",
":",
"self",
".",
"stream",
".",
"isatty",
"(",
")",
"if",
"self",
".",
"stream",
".",
"name",
"in",
"[",
"\"<stdin>\"",
",",
"\"<stdout>\"",
",... | Close the current |stream|. | [
"Close",
"the",
"current",
"|stream|",
"."
] | 52ea85ed8e89097afa64f137c6a1b3acdfefdbda | https://github.com/thombashi/pytablewriter/blob/52ea85ed8e89097afa64f137c6a1b3acdfefdbda/pytablewriter/writer/_table_writer.py#L495-L540 | train |
heroku/heroku.py | heroku/models.py | BaseResource._ids | def _ids(self):
"""The list of primary keys to validate against."""
for pk in self._pks:
yield getattr(self, pk)
for pk in self._pks:
try:
yield str(getattr(self, pk))
except ValueError:
pass | python | def _ids(self):
"""The list of primary keys to validate against."""
for pk in self._pks:
yield getattr(self, pk)
for pk in self._pks:
try:
yield str(getattr(self, pk))
except ValueError:
pass | [
"def",
"_ids",
"(",
"self",
")",
":",
"for",
"pk",
"in",
"self",
".",
"_pks",
":",
"yield",
"getattr",
"(",
"self",
",",
"pk",
")",
"for",
"pk",
"in",
"self",
".",
"_pks",
":",
"try",
":",
"yield",
"str",
"(",
"getattr",
"(",
"self",
",",
"pk",... | The list of primary keys to validate against. | [
"The",
"list",
"of",
"primary",
"keys",
"to",
"validate",
"against",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/models.py#L57-L67 | train |
heroku/heroku.py | heroku/models.py | Addon.upgrade | def upgrade(self, name, params=None):
"""Upgrades an addon to the given tier."""
# Allow non-namespaced upgrades. (e.g. advanced vs logging:advanced)
if ':' not in name:
name = '{0}:{1}'.format(self.type, name)
r = self._h._http_resource(
method='PUT',
... | python | def upgrade(self, name, params=None):
"""Upgrades an addon to the given tier."""
# Allow non-namespaced upgrades. (e.g. advanced vs logging:advanced)
if ':' not in name:
name = '{0}:{1}'.format(self.type, name)
r = self._h._http_resource(
method='PUT',
... | [
"def",
"upgrade",
"(",
"self",
",",
"name",
",",
"params",
"=",
"None",
")",
":",
"# Allow non-namespaced upgrades. (e.g. advanced vs logging:advanced)",
"if",
"':'",
"not",
"in",
"name",
":",
"name",
"=",
"'{0}:{1}'",
".",
"format",
"(",
"self",
".",
"type",
... | Upgrades an addon to the given tier. | [
"Upgrades",
"an",
"addon",
"to",
"the",
"given",
"tier",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/models.py#L153-L166 | train |
heroku/heroku.py | heroku/models.py | App.new | def new(self, name=None, stack='cedar', region=None):
"""Creates a new app."""
payload = {}
if name:
payload['app[name]'] = name
if stack:
payload['app[stack]'] = stack
if region:
payload['app[region]'] = region
r = self._h._http_r... | python | def new(self, name=None, stack='cedar', region=None):
"""Creates a new app."""
payload = {}
if name:
payload['app[name]'] = name
if stack:
payload['app[stack]'] = stack
if region:
payload['app[region]'] = region
r = self._h._http_r... | [
"def",
"new",
"(",
"self",
",",
"name",
"=",
"None",
",",
"stack",
"=",
"'cedar'",
",",
"region",
"=",
"None",
")",
":",
"payload",
"=",
"{",
"}",
"if",
"name",
":",
"payload",
"[",
"'app[name]'",
"]",
"=",
"name",
"if",
"stack",
":",
"payload",
... | Creates a new app. | [
"Creates",
"a",
"new",
"app",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/models.py#L183-L204 | train |
heroku/heroku.py | heroku/models.py | App.collaborators | def collaborators(self):
"""The collaborators for this app."""
return self._h._get_resources(
resource=('apps', self.name, 'collaborators'),
obj=Collaborator, app=self
) | python | def collaborators(self):
"""The collaborators for this app."""
return self._h._get_resources(
resource=('apps', self.name, 'collaborators'),
obj=Collaborator, app=self
) | [
"def",
"collaborators",
"(",
"self",
")",
":",
"return",
"self",
".",
"_h",
".",
"_get_resources",
"(",
"resource",
"=",
"(",
"'apps'",
",",
"self",
".",
"name",
",",
"'collaborators'",
")",
",",
"obj",
"=",
"Collaborator",
",",
"app",
"=",
"self",
")"... | The collaborators for this app. | [
"The",
"collaborators",
"for",
"this",
"app",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/models.py#L214-L219 | train |
heroku/heroku.py | heroku/models.py | App.domains | def domains(self):
"""The domains for this app."""
return self._h._get_resources(
resource=('apps', self.name, 'domains'),
obj=Domain, app=self
) | python | def domains(self):
"""The domains for this app."""
return self._h._get_resources(
resource=('apps', self.name, 'domains'),
obj=Domain, app=self
) | [
"def",
"domains",
"(",
"self",
")",
":",
"return",
"self",
".",
"_h",
".",
"_get_resources",
"(",
"resource",
"=",
"(",
"'apps'",
",",
"self",
".",
"name",
",",
"'domains'",
")",
",",
"obj",
"=",
"Domain",
",",
"app",
"=",
"self",
")"
] | The domains for this app. | [
"The",
"domains",
"for",
"this",
"app",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/models.py#L222-L227 | train |
heroku/heroku.py | heroku/models.py | App.releases | def releases(self):
"""The releases for this app."""
return self._h._get_resources(
resource=('apps', self.name, 'releases'),
obj=Release, app=self
) | python | def releases(self):
"""The releases for this app."""
return self._h._get_resources(
resource=('apps', self.name, 'releases'),
obj=Release, app=self
) | [
"def",
"releases",
"(",
"self",
")",
":",
"return",
"self",
".",
"_h",
".",
"_get_resources",
"(",
"resource",
"=",
"(",
"'apps'",
",",
"self",
".",
"name",
",",
"'releases'",
")",
",",
"obj",
"=",
"Release",
",",
"app",
"=",
"self",
")"
] | The releases for this app. | [
"The",
"releases",
"for",
"this",
"app",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/models.py#L230-L235 | train |
heroku/heroku.py | heroku/models.py | App.processes | def processes(self):
"""The proccesses for this app."""
return self._h._get_resources(
resource=('apps', self.name, 'ps'),
obj=Process, app=self, map=ProcessListResource
) | python | def processes(self):
"""The proccesses for this app."""
return self._h._get_resources(
resource=('apps', self.name, 'ps'),
obj=Process, app=self, map=ProcessListResource
) | [
"def",
"processes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_h",
".",
"_get_resources",
"(",
"resource",
"=",
"(",
"'apps'",
",",
"self",
".",
"name",
",",
"'ps'",
")",
",",
"obj",
"=",
"Process",
",",
"app",
"=",
"self",
",",
"map",
"=",
... | The proccesses for this app. | [
"The",
"proccesses",
"for",
"this",
"app",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/models.py#L238-L243 | train |
heroku/heroku.py | heroku/models.py | App.config | def config(self):
"""The envs for this app."""
return self._h._get_resource(
resource=('apps', self.name, 'config_vars'),
obj=ConfigVars, app=self
) | python | def config(self):
"""The envs for this app."""
return self._h._get_resource(
resource=('apps', self.name, 'config_vars'),
obj=ConfigVars, app=self
) | [
"def",
"config",
"(",
"self",
")",
":",
"return",
"self",
".",
"_h",
".",
"_get_resource",
"(",
"resource",
"=",
"(",
"'apps'",
",",
"self",
".",
"name",
",",
"'config_vars'",
")",
",",
"obj",
"=",
"ConfigVars",
",",
"app",
"=",
"self",
")"
] | The envs for this app. | [
"The",
"envs",
"for",
"this",
"app",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/models.py#L246-L252 | train |
heroku/heroku.py | heroku/models.py | App.info | def info(self):
"""Returns current info for this app."""
return self._h._get_resource(
resource=('apps', self.name),
obj=App,
) | python | def info(self):
"""Returns current info for this app."""
return self._h._get_resource(
resource=('apps', self.name),
obj=App,
) | [
"def",
"info",
"(",
"self",
")",
":",
"return",
"self",
".",
"_h",
".",
"_get_resource",
"(",
"resource",
"=",
"(",
"'apps'",
",",
"self",
".",
"name",
")",
",",
"obj",
"=",
"App",
",",
")"
] | Returns current info for this app. | [
"Returns",
"current",
"info",
"for",
"this",
"app",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/models.py#L255-L261 | train |
heroku/heroku.py | heroku/models.py | App.rollback | def rollback(self, release):
"""Rolls back the release to the given version."""
r = self._h._http_resource(
method='POST',
resource=('apps', self.name, 'releases'),
data={'rollback': release}
)
return self.releases[-1] | python | def rollback(self, release):
"""Rolls back the release to the given version."""
r = self._h._http_resource(
method='POST',
resource=('apps', self.name, 'releases'),
data={'rollback': release}
)
return self.releases[-1] | [
"def",
"rollback",
"(",
"self",
",",
"release",
")",
":",
"r",
"=",
"self",
".",
"_h",
".",
"_http_resource",
"(",
"method",
"=",
"'POST'",
",",
"resource",
"=",
"(",
"'apps'",
",",
"self",
".",
"name",
",",
"'releases'",
")",
",",
"data",
"=",
"{"... | Rolls back the release to the given version. | [
"Rolls",
"back",
"the",
"release",
"to",
"the",
"given",
"version",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/models.py#L270-L277 | train |
heroku/heroku.py | heroku/models.py | App.rename | def rename(self, name):
"""Renames app to given name."""
r = self._h._http_resource(
method='PUT',
resource=('apps', self.name),
data={'app[name]': name}
)
return r.ok | python | def rename(self, name):
"""Renames app to given name."""
r = self._h._http_resource(
method='PUT',
resource=('apps', self.name),
data={'app[name]': name}
)
return r.ok | [
"def",
"rename",
"(",
"self",
",",
"name",
")",
":",
"r",
"=",
"self",
".",
"_h",
".",
"_http_resource",
"(",
"method",
"=",
"'PUT'",
",",
"resource",
"=",
"(",
"'apps'",
",",
"self",
".",
"name",
")",
",",
"data",
"=",
"{",
"'app[name]'",
":",
"... | Renames app to given name. | [
"Renames",
"app",
"to",
"given",
"name",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/models.py#L280-L288 | train |
heroku/heroku.py | heroku/models.py | App.transfer | def transfer(self, user):
"""Transfers app to given username's account."""
r = self._h._http_resource(
method='PUT',
resource=('apps', self.name),
data={'app[transfer_owner]': user}
)
return r.ok | python | def transfer(self, user):
"""Transfers app to given username's account."""
r = self._h._http_resource(
method='PUT',
resource=('apps', self.name),
data={'app[transfer_owner]': user}
)
return r.ok | [
"def",
"transfer",
"(",
"self",
",",
"user",
")",
":",
"r",
"=",
"self",
".",
"_h",
".",
"_http_resource",
"(",
"method",
"=",
"'PUT'",
",",
"resource",
"=",
"(",
"'apps'",
",",
"self",
".",
"name",
")",
",",
"data",
"=",
"{",
"'app[transfer_owner]'"... | Transfers app to given username's account. | [
"Transfers",
"app",
"to",
"given",
"username",
"s",
"account",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/models.py#L290-L298 | train |
heroku/heroku.py | heroku/models.py | App.maintenance | def maintenance(self, on=True):
"""Toggles maintenance mode."""
r = self._h._http_resource(
method='POST',
resource=('apps', self.name, 'server', 'maintenance'),
data={'maintenance_mode': int(on)}
)
return r.ok | python | def maintenance(self, on=True):
"""Toggles maintenance mode."""
r = self._h._http_resource(
method='POST',
resource=('apps', self.name, 'server', 'maintenance'),
data={'maintenance_mode': int(on)}
)
return r.ok | [
"def",
"maintenance",
"(",
"self",
",",
"on",
"=",
"True",
")",
":",
"r",
"=",
"self",
".",
"_h",
".",
"_http_resource",
"(",
"method",
"=",
"'POST'",
",",
"resource",
"=",
"(",
"'apps'",
",",
"self",
".",
"name",
",",
"'server'",
",",
"'maintenance'... | Toggles maintenance mode. | [
"Toggles",
"maintenance",
"mode",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/models.py#L300-L308 | train |
heroku/heroku.py | heroku/models.py | App.destroy | def destroy(self):
"""Destoys the app. Do be careful."""
r = self._h._http_resource(
method='DELETE',
resource=('apps', self.name)
)
return r.ok | python | def destroy(self):
"""Destoys the app. Do be careful."""
r = self._h._http_resource(
method='DELETE',
resource=('apps', self.name)
)
return r.ok | [
"def",
"destroy",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"_h",
".",
"_http_resource",
"(",
"method",
"=",
"'DELETE'",
",",
"resource",
"=",
"(",
"'apps'",
",",
"self",
".",
"name",
")",
")",
"return",
"r",
".",
"ok"
] | Destoys the app. Do be careful. | [
"Destoys",
"the",
"app",
".",
"Do",
"be",
"careful",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/models.py#L310-L317 | train |
heroku/heroku.py | heroku/models.py | App.logs | def logs(self, num=None, source=None, ps=None, tail=False):
"""Returns the requested log."""
# Bootstrap payload package.
payload = {'logplex': 'true'}
if num:
payload['num'] = num
if source:
payload['source'] = source
if ps:
payloa... | python | def logs(self, num=None, source=None, ps=None, tail=False):
"""Returns the requested log."""
# Bootstrap payload package.
payload = {'logplex': 'true'}
if num:
payload['num'] = num
if source:
payload['source'] = source
if ps:
payloa... | [
"def",
"logs",
"(",
"self",
",",
"num",
"=",
"None",
",",
"source",
"=",
"None",
",",
"ps",
"=",
"None",
",",
"tail",
"=",
"False",
")",
":",
"# Bootstrap payload package.",
"payload",
"=",
"{",
"'logplex'",
":",
"'true'",
"}",
"if",
"num",
":",
"pay... | Returns the requested log. | [
"Returns",
"the",
"requested",
"log",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/models.py#L319-L351 | train |
heroku/heroku.py | heroku/models.py | Key.delete | def delete(self):
"""Deletes the key."""
r = self._h._http_resource(
method='DELETE',
resource=('user', 'keys', self.id)
)
r.raise_for_status() | python | def delete(self):
"""Deletes the key."""
r = self._h._http_resource(
method='DELETE',
resource=('user', 'keys', self.id)
)
r.raise_for_status() | [
"def",
"delete",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"_h",
".",
"_http_resource",
"(",
"method",
"=",
"'DELETE'",
",",
"resource",
"=",
"(",
"'user'",
",",
"'keys'",
",",
"self",
".",
"id",
")",
")",
"r",
".",
"raise_for_status",
"(",
")"... | Deletes the key. | [
"Deletes",
"the",
"key",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/models.py#L492-L499 | train |
heroku/heroku.py | heroku/models.py | Process.restart | def restart(self, all=False):
"""Restarts the given process."""
if all:
data = {'type': self.type}
else:
data = {'ps': self.process}
r = self._h._http_resource(
method='POST',
resource=('apps', self.app.name, 'ps', 'restart'),
... | python | def restart(self, all=False):
"""Restarts the given process."""
if all:
data = {'type': self.type}
else:
data = {'ps': self.process}
r = self._h._http_resource(
method='POST',
resource=('apps', self.app.name, 'ps', 'restart'),
... | [
"def",
"restart",
"(",
"self",
",",
"all",
"=",
"False",
")",
":",
"if",
"all",
":",
"data",
"=",
"{",
"'type'",
":",
"self",
".",
"type",
"}",
"else",
":",
"data",
"=",
"{",
"'ps'",
":",
"self",
".",
"process",
"}",
"r",
"=",
"self",
".",
"_... | Restarts the given process. | [
"Restarts",
"the",
"given",
"process",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/models.py#L547-L562 | train |
heroku/heroku.py | heroku/models.py | Process.scale | def scale(self, quantity):
"""Scales the given process to the given number of dynos."""
r = self._h._http_resource(
method='POST',
resource=('apps', self.app.name, 'ps', 'scale'),
data={'type': self.type, 'qty': quantity}
)
r.raise_for_status()
... | python | def scale(self, quantity):
"""Scales the given process to the given number of dynos."""
r = self._h._http_resource(
method='POST',
resource=('apps', self.app.name, 'ps', 'scale'),
data={'type': self.type, 'qty': quantity}
)
r.raise_for_status()
... | [
"def",
"scale",
"(",
"self",
",",
"quantity",
")",
":",
"r",
"=",
"self",
".",
"_h",
".",
"_http_resource",
"(",
"method",
"=",
"'POST'",
",",
"resource",
"=",
"(",
"'apps'",
",",
"self",
".",
"app",
".",
"name",
",",
"'ps'",
",",
"'scale'",
")",
... | Scales the given process to the given number of dynos. | [
"Scales",
"the",
"given",
"process",
"to",
"the",
"given",
"number",
"of",
"dynos",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/models.py#L581-L595 | train |
heroku/heroku.py | heroku/helpers.py | is_collection | def is_collection(obj):
"""Tests if an object is a collection."""
col = getattr(obj, '__getitem__', False)
val = False if (not col) else True
if isinstance(obj, basestring):
val = False
return val | python | def is_collection(obj):
"""Tests if an object is a collection."""
col = getattr(obj, '__getitem__', False)
val = False if (not col) else True
if isinstance(obj, basestring):
val = False
return val | [
"def",
"is_collection",
"(",
"obj",
")",
":",
"col",
"=",
"getattr",
"(",
"obj",
",",
"'__getitem__'",
",",
"False",
")",
"val",
"=",
"False",
"if",
"(",
"not",
"col",
")",
"else",
"True",
"if",
"isinstance",
"(",
"obj",
",",
"basestring",
")",
":",
... | Tests if an object is a collection. | [
"Tests",
"if",
"an",
"object",
"is",
"a",
"collection",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/helpers.py#L19-L28 | train |
heroku/heroku.py | heroku/helpers.py | to_python | def to_python(obj,
in_dict,
str_keys=None,
date_keys=None,
int_keys=None,
object_map=None,
bool_keys=None,
dict_keys=None,
**kwargs):
"""Extends a given object for API Consumption.
:param obj: Object to extend.
:param in_dict: Dict to extract data from.
:param string_key... | python | def to_python(obj,
in_dict,
str_keys=None,
date_keys=None,
int_keys=None,
object_map=None,
bool_keys=None,
dict_keys=None,
**kwargs):
"""Extends a given object for API Consumption.
:param obj: Object to extend.
:param in_dict: Dict to extract data from.
:param string_key... | [
"def",
"to_python",
"(",
"obj",
",",
"in_dict",
",",
"str_keys",
"=",
"None",
",",
"date_keys",
"=",
"None",
",",
"int_keys",
"=",
"None",
",",
"object_map",
"=",
"None",
",",
"bool_keys",
"=",
"None",
",",
"dict_keys",
"=",
"None",
",",
"*",
"*",
"k... | Extends a given object for API Consumption.
:param obj: Object to extend.
:param in_dict: Dict to extract data from.
:param string_keys: List of in_dict keys that will be extracted as strings.
:param date_keys: List of in_dict keys that will be extrad as datetimes.
:param object_map: Dict of {key, ... | [
"Extends",
"a",
"given",
"object",
"for",
"API",
"Consumption",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/helpers.py#L33-L95 | train |
heroku/heroku.py | heroku/helpers.py | to_api | def to_api(in_dict, int_keys=None, date_keys=None, bool_keys=None):
"""Extends a given object for API Production."""
# Cast all int_keys to int()
if int_keys:
for in_key in int_keys:
if (in_key in in_dict) and (in_dict.get(in_key, None) is not None):
in_dict[in_key] = in... | python | def to_api(in_dict, int_keys=None, date_keys=None, bool_keys=None):
"""Extends a given object for API Production."""
# Cast all int_keys to int()
if int_keys:
for in_key in int_keys:
if (in_key in in_dict) and (in_dict.get(in_key, None) is not None):
in_dict[in_key] = in... | [
"def",
"to_api",
"(",
"in_dict",
",",
"int_keys",
"=",
"None",
",",
"date_keys",
"=",
"None",
",",
"bool_keys",
"=",
"None",
")",
":",
"# Cast all int_keys to int()",
"if",
"int_keys",
":",
"for",
"in_key",
"in",
"int_keys",
":",
"if",
"(",
"in_key",
"in",... | Extends a given object for API Production. | [
"Extends",
"a",
"given",
"object",
"for",
"API",
"Production",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/helpers.py#L99-L131 | train |
heroku/heroku.py | heroku/structures.py | SSHKeyListResource.clear | def clear(self):
"""Removes all SSH keys from a user's system."""
r = self._h._http_resource(
method='DELETE',
resource=('user', 'keys'),
)
return r.ok | python | def clear(self):
"""Removes all SSH keys from a user's system."""
r = self._h._http_resource(
method='DELETE',
resource=('user', 'keys'),
)
return r.ok | [
"def",
"clear",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"_h",
".",
"_http_resource",
"(",
"method",
"=",
"'DELETE'",
",",
"resource",
"=",
"(",
"'user'",
",",
"'keys'",
")",
",",
")",
"return",
"r",
".",
"ok"
] | Removes all SSH keys from a user's system. | [
"Removes",
"all",
"SSH",
"keys",
"from",
"a",
"user",
"s",
"system",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/structures.py#L108-L116 | train |
heroku/heroku.py | heroku/api.py | HerokuCore.authenticate | def authenticate(self, api_key):
"""Logs user into Heroku with given api_key."""
self._api_key = api_key
# Attach auth to session.
self._session.auth = ('', self._api_key)
return self._verify_api_key() | python | def authenticate(self, api_key):
"""Logs user into Heroku with given api_key."""
self._api_key = api_key
# Attach auth to session.
self._session.auth = ('', self._api_key)
return self._verify_api_key() | [
"def",
"authenticate",
"(",
"self",
",",
"api_key",
")",
":",
"self",
".",
"_api_key",
"=",
"api_key",
"# Attach auth to session.",
"self",
".",
"_session",
".",
"auth",
"=",
"(",
"''",
",",
"self",
".",
"_api_key",
")",
"return",
"self",
".",
"_verify_api... | Logs user into Heroku with given api_key. | [
"Logs",
"user",
"into",
"Heroku",
"with",
"given",
"api_key",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/api.py#L40-L47 | train |
heroku/heroku.py | heroku/api.py | HerokuCore._get_resource | def _get_resource(self, resource, obj, params=None, **kwargs):
"""Returns a mapped object from an HTTP resource."""
r = self._http_resource('GET', resource, params=params)
item = self._resource_deserialize(r.content.decode("utf-8"))
return obj.new_from_dict(item, h=self, **kwargs) | python | def _get_resource(self, resource, obj, params=None, **kwargs):
"""Returns a mapped object from an HTTP resource."""
r = self._http_resource('GET', resource, params=params)
item = self._resource_deserialize(r.content.decode("utf-8"))
return obj.new_from_dict(item, h=self, **kwargs) | [
"def",
"_get_resource",
"(",
"self",
",",
"resource",
",",
"obj",
",",
"params",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"r",
"=",
"self",
".",
"_http_resource",
"(",
"'GET'",
",",
"resource",
",",
"params",
"=",
"params",
")",
"item",
"=",
... | Returns a mapped object from an HTTP resource. | [
"Returns",
"a",
"mapped",
"object",
"from",
"an",
"HTTP",
"resource",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/api.py#L110-L115 | train |
heroku/heroku.py | heroku/api.py | HerokuCore._get_resources | def _get_resources(self, resource, obj, params=None, map=None, **kwargs):
"""Returns a list of mapped objects from an HTTP resource."""
r = self._http_resource('GET', resource, params=params)
d_items = self._resource_deserialize(r.content.decode("utf-8"))
items = [obj.new_from_dict(ite... | python | def _get_resources(self, resource, obj, params=None, map=None, **kwargs):
"""Returns a list of mapped objects from an HTTP resource."""
r = self._http_resource('GET', resource, params=params)
d_items = self._resource_deserialize(r.content.decode("utf-8"))
items = [obj.new_from_dict(ite... | [
"def",
"_get_resources",
"(",
"self",
",",
"resource",
",",
"obj",
",",
"params",
"=",
"None",
",",
"map",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"r",
"=",
"self",
".",
"_http_resource",
"(",
"'GET'",
",",
"resource",
",",
"params",
"=",
"... | Returns a list of mapped objects from an HTTP resource. | [
"Returns",
"a",
"list",
"of",
"mapped",
"objects",
"from",
"an",
"HTTP",
"resource",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/api.py#L117-L132 | train |
heroku/heroku.py | heroku/core.py | from_key | def from_key(api_key, **kwargs):
"""Returns an authenticated Heroku instance, via API Key."""
h = Heroku(**kwargs)
# Login.
h.authenticate(api_key)
return h | python | def from_key(api_key, **kwargs):
"""Returns an authenticated Heroku instance, via API Key."""
h = Heroku(**kwargs)
# Login.
h.authenticate(api_key)
return h | [
"def",
"from_key",
"(",
"api_key",
",",
"*",
"*",
"kwargs",
")",
":",
"h",
"=",
"Heroku",
"(",
"*",
"*",
"kwargs",
")",
"# Login.",
"h",
".",
"authenticate",
"(",
"api_key",
")",
"return",
"h"
] | Returns an authenticated Heroku instance, via API Key. | [
"Returns",
"an",
"authenticated",
"Heroku",
"instance",
"via",
"API",
"Key",
"."
] | cadc0a074896cf29c65a457c5c5bdb2069470af0 | https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/core.py#L12-L20 | train |
pyviz/param | param/version.py | OldDeprecatedVersion.abbrev | def abbrev(self,dev_suffix=""):
"""
Abbreviated string representation, optionally declaring whether it is
a development version.
"""
return '.'.join(str(el) for el in self.release) + \
(dev_suffix if self.commit_count > 0 or self.dirty else "") | python | def abbrev(self,dev_suffix=""):
"""
Abbreviated string representation, optionally declaring whether it is
a development version.
"""
return '.'.join(str(el) for el in self.release) + \
(dev_suffix if self.commit_count > 0 or self.dirty else "") | [
"def",
"abbrev",
"(",
"self",
",",
"dev_suffix",
"=",
"\"\"",
")",
":",
"return",
"'.'",
".",
"join",
"(",
"str",
"(",
"el",
")",
"for",
"el",
"in",
"self",
".",
"release",
")",
"+",
"(",
"dev_suffix",
"if",
"self",
".",
"commit_count",
">",
"0",
... | Abbreviated string representation, optionally declaring whether it is
a development version. | [
"Abbreviated",
"string",
"representation",
"optionally",
"declaring",
"whether",
"it",
"is",
"a",
"development",
"version",
"."
] | 8f0dafa78defa883247b40635f96cc6d5c1b3481 | https://github.com/pyviz/param/blob/8f0dafa78defa883247b40635f96cc6d5c1b3481/param/version.py#L704-L710 | train |
pyviz/param | param/version.py | OldDeprecatedVersion.verify | def verify(self, string_version=None):
"""
Check that the version information is consistent with the VCS
before doing a release. If supplied with a string version,
this is also checked against the current version. Should be
called from setup.py with the declared package version b... | python | def verify(self, string_version=None):
"""
Check that the version information is consistent with the VCS
before doing a release. If supplied with a string version,
this is also checked against the current version. Should be
called from setup.py with the declared package version b... | [
"def",
"verify",
"(",
"self",
",",
"string_version",
"=",
"None",
")",
":",
"if",
"string_version",
"and",
"string_version",
"!=",
"str",
"(",
"self",
")",
":",
"raise",
"Exception",
"(",
"\"Supplied string version does not match current version.\"",
")",
"if",
"s... | Check that the version information is consistent with the VCS
before doing a release. If supplied with a string version,
this is also checked against the current version. Should be
called from setup.py with the declared package version before
releasing to PyPI. | [
"Check",
"that",
"the",
"version",
"information",
"is",
"consistent",
"with",
"the",
"VCS",
"before",
"doing",
"a",
"release",
".",
"If",
"supplied",
"with",
"a",
"string",
"version",
"this",
"is",
"also",
"checked",
"against",
"the",
"current",
"version",
"... | 8f0dafa78defa883247b40635f96cc6d5c1b3481 | https://github.com/pyviz/param/blob/8f0dafa78defa883247b40635f96cc6d5c1b3481/param/version.py#L743-L764 | train |
pyviz/param | numbergen/__init__.py | TimeAware._check_time_fn | def _check_time_fn(self, time_instance=False):
"""
If time_fn is the global time function supplied by
param.Dynamic.time_fn, make sure Dynamic parameters are using
this time function to control their behaviour.
If time_instance is True, time_fn must be a param.Time instance.
... | python | def _check_time_fn(self, time_instance=False):
"""
If time_fn is the global time function supplied by
param.Dynamic.time_fn, make sure Dynamic parameters are using
this time function to control their behaviour.
If time_instance is True, time_fn must be a param.Time instance.
... | [
"def",
"_check_time_fn",
"(",
"self",
",",
"time_instance",
"=",
"False",
")",
":",
"if",
"time_instance",
"and",
"not",
"isinstance",
"(",
"self",
".",
"time_fn",
",",
"param",
".",
"Time",
")",
":",
"raise",
"AssertionError",
"(",
"\"%s requires a Time objec... | If time_fn is the global time function supplied by
param.Dynamic.time_fn, make sure Dynamic parameters are using
this time function to control their behaviour.
If time_instance is True, time_fn must be a param.Time instance. | [
"If",
"time_fn",
"is",
"the",
"global",
"time",
"function",
"supplied",
"by",
"param",
".",
"Dynamic",
".",
"time_fn",
"make",
"sure",
"Dynamic",
"parameters",
"are",
"using",
"this",
"time",
"function",
"to",
"control",
"their",
"behaviour",
"."
] | 8f0dafa78defa883247b40635f96cc6d5c1b3481 | https://github.com/pyviz/param/blob/8f0dafa78defa883247b40635f96cc6d5c1b3481/numbergen/__init__.py#L48-L64 | train |
pyviz/param | numbergen/__init__.py | Hash._rational | def _rational(self, val):
"""Convert the given value to a rational, if necessary."""
I32 = 4294967296 # Maximum 32 bit unsigned int (i.e. 'I') value
if isinstance(val, int):
numer, denom = val, 1
elif isinstance(val, fractions.Fraction):
numer, denom = val.numer... | python | def _rational(self, val):
"""Convert the given value to a rational, if necessary."""
I32 = 4294967296 # Maximum 32 bit unsigned int (i.e. 'I') value
if isinstance(val, int):
numer, denom = val, 1
elif isinstance(val, fractions.Fraction):
numer, denom = val.numer... | [
"def",
"_rational",
"(",
"self",
",",
"val",
")",
":",
"I32",
"=",
"4294967296",
"# Maximum 32 bit unsigned int (i.e. 'I') value",
"if",
"isinstance",
"(",
"val",
",",
"int",
")",
":",
"numer",
",",
"denom",
"=",
"val",
",",
"1",
"elif",
"isinstance",
"(",
... | Convert the given value to a rational, if necessary. | [
"Convert",
"the",
"given",
"value",
"to",
"a",
"rational",
"if",
"necessary",
"."
] | 8f0dafa78defa883247b40635f96cc6d5c1b3481 | https://github.com/pyviz/param/blob/8f0dafa78defa883247b40635f96cc6d5c1b3481/numbergen/__init__.py#L200-L215 | train |
pyviz/param | numbergen/__init__.py | TimeAwareRandomState._initialize_random_state | def _initialize_random_state(self, seed=None, shared=True, name=None):
"""
Initialization method to be called in the constructor of
subclasses to initialize the random state correctly.
If seed is None, there is no control over the random stream
(no reproducibility of the stream)... | python | def _initialize_random_state(self, seed=None, shared=True, name=None):
"""
Initialization method to be called in the constructor of
subclasses to initialize the random state correctly.
If seed is None, there is no control over the random stream
(no reproducibility of the stream)... | [
"def",
"_initialize_random_state",
"(",
"self",
",",
"seed",
"=",
"None",
",",
"shared",
"=",
"True",
",",
"name",
"=",
"None",
")",
":",
"if",
"seed",
"is",
"None",
":",
"# Equivalent to an uncontrolled seed.",
"seed",
"=",
"random",
".",
"Random",
"(",
"... | Initialization method to be called in the constructor of
subclasses to initialize the random state correctly.
If seed is None, there is no control over the random stream
(no reproducibility of the stream).
If shared is True (and not time-dependent), the random state
is shared a... | [
"Initialization",
"method",
"to",
"be",
"called",
"in",
"the",
"constructor",
"of",
"subclasses",
"to",
"initialize",
"the",
"random",
"state",
"correctly",
"."
] | 8f0dafa78defa883247b40635f96cc6d5c1b3481 | https://github.com/pyviz/param/blob/8f0dafa78defa883247b40635f96cc6d5c1b3481/numbergen/__init__.py#L300-L338 | train |
pyviz/param | numbergen/__init__.py | TimeAwareRandomState._verify_constrained_hash | def _verify_constrained_hash(self):
"""
Warn if the object name is not explicitly set.
"""
changed_params = dict(self.param.get_param_values(onlychanged=True))
if self.time_dependent and ('name' not in changed_params):
self.param.warning("Default object name used to s... | python | def _verify_constrained_hash(self):
"""
Warn if the object name is not explicitly set.
"""
changed_params = dict(self.param.get_param_values(onlychanged=True))
if self.time_dependent and ('name' not in changed_params):
self.param.warning("Default object name used to s... | [
"def",
"_verify_constrained_hash",
"(",
"self",
")",
":",
"changed_params",
"=",
"dict",
"(",
"self",
".",
"param",
".",
"get_param_values",
"(",
"onlychanged",
"=",
"True",
")",
")",
"if",
"self",
".",
"time_dependent",
"and",
"(",
"'name'",
"not",
"in",
... | Warn if the object name is not explicitly set. | [
"Warn",
"if",
"the",
"object",
"name",
"is",
"not",
"explicitly",
"set",
"."
] | 8f0dafa78defa883247b40635f96cc6d5c1b3481 | https://github.com/pyviz/param/blob/8f0dafa78defa883247b40635f96cc6d5c1b3481/numbergen/__init__.py#L341-L348 | train |
pyviz/param | setup.py | get_setup_version | def get_setup_version(reponame):
"""Use autover to get up to date version."""
# importing self into setup.py is unorthodox, but param has no
# required dependencies outside of python
from param.version import Version
return Version.setup_version(os.path.dirname(__file__),reponame,archive_commit="$Fo... | python | def get_setup_version(reponame):
"""Use autover to get up to date version."""
# importing self into setup.py is unorthodox, but param has no
# required dependencies outside of python
from param.version import Version
return Version.setup_version(os.path.dirname(__file__),reponame,archive_commit="$Fo... | [
"def",
"get_setup_version",
"(",
"reponame",
")",
":",
"# importing self into setup.py is unorthodox, but param has no",
"# required dependencies outside of python",
"from",
"param",
".",
"version",
"import",
"Version",
"return",
"Version",
".",
"setup_version",
"(",
"os",
".... | Use autover to get up to date version. | [
"Use",
"autover",
"to",
"get",
"up",
"to",
"date",
"version",
"."
] | 8f0dafa78defa883247b40635f96cc6d5c1b3481 | https://github.com/pyviz/param/blob/8f0dafa78defa883247b40635f96cc6d5c1b3481/setup.py#L8-L13 | train |
pyviz/param | param/ipython.py | ParamPager.get_param_info | def get_param_info(self, obj, include_super=True):
"""
Get the parameter dictionary, the list of modifed parameters
and the dictionary or parameter values. If include_super is
True, parameters are also collected from the super classes.
"""
params = dict(obj.param.objects... | python | def get_param_info(self, obj, include_super=True):
"""
Get the parameter dictionary, the list of modifed parameters
and the dictionary or parameter values. If include_super is
True, parameters are also collected from the super classes.
"""
params = dict(obj.param.objects... | [
"def",
"get_param_info",
"(",
"self",
",",
"obj",
",",
"include_super",
"=",
"True",
")",
":",
"params",
"=",
"dict",
"(",
"obj",
".",
"param",
".",
"objects",
"(",
"'existing'",
")",
")",
"if",
"isinstance",
"(",
"obj",
",",
"type",
")",
":",
"chang... | Get the parameter dictionary, the list of modifed parameters
and the dictionary or parameter values. If include_super is
True, parameters are also collected from the super classes. | [
"Get",
"the",
"parameter",
"dictionary",
"the",
"list",
"of",
"modifed",
"parameters",
"and",
"the",
"dictionary",
"or",
"parameter",
"values",
".",
"If",
"include_super",
"is",
"True",
"parameters",
"are",
"also",
"collected",
"from",
"the",
"super",
"classes",... | 8f0dafa78defa883247b40635f96cc6d5c1b3481 | https://github.com/pyviz/param/blob/8f0dafa78defa883247b40635f96cc6d5c1b3481/param/ipython.py#L55-L77 | train |
pyviz/param | param/ipython.py | ParamPager._build_table | def _build_table(self, info, order, max_col_len=40, only_changed=False):
"""
Collect the information about parameters needed to build a
properly formatted table and then tabulate it.
"""
info_dict, bounds_dict = {}, {}
(params, val_dict, changed) = info
col_width... | python | def _build_table(self, info, order, max_col_len=40, only_changed=False):
"""
Collect the information about parameters needed to build a
properly formatted table and then tabulate it.
"""
info_dict, bounds_dict = {}, {}
(params, val_dict, changed) = info
col_width... | [
"def",
"_build_table",
"(",
"self",
",",
"info",
",",
"order",
",",
"max_col_len",
"=",
"40",
",",
"only_changed",
"=",
"False",
")",
":",
"info_dict",
",",
"bounds_dict",
"=",
"{",
"}",
",",
"{",
"}",
"(",
"params",
",",
"val_dict",
",",
"changed",
... | Collect the information about parameters needed to build a
properly formatted table and then tabulate it. | [
"Collect",
"the",
"information",
"about",
"parameters",
"needed",
"to",
"build",
"a",
"properly",
"formatted",
"table",
"and",
"then",
"tabulate",
"it",
"."
] | 8f0dafa78defa883247b40635f96cc6d5c1b3481 | https://github.com/pyviz/param/blob/8f0dafa78defa883247b40635f96cc6d5c1b3481/param/ipython.py#L127-L176 | train |
pyviz/param | param/ipython.py | ParamPager._tabulate | def _tabulate(self, info_dict, col_widths, changed, order, bounds_dict):
"""
Returns the supplied information as a table suitable for
printing or paging.
info_dict: Dictionary of the parameters name, type and mode.
col_widths: Dictionary of column widths in characters
c... | python | def _tabulate(self, info_dict, col_widths, changed, order, bounds_dict):
"""
Returns the supplied information as a table suitable for
printing or paging.
info_dict: Dictionary of the parameters name, type and mode.
col_widths: Dictionary of column widths in characters
c... | [
"def",
"_tabulate",
"(",
"self",
",",
"info_dict",
",",
"col_widths",
",",
"changed",
",",
"order",
",",
"bounds_dict",
")",
":",
"contents",
",",
"tail",
"=",
"[",
"]",
",",
"[",
"]",
"column_set",
"=",
"set",
"(",
"k",
"for",
"row",
"in",
"info_dic... | Returns the supplied information as a table suitable for
printing or paging.
info_dict: Dictionary of the parameters name, type and mode.
col_widths: Dictionary of column widths in characters
changed: List of parameters modified from their defaults.
order: The order of ... | [
"Returns",
"the",
"supplied",
"information",
"as",
"a",
"table",
"suitable",
"for",
"printing",
"or",
"paging",
"."
] | 8f0dafa78defa883247b40635f96cc6d5c1b3481 | https://github.com/pyviz/param/blob/8f0dafa78defa883247b40635f96cc6d5c1b3481/param/ipython.py#L179-L229 | train |
pyviz/param | param/__init__.py | is_ordered_dict | def is_ordered_dict(d):
"""
Predicate checking for ordered dictionaries. OrderedDict is always
ordered, and vanilla Python dictionaries are ordered for Python 3.6+
"""
py3_ordered_dicts = (sys.version_info.major == 3) and (sys.version_info.minor >= 6)
vanilla_odicts = (sys.version_info.major > 3... | python | def is_ordered_dict(d):
"""
Predicate checking for ordered dictionaries. OrderedDict is always
ordered, and vanilla Python dictionaries are ordered for Python 3.6+
"""
py3_ordered_dicts = (sys.version_info.major == 3) and (sys.version_info.minor >= 6)
vanilla_odicts = (sys.version_info.major > 3... | [
"def",
"is_ordered_dict",
"(",
"d",
")",
":",
"py3_ordered_dicts",
"=",
"(",
"sys",
".",
"version_info",
".",
"major",
"==",
"3",
")",
"and",
"(",
"sys",
".",
"version_info",
".",
"minor",
">=",
"6",
")",
"vanilla_odicts",
"=",
"(",
"sys",
".",
"versio... | Predicate checking for ordered dictionaries. OrderedDict is always
ordered, and vanilla Python dictionaries are ordered for Python 3.6+ | [
"Predicate",
"checking",
"for",
"ordered",
"dictionaries",
".",
"OrderedDict",
"is",
"always",
"ordered",
"and",
"vanilla",
"Python",
"dictionaries",
"are",
"ordered",
"for",
"Python",
"3",
".",
"6",
"+"
] | 8f0dafa78defa883247b40635f96cc6d5c1b3481 | https://github.com/pyviz/param/blob/8f0dafa78defa883247b40635f96cc6d5c1b3481/param/__init__.py#L91-L98 | train |
pyviz/param | param/__init__.py | named_objs | def named_objs(objlist, namesdict=None):
"""
Given a list of objects, returns a dictionary mapping from
string name for the object to the object itself. Accepts
an optional name,obj dictionary, which will override any other
name if that item is present in the dictionary.
"""
objs = OrderedDi... | python | def named_objs(objlist, namesdict=None):
"""
Given a list of objects, returns a dictionary mapping from
string name for the object to the object itself. Accepts
an optional name,obj dictionary, which will override any other
name if that item is present in the dictionary.
"""
objs = OrderedDi... | [
"def",
"named_objs",
"(",
"objlist",
",",
"namesdict",
"=",
"None",
")",
":",
"objs",
"=",
"OrderedDict",
"(",
")",
"if",
"namesdict",
"is",
"not",
"None",
":",
"objtoname",
"=",
"{",
"hashable",
"(",
"v",
")",
":",
"k",
"for",
"k",
",",
"v",
"in",... | Given a list of objects, returns a dictionary mapping from
string name for the object to the object itself. Accepts
an optional name,obj dictionary, which will override any other
name if that item is present in the dictionary. | [
"Given",
"a",
"list",
"of",
"objects",
"returns",
"a",
"dictionary",
"mapping",
"from",
"string",
"name",
"for",
"the",
"object",
"to",
"the",
"object",
"itself",
".",
"Accepts",
"an",
"optional",
"name",
"obj",
"dictionary",
"which",
"will",
"override",
"an... | 8f0dafa78defa883247b40635f96cc6d5c1b3481 | https://github.com/pyviz/param/blob/8f0dafa78defa883247b40635f96cc6d5c1b3481/param/__init__.py#L117-L139 | train |
pyviz/param | param/__init__.py | guess_param_types | def guess_param_types(**kwargs):
"""
Given a set of keyword literals, promote to the appropriate
parameter type based on some simple heuristics.
"""
params = {}
for k, v in kwargs.items():
kws = dict(default=v, constant=True)
if isinstance(v, Parameter):
params[k] = v... | python | def guess_param_types(**kwargs):
"""
Given a set of keyword literals, promote to the appropriate
parameter type based on some simple heuristics.
"""
params = {}
for k, v in kwargs.items():
kws = dict(default=v, constant=True)
if isinstance(v, Parameter):
params[k] = v... | [
"def",
"guess_param_types",
"(",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"kws",
"=",
"dict",
"(",
"default",
"=",
"v",
",",
"constant",
"=",
"True",
")",
"if",
"i... | Given a set of keyword literals, promote to the appropriate
parameter type based on some simple heuristics. | [
"Given",
"a",
"set",
"of",
"keyword",
"literals",
"promote",
"to",
"the",
"appropriate",
"parameter",
"type",
"based",
"on",
"some",
"simple",
"heuristics",
"."
] | 8f0dafa78defa883247b40635f96cc6d5c1b3481 | https://github.com/pyviz/param/blob/8f0dafa78defa883247b40635f96cc6d5c1b3481/param/__init__.py#L164-L208 | train |
pyviz/param | param/__init__.py | guess_bounds | def guess_bounds(params, **overrides):
"""
Given a dictionary of Parameter instances, return a corresponding
set of copies with the bounds appropriately set.
If given a set of override keywords, use those numeric tuple bounds.
"""
guessed = {}
for name, p in params.items():
new_par... | python | def guess_bounds(params, **overrides):
"""
Given a dictionary of Parameter instances, return a corresponding
set of copies with the bounds appropriately set.
If given a set of override keywords, use those numeric tuple bounds.
"""
guessed = {}
for name, p in params.items():
new_par... | [
"def",
"guess_bounds",
"(",
"params",
",",
"*",
"*",
"overrides",
")",
":",
"guessed",
"=",
"{",
"}",
"for",
"name",
",",
"p",
"in",
"params",
".",
"items",
"(",
")",
":",
"new_param",
"=",
"copy",
".",
"copy",
"(",
"p",
")",
"if",
"isinstance",
... | Given a dictionary of Parameter instances, return a corresponding
set of copies with the bounds appropriately set.
If given a set of override keywords, use those numeric tuple bounds. | [
"Given",
"a",
"dictionary",
"of",
"Parameter",
"instances",
"return",
"a",
"corresponding",
"set",
"of",
"copies",
"with",
"the",
"bounds",
"appropriately",
"set",
"."
] | 8f0dafa78defa883247b40635f96cc6d5c1b3481 | https://github.com/pyviz/param/blob/8f0dafa78defa883247b40635f96cc6d5c1b3481/param/__init__.py#L221-L239 | train |
pyviz/param | param/__init__.py | Dynamic._initialize_generator | def _initialize_generator(self,gen,obj=None):
"""
Add 'last time' and 'last value' attributes to the generator.
"""
# CEBALERT: use a dictionary to hold these things.
if hasattr(obj,"_Dynamic_time_fn"):
gen._Dynamic_time_fn = obj._Dynamic_time_fn
gen._Dynamic... | python | def _initialize_generator(self,gen,obj=None):
"""
Add 'last time' and 'last value' attributes to the generator.
"""
# CEBALERT: use a dictionary to hold these things.
if hasattr(obj,"_Dynamic_time_fn"):
gen._Dynamic_time_fn = obj._Dynamic_time_fn
gen._Dynamic... | [
"def",
"_initialize_generator",
"(",
"self",
",",
"gen",
",",
"obj",
"=",
"None",
")",
":",
"# CEBALERT: use a dictionary to hold these things.",
"if",
"hasattr",
"(",
"obj",
",",
"\"_Dynamic_time_fn\"",
")",
":",
"gen",
".",
"_Dynamic_time_fn",
"=",
"obj",
".",
... | Add 'last time' and 'last value' attributes to the generator. | [
"Add",
"last",
"time",
"and",
"last",
"value",
"attributes",
"to",
"the",
"generator",
"."
] | 8f0dafa78defa883247b40635f96cc6d5c1b3481 | https://github.com/pyviz/param/blob/8f0dafa78defa883247b40635f96cc6d5c1b3481/param/__init__.py#L576-L590 | train |
pyviz/param | param/__init__.py | Dynamic._produce_value | def _produce_value(self,gen,force=False):
"""
Return a value from gen.
If there is no time_fn, then a new value will be returned
(i.e. gen will be asked to produce a new value).
If force is True, or the value of time_fn() is different from
what it was was last time prod... | python | def _produce_value(self,gen,force=False):
"""
Return a value from gen.
If there is no time_fn, then a new value will be returned
(i.e. gen will be asked to produce a new value).
If force is True, or the value of time_fn() is different from
what it was was last time prod... | [
"def",
"_produce_value",
"(",
"self",
",",
"gen",
",",
"force",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"gen",
",",
"\"_Dynamic_time_fn\"",
")",
":",
"time_fn",
"=",
"gen",
".",
"_Dynamic_time_fn",
"else",
":",
"time_fn",
"=",
"self",
".",
"time_fn... | Return a value from gen.
If there is no time_fn, then a new value will be returned
(i.e. gen will be asked to produce a new value).
If force is True, or the value of time_fn() is different from
what it was was last time produce_value was called, a new
value will be produced and... | [
"Return",
"a",
"value",
"from",
"gen",
"."
] | 8f0dafa78defa883247b40635f96cc6d5c1b3481 | https://github.com/pyviz/param/blob/8f0dafa78defa883247b40635f96cc6d5c1b3481/param/__init__.py#L623-L655 | train |
pyviz/param | param/__init__.py | Dynamic._inspect | def _inspect(self,obj,objtype=None):
"""Return the last generated value for this parameter."""
gen=super(Dynamic,self).__get__(obj,objtype)
if hasattr(gen,'_Dynamic_last'):
return gen._Dynamic_last
else:
return gen | python | def _inspect(self,obj,objtype=None):
"""Return the last generated value for this parameter."""
gen=super(Dynamic,self).__get__(obj,objtype)
if hasattr(gen,'_Dynamic_last'):
return gen._Dynamic_last
else:
return gen | [
"def",
"_inspect",
"(",
"self",
",",
"obj",
",",
"objtype",
"=",
"None",
")",
":",
"gen",
"=",
"super",
"(",
"Dynamic",
",",
"self",
")",
".",
"__get__",
"(",
"obj",
",",
"objtype",
")",
"if",
"hasattr",
"(",
"gen",
",",
"'_Dynamic_last'",
")",
":"... | Return the last generated value for this parameter. | [
"Return",
"the",
"last",
"generated",
"value",
"for",
"this",
"parameter",
"."
] | 8f0dafa78defa883247b40635f96cc6d5c1b3481 | https://github.com/pyviz/param/blob/8f0dafa78defa883247b40635f96cc6d5c1b3481/param/__init__.py#L666-L673 | train |
pyviz/param | param/__init__.py | Dynamic._force | def _force(self,obj,objtype=None):
"""Force a new value to be generated, and return it."""
gen=super(Dynamic,self).__get__(obj,objtype)
if hasattr(gen,'_Dynamic_last'):
return self._produce_value(gen,force=True)
else:
return gen | python | def _force(self,obj,objtype=None):
"""Force a new value to be generated, and return it."""
gen=super(Dynamic,self).__get__(obj,objtype)
if hasattr(gen,'_Dynamic_last'):
return self._produce_value(gen,force=True)
else:
return gen | [
"def",
"_force",
"(",
"self",
",",
"obj",
",",
"objtype",
"=",
"None",
")",
":",
"gen",
"=",
"super",
"(",
"Dynamic",
",",
"self",
")",
".",
"__get__",
"(",
"obj",
",",
"objtype",
")",
"if",
"hasattr",
"(",
"gen",
",",
"'_Dynamic_last'",
")",
":",
... | Force a new value to be generated, and return it. | [
"Force",
"a",
"new",
"value",
"to",
"be",
"generated",
"and",
"return",
"it",
"."
] | 8f0dafa78defa883247b40635f96cc6d5c1b3481 | https://github.com/pyviz/param/blob/8f0dafa78defa883247b40635f96cc6d5c1b3481/param/__init__.py#L676-L683 | train |
pyviz/param | param/__init__.py | Number.set_in_bounds | def set_in_bounds(self,obj,val):
"""
Set to the given value, but cropped to be within the legal bounds.
All objects are accepted, and no exceptions will be raised. See
crop_to_bounds for details on how cropping is done.
"""
if not callable(val):
bounded_val =... | python | def set_in_bounds(self,obj,val):
"""
Set to the given value, but cropped to be within the legal bounds.
All objects are accepted, and no exceptions will be raised. See
crop_to_bounds for details on how cropping is done.
"""
if not callable(val):
bounded_val =... | [
"def",
"set_in_bounds",
"(",
"self",
",",
"obj",
",",
"val",
")",
":",
"if",
"not",
"callable",
"(",
"val",
")",
":",
"bounded_val",
"=",
"self",
".",
"crop_to_bounds",
"(",
"val",
")",
"else",
":",
"bounded_val",
"=",
"val",
"super",
"(",
"Number",
... | Set to the given value, but cropped to be within the legal bounds.
All objects are accepted, and no exceptions will be raised. See
crop_to_bounds for details on how cropping is done. | [
"Set",
"to",
"the",
"given",
"value",
"but",
"cropped",
"to",
"be",
"within",
"the",
"legal",
"bounds",
".",
"All",
"objects",
"are",
"accepted",
"and",
"no",
"exceptions",
"will",
"be",
"raised",
".",
"See",
"crop_to_bounds",
"for",
"details",
"on",
"how"... | 8f0dafa78defa883247b40635f96cc6d5c1b3481 | https://github.com/pyviz/param/blob/8f0dafa78defa883247b40635f96cc6d5c1b3481/param/__init__.py#L786-L796 | train |
pyviz/param | param/__init__.py | Number.crop_to_bounds | def crop_to_bounds(self,val):
"""
Return the given value cropped to be within the hard bounds
for this parameter.
If a numeric value is passed in, check it is within the hard
bounds. If it is larger than the high bound, return the high
bound. If it's smaller, return the ... | python | def crop_to_bounds(self,val):
"""
Return the given value cropped to be within the hard bounds
for this parameter.
If a numeric value is passed in, check it is within the hard
bounds. If it is larger than the high bound, return the high
bound. If it's smaller, return the ... | [
"def",
"crop_to_bounds",
"(",
"self",
",",
"val",
")",
":",
"# Currently, values outside the bounds are silently cropped to",
"# be inside the bounds; it may be appropriate to add a warning",
"# in such cases.",
"if",
"_is_number",
"(",
"val",
")",
":",
"if",
"self",
".",
"bo... | Return the given value cropped to be within the hard bounds
for this parameter.
If a numeric value is passed in, check it is within the hard
bounds. If it is larger than the high bound, return the high
bound. If it's smaller, return the low bound. In either case, the
returned va... | [
"Return",
"the",
"given",
"value",
"cropped",
"to",
"be",
"within",
"the",
"hard",
"bounds",
"for",
"this",
"parameter",
"."
] | 8f0dafa78defa883247b40635f96cc6d5c1b3481 | https://github.com/pyviz/param/blob/8f0dafa78defa883247b40635f96cc6d5c1b3481/param/__init__.py#L801-L835 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.