repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
pycampers/zproc
zproc/util.py
strict_request_reply
def strict_request_reply(msg, send: Callable, recv: Callable): """ Ensures a strict req-reply loop, so that clients dont't receive out-of-order messages, if an exception occurs between request-reply. """ try: send(msg) except Exception: raise try: return recv() ...
python
def strict_request_reply(msg, send: Callable, recv: Callable): """ Ensures a strict req-reply loop, so that clients dont't receive out-of-order messages, if an exception occurs between request-reply. """ try: send(msg) except Exception: raise try: return recv() ...
[ "def", "strict_request_reply", "(", "msg", ",", "send", ":", "Callable", ",", "recv", ":", "Callable", ")", ":", "try", ":", "send", "(", "msg", ")", "except", "Exception", ":", "raise", "try", ":", "return", "recv", "(", ")", "except", "Exception", ":...
Ensures a strict req-reply loop, so that clients dont't receive out-of-order messages, if an exception occurs between request-reply.
[ "Ensures", "a", "strict", "req", "-", "reply", "loop", "so", "that", "clients", "dont", "t", "receive", "out", "-", "of", "-", "order", "messages", "if", "an", "exception", "occurs", "between", "request", "-", "reply", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/util.py#L220-L235
pycampers/zproc
zproc/server/tools.py
start_server
def start_server( server_address: str = None, *, backend: Callable = multiprocessing.Process ) -> Tuple[multiprocessing.Process, str]: """ Start a new zproc server. :param server_address: .. include:: /api/snippets/server_address.rst :param backend: .. include:: /api/snippets/ba...
python
def start_server( server_address: str = None, *, backend: Callable = multiprocessing.Process ) -> Tuple[multiprocessing.Process, str]: """ Start a new zproc server. :param server_address: .. include:: /api/snippets/server_address.rst :param backend: .. include:: /api/snippets/ba...
[ "def", "start_server", "(", "server_address", ":", "str", "=", "None", ",", "*", ",", "backend", ":", "Callable", "=", "multiprocessing", ".", "Process", ")", "->", "Tuple", "[", "multiprocessing", ".", "Process", ",", "str", "]", ":", "recv_conn", ",", ...
Start a new zproc server. :param server_address: .. include:: /api/snippets/server_address.rst :param backend: .. include:: /api/snippets/backend.rst :return: ` A `tuple``, containing a :py:class:`multiprocessing.Process` object for server and the server address.
[ "Start", "a", "new", "zproc", "server", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/server/tools.py#L14-L49
pycampers/zproc
zproc/server/tools.py
ping
def ping( server_address: str, *, timeout: float = None, payload: Union[bytes] = None ) -> int: """ Ping the zproc server. This can be used to easily detect if a server is alive and running, with the aid of a suitable ``timeout``. :param server_address: .. include:: /api/snippets/serve...
python
def ping( server_address: str, *, timeout: float = None, payload: Union[bytes] = None ) -> int: """ Ping the zproc server. This can be used to easily detect if a server is alive and running, with the aid of a suitable ``timeout``. :param server_address: .. include:: /api/snippets/serve...
[ "def", "ping", "(", "server_address", ":", "str", ",", "*", ",", "timeout", ":", "float", "=", "None", ",", "payload", ":", "Union", "[", "bytes", "]", "=", "None", ")", "->", "int", ":", "if", "payload", "is", "None", ":", "payload", "=", "os", ...
Ping the zproc server. This can be used to easily detect if a server is alive and running, with the aid of a suitable ``timeout``. :param server_address: .. include:: /api/snippets/server_address.rst :param timeout: The timeout in seconds. If this is set to ``None``, then it will ...
[ "Ping", "the", "zproc", "server", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/server/tools.py#L52-L107
pycampers/zproc
examples/cookie_eater.py
cookie_eater
def cookie_eater(ctx): """Eat cookies as they're baked.""" state = ctx.create_state() state["ready"] = True for _ in state.when_change("cookies"): eat_cookie(state)
python
def cookie_eater(ctx): """Eat cookies as they're baked.""" state = ctx.create_state() state["ready"] = True for _ in state.when_change("cookies"): eat_cookie(state)
[ "def", "cookie_eater", "(", "ctx", ")", ":", "state", "=", "ctx", ".", "create_state", "(", ")", "state", "[", "\"ready\"", "]", "=", "True", "for", "_", "in", "state", ".", "when_change", "(", "\"cookies\"", ")", ":", "eat_cookie", "(", "state", ")" ]
Eat cookies as they're baked.
[ "Eat", "cookies", "as", "they", "re", "baked", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/examples/cookie_eater.py#L39-L45
pycampers/zproc
zproc/task/swarm.py
Swarm.map_lazy
def map_lazy( self, target: Callable, map_iter: Sequence[Any] = None, *, map_args: Sequence[Sequence[Any]] = None, args: Sequence = None, map_kwargs: Sequence[Mapping[str, Any]] = None, kwargs: Mapping = None, pass_state: bool = False, num_...
python
def map_lazy( self, target: Callable, map_iter: Sequence[Any] = None, *, map_args: Sequence[Sequence[Any]] = None, args: Sequence = None, map_kwargs: Sequence[Mapping[str, Any]] = None, kwargs: Mapping = None, pass_state: bool = False, num_...
[ "def", "map_lazy", "(", "self", ",", "target", ":", "Callable", ",", "map_iter", ":", "Sequence", "[", "Any", "]", "=", "None", ",", "*", ",", "map_args", ":", "Sequence", "[", "Sequence", "[", "Any", "]", "]", "=", "None", ",", "args", ":", "Seque...
r""" Functional equivalent of ``map()`` in-built function, but executed in a parallel fashion. Distributes the iterables, provided in the ``map_*`` arguments to ``num_chunks`` no of worker nodes. The idea is to: 1. Split the the iterables provided in the ``map_*`` a...
[ "r", "Functional", "equivalent", "of", "map", "()", "in", "-", "built", "function", "but", "executed", "in", "a", "parallel", "fashion", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/task/swarm.py#L109-L243
pycampers/zproc
zproc/task/map_plus.py
map_plus
def map_plus(target: Callable, mi, ma, a, mk, k): """The builtin `map()`, but with superpowers.""" if a is None: a = [] if k is None: k = {} if mi is None and ma is None and mk is None: return [] elif mi is None and ma is None: return [target(*a, **mki, **k) for mki ...
python
def map_plus(target: Callable, mi, ma, a, mk, k): """The builtin `map()`, but with superpowers.""" if a is None: a = [] if k is None: k = {} if mi is None and ma is None and mk is None: return [] elif mi is None and ma is None: return [target(*a, **mki, **k) for mki ...
[ "def", "map_plus", "(", "target", ":", "Callable", ",", "mi", ",", "ma", ",", "a", ",", "mk", ",", "k", ")", ":", "if", "a", "is", "None", ":", "a", "=", "[", "]", "if", "k", "is", "None", ":", "k", "=", "{", "}", "if", "mi", "is", "None"...
The builtin `map()`, but with superpowers.
[ "The", "builtin", "map", "()", "but", "with", "superpowers", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/task/map_plus.py#L4-L26
pycampers/zproc
zproc/exceptions.py
signal_to_exception
def signal_to_exception(sig: signal.Signals) -> SignalException: """ Convert a ``signal.Signals`` to a ``SignalException``. This allows for natural, pythonic signal handing with the use of try-except blocks. .. code-block:: python import signal import zproc zproc.signal_to_ex...
python
def signal_to_exception(sig: signal.Signals) -> SignalException: """ Convert a ``signal.Signals`` to a ``SignalException``. This allows for natural, pythonic signal handing with the use of try-except blocks. .. code-block:: python import signal import zproc zproc.signal_to_ex...
[ "def", "signal_to_exception", "(", "sig", ":", "signal", ".", "Signals", ")", "->", "SignalException", ":", "signal", ".", "signal", "(", "sig", ",", "_sig_exc_handler", ")", "return", "SignalException", "(", "sig", ")" ]
Convert a ``signal.Signals`` to a ``SignalException``. This allows for natural, pythonic signal handing with the use of try-except blocks. .. code-block:: python import signal import zproc zproc.signal_to_exception(signals.SIGTERM) try: ... except zproc.Si...
[ "Convert", "a", "signal", ".", "Signals", "to", "a", "SignalException", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/exceptions.py#L63-L83
pycampers/zproc
zproc/exceptions.py
exception_to_signal
def exception_to_signal(sig: Union[SignalException, signal.Signals]): """ Rollback any changes done by :py:func:`signal_to_exception`. """ if isinstance(sig, SignalException): signum = sig.signum else: signum = sig.value signal.signal(signum, signal.SIG_DFL)
python
def exception_to_signal(sig: Union[SignalException, signal.Signals]): """ Rollback any changes done by :py:func:`signal_to_exception`. """ if isinstance(sig, SignalException): signum = sig.signum else: signum = sig.value signal.signal(signum, signal.SIG_DFL)
[ "def", "exception_to_signal", "(", "sig", ":", "Union", "[", "SignalException", ",", "signal", ".", "Signals", "]", ")", ":", "if", "isinstance", "(", "sig", ",", "SignalException", ")", ":", "signum", "=", "sig", ".", "signum", "else", ":", "signum", "=...
Rollback any changes done by :py:func:`signal_to_exception`.
[ "Rollback", "any", "changes", "done", "by", ":", "py", ":", "func", ":", "signal_to_exception", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/exceptions.py#L86-L94
pycampers/zproc
zproc/state/state.py
atomic
def atomic(fn: Callable) -> Callable: """ Wraps a function, to create an atomic operation out of it. This contract guarantees, that while an atomic ``fn`` is running - - No one, except the "callee" may access the state. - If an ``Exception`` occurs while the ``fn`` is running, the state remains un...
python
def atomic(fn: Callable) -> Callable: """ Wraps a function, to create an atomic operation out of it. This contract guarantees, that while an atomic ``fn`` is running - - No one, except the "callee" may access the state. - If an ``Exception`` occurs while the ``fn`` is running, the state remains un...
[ "def", "atomic", "(", "fn", ":", "Callable", ")", "->", "Callable", ":", "msg", "=", "{", "Msgs", ".", "cmd", ":", "Cmds", ".", "run_fn_atomically", ",", "Msgs", ".", "info", ":", "serializer", ".", "dumps_fn", "(", "fn", ")", ",", "Msgs", ".", "ar...
Wraps a function, to create an atomic operation out of it. This contract guarantees, that while an atomic ``fn`` is running - - No one, except the "callee" may access the state. - If an ``Exception`` occurs while the ``fn`` is running, the state remains unaffected. - | If a signal is sent to the "call...
[ "Wraps", "a", "function", "to", "create", "an", "atomic", "operation", "out", "of", "it", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/state/state.py#L522-L575
pycampers/zproc
zproc/state/state.py
State.fork
def fork(self, server_address: str = None, *, namespace: str = None) -> "State": r""" "Forks" this State object. Takes the same args as the :py:class:`State` constructor, except that they automatically default to the values provided during the creation of this State object. If ...
python
def fork(self, server_address: str = None, *, namespace: str = None) -> "State": r""" "Forks" this State object. Takes the same args as the :py:class:`State` constructor, except that they automatically default to the values provided during the creation of this State object. If ...
[ "def", "fork", "(", "self", ",", "server_address", ":", "str", "=", "None", ",", "*", ",", "namespace", ":", "str", "=", "None", ")", "->", "\"State\"", ":", "if", "server_address", "is", "None", ":", "server_address", "=", "self", ".", "server_address",...
r""" "Forks" this State object. Takes the same args as the :py:class:`State` constructor, except that they automatically default to the values provided during the creation of this State object. If no args are provided to this function, then it shall create a new :py:class:`Stat...
[ "r", "Forks", "this", "State", "object", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/state/state.py#L183-L203
pycampers/zproc
zproc/state/state.py
State.set
def set(self, value: dict): """ Set the state, completely over-writing the previous value. .. caution:: This kind of operation usually leads to a data race. Please take good care while using this. Use the :py:func:`atomic` deocrator if you're feeling anxio...
python
def set(self, value: dict): """ Set the state, completely over-writing the previous value. .. caution:: This kind of operation usually leads to a data race. Please take good care while using this. Use the :py:func:`atomic` deocrator if you're feeling anxio...
[ "def", "set", "(", "self", ",", "value", ":", "dict", ")", ":", "self", ".", "_s_request_reply", "(", "{", "Msgs", ".", "cmd", ":", "Cmds", ".", "set_state", ",", "Msgs", ".", "info", ":", "value", "}", ")" ]
Set the state, completely over-writing the previous value. .. caution:: This kind of operation usually leads to a data race. Please take good care while using this. Use the :py:func:`atomic` deocrator if you're feeling anxious.
[ "Set", "the", "state", "completely", "over", "-", "writing", "the", "previous", "value", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/state/state.py#L253-L265
pycampers/zproc
zproc/state/state.py
State.when_change_raw
def when_change_raw( self, *, live: bool = False, timeout: float = None, identical_okay: bool = False, start_time: bool = None, count: int = None, ) -> StateWatcher: """ A low-level hook that emits each and every state update. All other...
python
def when_change_raw( self, *, live: bool = False, timeout: float = None, identical_okay: bool = False, start_time: bool = None, count: int = None, ) -> StateWatcher: """ A low-level hook that emits each and every state update. All other...
[ "def", "when_change_raw", "(", "self", ",", "*", ",", "live", ":", "bool", "=", "False", ",", "timeout", ":", "float", "=", "None", ",", "identical_okay", ":", "bool", "=", "False", ",", "start_time", ":", "bool", "=", "None", ",", "count", ":", "int...
A low-level hook that emits each and every state update. All other state watchers are built upon this only. .. include:: /api/state/get_raw_update.rst
[ "A", "low", "-", "level", "hook", "that", "emits", "each", "and", "every", "state", "update", ".", "All", "other", "state", "watchers", "are", "built", "upon", "this", "only", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/state/state.py#L305-L327
pycampers/zproc
zproc/state/state.py
State.when_change
def when_change( self, *keys: Hashable, exclude: bool = False, live: bool = False, timeout: float = None, identical_okay: bool = False, start_time: bool = None, count: int = None, ) -> StateWatcher: """ Block until a change is observed,...
python
def when_change( self, *keys: Hashable, exclude: bool = False, live: bool = False, timeout: float = None, identical_okay: bool = False, start_time: bool = None, count: int = None, ) -> StateWatcher: """ Block until a change is observed,...
[ "def", "when_change", "(", "self", ",", "*", "keys", ":", "Hashable", ",", "exclude", ":", "bool", "=", "False", ",", "live", ":", "bool", "=", "False", ",", "timeout", ":", "float", "=", "None", ",", "identical_okay", ":", "bool", "=", "False", ",",...
Block until a change is observed, and then return a copy of the state. .. include:: /api/state/get_when_change.rst
[ "Block", "until", "a", "change", "is", "observed", "and", "then", "return", "a", "copy", "of", "the", "state", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/state/state.py#L329-L382
pycampers/zproc
zproc/state/state.py
State.when
def when( self, test_fn, *, args: Sequence = None, kwargs: Mapping = None, live: bool = False, timeout: float = None, identical_okay: bool = False, start_time: bool = None, count: int = None, ) -> StateWatcher: """ Block...
python
def when( self, test_fn, *, args: Sequence = None, kwargs: Mapping = None, live: bool = False, timeout: float = None, identical_okay: bool = False, start_time: bool = None, count: int = None, ) -> StateWatcher: """ Block...
[ "def", "when", "(", "self", ",", "test_fn", ",", "*", ",", "args", ":", "Sequence", "=", "None", ",", "kwargs", ":", "Mapping", "=", "None", ",", "live", ":", "bool", "=", "False", ",", "timeout", ":", "float", "=", "None", ",", "identical_okay", "...
Block until ``test_fn(snapshot)`` returns a "truthy" value, and then return a copy of the state. *Where-* ``snapshot`` is a ``dict``, containing a version of the state after this update was applied. .. include:: /api/state/get_when.rst
[ "Block", "until", "test_fn", "(", "snapshot", ")", "returns", "a", "truthy", "value", "and", "then", "return", "a", "copy", "of", "the", "state", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/state/state.py#L384-L425
pycampers/zproc
zproc/state/state.py
State.when_equal
def when_equal(self, key: Hashable, value: Any, **when_kwargs) -> StateWatcher: """ Block until ``state[key] == value``, and then return a copy of the state. .. include:: /api/state/get_when_equality.rst """ def _(snapshot): try: return snapshot[key]...
python
def when_equal(self, key: Hashable, value: Any, **when_kwargs) -> StateWatcher: """ Block until ``state[key] == value``, and then return a copy of the state. .. include:: /api/state/get_when_equality.rst """ def _(snapshot): try: return snapshot[key]...
[ "def", "when_equal", "(", "self", ",", "key", ":", "Hashable", ",", "value", ":", "Any", ",", "*", "*", "when_kwargs", ")", "->", "StateWatcher", ":", "def", "_", "(", "snapshot", ")", ":", "try", ":", "return", "snapshot", "[", "key", "]", "==", "...
Block until ``state[key] == value``, and then return a copy of the state. .. include:: /api/state/get_when_equality.rst
[ "Block", "until", "state", "[", "key", "]", "==", "value", "and", "then", "return", "a", "copy", "of", "the", "state", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/state/state.py#L445-L458
pycampers/zproc
zproc/state/state.py
State.when_available
def when_available(self, key: Hashable, **when_kwargs) -> StateWatcher: """ Block until ``key in state``, and then return a copy of the state. .. include:: /api/state/get_when_equality.rst """ return self.when(lambda snapshot: key in snapshot, **when_kwargs)
python
def when_available(self, key: Hashable, **when_kwargs) -> StateWatcher: """ Block until ``key in state``, and then return a copy of the state. .. include:: /api/state/get_when_equality.rst """ return self.when(lambda snapshot: key in snapshot, **when_kwargs)
[ "def", "when_available", "(", "self", ",", "key", ":", "Hashable", ",", "*", "*", "when_kwargs", ")", "->", "StateWatcher", ":", "return", "self", ".", "when", "(", "lambda", "snapshot", ":", "key", "in", "snapshot", ",", "*", "*", "when_kwargs", ")" ]
Block until ``key in state``, and then return a copy of the state. .. include:: /api/state/get_when_equality.rst
[ "Block", "until", "key", "in", "state", "and", "then", "return", "a", "copy", "of", "the", "state", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/state/state.py#L505-L511
pycampers/zproc
zproc/process.py
Process.stop
def stop(self): """ Stop this process. Once closed, it should not, and cannot be used again. :return: :py:attr:`~exitcode`. """ self.child.terminate() self._cleanup() return self.child.exitcode
python
def stop(self): """ Stop this process. Once closed, it should not, and cannot be used again. :return: :py:attr:`~exitcode`. """ self.child.terminate() self._cleanup() return self.child.exitcode
[ "def", "stop", "(", "self", ")", ":", "self", ".", "child", ".", "terminate", "(", ")", "self", ".", "_cleanup", "(", ")", "return", "self", ".", "child", ".", "exitcode" ]
Stop this process. Once closed, it should not, and cannot be used again. :return: :py:attr:`~exitcode`.
[ "Stop", "this", "process", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/process.py#L232-L242
pycampers/zproc
zproc/process.py
Process.wait
def wait(self, timeout: Union[int, float] = None): """ Wait until this process finishes execution, then return the value returned by the ``target``. This method raises a a :py:exc:`.ProcessWaitError`, if the child Process exits with a non-zero exitcode, or if something g...
python
def wait(self, timeout: Union[int, float] = None): """ Wait until this process finishes execution, then return the value returned by the ``target``. This method raises a a :py:exc:`.ProcessWaitError`, if the child Process exits with a non-zero exitcode, or if something g...
[ "def", "wait", "(", "self", ",", "timeout", ":", "Union", "[", "int", ",", "float", "]", "=", "None", ")", ":", "# try to fetch the cached result.", "if", "self", ".", "_has_returned", ":", "return", "self", ".", "_result", "if", "timeout", "is", "not", ...
Wait until this process finishes execution, then return the value returned by the ``target``. This method raises a a :py:exc:`.ProcessWaitError`, if the child Process exits with a non-zero exitcode, or if something goes wrong while communicating with the child. :param timeout: ...
[ "Wait", "until", "this", "process", "finishes", "execution", "then", "return", "the", "value", "returned", "by", "the", "target", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/process.py#L244-L299
pycampers/zproc
zproc/context.py
ProcessList.wait
def wait( self, timeout: Union[int, float] = None, safe: bool = False ) -> List[Union[Any, Exception]]: """ Call :py:meth:`~Process.wait()` on all the Processes in this list. :param timeout: Same as :py:meth:`~Process.wait()`. This parameter controls the tim...
python
def wait( self, timeout: Union[int, float] = None, safe: bool = False ) -> List[Union[Any, Exception]]: """ Call :py:meth:`~Process.wait()` on all the Processes in this list. :param timeout: Same as :py:meth:`~Process.wait()`. This parameter controls the tim...
[ "def", "wait", "(", "self", ",", "timeout", ":", "Union", "[", "int", ",", "float", "]", "=", "None", ",", "safe", ":", "bool", "=", "False", ")", "->", "List", "[", "Union", "[", "Any", ",", "Exception", "]", "]", ":", "if", "safe", ":", "_wai...
Call :py:meth:`~Process.wait()` on all the Processes in this list. :param timeout: Same as :py:meth:`~Process.wait()`. This parameter controls the timeout for all the Processes combined, not a single :py:meth:`~Process.wait()` call. :param safe: Suppress...
[ "Call", ":", "py", ":", "meth", ":", "~Process", ".", "wait", "()", "on", "all", "the", "Processes", "in", "this", "list", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/context.py#L34-L61
pycampers/zproc
zproc/context.py
Context.create_state
def create_state(self, value: dict = None, *, namespace: str = None): """ Creates a new :py:class:`State` object, sharing the same zproc server as this Context. :param value: If provided, call ``state.update(value)``. :param namespace: Use this as the namespace f...
python
def create_state(self, value: dict = None, *, namespace: str = None): """ Creates a new :py:class:`State` object, sharing the same zproc server as this Context. :param value: If provided, call ``state.update(value)``. :param namespace: Use this as the namespace f...
[ "def", "create_state", "(", "self", ",", "value", ":", "dict", "=", "None", ",", "*", ",", "namespace", ":", "str", "=", "None", ")", ":", "if", "namespace", "is", "None", ":", "namespace", "=", "self", ".", "namespace", "state", "=", "State", "(", ...
Creates a new :py:class:`State` object, sharing the same zproc server as this Context. :param value: If provided, call ``state.update(value)``. :param namespace: Use this as the namespace for the :py:class:`State` object, instead of this :py:class:`Context`\ 's names...
[ "Creates", "a", "new", ":", "py", ":", "class", ":", "State", "object", "sharing", "the", "same", "zproc", "server", "as", "this", "Context", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/context.py#L201-L218
pycampers/zproc
zproc/context.py
Context._process
def _process( self, target: Callable = None, **process_kwargs ) -> Union[Process, Callable]: r""" Produce a child process bound to this context. Can be used both as a function and decorator: .. code-block:: python :caption: Usage @zproc.process(pass...
python
def _process( self, target: Callable = None, **process_kwargs ) -> Union[Process, Callable]: r""" Produce a child process bound to this context. Can be used both as a function and decorator: .. code-block:: python :caption: Usage @zproc.process(pass...
[ "def", "_process", "(", "self", ",", "target", ":", "Callable", "=", "None", ",", "*", "*", "process_kwargs", ")", "->", "Union", "[", "Process", ",", "Callable", "]", ":", "process", "=", "Process", "(", "self", ".", "server_address", ",", "target", "...
r""" Produce a child process bound to this context. Can be used both as a function and decorator: .. code-block:: python :caption: Usage @zproc.process(pass_context=True) # you may pass some arguments here def p1(ctx): print('hello', ctx) ...
[ "r", "Produce", "a", "child", "process", "bound", "to", "this", "context", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/context.py#L230-L270
pycampers/zproc
zproc/context.py
Context.spawn
def spawn(self, *targets: Callable, count: int = 1, **process_kwargs): r""" Produce one or many child process(s) bound to this context. :param \*targets: Passed on to the :py:class:`Process` constructor, one at a time. :param count: The number of processes to sp...
python
def spawn(self, *targets: Callable, count: int = 1, **process_kwargs): r""" Produce one or many child process(s) bound to this context. :param \*targets: Passed on to the :py:class:`Process` constructor, one at a time. :param count: The number of processes to sp...
[ "def", "spawn", "(", "self", ",", "*", "targets", ":", "Callable", ",", "count", ":", "int", "=", "1", ",", "*", "*", "process_kwargs", ")", ":", "if", "not", "targets", ":", "def", "wrapper", "(", "target", ":", "Callable", ")", ":", "return", "se...
r""" Produce one or many child process(s) bound to this context. :param \*targets: Passed on to the :py:class:`Process` constructor, one at a time. :param count: The number of processes to spawn for each item in ``targets``. :param \*\*process_kwargs: ...
[ "r", "Produce", "one", "or", "many", "child", "process", "(", "s", ")", "bound", "to", "this", "context", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/context.py#L272-L303
pycampers/zproc
zproc/context.py
Context.wait
def wait( self, timeout: Union[int, float] = None, safe: bool = False ) -> List[Union[Any, Exception]]: """ alias for :py:meth:`ProcessList.wait()` """ return self.process_list.wait(timeout, safe)
python
def wait( self, timeout: Union[int, float] = None, safe: bool = False ) -> List[Union[Any, Exception]]: """ alias for :py:meth:`ProcessList.wait()` """ return self.process_list.wait(timeout, safe)
[ "def", "wait", "(", "self", ",", "timeout", ":", "Union", "[", "int", ",", "float", "]", "=", "None", ",", "safe", ":", "bool", "=", "False", ")", "->", "List", "[", "Union", "[", "Any", ",", "Exception", "]", "]", ":", "return", "self", ".", "...
alias for :py:meth:`ProcessList.wait()`
[ "alias", "for", ":", "py", ":", "meth", ":", "ProcessList", ".", "wait", "()" ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/context.py#L329-L335
chr-1x/ananas
ananas/ananas.py
_expand_scheduledict
def _expand_scheduledict(scheduledict): """Converts a dict of items, some of which are scalar and some of which are lists, to a list of dicts with scalar items.""" result = [] def f(d): nonlocal result #print(d) d2 = {} for k,v in d.items(): if isinstance(v, s...
python
def _expand_scheduledict(scheduledict): """Converts a dict of items, some of which are scalar and some of which are lists, to a list of dicts with scalar items.""" result = [] def f(d): nonlocal result #print(d) d2 = {} for k,v in d.items(): if isinstance(v, s...
[ "def", "_expand_scheduledict", "(", "scheduledict", ")", ":", "result", "=", "[", "]", "def", "f", "(", "d", ")", ":", "nonlocal", "result", "#print(d)", "d2", "=", "{", "}", "for", "k", ",", "v", "in", "d", ".", "items", "(", ")", ":", "if", "is...
Converts a dict of items, some of which are scalar and some of which are lists, to a list of dicts with scalar items.
[ "Converts", "a", "dict", "of", "items", "some", "of", "which", "are", "scalar", "and", "some", "of", "which", "are", "lists", "to", "a", "list", "of", "dicts", "with", "scalar", "items", "." ]
train
https://github.com/chr-1x/ananas/blob/e4625a3da193fa1c77119edb68d4ee18dcbc56ca/ananas/ananas.py#L55-L85
chr-1x/ananas
ananas/ananas.py
interval_next
def interval_next(f, t = datetime.now(), tLast = datetime.now()): """ Calculate the number of seconds from now until the function should next run. This function handles both cron-like and interval-like scheduling via the following: ∗ If no interval and no schedule are specified, return 0 ∗ If ...
python
def interval_next(f, t = datetime.now(), tLast = datetime.now()): """ Calculate the number of seconds from now until the function should next run. This function handles both cron-like and interval-like scheduling via the following: ∗ If no interval and no schedule are specified, return 0 ∗ If ...
[ "def", "interval_next", "(", "f", ",", "t", "=", "datetime", ".", "now", "(", ")", ",", "tLast", "=", "datetime", ".", "now", "(", ")", ")", ":", "has_interval", "=", "hasattr", "(", "f", ",", "\"interval\"", ")", "has_schedule", "=", "hasattr", "(",...
Calculate the number of seconds from now until the function should next run. This function handles both cron-like and interval-like scheduling via the following: ∗ If no interval and no schedule are specified, return 0 ∗ If an interval is specified but no schedule, return the number of seconds ...
[ "Calculate", "the", "number", "of", "seconds", "from", "now", "until", "the", "function", "should", "next", "run", ".", "This", "function", "handles", "both", "cron", "-", "like", "and", "interval", "-", "like", "scheduling", "via", "the", "following", ":", ...
train
https://github.com/chr-1x/ananas/blob/e4625a3da193fa1c77119edb68d4ee18dcbc56ca/ananas/ananas.py#L109-L152
chr-1x/ananas
ananas/ananas.py
get_mentions
def get_mentions(status_dict, exclude=[]): """ Given a status dictionary, return all people mentioned in the toot, excluding those in the list passed in exclude. """ # Canonicalise the exclusion dictionary by lowercasing all names and # removing leading @'s for i, user in enumerate(exclude):...
python
def get_mentions(status_dict, exclude=[]): """ Given a status dictionary, return all people mentioned in the toot, excluding those in the list passed in exclude. """ # Canonicalise the exclusion dictionary by lowercasing all names and # removing leading @'s for i, user in enumerate(exclude):...
[ "def", "get_mentions", "(", "status_dict", ",", "exclude", "=", "[", "]", ")", ":", "# Canonicalise the exclusion dictionary by lowercasing all names and", "# removing leading @'s", "for", "i", ",", "user", "in", "enumerate", "(", "exclude", ")", ":", "user", "=", "...
Given a status dictionary, return all people mentioned in the toot, excluding those in the list passed in exclude.
[ "Given", "a", "status", "dictionary", "return", "all", "people", "mentioned", "in", "the", "toot", "excluding", "those", "in", "the", "list", "passed", "in", "exclude", "." ]
train
https://github.com/chr-1x/ananas/blob/e4625a3da193fa1c77119edb68d4ee18dcbc56ca/ananas/ananas.py#L210-L226
chr-1x/ananas
ananas/ananas.py
PineappleBot.report_error
def report_error(self, error, location=None): """Report an error that occurred during bot operations. The default handler tries to DM the bot admin, if one is set, but more handlers can be added by using the @error_reporter decorator.""" if location == None: location = inspect.stack()[1]...
python
def report_error(self, error, location=None): """Report an error that occurred during bot operations. The default handler tries to DM the bot admin, if one is set, but more handlers can be added by using the @error_reporter decorator.""" if location == None: location = inspect.stack()[1]...
[ "def", "report_error", "(", "self", ",", "error", ",", "location", "=", "None", ")", ":", "if", "location", "==", "None", ":", "location", "=", "inspect", ".", "stack", "(", ")", "[", "1", "]", "[", "3", "]", "self", ".", "log", "(", "location", ...
Report an error that occurred during bot operations. The default handler tries to DM the bot admin, if one is set, but more handlers can be added by using the @error_reporter decorator.
[ "Report", "an", "error", "that", "occurred", "during", "bot", "operations", ".", "The", "default", "handler", "tries", "to", "DM", "the", "bot", "admin", "if", "one", "is", "set", "but", "more", "handlers", "can", "be", "added", "by", "using", "the" ]
train
https://github.com/chr-1x/ananas/blob/e4625a3da193fa1c77119edb68d4ee18dcbc56ca/ananas/ananas.py#L502-L509
chr-1x/ananas
ananas/ananas.py
PineappleBot.get_reply_visibility
def get_reply_visibility(self, status_dict): """Given a status dict, return the visibility that should be used. This behaves like Mastodon does by default. """ # Visibility rankings (higher is more limited) visibility = ("public", "unlisted", "private", "direct") default...
python
def get_reply_visibility(self, status_dict): """Given a status dict, return the visibility that should be used. This behaves like Mastodon does by default. """ # Visibility rankings (higher is more limited) visibility = ("public", "unlisted", "private", "direct") default...
[ "def", "get_reply_visibility", "(", "self", ",", "status_dict", ")", ":", "# Visibility rankings (higher is more limited)", "visibility", "=", "(", "\"public\"", ",", "\"unlisted\"", ",", "\"private\"", ",", "\"direct\"", ")", "default_visibility", "=", "visibility", "....
Given a status dict, return the visibility that should be used. This behaves like Mastodon does by default.
[ "Given", "a", "status", "dict", "return", "the", "visibility", "that", "should", "be", "used", ".", "This", "behaves", "like", "Mastodon", "does", "by", "default", "." ]
train
https://github.com/chr-1x/ananas/blob/e4625a3da193fa1c77119edb68d4ee18dcbc56ca/ananas/ananas.py#L556-L566
chr-1x/ananas
ananas/default/roll.py
spec_dice
def spec_dice(spec): """ Return the dice specification as a string in a common format """ if spec[0] == 'c': return str(spec[1]) elif spec[0] == 'r': r = spec[1:] s = "{}d{}".format(r[0], r[1]) if len(r) == 4 and ((r[2] == 'd' and r[3] < r[0]) or (r[2] == 'k' and r[3] > 0)):...
python
def spec_dice(spec): """ Return the dice specification as a string in a common format """ if spec[0] == 'c': return str(spec[1]) elif spec[0] == 'r': r = spec[1:] s = "{}d{}".format(r[0], r[1]) if len(r) == 4 and ((r[2] == 'd' and r[3] < r[0]) or (r[2] == 'k' and r[3] > 0)):...
[ "def", "spec_dice", "(", "spec", ")", ":", "if", "spec", "[", "0", "]", "==", "'c'", ":", "return", "str", "(", "spec", "[", "1", "]", ")", "elif", "spec", "[", "0", "]", "==", "'r'", ":", "r", "=", "spec", "[", "1", ":", "]", "s", "=", "...
Return the dice specification as a string in a common format
[ "Return", "the", "dice", "specification", "as", "a", "string", "in", "a", "common", "format" ]
train
https://github.com/chr-1x/ananas/blob/e4625a3da193fa1c77119edb68d4ee18dcbc56ca/ananas/default/roll.py#L155-L167
chr-1x/ananas
ananas/default/roll.py
roll_dice
def roll_dice(spec): """ Perform the dice rolls and replace all roll expressions with lists of the dice faces that landed up. """ if spec[0] == 'c': return spec if spec[0] == 'r': r = spec[1:] if len(r) == 2: return ('r', perform_roll(r[0], r[1])) k = r[3] if r[2] == 'k' else -1 ...
python
def roll_dice(spec): """ Perform the dice rolls and replace all roll expressions with lists of the dice faces that landed up. """ if spec[0] == 'c': return spec if spec[0] == 'r': r = spec[1:] if len(r) == 2: return ('r', perform_roll(r[0], r[1])) k = r[3] if r[2] == 'k' else -1 ...
[ "def", "roll_dice", "(", "spec", ")", ":", "if", "spec", "[", "0", "]", "==", "'c'", ":", "return", "spec", "if", "spec", "[", "0", "]", "==", "'r'", ":", "r", "=", "spec", "[", "1", ":", "]", "if", "len", "(", "r", ")", "==", "2", ":", "...
Perform the dice rolls and replace all roll expressions with lists of the dice faces that landed up.
[ "Perform", "the", "dice", "rolls", "and", "replace", "all", "roll", "expressions", "with", "lists", "of", "the", "dice", "faces", "that", "landed", "up", "." ]
train
https://github.com/chr-1x/ananas/blob/e4625a3da193fa1c77119edb68d4ee18dcbc56ca/ananas/default/roll.py#L169-L195
chr-1x/ananas
ananas/default/roll.py
sum_dice
def sum_dice(spec): """ Replace the dice roll arrays from roll_dice in place with summations of the rolls. """ if spec[0] == 'c': return spec[1] elif spec[0] == 'r': return sum(spec[1]) elif spec[0] == 'x': return [sum_dice(r) for r in spec[1]] elif spec[0] in ops: return (spec[0...
python
def sum_dice(spec): """ Replace the dice roll arrays from roll_dice in place with summations of the rolls. """ if spec[0] == 'c': return spec[1] elif spec[0] == 'r': return sum(spec[1]) elif spec[0] == 'x': return [sum_dice(r) for r in spec[1]] elif spec[0] in ops: return (spec[0...
[ "def", "sum_dice", "(", "spec", ")", ":", "if", "spec", "[", "0", "]", "==", "'c'", ":", "return", "spec", "[", "1", "]", "elif", "spec", "[", "0", "]", "==", "'r'", ":", "return", "sum", "(", "spec", "[", "1", "]", ")", "elif", "spec", "[", ...
Replace the dice roll arrays from roll_dice in place with summations of the rolls.
[ "Replace", "the", "dice", "roll", "arrays", "from", "roll_dice", "in", "place", "with", "summations", "of", "the", "rolls", "." ]
train
https://github.com/chr-1x/ananas/blob/e4625a3da193fa1c77119edb68d4ee18dcbc56ca/ananas/default/roll.py#L197-L206
mutalyzer/description-extractor
repeat-extractor.py
short_sequence_repeat_extractor
def short_sequence_repeat_extractor(string, min_length=1): """ Extract the short tandem repeat structure from a string. :arg string string: The string. :arg integer min_length: Minimum length of the repeat structure. """ length = len(string) k_max = length // 2 + 1 if k_max > THRESHOLD...
python
def short_sequence_repeat_extractor(string, min_length=1): """ Extract the short tandem repeat structure from a string. :arg string string: The string. :arg integer min_length: Minimum length of the repeat structure. """ length = len(string) k_max = length // 2 + 1 if k_max > THRESHOLD...
[ "def", "short_sequence_repeat_extractor", "(", "string", ",", "min_length", "=", "1", ")", ":", "length", "=", "len", "(", "string", ")", "k_max", "=", "length", "//", "2", "+", "1", "if", "k_max", ">", "THRESHOLD", ":", "k_max", "=", "THRESHOLD", "//", ...
Extract the short tandem repeat structure from a string. :arg string string: The string. :arg integer min_length: Minimum length of the repeat structure.
[ "Extract", "the", "short", "tandem", "repeat", "structure", "from", "a", "string", "." ]
train
https://github.com/mutalyzer/description-extractor/blob/9bea5f161c5038956391d77ef3841a2dcd2f1a1b/repeat-extractor.py#L37-L79
nuagenetworks/monolithe
monolithe/lib/printer.py
Printer.raiseError
def raiseError(cls, message): """ Print an error message Args: message: the message to print """ error_message = "[error] %s" % message if cls.__raise_exception__: raise Exception(error_message) cls.colorprint(error_message, Fore.RED) ...
python
def raiseError(cls, message): """ Print an error message Args: message: the message to print """ error_message = "[error] %s" % message if cls.__raise_exception__: raise Exception(error_message) cls.colorprint(error_message, Fore.RED) ...
[ "def", "raiseError", "(", "cls", ",", "message", ")", ":", "error_message", "=", "\"[error] %s\"", "%", "message", "if", "cls", ".", "__raise_exception__", ":", "raise", "Exception", "(", "error_message", ")", "cls", ".", "colorprint", "(", "error_message", ",...
Print an error message Args: message: the message to print
[ "Print", "an", "error", "message" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/lib/printer.py#L65-L76
nuagenetworks/monolithe
monolithe/lib/printer.py
Printer.json
def json(cls, message): """ Print a nice JSON output Args: message: the message to print """ if type(message) is OrderedDict: pprint(dict(message)) else: pprint(message)
python
def json(cls, message): """ Print a nice JSON output Args: message: the message to print """ if type(message) is OrderedDict: pprint(dict(message)) else: pprint(message)
[ "def", "json", "(", "cls", ",", "message", ")", ":", "if", "type", "(", "message", ")", "is", "OrderedDict", ":", "pprint", "(", "dict", "(", "message", ")", ")", "else", ":", "pprint", "(", "message", ")" ]
Print a nice JSON output Args: message: the message to print
[ "Print", "a", "nice", "JSON", "output" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/lib/printer.py#L109-L119
nuagenetworks/monolithe
monolithe/specifications/specification.py
Specification.to_dict
def to_dict(self): """ Transform the current specification to a dictionary """ data = {"model": {}} data["model"]["description"] = self.description data["model"]["entity_name"] = self.entity_name data["model"]["package"] = self.package data["model"]["resource_n...
python
def to_dict(self): """ Transform the current specification to a dictionary """ data = {"model": {}} data["model"]["description"] = self.description data["model"]["entity_name"] = self.entity_name data["model"]["package"] = self.package data["model"]["resource_n...
[ "def", "to_dict", "(", "self", ")", ":", "data", "=", "{", "\"model\"", ":", "{", "}", "}", "data", "[", "\"model\"", "]", "[", "\"description\"", "]", "=", "self", ".", "description", "data", "[", "\"model\"", "]", "[", "\"entity_name\"", "]", "=", ...
Transform the current specification to a dictionary
[ "Transform", "the", "current", "specification", "to", "a", "dictionary" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/specifications/specification.py#L101-L131
nuagenetworks/monolithe
monolithe/specifications/specification.py
Specification.from_dict
def from_dict(self, data): """ Fill the current object with information from the specification """ if "model" in data: model = data["model"] self.description = model["description"] if "description" in model else None self.package = model["package"] if "packag...
python
def from_dict(self, data): """ Fill the current object with information from the specification """ if "model" in data: model = data["model"] self.description = model["description"] if "description" in model else None self.package = model["package"] if "packag...
[ "def", "from_dict", "(", "self", ",", "data", ")", ":", "if", "\"model\"", "in", "data", ":", "model", "=", "data", "[", "\"model\"", "]", "self", ".", "description", "=", "model", "[", "\"description\"", "]", "if", "\"description\"", "in", "model", "els...
Fill the current object with information from the specification
[ "Fill", "the", "current", "object", "with", "information", "from", "the", "specification" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/specifications/specification.py#L133-L158
nuagenetworks/monolithe
monolithe/specifications/specification.py
Specification._get_apis
def _get_apis(self, apis): """ Process apis for the given model Args: model: the model processed apis: the list of apis availble for the current model relations: dict containing all relations between resources """ ret = [] for...
python
def _get_apis(self, apis): """ Process apis for the given model Args: model: the model processed apis: the list of apis availble for the current model relations: dict containing all relations between resources """ ret = [] for...
[ "def", "_get_apis", "(", "self", ",", "apis", ")", ":", "ret", "=", "[", "]", "for", "data", "in", "apis", ":", "ret", ".", "append", "(", "SpecificationAPI", "(", "specification", "=", "self", ",", "data", "=", "data", ")", ")", "return", "sorted", ...
Process apis for the given model Args: model: the model processed apis: the list of apis availble for the current model relations: dict containing all relations between resources
[ "Process", "apis", "for", "the", "given", "model" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/specifications/specification.py#L160-L173
nuagenetworks/monolithe
monolithe/generators/lang/javascript/writers/apiversionwriter.py
APIVersionWriter._read_config
def _read_config(self): """ This method reads provided json config file. """ this_dir = os.path.dirname(__file__) config_file = os.path.abspath(os.path.join(this_dir, "..", "config", "config.json")) self.generic_enum_attrs = [] self.base_attrs = [] ...
python
def _read_config(self): """ This method reads provided json config file. """ this_dir = os.path.dirname(__file__) config_file = os.path.abspath(os.path.join(this_dir, "..", "config", "config.json")) self.generic_enum_attrs = [] self.base_attrs = [] ...
[ "def", "_read_config", "(", "self", ")", ":", "this_dir", "=", "os", ".", "path", ".", "dirname", "(", "__file__", ")", "config_file", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "join", "(", "this_dir", ",", "\"..\"", ",", ...
This method reads provided json config file.
[ "This", "method", "reads", "provided", "json", "config", "file", "." ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/javascript/writers/apiversionwriter.py#L36-L70
nuagenetworks/monolithe
monolithe/generators/lang/javascript/writers/apiversionwriter.py
APIVersionWriter.perform
def perform(self, specifications): """ This method is the entry point of javascript code writer. Monolithe will call it when the javascript plugin is to generate code. """ self.enum_list = [] self.model_list = [] self.job_commands = filter(lambda attr: attr.name == 'comma...
python
def perform(self, specifications): """ This method is the entry point of javascript code writer. Monolithe will call it when the javascript plugin is to generate code. """ self.enum_list = [] self.model_list = [] self.job_commands = filter(lambda attr: attr.name == 'comma...
[ "def", "perform", "(", "self", ",", "specifications", ")", ":", "self", ".", "enum_list", "=", "[", "]", "self", ".", "model_list", "=", "[", "]", "self", ".", "job_commands", "=", "filter", "(", "lambda", "attr", ":", "attr", ".", "name", "==", "'co...
This method is the entry point of javascript code writer. Monolithe will call it when the javascript plugin is to generate code.
[ "This", "method", "is", "the", "entry", "point", "of", "javascript", "code", "writer", ".", "Monolithe", "will", "call", "it", "when", "the", "javascript", "plugin", "is", "to", "generate", "code", "." ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/javascript/writers/apiversionwriter.py#L73-L103
nuagenetworks/monolithe
monolithe/generators/lang/javascript/writers/apiversionwriter.py
APIVersionWriter._write_abstract_named_entity
def _write_abstract_named_entity(self): """ This method generates AbstractNamedEntity class js file. """ filename = "%sAbstractNamedEntity.js" % (self._class_prefix) superclass_name = "%sEntity" % (self._class_prefix) # write will write a file using a te...
python
def _write_abstract_named_entity(self): """ This method generates AbstractNamedEntity class js file. """ filename = "%sAbstractNamedEntity.js" % (self._class_prefix) superclass_name = "%sEntity" % (self._class_prefix) # write will write a file using a te...
[ "def", "_write_abstract_named_entity", "(", "self", ")", ":", "filename", "=", "\"%sAbstractNamedEntity.js\"", "%", "(", "self", ".", "_class_prefix", ")", "superclass_name", "=", "\"%sEntity\"", "%", "(", "self", ".", "_class_prefix", ")", "# write will write a file ...
This method generates AbstractNamedEntity class js file.
[ "This", "method", "generates", "AbstractNamedEntity", "class", "js", "file", "." ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/javascript/writers/apiversionwriter.py#L131-L146
nuagenetworks/monolithe
monolithe/generators/lang/javascript/writers/apiversionwriter.py
APIVersionWriter._write_model
def _write_model(self, specification): """ This method writes the ouput for a particular specification. """ if specification.allowed_job_commands and not (set(specification.allowed_job_commands).issubset(self.job_commands)): raise Exception("Invalid allowed_job_commands %s s...
python
def _write_model(self, specification): """ This method writes the ouput for a particular specification. """ if specification.allowed_job_commands and not (set(specification.allowed_job_commands).issubset(self.job_commands)): raise Exception("Invalid allowed_job_commands %s s...
[ "def", "_write_model", "(", "self", ",", "specification", ")", ":", "if", "specification", ".", "allowed_job_commands", "and", "not", "(", "set", "(", "specification", ".", "allowed_job_commands", ")", ".", "issubset", "(", "self", ".", "job_commands", ")", ")...
This method writes the ouput for a particular specification.
[ "This", "method", "writes", "the", "ouput", "for", "a", "particular", "specification", "." ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/javascript/writers/apiversionwriter.py#L148-L227
nuagenetworks/monolithe
monolithe/generators/lang/javascript/writers/apiversionwriter.py
APIVersionWriter._write_enums
def _write_enums(self, entity_name, attributes): """ This method writes the ouput for a particular specification. """ self.enum_attrs_for_locale[entity_name] = attributes; for attribute in attributes: enum_name = "%s%sEnum" % (entity_name, attribute.name[0].upper() ...
python
def _write_enums(self, entity_name, attributes): """ This method writes the ouput for a particular specification. """ self.enum_attrs_for_locale[entity_name] = attributes; for attribute in attributes: enum_name = "%s%sEnum" % (entity_name, attribute.name[0].upper() ...
[ "def", "_write_enums", "(", "self", ",", "entity_name", ",", "attributes", ")", ":", "self", ".", "enum_attrs_for_locale", "[", "entity_name", "]", "=", "attributes", "for", "attribute", "in", "attributes", ":", "enum_name", "=", "\"%s%sEnum\"", "%", "(", "ent...
This method writes the ouput for a particular specification.
[ "This", "method", "writes", "the", "ouput", "for", "a", "particular", "specification", "." ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/javascript/writers/apiversionwriter.py#L242-L257
nuagenetworks/monolithe
monolithe/lib/taskmanager.py
TaskManager.wait_until_exit
def wait_until_exit(self): """ Wait until all the threads are finished. """ [t.join() for t in self.threads] self.threads = list()
python
def wait_until_exit(self): """ Wait until all the threads are finished. """ [t.join() for t in self.threads] self.threads = list()
[ "def", "wait_until_exit", "(", "self", ")", ":", "[", "t", ".", "join", "(", ")", "for", "t", "in", "self", ".", "threads", "]", "self", ".", "threads", "=", "list", "(", ")" ]
Wait until all the threads are finished.
[ "Wait", "until", "all", "the", "threads", "are", "finished", "." ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/lib/taskmanager.py#L45-L51
nuagenetworks/monolithe
monolithe/lib/taskmanager.py
TaskManager.start_task
def start_task(self, method, *args, **kwargs): """ Start a task in a separate thread Args: method: the method to start in a separate thread args: Accept args/kwargs arguments """ thread = threading.Thread(target=method, args=args, kwargs=kwargs) ...
python
def start_task(self, method, *args, **kwargs): """ Start a task in a separate thread Args: method: the method to start in a separate thread args: Accept args/kwargs arguments """ thread = threading.Thread(target=method, args=args, kwargs=kwargs) ...
[ "def", "start_task", "(", "self", ",", "method", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "thread", "=", "threading", ".", "Thread", "(", "target", "=", "method", ",", "args", "=", "args", ",", "kwargs", "=", "kwargs", ")", "thread", "....
Start a task in a separate thread Args: method: the method to start in a separate thread args: Accept args/kwargs arguments
[ "Start", "a", "task", "in", "a", "separate", "thread" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/lib/taskmanager.py#L53-L63
nuagenetworks/monolithe
monolithe/courgette/result.py
CourgetteResult.add_report
def add_report(self, specification_name, report): """ Adds a given report with the given specification_name as key to the reports list and computes the number of success, failures and errors Args: specification_name: string representing the specif...
python
def add_report(self, specification_name, report): """ Adds a given report with the given specification_name as key to the reports list and computes the number of success, failures and errors Args: specification_name: string representing the specif...
[ "def", "add_report", "(", "self", ",", "specification_name", ",", "report", ")", ":", "self", ".", "_reports", "[", "specification_name", "]", "=", "report", "self", ".", "_total", "=", "self", ".", "_total", "+", "report", ".", "testsRun", "self", ".", ...
Adds a given report with the given specification_name as key to the reports list and computes the number of success, failures and errors Args: specification_name: string representing the specification (with ".spec") report: The
[ "Adds", "a", "given", "report", "with", "the", "given", "specification_name", "as", "key", "to", "the", "reports", "list", "and", "computes", "the", "number", "of", "success", "failures", "and", "errors" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/courgette/result.py#L67-L82
nuagenetworks/monolithe
monolithe/lib/sdkutils.py
SDKUtils.massage_type_name
def massage_type_name(cls, type_name): """ Returns a readable type according to a java type """ if type_name.lower() in ("enum", "enumeration"): return "enum" if type_name.lower() in ("str", "string"): return "string" if type_name.lower() in ("boolean",...
python
def massage_type_name(cls, type_name): """ Returns a readable type according to a java type """ if type_name.lower() in ("enum", "enumeration"): return "enum" if type_name.lower() in ("str", "string"): return "string" if type_name.lower() in ("boolean",...
[ "def", "massage_type_name", "(", "cls", ",", "type_name", ")", ":", "if", "type_name", ".", "lower", "(", ")", "in", "(", "\"enum\"", ",", "\"enumeration\"", ")", ":", "return", "\"enum\"", "if", "type_name", ".", "lower", "(", ")", "in", "(", "\"str\"",...
Returns a readable type according to a java type
[ "Returns", "a", "readable", "type", "according", "to", "a", "java", "type" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/lib/sdkutils.py#L44-L75
nuagenetworks/monolithe
monolithe/lib/sdkutils.py
SDKUtils.get_idiomatic_name_in_language
def get_idiomatic_name_in_language(cls, name, language): """ Get the name for the given language Args: name (str): the name to convert language (str): the language to use Returns: a name in the given language Example: ...
python
def get_idiomatic_name_in_language(cls, name, language): """ Get the name for the given language Args: name (str): the name to convert language (str): the language to use Returns: a name in the given language Example: ...
[ "def", "get_idiomatic_name_in_language", "(", "cls", ",", "name", ",", "language", ")", ":", "if", "language", "in", "cls", ".", "idiomatic_methods_cache", ":", "m", "=", "cls", ".", "idiomatic_methods_cache", "[", "language", "]", "if", "not", "m", ":", "re...
Get the name for the given language Args: name (str): the name to convert language (str): the language to use Returns: a name in the given language Example: get_idiomatic_name_in_language("EnterpriseNetwork", "python"...
[ "Get", "the", "name", "for", "the", "given", "language" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/lib/sdkutils.py#L141-L177
nuagenetworks/monolithe
monolithe/lib/sdkutils.py
SDKUtils.get_type_name_in_language
def get_type_name_in_language(cls, type_name, sub_type, language): """ Get the type for the given language Args: type_name (str): the type to convert language (str): the language to use Returns: a type name in the given language ...
python
def get_type_name_in_language(cls, type_name, sub_type, language): """ Get the type for the given language Args: type_name (str): the type to convert language (str): the language to use Returns: a type name in the given language ...
[ "def", "get_type_name_in_language", "(", "cls", ",", "type_name", ",", "sub_type", ",", "language", ")", ":", "if", "language", "in", "cls", ".", "type_methods_cache", ":", "m", "=", "cls", ".", "type_methods_cache", "[", "language", "]", "if", "not", "m", ...
Get the type for the given language Args: type_name (str): the type to convert language (str): the language to use Returns: a type name in the given language Example: get_type_name_in_language("Varchar", "python") ...
[ "Get", "the", "type", "for", "the", "given", "language" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/lib/sdkutils.py#L180-L216
nuagenetworks/monolithe
monolithe/generators/lang/csharp/converter.py
get_type_name
def get_type_name(type_name, sub_type=None): """ Returns a c# type according to a spec type """ if type_name == "enum": return type_name elif type_name == "boolean": return "bool" elif type_name == "integer": return "long" elif type_name == "time": return "long" ...
python
def get_type_name(type_name, sub_type=None): """ Returns a c# type according to a spec type """ if type_name == "enum": return type_name elif type_name == "boolean": return "bool" elif type_name == "integer": return "long" elif type_name == "time": return "long" ...
[ "def", "get_type_name", "(", "type_name", ",", "sub_type", "=", "None", ")", ":", "if", "type_name", "==", "\"enum\"", ":", "return", "type_name", "elif", "type_name", "==", "\"boolean\"", ":", "return", "\"bool\"", "elif", "type_name", "==", "\"integer\"", ":...
Returns a c# type according to a spec type
[ "Returns", "a", "c#", "type", "according", "to", "a", "spec", "type" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/csharp/converter.py#L29-L48
nuagenetworks/monolithe
monolithe/generators/lang/java/writers/apiversionwriter.py
APIVersionWriter._write_build_file
def _write_build_file(self): """ Write Maven build file (pom.xml) """ self.write(destination=self._base_output_directory, filename="pom.xml", template_name="pom.xml.tpl", version=self.api_version, product_accronym=self....
python
def _write_build_file(self): """ Write Maven build file (pom.xml) """ self.write(destination=self._base_output_directory, filename="pom.xml", template_name="pom.xml.tpl", version=self.api_version, product_accronym=self....
[ "def", "_write_build_file", "(", "self", ")", ":", "self", ".", "write", "(", "destination", "=", "self", ".", "_base_output_directory", ",", "filename", "=", "\"pom.xml\"", ",", "template_name", "=", "\"pom.xml.tpl\"", ",", "version", "=", "self", ".", "api_v...
Write Maven build file (pom.xml)
[ "Write", "Maven", "build", "file", "(", "pom", ".", "xml", ")" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/java/writers/apiversionwriter.py#L198-L215
nuagenetworks/monolithe
monolithe/generators/lang/go/converter.py
get_type_name
def get_type_name(type_name, sub_type=None): """ Returns a go type according to a spec type """ if type_name in ("string", "enum"): return "string" if type_name == "float": return "float64" if type_name == "boolean": return "bool" if type_name == "list": st = ...
python
def get_type_name(type_name, sub_type=None): """ Returns a go type according to a spec type """ if type_name in ("string", "enum"): return "string" if type_name == "float": return "float64" if type_name == "boolean": return "bool" if type_name == "list": st = ...
[ "def", "get_type_name", "(", "type_name", ",", "sub_type", "=", "None", ")", ":", "if", "type_name", "in", "(", "\"string\"", ",", "\"enum\"", ")", ":", "return", "\"string\"", "if", "type_name", "==", "\"float\"", ":", "return", "\"float64\"", "if", "type_n...
Returns a go type according to a spec type
[ "Returns", "a", "go", "type", "according", "to", "a", "spec", "type" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/go/converter.py#L29-L52
nuagenetworks/monolithe
monolithe/generators/lang/csharp/writers/apiversionwriter.py
APIVersionWriter._write_info
def _write_info(self): """ Write API Info file """ self.write(destination=self.output_directory, filename="vspk/SdkInfo.cs", template_name="sdkinfo.cs.tpl", version=self.api_version, product_accronym=self._product_accron...
python
def _write_info(self): """ Write API Info file """ self.write(destination=self.output_directory, filename="vspk/SdkInfo.cs", template_name="sdkinfo.cs.tpl", version=self.api_version, product_accronym=self._product_accron...
[ "def", "_write_info", "(", "self", ")", ":", "self", ".", "write", "(", "destination", "=", "self", ".", "output_directory", ",", "filename", "=", "\"vspk/SdkInfo.cs\"", ",", "template_name", "=", "\"sdkinfo.cs.tpl\"", ",", "version", "=", "self", ".", "api_ve...
Write API Info file
[ "Write", "API", "Info", "file" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/csharp/writers/apiversionwriter.py#L125-L140
nuagenetworks/monolithe
monolithe/generators/lang/csharp/writers/apiversionwriter.py
APIVersionWriter._write_model
def _write_model(self, specification, specification_set): """ Write autogenerate specification file """ filename = "vspk/%s%s.cs" % (self._class_prefix, specification.entity_name) override_content = self._extract_override_content(specification.entity_name) superclass_name = "Re...
python
def _write_model(self, specification, specification_set): """ Write autogenerate specification file """ filename = "vspk/%s%s.cs" % (self._class_prefix, specification.entity_name) override_content = self._extract_override_content(specification.entity_name) superclass_name = "Re...
[ "def", "_write_model", "(", "self", ",", "specification", ",", "specification_set", ")", ":", "filename", "=", "\"vspk/%s%s.cs\"", "%", "(", "self", ".", "_class_prefix", ",", "specification", ".", "entity_name", ")", "override_content", "=", "self", ".", "_extr...
Write autogenerate specification file
[ "Write", "autogenerate", "specification", "file" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/csharp/writers/apiversionwriter.py#L142-L173
nuagenetworks/monolithe
monolithe/generators/lang/csharp/writers/apiversionwriter.py
APIVersionWriter._write_fetcher
def _write_fetcher(self, specification, specification_set): """ Write fetcher """ destination = "%s" % (self.output_directory) base_name = "%sFetcher" % specification.entity_name_plural filename = "vspk/%s%s.cs" % (self._class_prefix, base_name) override_content = self._...
python
def _write_fetcher(self, specification, specification_set): """ Write fetcher """ destination = "%s" % (self.output_directory) base_name = "%sFetcher" % specification.entity_name_plural filename = "vspk/%s%s.cs" % (self._class_prefix, base_name) override_content = self._...
[ "def", "_write_fetcher", "(", "self", ",", "specification", ",", "specification_set", ")", ":", "destination", "=", "\"%s\"", "%", "(", "self", ".", "output_directory", ")", "base_name", "=", "\"%sFetcher\"", "%", "specification", ".", "entity_name_plural", "filen...
Write fetcher
[ "Write", "fetcher" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/csharp/writers/apiversionwriter.py#L175-L197
nuagenetworks/monolithe
monolithe/generators/lang/csharp/writers/apiversionwriter.py
APIVersionWriter._set_enum_list_local_type
def _set_enum_list_local_type(self, specifications): """ This method is needed until get_type_name() is enhanced to include specification subtype and local_name """ for rest_name, specification in specifications.items(): for attribute in specification.attributes: if a...
python
def _set_enum_list_local_type(self, specifications): """ This method is needed until get_type_name() is enhanced to include specification subtype and local_name """ for rest_name, specification in specifications.items(): for attribute in specification.attributes: if a...
[ "def", "_set_enum_list_local_type", "(", "self", ",", "specifications", ")", ":", "for", "rest_name", ",", "specification", "in", "specifications", ".", "items", "(", ")", ":", "for", "attribute", "in", "specification", ".", "attributes", ":", "if", "attribute",...
This method is needed until get_type_name() is enhanced to include specification subtype and local_name
[ "This", "method", "is", "needed", "until", "get_type_name", "()", "is", "enhanced", "to", "include", "specification", "subtype", "and", "local_name" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/csharp/writers/apiversionwriter.py#L291-L320
nuagenetworks/monolithe
monolithe/specifications/specification_attribute.py
SpecificationAttribute.to_dict
def to_dict(self): """ Transform an attribute to a dict """ data = {} # mandatory characteristics data["name"] = self.name data["description"] = self.description if self.description and len(self.description) else None data["type"] = self.type if self.type and len...
python
def to_dict(self): """ Transform an attribute to a dict """ data = {} # mandatory characteristics data["name"] = self.name data["description"] = self.description if self.description and len(self.description) else None data["type"] = self.type if self.type and len...
[ "def", "to_dict", "(", "self", ")", ":", "data", "=", "{", "}", "# mandatory characteristics", "data", "[", "\"name\"", "]", "=", "self", ".", "name", "data", "[", "\"description\"", "]", "=", "self", ".", "description", "if", "self", ".", "description", ...
Transform an attribute to a dict
[ "Transform", "an", "attribute", "to", "a", "dict" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/specifications/specification_attribute.py#L158-L191
nuagenetworks/monolithe
monolithe/generators/lang/vro/writers/apiversionwriter.py
APIVersionWriter._write_model
def _write_model(self, specification, specification_set, output_directory, package_name): """ Write autogenerate specification file """ template_file = "o11nplugin-core/model.java.tpl" filename = "%s%s.java" % (self._class_prefix, specification.entity_name) override_content = s...
python
def _write_model(self, specification, specification_set, output_directory, package_name): """ Write autogenerate specification file """ template_file = "o11nplugin-core/model.java.tpl" filename = "%s%s.java" % (self._class_prefix, specification.entity_name) override_content = s...
[ "def", "_write_model", "(", "self", ",", "specification", ",", "specification_set", ",", "output_directory", ",", "package_name", ")", ":", "template_file", "=", "\"o11nplugin-core/model.java.tpl\"", "filename", "=", "\"%s%s.java\"", "%", "(", "self", ".", "_class_pre...
Write autogenerate specification file
[ "Write", "autogenerate", "specification", "file" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/vro/writers/apiversionwriter.py#L230-L273
nuagenetworks/monolithe
monolithe/generators/lang/vro/writers/apiversionwriter.py
APIVersionWriter._write_enum
def _write_enum(self, specification, attribute, output_directory, package_name): """ Write autogenerate specification file """ enum_name = specification.entity_name + attribute.local_name[0:1].upper() + attribute.local_name[1:] template_file = "o11nplugin-core/enum.java.tpl" des...
python
def _write_enum(self, specification, attribute, output_directory, package_name): """ Write autogenerate specification file """ enum_name = specification.entity_name + attribute.local_name[0:1].upper() + attribute.local_name[1:] template_file = "o11nplugin-core/enum.java.tpl" des...
[ "def", "_write_enum", "(", "self", ",", "specification", ",", "attribute", ",", "output_directory", ",", "package_name", ")", ":", "enum_name", "=", "specification", ".", "entity_name", "+", "attribute", ".", "local_name", "[", "0", ":", "1", "]", ".", "uppe...
Write autogenerate specification file
[ "Write", "autogenerate", "specification", "file" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/vro/writers/apiversionwriter.py#L518-L536
nuagenetworks/monolithe
monolithe/generators/lib/templatefilewriter.py
_FileWriter.write
def write(self, destination, filename, content): """ Write a file at the specific destination with the content. Args: destination (string): the destination location filename (string): the filename that will be written content (string): the content of ...
python
def write(self, destination, filename, content): """ Write a file at the specific destination with the content. Args: destination (string): the destination location filename (string): the filename that will be written content (string): the content of ...
[ "def", "write", "(", "self", ",", "destination", ",", "filename", ",", "content", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "destination", ")", ":", "try", ":", "os", ".", "makedirs", "(", "destination", ")", "except", ":", "# The...
Write a file at the specific destination with the content. Args: destination (string): the destination location filename (string): the filename that will be written content (string): the content of the filename
[ "Write", "a", "file", "at", "the", "specific", "destination", "with", "the", "content", "." ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lib/templatefilewriter.py#L39-L58
nuagenetworks/monolithe
monolithe/generators/lib/templatefilewriter.py
TemplateFileWriter.write
def write(self, destination, filename, template_name, **kwargs): """ Write a file according to the template name Args: destination (string): the destination location filename (string): the filename that will be written template_name (string): the name...
python
def write(self, destination, filename, template_name, **kwargs): """ Write a file according to the template name Args: destination (string): the destination location filename (string): the filename that will be written template_name (string): the name...
[ "def", "write", "(", "self", ",", "destination", ",", "filename", ",", "template_name", ",", "*", "*", "kwargs", ")", ":", "template", "=", "self", ".", "env", ".", "get_template", "(", "template_name", ")", "content", "=", "template", ".", "render", "("...
Write a file according to the template name Args: destination (string): the destination location filename (string): the filename that will be written template_name (string): the name of the template kwargs (dict): all attribute that will be pa...
[ "Write", "a", "file", "according", "to", "the", "template", "name" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lib/templatefilewriter.py#L76-L87
nuagenetworks/monolithe
monolithe/generators/lang/python/writers/apiversionwriter.py
APIVersionWriter._write_session
def _write_session(self): """ Write SDK session file Args: version (str): the version of the server """ base_name = "%ssession" % self._product_accronym.lower() filename = "%s%s.py" % (self._class_prefix.lower(), base_name) override_content = self._e...
python
def _write_session(self): """ Write SDK session file Args: version (str): the version of the server """ base_name = "%ssession" % self._product_accronym.lower() filename = "%s%s.py" % (self._class_prefix.lower(), base_name) override_content = self._e...
[ "def", "_write_session", "(", "self", ")", ":", "base_name", "=", "\"%ssession\"", "%", "self", ".", "_product_accronym", ".", "lower", "(", ")", "filename", "=", "\"%s%s.py\"", "%", "(", "self", ".", "_class_prefix", ".", "lower", "(", ")", ",", "base_nam...
Write SDK session file Args: version (str): the version of the server
[ "Write", "SDK", "session", "file" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/python/writers/apiversionwriter.py#L84-L102
nuagenetworks/monolithe
monolithe/generators/lang/python/writers/apiversionwriter.py
APIVersionWriter._write_init_models
def _write_init_models(self, filenames): """ Write init file Args: filenames (dict): dict of filename and classes """ self.write(destination=self.output_directory, filename="__init__.py", template_name="__init_model__.py.tpl", filenames=self._pre...
python
def _write_init_models(self, filenames): """ Write init file Args: filenames (dict): dict of filename and classes """ self.write(destination=self.output_directory, filename="__init__.py", template_name="__init_model__.py.tpl", filenames=self._pre...
[ "def", "_write_init_models", "(", "self", ",", "filenames", ")", ":", "self", ".", "write", "(", "destination", "=", "self", ".", "output_directory", ",", "filename", "=", "\"__init__.py\"", ",", "template_name", "=", "\"__init_model__.py.tpl\"", ",", "filenames",...
Write init file Args: filenames (dict): dict of filename and classes
[ "Write", "init", "file" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/python/writers/apiversionwriter.py#L117-L129
nuagenetworks/monolithe
monolithe/generators/lang/python/writers/apiversionwriter.py
APIVersionWriter._write_model
def _write_model(self, specification, specification_set): """ Write autogenerate specification file """ filename = "%s%s.py" % (self._class_prefix.lower(), specification.entity_name.lower()) override_content = self._extract_override_content(specification.entity_name) constants ...
python
def _write_model(self, specification, specification_set): """ Write autogenerate specification file """ filename = "%s%s.py" % (self._class_prefix.lower(), specification.entity_name.lower()) override_content = self._extract_override_content(specification.entity_name) constants ...
[ "def", "_write_model", "(", "self", ",", "specification", ",", "specification_set", ")", ":", "filename", "=", "\"%s%s.py\"", "%", "(", "self", ".", "_class_prefix", ".", "lower", "(", ")", ",", "specification", ".", "entity_name", ".", "lower", "(", ")", ...
Write autogenerate specification file
[ "Write", "autogenerate", "specification", "file" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/python/writers/apiversionwriter.py#L141-L162
nuagenetworks/monolithe
monolithe/generators/lang/python/writers/apiversionwriter.py
APIVersionWriter._write_init_fetchers
def _write_init_fetchers(self, filenames): """ Write fetcher init file Args: filenames (dict): dict of filename and classes """ destination = "%s%s" % (self.output_directory, self.fetchers_path) self.write(destination=destination, filename="__init__.py", tem...
python
def _write_init_fetchers(self, filenames): """ Write fetcher init file Args: filenames (dict): dict of filename and classes """ destination = "%s%s" % (self.output_directory, self.fetchers_path) self.write(destination=destination, filename="__init__.py", tem...
[ "def", "_write_init_fetchers", "(", "self", ",", "filenames", ")", ":", "destination", "=", "\"%s%s\"", "%", "(", "self", ".", "output_directory", ",", "self", ".", "fetchers_path", ")", "self", ".", "write", "(", "destination", "=", "destination", ",", "fil...
Write fetcher init file Args: filenames (dict): dict of filename and classes
[ "Write", "fetcher", "init", "file" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/python/writers/apiversionwriter.py#L164-L176
nuagenetworks/monolithe
monolithe/generators/lang/python/writers/apiversionwriter.py
APIVersionWriter._write_fetcher
def _write_fetcher(self, specification, specification_set): """ Write fetcher """ destination = "%s%s" % (self.output_directory, self.fetchers_path) base_name = "%s_fetcher" % specification.entity_name_plural.lower() filename = "%s%s.py" % (self._class_prefix.lower(), base_name)...
python
def _write_fetcher(self, specification, specification_set): """ Write fetcher """ destination = "%s%s" % (self.output_directory, self.fetchers_path) base_name = "%s_fetcher" % specification.entity_name_plural.lower() filename = "%s%s.py" % (self._class_prefix.lower(), base_name)...
[ "def", "_write_fetcher", "(", "self", ",", "specification", ",", "specification_set", ")", ":", "destination", "=", "\"%s%s\"", "%", "(", "self", ".", "output_directory", ",", "self", ".", "fetchers_path", ")", "base_name", "=", "\"%s_fetcher\"", "%", "specifica...
Write fetcher
[ "Write", "fetcher" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/python/writers/apiversionwriter.py#L178-L195
nuagenetworks/monolithe
monolithe/generators/lang/python/writers/apiversionwriter.py
APIVersionWriter._extract_constants
def _extract_constants(self, specification): """ Removes attributes and computes constants """ constants = {} for attribute in specification.attributes: if attribute.allowed_choices and len(attribute.allowed_choices) > 0: name = attribute.local_name.upper(...
python
def _extract_constants(self, specification): """ Removes attributes and computes constants """ constants = {} for attribute in specification.attributes: if attribute.allowed_choices and len(attribute.allowed_choices) > 0: name = attribute.local_name.upper(...
[ "def", "_extract_constants", "(", "self", ",", "specification", ")", ":", "constants", "=", "{", "}", "for", "attribute", "in", "specification", ".", "attributes", ":", "if", "attribute", ".", "allowed_choices", "and", "len", "(", "attribute", ".", "allowed_ch...
Removes attributes and computes constants
[ "Removes", "attributes", "and", "computes", "constants" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/python/writers/apiversionwriter.py#L244-L259
nuagenetworks/monolithe
monolithe/courgette/courgette.py
Courgette.run
def run(self, configurations): """ Run all tests Returns: A dictionnary containing tests results. """ result = CourgetteResult() for configuration in configurations: runner = CourgetteTestsRunner(url=self.url, ...
python
def run(self, configurations): """ Run all tests Returns: A dictionnary containing tests results. """ result = CourgetteResult() for configuration in configurations: runner = CourgetteTestsRunner(url=self.url, ...
[ "def", "run", "(", "self", ",", "configurations", ")", ":", "result", "=", "CourgetteResult", "(", ")", "for", "configuration", "in", "configurations", ":", "runner", "=", "CourgetteTestsRunner", "(", "url", "=", "self", ".", "url", ",", "username", "=", "...
Run all tests Returns: A dictionnary containing tests results.
[ "Run", "all", "tests" ]
train
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/courgette/courgette.py#L57-L82
agiliq/django-graphos
graphos/renderers/highcharts.py
BaseHighCharts.get_series
def get_series(self): """ Example usage: data = [ ['Year', 'Sales', 'Expenses', 'Items Sold', 'Net Profit'], ['2004', 1000, 400, 100, 600], ['2005', 1170, 460, 120, 310], ['2006', 660, 1120, 50, -460], ['2007', 1030, ...
python
def get_series(self): """ Example usage: data = [ ['Year', 'Sales', 'Expenses', 'Items Sold', 'Net Profit'], ['2004', 1000, 400, 100, 600], ['2005', 1170, 460, 120, 310], ['2006', 660, 1120, 50, -460], ['2007', 1030, ...
[ "def", "get_series", "(", "self", ")", ":", "data", "=", "self", ".", "get_data", "(", ")", "series_names", "=", "data", "[", "0", "]", "[", "1", ":", "]", "serieses", "=", "[", "]", "options", "=", "self", ".", "get_options", "(", ")", "if", "'a...
Example usage: data = [ ['Year', 'Sales', 'Expenses', 'Items Sold', 'Net Profit'], ['2004', 1000, 400, 100, 600], ['2005', 1170, 460, 120, 310], ['2006', 660, 1120, 50, -460], ['2007', 1030, 540, 100, 200], ] ...
[ "Example", "usage", ":", "data", "=", "[", "[", "Year", "Sales", "Expenses", "Items", "Sold", "Net", "Profit", "]", "[", "2004", "1000", "400", "100", "600", "]", "[", "2005", "1170", "460", "120", "310", "]", "[", "2006", "660", "1120", "50", "-",...
train
https://github.com/agiliq/django-graphos/blob/2f11e98de8a51f808e536099e830b2fc3a508a6a/graphos/renderers/highcharts.py#L24-L72
agiliq/django-graphos
graphos/utils.py
get_db
def get_db(db_name=None): """ GetDB - simple function to wrap getting a database connection from the connection pool. """ import pymongo return pymongo.Connection(host=DB_HOST, port=DB_PORT)[db_name]
python
def get_db(db_name=None): """ GetDB - simple function to wrap getting a database connection from the connection pool. """ import pymongo return pymongo.Connection(host=DB_HOST, port=DB_PORT)[db_name]
[ "def", "get_db", "(", "db_name", "=", "None", ")", ":", "import", "pymongo", "return", "pymongo", ".", "Connection", "(", "host", "=", "DB_HOST", ",", "port", "=", "DB_PORT", ")", "[", "db_name", "]" ]
GetDB - simple function to wrap getting a database connection from the connection pool.
[ "GetDB", "-", "simple", "function", "to", "wrap", "getting", "a", "database", "connection", "from", "the", "connection", "pool", "." ]
train
https://github.com/agiliq/django-graphos/blob/2f11e98de8a51f808e536099e830b2fc3a508a6a/graphos/utils.py#L35-L41
vstconsulting/vstutils
vstutils/api/doc_generator.py
VSTOpenApiBase.load_yaml
def load_yaml(self): ''' Load OpenAPI specification from yaml file. Path to file taking from command `vst_openapi`. :return: ''' env = self.state.document.settings.env relpath, abspath = env.relfn2path(directives.path(self.arguments[0])) env.note_dependen...
python
def load_yaml(self): ''' Load OpenAPI specification from yaml file. Path to file taking from command `vst_openapi`. :return: ''' env = self.state.document.settings.env relpath, abspath = env.relfn2path(directives.path(self.arguments[0])) env.note_dependen...
[ "def", "load_yaml", "(", "self", ")", ":", "env", "=", "self", ".", "state", ".", "document", ".", "settings", ".", "env", "relpath", ",", "abspath", "=", "env", ".", "relfn2path", "(", "directives", ".", "path", "(", "self", ".", "arguments", "[", "...
Load OpenAPI specification from yaml file. Path to file taking from command `vst_openapi`. :return:
[ "Load", "OpenAPI", "specification", "from", "yaml", "file", ".", "Path", "to", "file", "taking", "from", "command", "vst_openapi", ".", ":", "return", ":" ]
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/api/doc_generator.py#L56-L74
vstconsulting/vstutils
vstutils/api/doc_generator.py
VSTOpenApiBase.write
def write(self, value, indent_depth=0): ''' Add lines to ViewList, for further rendering. :param value: --line that would be added to render list :type value: str, unicode :param indent_depth: --value that show indent from left border :type indent_depth: integer :...
python
def write(self, value, indent_depth=0): ''' Add lines to ViewList, for further rendering. :param value: --line that would be added to render list :type value: str, unicode :param indent_depth: --value that show indent from left border :type indent_depth: integer :...
[ "def", "write", "(", "self", ",", "value", ",", "indent_depth", "=", "0", ")", ":", "indent_depth", "=", "indent_depth", "self", ".", "__view_list", ".", "append", "(", "self", ".", "indent", "*", "indent_depth", "+", "value", ",", "'<openapi>'", ")" ]
Add lines to ViewList, for further rendering. :param value: --line that would be added to render list :type value: str, unicode :param indent_depth: --value that show indent from left border :type indent_depth: integer :return:
[ "Add", "lines", "to", "ViewList", "for", "further", "rendering", ".", ":", "param", "value", ":", "--", "line", "that", "would", "be", "added", "to", "render", "list", ":", "type", "value", ":", "str", "unicode", ":", "param", "indent_depth", ":", "--", ...
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/api/doc_generator.py#L76-L86
vstconsulting/vstutils
vstutils/api/doc_generator.py
VSTOpenApiBase.run
def run(self): ''' Main function for prepare and render OpenAPI specification :return: ''' # Loading yaml self.load_yaml() # Print paths from schema section_title = '**API Paths**' self.write(section_title) self.write('=' * len(section_tit...
python
def run(self): ''' Main function for prepare and render OpenAPI specification :return: ''' # Loading yaml self.load_yaml() # Print paths from schema section_title = '**API Paths**' self.write(section_title) self.write('=' * len(section_tit...
[ "def", "run", "(", "self", ")", ":", "# Loading yaml", "self", ".", "load_yaml", "(", ")", "# Print paths from schema", "section_title", "=", "'**API Paths**'", "self", ".", "write", "(", "section_title", ")", "self", ".", "write", "(", "'='", "*", "len", "(...
Main function for prepare and render OpenAPI specification :return:
[ "Main", "function", "for", "prepare", "and", "render", "OpenAPI", "specification", ":", "return", ":" ]
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/api/doc_generator.py#L88-L112
vstconsulting/vstutils
vstutils/api/doc_generator.py
VSTOpenApiBase.print_paths
def print_paths(self): ''' Cycle for prepare information about paths :return: ''' for path_key, path_value in self.paths.items(): # Handler for request in path self.current_path = path_key for request_key, request_value in path_value.items(): ...
python
def print_paths(self): ''' Cycle for prepare information about paths :return: ''' for path_key, path_value in self.paths.items(): # Handler for request in path self.current_path = path_key for request_key, request_value in path_value.items(): ...
[ "def", "print_paths", "(", "self", ")", ":", "for", "path_key", ",", "path_value", "in", "self", ".", "paths", ".", "items", "(", ")", ":", "# Handler for request in path", "self", ".", "current_path", "=", "path_key", "for", "request_key", ",", "request_value...
Cycle for prepare information about paths :return:
[ "Cycle", "for", "prepare", "information", "about", "paths", ":", "return", ":" ]
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/api/doc_generator.py#L114-L129
vstconsulting/vstutils
vstutils/api/doc_generator.py
VSTOpenApiBase.print_schemas
def print_schemas(self): ''' Print all schemas, one by one :return: ''' self.indent_depth += 1 for i in self.definitions: def_name = i.split('/')[-1] self.write('.. _{}:'.format(def_name)) self.write('') self.write('{} Schem...
python
def print_schemas(self): ''' Print all schemas, one by one :return: ''' self.indent_depth += 1 for i in self.definitions: def_name = i.split('/')[-1] self.write('.. _{}:'.format(def_name)) self.write('') self.write('{} Schem...
[ "def", "print_schemas", "(", "self", ")", ":", "self", ".", "indent_depth", "+=", "1", "for", "i", "in", "self", ".", "definitions", ":", "def_name", "=", "i", ".", "split", "(", "'/'", ")", "[", "-", "1", "]", "self", ".", "write", "(", "'.. _{}:'...
Print all schemas, one by one :return:
[ "Print", "all", "schemas", "one", "by", "one", ":", "return", ":" ]
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/api/doc_generator.py#L131-L151
vstconsulting/vstutils
vstutils/api/doc_generator.py
VSTOpenApiBase.get_main_title
def get_main_title(self, path_name, request_name): ''' Get title, from request type and path :param path_name: --path for create title :type path_name: str, unicode :param request_name: --name of request :type request_name: str, unicode :return: ''' ...
python
def get_main_title(self, path_name, request_name): ''' Get title, from request type and path :param path_name: --path for create title :type path_name: str, unicode :param request_name: --name of request :type request_name: str, unicode :return: ''' ...
[ "def", "get_main_title", "(", "self", ",", "path_name", ",", "request_name", ")", ":", "main_title", "=", "'.. http:{}:: {}'", ".", "format", "(", "request_name", ",", "path_name", ")", "self", ".", "write", "(", "main_title", ")", "self", ".", "write", "(",...
Get title, from request type and path :param path_name: --path for create title :type path_name: str, unicode :param request_name: --name of request :type request_name: str, unicode :return:
[ "Get", "title", "from", "request", "type", "and", "path" ]
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/api/doc_generator.py#L153-L165
vstconsulting/vstutils
vstutils/api/doc_generator.py
VSTOpenApiBase.get_status_code_and_schema_rst
def get_status_code_and_schema_rst(self, responses): ''' Function for prepare information about responses with example, prepare only responses with status code from `101` to `299` :param responses: -- dictionary that contains responses, with status code as key :type responses: di...
python
def get_status_code_and_schema_rst(self, responses): ''' Function for prepare information about responses with example, prepare only responses with status code from `101` to `299` :param responses: -- dictionary that contains responses, with status code as key :type responses: di...
[ "def", "get_status_code_and_schema_rst", "(", "self", ",", "responses", ")", ":", "for", "status_code", ",", "response_schema", "in", "responses", ".", "items", "(", ")", ":", "status_code", "=", "int", "(", "status_code", ")", "schema", "=", "response_schema", ...
Function for prepare information about responses with example, prepare only responses with status code from `101` to `299` :param responses: -- dictionary that contains responses, with status code as key :type responses: dict :return:
[ "Function", "for", "prepare", "information", "about", "responses", "with", "example", "prepare", "only", "responses", "with", "status", "code", "from", "101", "to", "299", ":", "param", "responses", ":", "--", "dictionary", "that", "contains", "responses", "with...
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/api/doc_generator.py#L167-L193
vstconsulting/vstutils
vstutils/api/doc_generator.py
VSTOpenApiBase.schema_handler
def schema_handler(self, schema): ''' Function prepare body of response with examples and create detailed information about response fields :param schema: --dictionary with information about answer :type schema: dict :return: ''' dict_for_render = schema....
python
def schema_handler(self, schema): ''' Function prepare body of response with examples and create detailed information about response fields :param schema: --dictionary with information about answer :type schema: dict :return: ''' dict_for_render = schema....
[ "def", "schema_handler", "(", "self", ",", "schema", ")", ":", "dict_for_render", "=", "schema", ".", "get", "(", "'properties'", ",", "dict", "(", ")", ")", ".", "items", "(", ")", "if", "schema", ".", "get", "(", "'$ref'", ",", "None", ")", ":", ...
Function prepare body of response with examples and create detailed information about response fields :param schema: --dictionary with information about answer :type schema: dict :return:
[ "Function", "prepare", "body", "of", "response", "with", "examples", "and", "create", "detailed", "information", "about", "response", "fields" ]
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/api/doc_generator.py#L195-L231
vstconsulting/vstutils
vstutils/api/doc_generator.py
VSTOpenApiBase.get_json_props_for_response
def get_json_props_for_response(self, var_type, option_value): ''' Prepare JSON section with detailed information about response :param var_type: --contains variable type :type var_type: , unicode :param option_value: --dictionary that contains information about property ...
python
def get_json_props_for_response(self, var_type, option_value): ''' Prepare JSON section with detailed information about response :param var_type: --contains variable type :type var_type: , unicode :param option_value: --dictionary that contains information about property ...
[ "def", "get_json_props_for_response", "(", "self", ",", "var_type", ",", "option_value", ")", ":", "props", "=", "list", "(", ")", "for", "name", ",", "value", "in", "option_value", ".", "items", "(", ")", ":", "if", "var_type", "in", "[", "'dynamic'", "...
Prepare JSON section with detailed information about response :param var_type: --contains variable type :type var_type: , unicode :param option_value: --dictionary that contains information about property :type option_value: dict :return: dictionary that contains, title and all ...
[ "Prepare", "JSON", "section", "with", "detailed", "information", "about", "response" ]
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/api/doc_generator.py#L233-L263
vstconsulting/vstutils
vstutils/api/doc_generator.py
VSTOpenApiBase.get_response_example
def get_response_example(self, opt_name, var_type, opt_values): ''' Depends on type of variable, return string with example :param opt_name: --option name :type opt_name: str,unicode :param var_type: --type of variable :type var_type: str, unicode :param opt_value...
python
def get_response_example(self, opt_name, var_type, opt_values): ''' Depends on type of variable, return string with example :param opt_name: --option name :type opt_name: str,unicode :param var_type: --type of variable :type var_type: str, unicode :param opt_value...
[ "def", "get_response_example", "(", "self", ",", "opt_name", ",", "var_type", ",", "opt_values", ")", ":", "if", "opt_name", "==", "'previous'", "and", "var_type", "==", "'uri'", ":", "result", "=", "None", "elif", "var_type", "==", "'uri'", ":", "params", ...
Depends on type of variable, return string with example :param opt_name: --option name :type opt_name: str,unicode :param var_type: --type of variable :type var_type: str, unicode :param opt_values: --dictionary with properties of this variable :type opt_values: dict ...
[ "Depends", "on", "type", "of", "variable", "return", "string", "with", "example", ":", "param", "opt_name", ":", "--", "option", "name", ":", "type", "opt_name", ":", "str", "unicode", ":", "param", "var_type", ":", "--", "type", "of", "variable", ":", "...
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/api/doc_generator.py#L265-L307
vstconsulting/vstutils
vstutils/api/doc_generator.py
VSTOpenApiBase.get_object_example
def get_object_example(self, def_name): ''' Create example for response, from object structure :param def_name: --deffinition name of structure :type def_name: str, unicode :return: example of object :rtype: dict ''' def_model = self.definitions[def_name]...
python
def get_object_example(self, def_name): ''' Create example for response, from object structure :param def_name: --deffinition name of structure :type def_name: str, unicode :return: example of object :rtype: dict ''' def_model = self.definitions[def_name]...
[ "def", "get_object_example", "(", "self", ",", "def_name", ")", ":", "def_model", "=", "self", ".", "definitions", "[", "def_name", "]", "example", "=", "dict", "(", ")", "for", "opt_name", ",", "opt_value", "in", "def_model", ".", "get", "(", "'properties...
Create example for response, from object structure :param def_name: --deffinition name of structure :type def_name: str, unicode :return: example of object :rtype: dict
[ "Create", "example", "for", "response", "from", "object", "structure" ]
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/api/doc_generator.py#L309-L325
vstconsulting/vstutils
vstutils/api/doc_generator.py
VSTOpenApiBase.definition_rst
def definition_rst(self, definition, spec_path=None): ''' Prepare and write information about definition :param definition: --name of definition that would be prepared for render :type definition: str, unicode :param spec_path: --path to definitions :type spec_path: str, ...
python
def definition_rst(self, definition, spec_path=None): ''' Prepare and write information about definition :param definition: --name of definition that would be prepared for render :type definition: str, unicode :param spec_path: --path to definitions :type spec_path: str, ...
[ "def", "definition_rst", "(", "self", ",", "definition", ",", "spec_path", "=", "None", ")", ":", "spec_path", "=", "spec_path", "or", "self", ".", "models_path", "definitions", "=", "self", ".", "spec", "[", "spec_path", "]", "definition_property", "=", "de...
Prepare and write information about definition :param definition: --name of definition that would be prepared for render :type definition: str, unicode :param spec_path: --path to definitions :type spec_path: str, unicode :return:
[ "Prepare", "and", "write", "information", "about", "definition", ":", "param", "definition", ":", "--", "name", "of", "definition", "that", "would", "be", "prepared", "for", "render", ":", "type", "definition", ":", "str", "unicode", ":", "param", "spec_path",...
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/api/doc_generator.py#L327-L347
vstconsulting/vstutils
vstutils/api/doc_generator.py
VSTOpenApiBase.find_nested_models
def find_nested_models(self, model, definitions): ''' Prepare dictionary with reference to another definitions, create one dictionary that contains full information about model, with all nested reference :param model: --dictionary that contains information about model :type model...
python
def find_nested_models(self, model, definitions): ''' Prepare dictionary with reference to another definitions, create one dictionary that contains full information about model, with all nested reference :param model: --dictionary that contains information about model :type model...
[ "def", "find_nested_models", "(", "self", ",", "model", ",", "definitions", ")", ":", "for", "key", ",", "value", "in", "model", ".", "items", "(", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "model", "[", "key", "]", "=", "s...
Prepare dictionary with reference to another definitions, create one dictionary that contains full information about model, with all nested reference :param model: --dictionary that contains information about model :type model: dict :param definitions: --dictionary that contains copy of ...
[ "Prepare", "dictionary", "with", "reference", "to", "another", "definitions", "create", "one", "dictionary", "that", "contains", "full", "information", "about", "model", "with", "all", "nested", "reference", ":", "param", "model", ":", "--", "dictionary", "that", ...
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/api/doc_generator.py#L349-L367
vstconsulting/vstutils
vstutils/api/doc_generator.py
VSTOpenApiBase.get_params
def get_params(self, params, name_request): ''' Prepare and add for further render parameters. :param params: --dictionary with parameters :type params: dict :param name_request: --type of the parameters :type name_request: str, unicode :return: ''' ...
python
def get_params(self, params, name_request): ''' Prepare and add for further render parameters. :param params: --dictionary with parameters :type params: dict :param name_request: --type of the parameters :type name_request: str, unicode :return: ''' ...
[ "def", "get_params", "(", "self", ",", "params", ",", "name_request", ")", ":", "self", ".", "write", "(", "''", ")", "for", "elem", "in", "params", ":", "request_type", "=", "elem", "[", "'type'", "]", "if", "elem", ".", "get", "(", "'type'", ",", ...
Prepare and add for further render parameters. :param params: --dictionary with parameters :type params: dict :param name_request: --type of the parameters :type name_request: str, unicode :return:
[ "Prepare", "and", "add", "for", "further", "render", "parameters", ".", ":", "param", "params", ":", "--", "dictionary", "with", "parameters", ":", "type", "params", ":", "dict", ":", "param", "name_request", ":", "--", "type", "of", "the", "parameters", "...
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/api/doc_generator.py#L369-L394
vstconsulting/vstutils
vstutils/utils.py
get_render
def get_render(name, data, trans='en'): """ Render string based on template :param name: -- full template name :type name: str,unicode :param data: -- dict of rendered vars :type data: dict :param trans: -- translation for render. Default 'en'. :type trans: str,unicode :return: -- r...
python
def get_render(name, data, trans='en'): """ Render string based on template :param name: -- full template name :type name: str,unicode :param data: -- dict of rendered vars :type data: dict :param trans: -- translation for render. Default 'en'. :type trans: str,unicode :return: -- r...
[ "def", "get_render", "(", "name", ",", "data", ",", "trans", "=", "'en'", ")", ":", "translation", ".", "activate", "(", "trans", ")", "config", "=", "loader", ".", "get_template", "(", "name", ")", "result", "=", "config", ".", "render", "(", "data", ...
Render string based on template :param name: -- full template name :type name: str,unicode :param data: -- dict of rendered vars :type data: dict :param trans: -- translation for render. Default 'en'. :type trans: str,unicode :return: -- rendered string :rtype: str,unicode
[ "Render", "string", "based", "on", "template" ]
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/utils.py#L30-L47
vstconsulting/vstutils
vstutils/utils.py
tmp_file.write
def write(self, wr_string): """ Write to file and flush :param wr_string: -- writable string :type wr_string: str :return: None :rtype: None """ result = self.fd.write(wr_string) self.fd.flush() return result
python
def write(self, wr_string): """ Write to file and flush :param wr_string: -- writable string :type wr_string: str :return: None :rtype: None """ result = self.fd.write(wr_string) self.fd.flush() return result
[ "def", "write", "(", "self", ",", "wr_string", ")", ":", "result", "=", "self", ".", "fd", ".", "write", "(", "wr_string", ")", "self", ".", "fd", ".", "flush", "(", ")", "return", "result" ]
Write to file and flush :param wr_string: -- writable string :type wr_string: str :return: None :rtype: None
[ "Write", "to", "file", "and", "flush" ]
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/utils.py#L154-L165
vstconsulting/vstutils
vstutils/utils.py
BaseVstObject.get_django_settings
def get_django_settings(cls, name, default=None): # pylint: disable=access-member-before-definition """ Get params from Django settings. :param name: name of param :type name: str,unicode :param default: default value of param :type default: object :retur...
python
def get_django_settings(cls, name, default=None): # pylint: disable=access-member-before-definition """ Get params from Django settings. :param name: name of param :type name: str,unicode :param default: default value of param :type default: object :retur...
[ "def", "get_django_settings", "(", "cls", ",", "name", ",", "default", "=", "None", ")", ":", "# pylint: disable=access-member-before-definition", "if", "hasattr", "(", "cls", ",", "'__django_settings__'", ")", ":", "return", "getattr", "(", "cls", ".", "__django_...
Get params from Django settings. :param name: name of param :type name: str,unicode :param default: default value of param :type default: object :return: Param from Django settings or default.
[ "Get", "params", "from", "Django", "settings", "." ]
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/utils.py#L270-L285
vstconsulting/vstutils
vstutils/utils.py
Executor._unbuffered
def _unbuffered(self, proc, stream='stdout'): """ Unbuffered output handler. :type proc: subprocess.Popen :type stream: six.text_types :return: """ if self.working_handler is not None: t = Thread(target=self._handle_process, args=(proc, stream)) ...
python
def _unbuffered(self, proc, stream='stdout'): """ Unbuffered output handler. :type proc: subprocess.Popen :type stream: six.text_types :return: """ if self.working_handler is not None: t = Thread(target=self._handle_process, args=(proc, stream)) ...
[ "def", "_unbuffered", "(", "self", ",", "proc", ",", "stream", "=", "'stdout'", ")", ":", "if", "self", ".", "working_handler", "is", "not", "None", ":", "t", "=", "Thread", "(", "target", "=", "self", ".", "_handle_process", ",", "args", "=", "(", "...
Unbuffered output handler. :type proc: subprocess.Popen :type stream: six.text_types :return:
[ "Unbuffered", "output", "handler", "." ]
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/utils.py#L341-L357
vstconsulting/vstutils
vstutils/utils.py
Executor.execute
def execute(self, cmd, cwd): """ Execute commands and output this :param cmd: -- list of cmd command and arguments :type cmd: list :param cwd: -- workdir for executions :type cwd: str,unicode :return: -- string with full output :rtype: str """ ...
python
def execute(self, cmd, cwd): """ Execute commands and output this :param cmd: -- list of cmd command and arguments :type cmd: list :param cwd: -- workdir for executions :type cwd: str,unicode :return: -- string with full output :rtype: str """ ...
[ "def", "execute", "(", "self", ",", "cmd", ",", "cwd", ")", ":", "self", ".", "output", "=", "\"\"", "env", "=", "os", ".", "environ", ".", "copy", "(", ")", "env", ".", "update", "(", "self", ".", "env", ")", "if", "six", ".", "PY2", ":", "#...
Execute commands and output this :param cmd: -- list of cmd command and arguments :type cmd: list :param cwd: -- workdir for executions :type cwd: str,unicode :return: -- string with full output :rtype: str
[ "Execute", "commands", "and", "output", "this" ]
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/utils.py#L369-L403
vstconsulting/vstutils
vstutils/utils.py
ModelHandlers.backend
def backend(self, name): """ Get backend class :param name: -- name of backend type :type name: str :return: class of backend :rtype: class,module,object """ try: backend = self.get_backend_handler_path(name) if backend is None: ...
python
def backend(self, name): """ Get backend class :param name: -- name of backend type :type name: str :return: class of backend :rtype: class,module,object """ try: backend = self.get_backend_handler_path(name) if backend is None: ...
[ "def", "backend", "(", "self", ",", "name", ")", ":", "try", ":", "backend", "=", "self", ".", "get_backend_handler_path", "(", "name", ")", "if", "backend", "is", "None", ":", "raise", "ex", ".", "VSTUtilsException", "(", "\"Backend is 'None'.\"", ")", "#...
Get backend class :param name: -- name of backend type :type name: str :return: class of backend :rtype: class,module,object
[ "Get", "backend", "class" ]
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/utils.py#L650-L666
vstconsulting/vstutils
vstutils/utils.py
ModelHandlers.get_object
def get_object(self, name, obj): """ :param name: -- string name of backend :param name: str :param obj: -- model object :type obj: django.db.models.Model :return: backend object :rtype: object """ return self[name](obj, **self.opts(name))
python
def get_object(self, name, obj): """ :param name: -- string name of backend :param name: str :param obj: -- model object :type obj: django.db.models.Model :return: backend object :rtype: object """ return self[name](obj, **self.opts(name))
[ "def", "get_object", "(", "self", ",", "name", ",", "obj", ")", ":", "return", "self", "[", "name", "]", "(", "obj", ",", "*", "*", "self", ".", "opts", "(", "name", ")", ")" ]
:param name: -- string name of backend :param name: str :param obj: -- model object :type obj: django.db.models.Model :return: backend object :rtype: object
[ ":", "param", "name", ":", "--", "string", "name", "of", "backend", ":", "param", "name", ":", "str", ":", "param", "obj", ":", "--", "model", "object", ":", "type", "obj", ":", "django", ".", "db", ".", "models", ".", "Model", ":", "return", ":", ...
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/utils.py#L671-L680
vstconsulting/vstutils
vstutils/utils.py
URLHandlers.get_object
def get_object(self, name, *argv, **kwargs): """ Get url object tuple for url :param name: url regexp from :type name: str :param argv: overrided args :param kwargs: overrided kwargs :return: url object :rtype: django.conf.urls.url """ reg...
python
def get_object(self, name, *argv, **kwargs): """ Get url object tuple for url :param name: url regexp from :type name: str :param argv: overrided args :param kwargs: overrided kwargs :return: url object :rtype: django.conf.urls.url """ reg...
[ "def", "get_object", "(", "self", ",", "name", ",", "*", "argv", ",", "*", "*", "kwargs", ")", ":", "regexp", "=", "name", "options", "=", "self", ".", "opts", "(", "regexp", ")", "options", ".", "update", "(", "kwargs", ")", "args", "=", "options"...
Get url object tuple for url :param name: url regexp from :type name: str :param argv: overrided args :param kwargs: overrided kwargs :return: url object :rtype: django.conf.urls.url
[ "Get", "url", "object", "tuple", "for", "url" ]
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/utils.py#L718-L739
vstconsulting/vstutils
vstutils/api/base.py
CopyMixin.copy
def copy(self, request, **kwargs): # pylint: disable=unused-argument ''' Copy instance with deps. ''' instance = self.copy_instance(self.get_object()) serializer = self.get_serializer(instance, data=request.data, partial=True) serializer.is_valid() seriali...
python
def copy(self, request, **kwargs): # pylint: disable=unused-argument ''' Copy instance with deps. ''' instance = self.copy_instance(self.get_object()) serializer = self.get_serializer(instance, data=request.data, partial=True) serializer.is_valid() seriali...
[ "def", "copy", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable=unused-argument", "instance", "=", "self", ".", "copy_instance", "(", "self", ".", "get_object", "(", ")", ")", "serializer", "=", "self", ".", "get_serializer"...
Copy instance with deps.
[ "Copy", "instance", "with", "deps", "." ]
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/api/base.py#L273-L282
vstconsulting/vstutils
vstutils/models.py
BaseManager._get_queryset_methods
def _get_queryset_methods(cls, queryset_class): ''' Django overrloaded method for add cyfunction. ''' def create_method(name, method): def manager_method(self, *args, **kwargs): return getattr(self.get_queryset(), name)(*args, **kwargs) manager_me...
python
def _get_queryset_methods(cls, queryset_class): ''' Django overrloaded method for add cyfunction. ''' def create_method(name, method): def manager_method(self, *args, **kwargs): return getattr(self.get_queryset(), name)(*args, **kwargs) manager_me...
[ "def", "_get_queryset_methods", "(", "cls", ",", "queryset_class", ")", ":", "def", "create_method", "(", "name", ",", "method", ")", ":", "def", "manager_method", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "getattr", "("...
Django overrloaded method for add cyfunction.
[ "Django", "overrloaded", "method", "for", "add", "cyfunction", "." ]
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/models.py#L65-L89
vstconsulting/vstutils
vstutils/ldap_utils.py
LDAP.__authenticate
def __authenticate(self, ad, username, password): ''' Active Directory auth function :param ad: LDAP connection string ('ldap://server') :param username: username with domain ('user@domain.name') :param password: auth password :return: ldap connection or None if error ...
python
def __authenticate(self, ad, username, password): ''' Active Directory auth function :param ad: LDAP connection string ('ldap://server') :param username: username with domain ('user@domain.name') :param password: auth password :return: ldap connection or None if error ...
[ "def", "__authenticate", "(", "self", ",", "ad", ",", "username", ",", "password", ")", ":", "result", "=", "None", "conn", "=", "ldap", ".", "initialize", "(", "ad", ")", "conn", ".", "protocol_version", "=", "3", "conn", ".", "set_option", "(", "ldap...
Active Directory auth function :param ad: LDAP connection string ('ldap://server') :param username: username with domain ('user@domain.name') :param password: auth password :return: ldap connection or None if error
[ "Active", "Directory", "auth", "function" ]
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/ldap_utils.py#L91-L119
vstconsulting/vstutils
vstutils/ldap_utils.py
LDAP.isAuth
def isAuth(self): ''' Indicates that object auth worked :return: True or False ''' if isinstance(self.__conn, ldap.ldapobject.LDAPObject) or self.__conn: return True return False
python
def isAuth(self): ''' Indicates that object auth worked :return: True or False ''' if isinstance(self.__conn, ldap.ldapobject.LDAPObject) or self.__conn: return True return False
[ "def", "isAuth", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "__conn", ",", "ldap", ".", "ldapobject", ".", "LDAPObject", ")", "or", "self", ".", "__conn", ":", "return", "True", "return", "False" ]
Indicates that object auth worked :return: True or False
[ "Indicates", "that", "object", "auth", "worked", ":", "return", ":", "True", "or", "False" ]
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/ldap_utils.py#L135-L142
vstconsulting/vstutils
vstutils/environment.py
prepare_environment
def prepare_environment(default_settings=_default_settings, **kwargs): # pylint: disable=unused-argument ''' Prepare ENV for web-application :param default_settings: minimal needed settings for run app :type default_settings: dict :param kwargs: other overrided settings :rtype: None ''' ...
python
def prepare_environment(default_settings=_default_settings, **kwargs): # pylint: disable=unused-argument ''' Prepare ENV for web-application :param default_settings: minimal needed settings for run app :type default_settings: dict :param kwargs: other overrided settings :rtype: None ''' ...
[ "def", "prepare_environment", "(", "default_settings", "=", "_default_settings", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable=unused-argument", "for", "key", ",", "value", "in", "default_settings", ".", "items", "(", ")", ":", "os", ".", "environ", ".",...
Prepare ENV for web-application :param default_settings: minimal needed settings for run app :type default_settings: dict :param kwargs: other overrided settings :rtype: None
[ "Prepare", "ENV", "for", "web", "-", "application", ":", "param", "default_settings", ":", "minimal", "needed", "settings", "for", "run", "app", ":", "type", "default_settings", ":", "dict", ":", "param", "kwargs", ":", "other", "overrided", "settings", ":", ...
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/environment.py#L18-L34
vstconsulting/vstutils
vstutils/environment.py
cmd_execution
def cmd_execution(*args, **kwargs): # pylint: disable=unused-variable ''' Main function to executes from cmd. Emulates django-admin.py execution. :param kwargs: overrided env-settings :rtype: None ''' from django.core.management import execute_from_command_line prepare_environment(**kwar...
python
def cmd_execution(*args, **kwargs): # pylint: disable=unused-variable ''' Main function to executes from cmd. Emulates django-admin.py execution. :param kwargs: overrided env-settings :rtype: None ''' from django.core.management import execute_from_command_line prepare_environment(**kwar...
[ "def", "cmd_execution", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable=unused-variable", "from", "django", ".", "core", ".", "management", "import", "execute_from_command_line", "prepare_environment", "(", "*", "*", "kwargs", ")", "args", ...
Main function to executes from cmd. Emulates django-admin.py execution. :param kwargs: overrided env-settings :rtype: None
[ "Main", "function", "to", "executes", "from", "cmd", ".", "Emulates", "django", "-", "admin", ".", "py", "execution", ".", ":", "param", "kwargs", ":", "overrided", "env", "-", "settings", ":", "rtype", ":", "None" ]
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/environment.py#L37-L48
vstconsulting/vstutils
vstutils/environment.py
get_celery_app
def get_celery_app(name=None, **kwargs): # nocv # pylint: disable=import-error ''' Function to return celery-app. Works only if celery installed. :param name: Application name :param kwargs: overrided env-settings :return: Celery-app object ''' from celery import Celery prepare_envi...
python
def get_celery_app(name=None, **kwargs): # nocv # pylint: disable=import-error ''' Function to return celery-app. Works only if celery installed. :param name: Application name :param kwargs: overrided env-settings :return: Celery-app object ''' from celery import Celery prepare_envi...
[ "def", "get_celery_app", "(", "name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# nocv", "# pylint: disable=import-error", "from", "celery", "import", "Celery", "prepare_environment", "(", "*", "*", "kwargs", ")", "name", "=", "name", "or", "os", ".",...
Function to return celery-app. Works only if celery installed. :param name: Application name :param kwargs: overrided env-settings :return: Celery-app object
[ "Function", "to", "return", "celery", "-", "app", ".", "Works", "only", "if", "celery", "installed", ".", ":", "param", "name", ":", "Application", "name", ":", "param", "kwargs", ":", "overrided", "env", "-", "settings", ":", "return", ":", "Celery", "-...
train
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/environment.py#L51-L65
gregmuellegger/django-autofixture
autofixture/__init__.py
register
def register(model, autofixture, overwrite=False, fail_silently=False): ''' Register a model with the registry. Arguments: *model* can be either a model class or a string that contains the model's app label and class name seperated by a dot, e.g. ``"app.ModelClass"``. *autofixture...
python
def register(model, autofixture, overwrite=False, fail_silently=False): ''' Register a model with the registry. Arguments: *model* can be either a model class or a string that contains the model's app label and class name seperated by a dot, e.g. ``"app.ModelClass"``. *autofixture...
[ "def", "register", "(", "model", ",", "autofixture", ",", "overwrite", "=", "False", ",", "fail_silently", "=", "False", ")", ":", "from", ".", "compat", "import", "get_model", "if", "isinstance", "(", "model", ",", "string_types", ")", ":", "model", "=", ...
Register a model with the registry. Arguments: *model* can be either a model class or a string that contains the model's app label and class name seperated by a dot, e.g. ``"app.ModelClass"``. *autofixture* is the :mod:`AutoFixture` subclass that shall be used to generated instanc...
[ "Register", "a", "model", "with", "the", "registry", "." ]
train
https://github.com/gregmuellegger/django-autofixture/blob/0b696fd3a06747459981e4269aff427676f84ae0/autofixture/__init__.py#L21-L54
gregmuellegger/django-autofixture
autofixture/__init__.py
unregister
def unregister(model_or_iterable, fail_silently=False): ''' Remove one or more models from the autofixture registry. ''' from django.db import models from .compat import get_model if issubclass(model_or_iterable, models.Model): model_or_iterable = [model_or_iterable] for model in mo...
python
def unregister(model_or_iterable, fail_silently=False): ''' Remove one or more models from the autofixture registry. ''' from django.db import models from .compat import get_model if issubclass(model_or_iterable, models.Model): model_or_iterable = [model_or_iterable] for model in mo...
[ "def", "unregister", "(", "model_or_iterable", ",", "fail_silently", "=", "False", ")", ":", "from", "django", ".", "db", "import", "models", "from", ".", "compat", "import", "get_model", "if", "issubclass", "(", "model_or_iterable", ",", "models", ".", "Model...
Remove one or more models from the autofixture registry.
[ "Remove", "one", "or", "more", "models", "from", "the", "autofixture", "registry", "." ]
train
https://github.com/gregmuellegger/django-autofixture/blob/0b696fd3a06747459981e4269aff427676f84ae0/autofixture/__init__.py#L57-L78