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_documentation_string
stringlengths
1
47.2k
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() ...
Ensures a strict req-reply loop, so that clients dont't receive out-of-order messages, if an exception occurs between request-reply.
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...
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.
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...
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 ...
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)
Eat cookies as they're baked.
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_...
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...
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 ...
The builtin `map()`, but with superpowers.
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...
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...
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)
Rollback any changes done by :py:func:`signal_to_exception`.
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...
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...
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 ...
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...
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...
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.
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...
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
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,...
Block until a change is observed, and then return a copy of the state. .. include:: /api/state/get_when_change.rst
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...
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
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]...
Block until ``state[key] == value``, and then return a copy of the state. .. include:: /api/state/get_when_equality.rst
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)
Block until ``key in state``, and then return a copy of the state. .. include:: /api/state/get_when_equality.rst
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
Stop this process. Once closed, it should not, and cannot be used again. :return: :py:attr:`~exitcode`.
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...
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: ...
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...
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...
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...
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...
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...
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) ...
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...
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: ...
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)
alias for :py:meth:`ProcessList.wait()`
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...
Converts a dict of items, some of which are scalar and some of which are lists, to a list of dicts with scalar items.
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 ...
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 ...
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):...
Given a status dictionary, return all people mentioned in the toot, excluding those in the list passed in exclude.
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]...
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.
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...
Given a status dict, return the visibility that should be used. This behaves like Mastodon does by default.
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)):...
Return the dice specification as a string in a common format
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 ...
Perform the dice rolls and replace all roll expressions with lists of the dice faces that landed up.
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...
Replace the dice roll arrays from roll_dice in place with summations of the rolls.
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...
Extract the short tandem repeat structure from a string. :arg string string: The string. :arg integer min_length: Minimum length of the repeat structure.
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) ...
Print an error message Args: message: the message to print
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)
Print a nice JSON output Args: message: the message to print
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...
Transform the current specification to a dictionary
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...
Fill the current object with information from the specification
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...
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
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 = [] ...
This method reads provided json config file.
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...
This method is the entry point of javascript code writer. Monolithe will call it when the javascript plugin is to generate code.
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...
This method generates AbstractNamedEntity class js file.
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...
This method writes the ouput for a particular specification.
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() ...
This method writes the ouput for a particular specification.
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()
Wait until all the threads are finished.
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) ...
Start a task in a separate thread Args: method: the method to start in a separate thread args: Accept args/kwargs arguments
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...
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
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",...
Returns a readable type according to a java type
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: ...
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"...
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 ...
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") ...
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" ...
Returns a c# type according to a spec type
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....
Write Maven build file (pom.xml)
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 = ...
Returns a go type according to a spec type
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...
Write API Info file
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...
Write autogenerate specification file
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._...
Write fetcher
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...
This method is needed until get_type_name() is enhanced to include specification subtype and local_name
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...
Transform an attribute to a dict
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...
Write autogenerate specification file
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...
Write autogenerate specification file
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 ...
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
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...
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...
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...
Write SDK session file Args: version (str): the version of the server
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...
Write init file Args: filenames (dict): dict of filename and classes
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 ...
Write autogenerate specification file
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...
Write fetcher init file Args: filenames (dict): dict of filename and classes
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)...
Write fetcher
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(...
Removes attributes and computes constants
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, ...
Run all tests Returns: A dictionnary containing tests results.
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, ...
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], ] ...
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]
GetDB - simple function to wrap getting a database connection from the connection pool.
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...
Load OpenAPI specification from yaml file. Path to file taking from command `vst_openapi`. :return:
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 :...
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:
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...
Main function for prepare and render OpenAPI specification :return:
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(): ...
Cycle for prepare information about paths :return:
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...
Print all schemas, one by one :return:
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: ''' ...
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:
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...
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:
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....
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:
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 ...
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 ...
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...
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 ...
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]...
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
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, ...
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:
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...
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 ...
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: ''' ...
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:
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...
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
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
Write to file and flush :param wr_string: -- writable string :type wr_string: str :return: None :rtype: None
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...
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.
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)) ...
Unbuffered output handler. :type proc: subprocess.Popen :type stream: six.text_types :return:
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 """ ...
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
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: ...
Get backend class :param name: -- name of backend type :type name: str :return: class of backend :rtype: class,module,object
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))
:param name: -- string name of backend :param name: str :param obj: -- model object :type obj: django.db.models.Model :return: backend object :rtype: object
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...
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
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...
Copy instance with deps.
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...
Django overrloaded method for add cyfunction.
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 ...
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
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
Indicates that object auth worked :return: True or False
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 ''' ...
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
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...
Main function to executes from cmd. Emulates django-admin.py execution. :param kwargs: overrided env-settings :rtype: None
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...
Function to return celery-app. Works only if celery installed. :param name: Application name :param kwargs: overrided env-settings :return: Celery-app object
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...
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...
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...
Remove one or more models from the autofixture registry.
https://github.com/gregmuellegger/django-autofixture/blob/0b696fd3a06747459981e4269aff427676f84ae0/autofixture/__init__.py#L57-L78