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
geertj/gruvi
lib/gruvi/stream.py
Stream.wrap
def wrap(self, encoding, **textio_args): """Return a :class:`io.TextIOWrapper` that wraps the stream. The wrapper provides text IO on top of the byte stream, using the specified *encoding*. The *textio_args* keyword arguments are additional keyword arguments passed to the :class:`~io.Te...
python
def wrap(self, encoding, **textio_args): """Return a :class:`io.TextIOWrapper` that wraps the stream. The wrapper provides text IO on top of the byte stream, using the specified *encoding*. The *textio_args* keyword arguments are additional keyword arguments passed to the :class:`~io.Te...
[ "def", "wrap", "(", "self", ",", "encoding", ",", "*", "*", "textio_args", ")", ":", "# By default we want write_through behavior, unless the user specifies", "# something else.", "if", "'line_buffering'", "not", "in", "textio_args", "and", "'write_through'", "not", "in",...
Return a :class:`io.TextIOWrapper` that wraps the stream. The wrapper provides text IO on top of the byte stream, using the specified *encoding*. The *textio_args* keyword arguments are additional keyword arguments passed to the :class:`~io.TextIOWrapper` constructor. Unless another buf...
[ "Return", "a", ":", "class", ":", "io", ".", "TextIOWrapper", "that", "wraps", "the", "stream", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/stream.py#L177-L190
geertj/gruvi
lib/gruvi/stream.py
Stream.read
def read(self, size=-1): """Read up to *size* bytes. This function reads from the buffer multiple times until the requested number of bytes can be satisfied. This means that this function may block to wait for more data, even if some data is available. The only time a short read...
python
def read(self, size=-1): """Read up to *size* bytes. This function reads from the buffer multiple times until the requested number of bytes can be satisfied. This means that this function may block to wait for more data, even if some data is available. The only time a short read...
[ "def", "read", "(", "self", ",", "size", "=", "-", "1", ")", ":", "self", ".", "_check_readable", "(", ")", "chunks", "=", "[", "]", "bytes_read", "=", "0", "bytes_left", "=", "size", "while", "True", ":", "chunk", "=", "self", ".", "_buffer", ".",...
Read up to *size* bytes. This function reads from the buffer multiple times until the requested number of bytes can be satisfied. This means that this function may block to wait for more data, even if some data is available. The only time a short read is returned, is on EOF or error. ...
[ "Read", "up", "to", "*", "size", "*", "bytes", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/stream.py#L226-L253
geertj/gruvi
lib/gruvi/stream.py
Stream.read1
def read1(self, size=-1): """Read up to *size* bytes. This function reads from the buffer only once. It is useful in case you need to read a large input, and want to do so efficiently. If *size* is big enough, then this method will return the chunks passed into the memory buffer...
python
def read1(self, size=-1): """Read up to *size* bytes. This function reads from the buffer only once. It is useful in case you need to read a large input, and want to do so efficiently. If *size* is big enough, then this method will return the chunks passed into the memory buffer...
[ "def", "read1", "(", "self", ",", "size", "=", "-", "1", ")", ":", "self", ".", "_check_readable", "(", ")", "chunk", "=", "self", ".", "_buffer", ".", "get_chunk", "(", "size", ")", "if", "not", "chunk", "and", "not", "self", ".", "_buffer", ".", ...
Read up to *size* bytes. This function reads from the buffer only once. It is useful in case you need to read a large input, and want to do so efficiently. If *size* is big enough, then this method will return the chunks passed into the memory buffer verbatim without any copying or slic...
[ "Read", "up", "to", "*", "size", "*", "bytes", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/stream.py#L256-L268
geertj/gruvi
lib/gruvi/stream.py
Stream.readline
def readline(self, limit=-1, delim=b'\n'): """Read a single line. If EOF is reached before a full line can be read, a partial line is returned. If *limit* is specified, at most this many bytes will be read. """ self._check_readable() chunks = [] while True: ...
python
def readline(self, limit=-1, delim=b'\n'): """Read a single line. If EOF is reached before a full line can be read, a partial line is returned. If *limit* is specified, at most this many bytes will be read. """ self._check_readable() chunks = [] while True: ...
[ "def", "readline", "(", "self", ",", "limit", "=", "-", "1", ",", "delim", "=", "b'\\n'", ")", ":", "self", ".", "_check_readable", "(", ")", "chunks", "=", "[", "]", "while", "True", ":", "chunk", "=", "self", ".", "_buffer", ".", "get_chunk", "("...
Read a single line. If EOF is reached before a full line can be read, a partial line is returned. If *limit* is specified, at most this many bytes will be read.
[ "Read", "a", "single", "line", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/stream.py#L271-L292
geertj/gruvi
lib/gruvi/stream.py
Stream.readlines
def readlines(self, hint=-1): """Read lines until EOF, and return them as a list. If *hint* is specified, then stop reading lines as soon as the total size of all lines exceeds *hint*. """ self._check_readable() lines = [] chunks = [] bytes_read = 0 ...
python
def readlines(self, hint=-1): """Read lines until EOF, and return them as a list. If *hint* is specified, then stop reading lines as soon as the total size of all lines exceeds *hint*. """ self._check_readable() lines = [] chunks = [] bytes_read = 0 ...
[ "def", "readlines", "(", "self", ",", "hint", "=", "-", "1", ")", ":", "self", ".", "_check_readable", "(", ")", "lines", "=", "[", "]", "chunks", "=", "[", "]", "bytes_read", "=", "0", "while", "True", ":", "chunk", "=", "self", ".", "_buffer", ...
Read lines until EOF, and return them as a list. If *hint* is specified, then stop reading lines as soon as the total size of all lines exceeds *hint*.
[ "Read", "lines", "until", "EOF", "and", "return", "them", "as", "a", "list", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/stream.py#L295-L320
geertj/gruvi
lib/gruvi/stream.py
Stream.write
def write(self, data): """Write *data* to the transport. This method will block if the transport's write buffer is at capacity. """ self._check_writable() self._transport._can_write.wait() self._transport.write(data)
python
def write(self, data): """Write *data* to the transport. This method will block if the transport's write buffer is at capacity. """ self._check_writable() self._transport._can_write.wait() self._transport.write(data)
[ "def", "write", "(", "self", ",", "data", ")", ":", "self", ".", "_check_writable", "(", ")", "self", ".", "_transport", ".", "_can_write", ".", "wait", "(", ")", "self", ".", "_transport", ".", "write", "(", "data", ")" ]
Write *data* to the transport. This method will block if the transport's write buffer is at capacity.
[ "Write", "*", "data", "*", "to", "the", "transport", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/stream.py#L332-L339
geertj/gruvi
lib/gruvi/stream.py
Stream.writelines
def writelines(self, seq): """Write the elements of the sequence *seq* to the transport. This method will block if the transport's write buffer is at capacity. """ self._check_writable() for line in seq: self._transport._can_write.wait() self._transport.w...
python
def writelines(self, seq): """Write the elements of the sequence *seq* to the transport. This method will block if the transport's write buffer is at capacity. """ self._check_writable() for line in seq: self._transport._can_write.wait() self._transport.w...
[ "def", "writelines", "(", "self", ",", "seq", ")", ":", "self", ".", "_check_writable", "(", ")", "for", "line", "in", "seq", ":", "self", ".", "_transport", ".", "_can_write", ".", "wait", "(", ")", "self", ".", "_transport", ".", "write", "(", "lin...
Write the elements of the sequence *seq* to the transport. This method will block if the transport's write buffer is at capacity.
[ "Write", "the", "elements", "of", "the", "sequence", "*", "seq", "*", "to", "the", "transport", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/stream.py#L342-L350
geertj/gruvi
lib/gruvi/stream.py
Stream.write_eof
def write_eof(self): """Close the write direction of the transport. This method will block if the transport's write buffer is at capacity. """ self._check_writable() self._transport._can_write.wait() self._transport.write_eof()
python
def write_eof(self): """Close the write direction of the transport. This method will block if the transport's write buffer is at capacity. """ self._check_writable() self._transport._can_write.wait() self._transport.write_eof()
[ "def", "write_eof", "(", "self", ")", ":", "self", ".", "_check_writable", "(", ")", "self", ".", "_transport", ".", "_can_write", ".", "wait", "(", ")", "self", ".", "_transport", ".", "write_eof", "(", ")" ]
Close the write direction of the transport. This method will block if the transport's write buffer is at capacity.
[ "Close", "the", "write", "direction", "of", "the", "transport", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/stream.py#L353-L360
geertj/gruvi
lib/gruvi/stream.py
Stream.close
def close(self): """Close the stream. If *autoclose* was passed to the constructor then the underlying transport will be closed as well. """ if self._closed: return if self._autoclose: self._transport.close() self._transport._closed.wa...
python
def close(self): """Close the stream. If *autoclose* was passed to the constructor then the underlying transport will be closed as well. """ if self._closed: return if self._autoclose: self._transport.close() self._transport._closed.wa...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_closed", ":", "return", "if", "self", ".", "_autoclose", ":", "self", ".", "_transport", ".", "close", "(", ")", "self", ".", "_transport", ".", "_closed", ".", "wait", "(", ")", "self", "...
Close the stream. If *autoclose* was passed to the constructor then the underlying transport will be closed as well.
[ "Close", "the", "stream", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/stream.py#L363-L375
geertj/gruvi
lib/gruvi/futures.py
blocking
def blocking(func, *args, **kwargs): """Run a function that uses blocking IO. The function is run in the IO thread pool. """ pool = get_io_pool() fut = pool.submit(func, *args, **kwargs) return fut.result()
python
def blocking(func, *args, **kwargs): """Run a function that uses blocking IO. The function is run in the IO thread pool. """ pool = get_io_pool() fut = pool.submit(func, *args, **kwargs) return fut.result()
[ "def", "blocking", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "pool", "=", "get_io_pool", "(", ")", "fut", "=", "pool", ".", "submit", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", "return", "fut", ".", "re...
Run a function that uses blocking IO. The function is run in the IO thread pool.
[ "Run", "a", "function", "that", "uses", "blocking", "IO", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/futures.py#L464-L471
geertj/gruvi
lib/gruvi/futures.py
as_completed
def as_completed(objects, count=None, timeout=None): """Wait for one or more waitable objects, yielding them as they become ready. This is the iterator/generator version of :func:`wait`. """ for obj in objects: if not hasattr(obj, 'add_done_callback'): raise TypeError('Expecting...
python
def as_completed(objects, count=None, timeout=None): """Wait for one or more waitable objects, yielding them as they become ready. This is the iterator/generator version of :func:`wait`. """ for obj in objects: if not hasattr(obj, 'add_done_callback'): raise TypeError('Expecting...
[ "def", "as_completed", "(", "objects", ",", "count", "=", "None", ",", "timeout", "=", "None", ")", ":", "for", "obj", "in", "objects", ":", "if", "not", "hasattr", "(", "obj", ",", "'add_done_callback'", ")", ":", "raise", "TypeError", "(", "'Expecting ...
Wait for one or more waitable objects, yielding them as they become ready. This is the iterator/generator version of :func:`wait`.
[ "Wait", "for", "one", "or", "more", "waitable", "objects", "yielding", "them", "as", "they", "become", "ready", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/futures.py#L506-L526
geertj/gruvi
lib/gruvi/futures.py
wait
def wait(objects, count=None, timeout=None): """Wait for one or more waitable objects. This method waits until *count* elements from the sequence of waitable objects *objects* have become ready. If *count* is ``None`` (the default), then wait for all objects to become ready. What "ready" is means ...
python
def wait(objects, count=None, timeout=None): """Wait for one or more waitable objects. This method waits until *count* elements from the sequence of waitable objects *objects* have become ready. If *count* is ``None`` (the default), then wait for all objects to become ready. What "ready" is means ...
[ "def", "wait", "(", "objects", ",", "count", "=", "None", ",", "timeout", "=", "None", ")", ":", "for", "obj", "in", "objects", ":", "if", "not", "hasattr", "(", "obj", ",", "'add_done_callback'", ")", ":", "raise", "TypeError", "(", "'Expecting sequence...
Wait for one or more waitable objects. This method waits until *count* elements from the sequence of waitable objects *objects* have become ready. If *count* is ``None`` (the default), then wait for all objects to become ready. What "ready" is means depends on the object type. A waitable object is a ...
[ "Wait", "for", "one", "or", "more", "waitable", "objects", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/futures.py#L530-L564
geertj/gruvi
lib/gruvi/futures.py
Future.cancelled
def cancelled(self): """Return whether this future was successfully cancelled.""" return self._state == self.S_EXCEPTION and isinstance(self._result, Cancelled)
python
def cancelled(self): """Return whether this future was successfully cancelled.""" return self._state == self.S_EXCEPTION and isinstance(self._result, Cancelled)
[ "def", "cancelled", "(", "self", ")", ":", "return", "self", ".", "_state", "==", "self", ".", "S_EXCEPTION", "and", "isinstance", "(", "self", ".", "_result", ",", "Cancelled", ")" ]
Return whether this future was successfully cancelled.
[ "Return", "whether", "this", "future", "was", "successfully", "cancelled", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/futures.py#L67-L69
geertj/gruvi
lib/gruvi/futures.py
Future.cancel
def cancel(self): """Cancel the execution of the async function, if possible. This method marks the future as done and sets the :class:`Cancelled` exception. A future that is not running can always be cancelled. However when a future is running, the ability to cancel it depends...
python
def cancel(self): """Cancel the execution of the async function, if possible. This method marks the future as done and sets the :class:`Cancelled` exception. A future that is not running can always be cancelled. However when a future is running, the ability to cancel it depends...
[ "def", "cancel", "(", "self", ")", ":", "# We leverage/abuse our _done Event's thread lock as our own lock.", "# Since it's a private copy it should be OK, and it saves some memory.", "# Just be sure that we don't modify the event with the lock held.", "with", "self", ".", "_lock", ":", ...
Cancel the execution of the async function, if possible. This method marks the future as done and sets the :class:`Cancelled` exception. A future that is not running can always be cancelled. However when a future is running, the ability to cancel it depends on the pool implemen...
[ "Cancel", "the", "execution", "of", "the", "async", "function", "if", "possible", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/futures.py#L75-L97
geertj/gruvi
lib/gruvi/futures.py
Future.result
def result(self, timeout=None): """Wait for the future to complete and return its result. If the function returned normally, its return value is returned here. If the function raised an exception, the exception is re-raised here. """ if not self._done.wait(timeout): ...
python
def result(self, timeout=None): """Wait for the future to complete and return its result. If the function returned normally, its return value is returned here. If the function raised an exception, the exception is re-raised here. """ if not self._done.wait(timeout): ...
[ "def", "result", "(", "self", ",", "timeout", "=", "None", ")", ":", "if", "not", "self", ".", "_done", ".", "wait", "(", "timeout", ")", ":", "raise", "Timeout", "(", "'timeout waiting for future'", ")", "# No more state changes after _done is set so no lock need...
Wait for the future to complete and return its result. If the function returned normally, its return value is returned here. If the function raised an exception, the exception is re-raised here.
[ "Wait", "for", "the", "future", "to", "complete", "and", "return", "its", "result", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/futures.py#L100-L111
geertj/gruvi
lib/gruvi/futures.py
Future.exception
def exception(self, timeout=None): """Wait for the async function to complete and return its exception. If the function did not raise an exception this returns ``None``. """ if not self._done.wait(timeout): raise Timeout('timeout waiting for future') if self._state =...
python
def exception(self, timeout=None): """Wait for the async function to complete and return its exception. If the function did not raise an exception this returns ``None``. """ if not self._done.wait(timeout): raise Timeout('timeout waiting for future') if self._state =...
[ "def", "exception", "(", "self", ",", "timeout", "=", "None", ")", ":", "if", "not", "self", ".", "_done", ".", "wait", "(", "timeout", ")", ":", "raise", "Timeout", "(", "'timeout waiting for future'", ")", "if", "self", ".", "_state", "==", "self", "...
Wait for the async function to complete and return its exception. If the function did not raise an exception this returns ``None``.
[ "Wait", "for", "the", "async", "function", "to", "complete", "and", "return", "its", "exception", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/futures.py#L114-L122
geertj/gruvi
lib/gruvi/futures.py
Future.add_done_callback
def add_done_callback(self, callback, *args): """Add a callback that gets called when the future completes. The callback will be called in the context of the fiber that sets the future's result. The callback is called with the positional arguments *args* provided to this method. ...
python
def add_done_callback(self, callback, *args): """Add a callback that gets called when the future completes. The callback will be called in the context of the fiber that sets the future's result. The callback is called with the positional arguments *args* provided to this method. ...
[ "def", "add_done_callback", "(", "self", ",", "callback", ",", "*", "args", ")", ":", "with", "self", ".", "_lock", ":", "if", "self", ".", "_state", "not", "in", "(", "self", ".", "S_DONE", ",", "self", ".", "S_EXCEPTION", ")", ":", "return", "add_c...
Add a callback that gets called when the future completes. The callback will be called in the context of the fiber that sets the future's result. The callback is called with the positional arguments *args* provided to this method. The return value is an opaque handle that can be used w...
[ "Add", "a", "callback", "that", "gets", "called", "when", "the", "future", "completes", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/futures.py#L124-L140
geertj/gruvi
lib/gruvi/futures.py
PoolBase.submit
def submit(self, func, *args): """Run *func* asynchronously. The function is run in the pool which will run it asynchrously. The function is called with positional argument *args*. The return value is a :class:`Future` that captures the state and the future result of the asynch...
python
def submit(self, func, *args): """Run *func* asynchronously. The function is run in the pool which will run it asynchrously. The function is called with positional argument *args*. The return value is a :class:`Future` that captures the state and the future result of the asynch...
[ "def", "submit", "(", "self", ",", "func", ",", "*", "args", ")", ":", "with", "self", ".", "_lock", ":", "if", "self", ".", "_closing", ":", "raise", "RuntimeError", "(", "'pool is closing/closed'", ")", "result", "=", "Future", "(", ")", "self", ".",...
Run *func* asynchronously. The function is run in the pool which will run it asynchrously. The function is called with positional argument *args*. The return value is a :class:`Future` that captures the state and the future result of the asynchronous function call.
[ "Run", "*", "func", "*", "asynchronously", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/futures.py#L310-L325
geertj/gruvi
lib/gruvi/futures.py
PoolBase.map
def map(self, func, *iterables, **kwargs): """Apply *func* to the elements of the sequences in *iterables*. All invocations of *func* are run in the pool. If multiple iterables are provided, then *func* must take this many arguments, and is applied with one element from each iterable. A...
python
def map(self, func, *iterables, **kwargs): """Apply *func* to the elements of the sequences in *iterables*. All invocations of *func* are run in the pool. If multiple iterables are provided, then *func* must take this many arguments, and is applied with one element from each iterable. A...
[ "def", "map", "(", "self", ",", "func", ",", "*", "iterables", ",", "*", "*", "kwargs", ")", ":", "with", "self", ".", "_lock", ":", "if", "self", ".", "_closing", ":", "raise", "RuntimeError", "(", "'pool is closing/closed'", ")", "timeout", "=", "kwa...
Apply *func* to the elements of the sequences in *iterables*. All invocations of *func* are run in the pool. If multiple iterables are provided, then *func* must take this many arguments, and is applied with one element from each iterable. All iterables must yield the same number of ele...
[ "Apply", "*", "func", "*", "to", "the", "elements", "of", "the", "sequences", "in", "*", "iterables", "*", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/futures.py#L328-L360
geertj/gruvi
lib/gruvi/futures.py
PoolBase.close
def close(self): """Close the pool and wait for all workers to exit. New submissions will be blocked. Workers will exit once their current job is finished. This method will return after all workers have exited. """ with self._lock: if self._closing: r...
python
def close(self): """Close the pool and wait for all workers to exit. New submissions will be blocked. Workers will exit once their current job is finished. This method will return after all workers have exited. """ with self._lock: if self._closing: r...
[ "def", "close", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "if", "self", ".", "_closing", ":", "return", "self", ".", "_closing", "=", "True", "if", "not", "self", ".", "_workers", ":", "self", ".", "_closed", ".", "set", "(", ")", ...
Close the pool and wait for all workers to exit. New submissions will be blocked. Workers will exit once their current job is finished. This method will return after all workers have exited.
[ "Close", "the", "pool", "and", "wait", "for", "all", "workers", "to", "exit", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/futures.py#L373-L387
unique1o1/Meta-Music
Metamusic/fingerprint.py
fingerprint
def fingerprint(channel_samples: list, Fs: int = DEFAULT_FS, wsize: int = DEFAULT_WINDOW_SIZE, wratio: Union[int, float] = DEFAULT_OVERLAP_RATIO, fan_value: int = DEFAULT_FAN_VALUE, amp_min: Union[int, float] = DEFAULT_AMP_MIN)-> Iterator[tuple]: """ ...
python
def fingerprint(channel_samples: list, Fs: int = DEFAULT_FS, wsize: int = DEFAULT_WINDOW_SIZE, wratio: Union[int, float] = DEFAULT_OVERLAP_RATIO, fan_value: int = DEFAULT_FAN_VALUE, amp_min: Union[int, float] = DEFAULT_AMP_MIN)-> Iterator[tuple]: """ ...
[ "def", "fingerprint", "(", "channel_samples", ":", "list", ",", "Fs", ":", "int", "=", "DEFAULT_FS", ",", "wsize", ":", "int", "=", "DEFAULT_WINDOW_SIZE", ",", "wratio", ":", "Union", "[", "int", ",", "float", "]", "=", "DEFAULT_OVERLAP_RATIO", ",", "fan_v...
FFT the channel, log transform output, find local maxima, then return locally sensitive hashes. #
[ "FFT", "the", "channel", "log", "transform", "output", "find", "local", "maxima", "then", "return", "locally", "sensitive", "hashes", ".", "#" ]
train
https://github.com/unique1o1/Meta-Music/blob/8cd1b04011ae3671ece44cc6338d748f8d095eaf/Metamusic/fingerprint.py#L63-L88
unique1o1/Meta-Music
Metamusic/fingerprint.py
generate_hashes
def generate_hashes(peaks, fan_value: int = DEFAULT_FAN_VALUE): """ Hash list structure: sha1_hash[0:20] time_offset [(e05b341a9b77a51fd26, 32), ... ] """ if PEAK_SORT: peaks = sorted(peaks, key=lambda x: x[1]) # peaks.sort(key=itemgetter(1)) for i in range(len(peaks))...
python
def generate_hashes(peaks, fan_value: int = DEFAULT_FAN_VALUE): """ Hash list structure: sha1_hash[0:20] time_offset [(e05b341a9b77a51fd26, 32), ... ] """ if PEAK_SORT: peaks = sorted(peaks, key=lambda x: x[1]) # peaks.sort(key=itemgetter(1)) for i in range(len(peaks))...
[ "def", "generate_hashes", "(", "peaks", ",", "fan_value", ":", "int", "=", "DEFAULT_FAN_VALUE", ")", ":", "if", "PEAK_SORT", ":", "peaks", "=", "sorted", "(", "peaks", ",", "key", "=", "lambda", "x", ":", "x", "[", "1", "]", ")", "# peaks.sort(key=itemge...
Hash list structure: sha1_hash[0:20] time_offset [(e05b341a9b77a51fd26, 32), ... ]
[ "Hash", "list", "structure", ":", "sha1_hash", "[", "0", ":", "20", "]", "time_offset", "[", "(", "e05b341a9b77a51fd26", "32", ")", "...", "]" ]
train
https://github.com/unique1o1/Meta-Music/blob/8cd1b04011ae3671ece44cc6338d748f8d095eaf/Metamusic/fingerprint.py#L133-L156
geertj/gruvi
lib/gruvi/ssl.py
SslPipe.do_handshake
def do_handshake(self, callback=None): """Start the SSL handshake. Return a list of ssldata. The optional *callback* argument can be used to install a callback that will be called when the handshake is complete. The callback will be called without arguments. """ if self....
python
def do_handshake(self, callback=None): """Start the SSL handshake. Return a list of ssldata. The optional *callback* argument can be used to install a callback that will be called when the handshake is complete. The callback will be called without arguments. """ if self....
[ "def", "do_handshake", "(", "self", ",", "callback", "=", "None", ")", ":", "if", "self", ".", "_state", "!=", "self", ".", "S_UNWRAPPED", ":", "raise", "RuntimeError", "(", "'handshake in progress or completed'", ")", "self", ".", "_sslobj", "=", "sslcompat",...
Start the SSL handshake. Return a list of ssldata. The optional *callback* argument can be used to install a callback that will be called when the handshake is complete. The callback will be called without arguments.
[ "Start", "the", "SSL", "handshake", ".", "Return", "a", "list", "of", "ssldata", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/ssl.py#L93-L108
geertj/gruvi
lib/gruvi/ssl.py
SslPipe.shutdown
def shutdown(self, callback=None): """Start the SSL shutdown sequence. Return a list of ssldata. The optional *callback* argument can be used to install a callback that will be called when the shutdown is complete. The callback will be called without arguments. """ if se...
python
def shutdown(self, callback=None): """Start the SSL shutdown sequence. Return a list of ssldata. The optional *callback* argument can be used to install a callback that will be called when the shutdown is complete. The callback will be called without arguments. """ if se...
[ "def", "shutdown", "(", "self", ",", "callback", "=", "None", ")", ":", "if", "self", ".", "_state", "==", "self", ".", "S_UNWRAPPED", ":", "raise", "RuntimeError", "(", "'no security layer present'", ")", "self", ".", "_state", "=", "self", ".", "S_SHUTDO...
Start the SSL shutdown sequence. Return a list of ssldata. The optional *callback* argument can be used to install a callback that will be called when the shutdown is complete. The callback will be called without arguments.
[ "Start", "the", "SSL", "shutdown", "sequence", ".", "Return", "a", "list", "of", "ssldata", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/ssl.py#L110-L123
geertj/gruvi
lib/gruvi/ssl.py
SslPipe.feed_eof
def feed_eof(self): """Send a potentially "ragged" EOF. This method will raise an SSL_ERROR_EOF exception if the EOF is unexpected. """ self._incoming.write_eof() ssldata, appdata = self.feed_ssldata(b'') assert appdata == [] or appdata == [b'']
python
def feed_eof(self): """Send a potentially "ragged" EOF. This method will raise an SSL_ERROR_EOF exception if the EOF is unexpected. """ self._incoming.write_eof() ssldata, appdata = self.feed_ssldata(b'') assert appdata == [] or appdata == [b'']
[ "def", "feed_eof", "(", "self", ")", ":", "self", ".", "_incoming", ".", "write_eof", "(", ")", "ssldata", ",", "appdata", "=", "self", ".", "feed_ssldata", "(", "b''", ")", "assert", "appdata", "==", "[", "]", "or", "appdata", "==", "[", "b''", "]" ...
Send a potentially "ragged" EOF. This method will raise an SSL_ERROR_EOF exception if the EOF is unexpected.
[ "Send", "a", "potentially", "ragged", "EOF", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/ssl.py#L125-L133
geertj/gruvi
lib/gruvi/ssl.py
SslPipe.feed_ssldata
def feed_ssldata(self, data): """Feed SSL record level data into the pipe. The data must be a bytes instance. It is OK to send an empty bytes instance. This can be used to get ssldata for a handshake initiated by this endpoint. Return a (ssldata, appdata) tuple. The ssldata ele...
python
def feed_ssldata(self, data): """Feed SSL record level data into the pipe. The data must be a bytes instance. It is OK to send an empty bytes instance. This can be used to get ssldata for a handshake initiated by this endpoint. Return a (ssldata, appdata) tuple. The ssldata ele...
[ "def", "feed_ssldata", "(", "self", ",", "data", ")", ":", "if", "self", ".", "_state", "==", "self", ".", "S_UNWRAPPED", ":", "# If unwrapped, pass plaintext data straight through.", "return", "(", "[", "]", ",", "[", "data", "]", "if", "data", "else", "[",...
Feed SSL record level data into the pipe. The data must be a bytes instance. It is OK to send an empty bytes instance. This can be used to get ssldata for a handshake initiated by this endpoint. Return a (ssldata, appdata) tuple. The ssldata element is a list of buffers contain...
[ "Feed", "SSL", "record", "level", "data", "into", "the", "pipe", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/ssl.py#L135-L192
geertj/gruvi
lib/gruvi/ssl.py
SslPipe.feed_appdata
def feed_appdata(self, data, offset=0): """Feed plaintext data into the pipe. Return an (ssldata, offset) tuple. The ssldata element is a list of buffers containing record level data that needs to be sent to the remote SSL instance. The offset is the number of plaintext bytes that ...
python
def feed_appdata(self, data, offset=0): """Feed plaintext data into the pipe. Return an (ssldata, offset) tuple. The ssldata element is a list of buffers containing record level data that needs to be sent to the remote SSL instance. The offset is the number of plaintext bytes that ...
[ "def", "feed_appdata", "(", "self", ",", "data", ",", "offset", "=", "0", ")", ":", "if", "self", ".", "_state", "==", "self", ".", "S_UNWRAPPED", ":", "# pass through data in unwrapped mode", "return", "(", "[", "data", "[", "offset", ":", "]", "]", "if...
Feed plaintext data into the pipe. Return an (ssldata, offset) tuple. The ssldata element is a list of buffers containing record level data that needs to be sent to the remote SSL instance. The offset is the number of plaintext bytes that were processed, which may be less than the lengt...
[ "Feed", "plaintext", "data", "into", "the", "pipe", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/ssl.py#L194-L234
geertj/gruvi
lib/gruvi/ssl.py
SslTransport.get_extra_info
def get_extra_info(self, name, default=None): """Return transport specific data. The following fields are available, in addition to the information exposed by :meth:`Transport.get_extra_info`. ====================== =============================================== Name ...
python
def get_extra_info(self, name, default=None): """Return transport specific data. The following fields are available, in addition to the information exposed by :meth:`Transport.get_extra_info`. ====================== =============================================== Name ...
[ "def", "get_extra_info", "(", "self", ",", "name", ",", "default", "=", "None", ")", ":", "if", "name", "==", "'ssl'", ":", "return", "self", ".", "_sslpipe", ".", "ssl_object", "elif", "name", "==", "'sslctx'", ":", "return", "self", ".", "_sslpipe", ...
Return transport specific data. The following fields are available, in addition to the information exposed by :meth:`Transport.get_extra_info`. ====================== =============================================== Name Description ====================== ==...
[ "Return", "transport", "specific", "data", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/ssl.py#L290-L310
geertj/gruvi
lib/gruvi/ssl.py
SslTransport.do_handshake
def do_handshake(self): """Start the SSL handshake. This method only needs to be called if this transport was created with *do_handshake_on_connect* set to False (the default is True). The handshake needs to be synchronized between the both endpoints, so that SSL record level d...
python
def do_handshake(self): """Start the SSL handshake. This method only needs to be called if this transport was created with *do_handshake_on_connect* set to False (the default is True). The handshake needs to be synchronized between the both endpoints, so that SSL record level d...
[ "def", "do_handshake", "(", "self", ")", ":", "if", "self", ".", "_error", ":", "raise", "compat", ".", "saved_exc", "(", "self", ".", "_error", ")", "elif", "self", ".", "_closing", "or", "self", ".", "_handle", ".", "closed", ":", "raise", "Transport...
Start the SSL handshake. This method only needs to be called if this transport was created with *do_handshake_on_connect* set to False (the default is True). The handshake needs to be synchronized between the both endpoints, so that SSL record level data is not incidentially interprete...
[ "Start", "the", "SSL", "handshake", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/ssl.py#L446-L463
geertj/gruvi
lib/gruvi/ssl.py
SslTransport.unwrap
def unwrap(self): """Remove the security layer. Use this method only if you want to send plaintext data on the connection after the security layer has been removed. In all other cases, use :meth:`close`. If the unwrap is initiated by us, then any data sent after it will be ...
python
def unwrap(self): """Remove the security layer. Use this method only if you want to send plaintext data on the connection after the security layer has been removed. In all other cases, use :meth:`close`. If the unwrap is initiated by us, then any data sent after it will be ...
[ "def", "unwrap", "(", "self", ")", ":", "if", "self", ".", "_error", ":", "raise", "compat", ".", "saved_exc", "(", "self", ".", "_error", ")", "elif", "self", ".", "_closing", "or", "self", ".", "_handle", ".", "closed", ":", "raise", "TransportError"...
Remove the security layer. Use this method only if you want to send plaintext data on the connection after the security layer has been removed. In all other cases, use :meth:`close`. If the unwrap is initiated by us, then any data sent after it will be buffered until the corres...
[ "Remove", "the", "security", "layer", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/ssl.py#L465-L487
geertj/gruvi
lib/gruvi/ssl.py
SslTransport.close
def close(self): """Cleanly shut down the SSL protocol and close the transport.""" if self._closing or self._handle.closed: return self._closing = True self._write_backlog.append([b'', False]) self._process_write_backlog()
python
def close(self): """Cleanly shut down the SSL protocol and close the transport.""" if self._closing or self._handle.closed: return self._closing = True self._write_backlog.append([b'', False]) self._process_write_backlog()
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_closing", "or", "self", ".", "_handle", ".", "closed", ":", "return", "self", ".", "_closing", "=", "True", "self", ".", "_write_backlog", ".", "append", "(", "[", "b''", ",", "False", "]", ...
Cleanly shut down the SSL protocol and close the transport.
[ "Cleanly", "shut", "down", "the", "SSL", "protocol", "and", "close", "the", "transport", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/ssl.py#L494-L500
geertj/gruvi
lib/gruvi/sync.py
is_locked
def is_locked(lock): """Return whether a lock is locked. Suppors :class:`Lock`, :class:`RLock`, :class:`threading.Lock` and :class:`threading.RLock` instances. """ if hasattr(lock, 'locked'): return lock.locked() elif hasattr(lock, '_is_owned'): return lock._is_owned() else:...
python
def is_locked(lock): """Return whether a lock is locked. Suppors :class:`Lock`, :class:`RLock`, :class:`threading.Lock` and :class:`threading.RLock` instances. """ if hasattr(lock, 'locked'): return lock.locked() elif hasattr(lock, '_is_owned'): return lock._is_owned() else:...
[ "def", "is_locked", "(", "lock", ")", ":", "if", "hasattr", "(", "lock", ",", "'locked'", ")", ":", "return", "lock", ".", "locked", "(", ")", "elif", "hasattr", "(", "lock", ",", "'_is_owned'", ")", ":", "return", "lock", ".", "_is_owned", "(", ")",...
Return whether a lock is locked. Suppors :class:`Lock`, :class:`RLock`, :class:`threading.Lock` and :class:`threading.RLock` instances.
[ "Return", "whether", "a", "lock", "is", "locked", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/sync.py#L268-L279
geertj/gruvi
lib/gruvi/sync.py
acquire_restore
def acquire_restore(lock, state): """Acquire a lock and restore its state.""" if hasattr(lock, '_acquire_restore'): lock._acquire_restore(state) elif hasattr(lock, 'acquire'): lock.acquire() else: raise TypeError('expecting Lock/RLock')
python
def acquire_restore(lock, state): """Acquire a lock and restore its state.""" if hasattr(lock, '_acquire_restore'): lock._acquire_restore(state) elif hasattr(lock, 'acquire'): lock.acquire() else: raise TypeError('expecting Lock/RLock')
[ "def", "acquire_restore", "(", "lock", ",", "state", ")", ":", "if", "hasattr", "(", "lock", ",", "'_acquire_restore'", ")", ":", "lock", ".", "_acquire_restore", "(", "state", ")", "elif", "hasattr", "(", "lock", ",", "'acquire'", ")", ":", "lock", ".",...
Acquire a lock and restore its state.
[ "Acquire", "a", "lock", "and", "restore", "its", "state", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/sync.py#L281-L288
geertj/gruvi
lib/gruvi/sync.py
release_save
def release_save(lock): """Release a lock and return its state.""" if hasattr(lock, '_release_save'): return lock._release_save() elif hasattr(lock, 'release'): lock.release() else: raise TypeError('expecting Lock/RLock')
python
def release_save(lock): """Release a lock and return its state.""" if hasattr(lock, '_release_save'): return lock._release_save() elif hasattr(lock, 'release'): lock.release() else: raise TypeError('expecting Lock/RLock')
[ "def", "release_save", "(", "lock", ")", ":", "if", "hasattr", "(", "lock", ",", "'_release_save'", ")", ":", "return", "lock", ".", "_release_save", "(", ")", "elif", "hasattr", "(", "lock", ",", "'release'", ")", ":", "lock", ".", "release", "(", ")"...
Release a lock and return its state.
[ "Release", "a", "lock", "and", "return", "its", "state", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/sync.py#L290-L297
geertj/gruvi
lib/gruvi/sync.py
thread_lock
def thread_lock(lock): """Return the thread lock for *lock*.""" if hasattr(lock, '_lock'): return lock._lock elif hasattr(lock, 'acquire'): return lock else: raise TypeError('expecting Lock/RLock')
python
def thread_lock(lock): """Return the thread lock for *lock*.""" if hasattr(lock, '_lock'): return lock._lock elif hasattr(lock, 'acquire'): return lock else: raise TypeError('expecting Lock/RLock')
[ "def", "thread_lock", "(", "lock", ")", ":", "if", "hasattr", "(", "lock", ",", "'_lock'", ")", ":", "return", "lock", ".", "_lock", "elif", "hasattr", "(", "lock", ",", "'acquire'", ")", ":", "return", "lock", "else", ":", "raise", "TypeError", "(", ...
Return the thread lock for *lock*.
[ "Return", "the", "thread", "lock", "for", "*", "lock", "*", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/sync.py#L299-L306
geertj/gruvi
lib/gruvi/sync.py
_Lock.acquire
def acquire(self, blocking=True, timeout=None): """Acquire the lock. If *blocking* is true (the default), then this will block until the lock can be acquired. The *timeout* parameter specifies an optional timeout in seconds. The return value is a boolean indicating whether the ...
python
def acquire(self, blocking=True, timeout=None): """Acquire the lock. If *blocking* is true (the default), then this will block until the lock can be acquired. The *timeout* parameter specifies an optional timeout in seconds. The return value is a boolean indicating whether the ...
[ "def", "acquire", "(", "self", ",", "blocking", "=", "True", ",", "timeout", "=", "None", ")", ":", "hub", "=", "get_hub", "(", ")", "try", ":", "# switcher.__call__ needs to be synchronized with a lock IF it can", "# be called from different threads. This is the case her...
Acquire the lock. If *blocking* is true (the default), then this will block until the lock can be acquired. The *timeout* parameter specifies an optional timeout in seconds. The return value is a boolean indicating whether the lock was acquired.
[ "Acquire", "the", "lock", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/sync.py#L44-L95
geertj/gruvi
lib/gruvi/sync.py
_Lock.release
def release(self): """Release the lock.""" with self._lock: if not self._locked: raise RuntimeError('lock not currently held') elif self._reentrant and self._owner is not fibers.current(): raise RuntimeError('lock not owned by this fiber') ...
python
def release(self): """Release the lock.""" with self._lock: if not self._locked: raise RuntimeError('lock not currently held') elif self._reentrant and self._owner is not fibers.current(): raise RuntimeError('lock not owned by this fiber') ...
[ "def", "release", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "if", "not", "self", ".", "_locked", ":", "raise", "RuntimeError", "(", "'lock not currently held'", ")", "elif", "self", ".", "_reentrant", "and", "self", ".", "_owner", "is", "...
Release the lock.
[ "Release", "the", "lock", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/sync.py#L111-L118
geertj/gruvi
lib/gruvi/sync.py
Event.set
def set(self): """Set the internal flag, and wake up any fibers blocked on :meth:`wait`.""" with self._lock: if self._flag: return self._flag = True with assert_no_switchpoints(): run_callbacks(self)
python
def set(self): """Set the internal flag, and wake up any fibers blocked on :meth:`wait`.""" with self._lock: if self._flag: return self._flag = True with assert_no_switchpoints(): run_callbacks(self)
[ "def", "set", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "if", "self", ".", "_flag", ":", "return", "self", ".", "_flag", "=", "True", "with", "assert_no_switchpoints", "(", ")", ":", "run_callbacks", "(", "self", ")" ]
Set the internal flag, and wake up any fibers blocked on :meth:`wait`.
[ "Set", "the", "internal", "flag", "and", "wake", "up", "any", "fibers", "blocked", "on", ":", "meth", ":", "wait", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/sync.py#L208-L215
geertj/gruvi
lib/gruvi/sync.py
Event.wait
def wait(self, timeout=None): """If the internal flag is set, return immediately. Otherwise block until the flag gets set by another fiber calling :meth:`set`.""" # Optimization for the case the Event is already set. if self._flag: return True hub = get_hub() ...
python
def wait(self, timeout=None): """If the internal flag is set, return immediately. Otherwise block until the flag gets set by another fiber calling :meth:`set`.""" # Optimization for the case the Event is already set. if self._flag: return True hub = get_hub() ...
[ "def", "wait", "(", "self", ",", "timeout", "=", "None", ")", ":", "# Optimization for the case the Event is already set.", "if", "self", ".", "_flag", ":", "return", "True", "hub", "=", "get_hub", "(", ")", "try", ":", "with", "switch_back", "(", "timeout", ...
If the internal flag is set, return immediately. Otherwise block until the flag gets set by another fiber calling :meth:`set`.
[ "If", "the", "internal", "flag", "is", "set", "return", "immediately", ".", "Otherwise", "block", "until", "the", "flag", "gets", "set", "by", "another", "fiber", "calling", ":", "meth", ":", "set", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/sync.py#L223-L250
geertj/gruvi
lib/gruvi/sync.py
Condition.notify
def notify(self, n=1): """Raise the condition and wake up fibers waiting on it. The optional *n* parameter specifies how many fibers will be notified. By default, one fiber is notified. """ if not is_locked(self._lock): raise RuntimeError('lock is not locked') ...
python
def notify(self, n=1): """Raise the condition and wake up fibers waiting on it. The optional *n* parameter specifies how many fibers will be notified. By default, one fiber is notified. """ if not is_locked(self._lock): raise RuntimeError('lock is not locked') ...
[ "def", "notify", "(", "self", ",", "n", "=", "1", ")", ":", "if", "not", "is_locked", "(", "self", ".", "_lock", ")", ":", "raise", "RuntimeError", "(", "'lock is not locked'", ")", "notified", "=", "[", "0", "]", "# Work around lack of \"nonlocal\" in py27"...
Raise the condition and wake up fibers waiting on it. The optional *n* parameter specifies how many fibers will be notified. By default, one fiber is notified.
[ "Raise", "the", "condition", "and", "wake", "up", "fibers", "waiting", "on", "it", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/sync.py#L342-L361
geertj/gruvi
lib/gruvi/sync.py
Condition.wait_for
def wait_for(self, predicate, timeout=None): """Like :meth:`wait` but additionally for *predicate* to be true. The *predicate* argument must be a callable that takes no arguments. Its result is interpreted as a boolean value. """ if not is_locked(self._lock): raise R...
python
def wait_for(self, predicate, timeout=None): """Like :meth:`wait` but additionally for *predicate* to be true. The *predicate* argument must be a callable that takes no arguments. Its result is interpreted as a boolean value. """ if not is_locked(self._lock): raise R...
[ "def", "wait_for", "(", "self", ",", "predicate", ",", "timeout", "=", "None", ")", ":", "if", "not", "is_locked", "(", "self", ".", "_lock", ")", ":", "raise", "RuntimeError", "(", "'lock is not locked'", ")", "hub", "=", "get_hub", "(", ")", "try", "...
Like :meth:`wait` but additionally for *predicate* to be true. The *predicate* argument must be a callable that takes no arguments. Its result is interpreted as a boolean value.
[ "Like", ":", "meth", ":", "wait", "but", "additionally", "for", "*", "predicate", "*", "to", "be", "true", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/sync.py#L381-L406
geertj/gruvi
lib/gruvi/sync.py
Queue.put
def put(self, item, block=True, timeout=None, size=None): """Put *item* into the queue. If the queue is currently full and *block* is True (the default), then wait up to *timeout* seconds for space to become available. If no timeout is specified, then wait indefinitely. If the ...
python
def put(self, item, block=True, timeout=None, size=None): """Put *item* into the queue. If the queue is currently full and *block* is True (the default), then wait up to *timeout* seconds for space to become available. If no timeout is specified, then wait indefinitely. If the ...
[ "def", "put", "(", "self", ",", "item", ",", "block", "=", "True", ",", "timeout", "=", "None", ",", "size", "=", "None", ")", ":", "if", "size", "is", "None", ":", "size", "=", "1", "with", "self", ".", "_lock", ":", "priority", "=", "self", "...
Put *item* into the queue. If the queue is currently full and *block* is True (the default), then wait up to *timeout* seconds for space to become available. If no timeout is specified, then wait indefinitely. If the queue is full and *block* is False or a timeout occurs, then ...
[ "Put", "*", "item", "*", "into", "the", "queue", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/sync.py#L460-L486
geertj/gruvi
lib/gruvi/sync.py
Queue.put_nowait
def put_nowait(self, item, size=None): """"Equivalent of ``put(item, False)``.""" # Don't mark this method into a switchpoint as put() will never switch # if block is False. return self.put(item, False, size=size)
python
def put_nowait(self, item, size=None): """"Equivalent of ``put(item, False)``.""" # Don't mark this method into a switchpoint as put() will never switch # if block is False. return self.put(item, False, size=size)
[ "def", "put_nowait", "(", "self", ",", "item", ",", "size", "=", "None", ")", ":", "# Don't mark this method into a switchpoint as put() will never switch", "# if block is False.", "return", "self", ".", "put", "(", "item", ",", "False", ",", "size", "=", "size", ...
Equivalent of ``put(item, False)``.
[ "Equivalent", "of", "put", "(", "item", "False", ")", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/sync.py#L488-L492
geertj/gruvi
lib/gruvi/sync.py
Queue.get
def get(self, block=True, timeout=None): """Pop an item from the queue. If the queue is not empty, an item is returned immediately. Otherwise, if *block* is True (the default), wait up to *timeout* seconds for an item to become available. If not timeout is provided, then wait in...
python
def get(self, block=True, timeout=None): """Pop an item from the queue. If the queue is not empty, an item is returned immediately. Otherwise, if *block* is True (the default), wait up to *timeout* seconds for an item to become available. If not timeout is provided, then wait in...
[ "def", "get", "(", "self", ",", "block", "=", "True", ",", "timeout", "=", "None", ")", ":", "with", "self", ".", "_lock", ":", "while", "not", "self", ".", "_heap", ":", "if", "not", "block", ":", "raise", "QueueEmpty", "if", "not", "self", ".", ...
Pop an item from the queue. If the queue is not empty, an item is returned immediately. Otherwise, if *block* is True (the default), wait up to *timeout* seconds for an item to become available. If not timeout is provided, then wait indefinitely. If the queue is empty and *bloc...
[ "Pop", "an", "item", "from", "the", "queue", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/sync.py#L495-L516
geertj/gruvi
lib/gruvi/sync.py
Queue.task_done
def task_done(self): """Mark a task as done.""" with self._lock: unfinished = self._unfinished_tasks - 1 if unfinished < 0: raise RuntimeError('task_done() called too many times') elif unfinished == 0: self._alldone.notify() ...
python
def task_done(self): """Mark a task as done.""" with self._lock: unfinished = self._unfinished_tasks - 1 if unfinished < 0: raise RuntimeError('task_done() called too many times') elif unfinished == 0: self._alldone.notify() ...
[ "def", "task_done", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "unfinished", "=", "self", ".", "_unfinished_tasks", "-", "1", "if", "unfinished", "<", "0", ":", "raise", "RuntimeError", "(", "'task_done() called too many times'", ")", "elif", ...
Mark a task as done.
[ "Mark", "a", "task", "as", "done", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/sync.py#L523-L531
geertj/gruvi
lib/gruvi/process.py
Process.spawn
def spawn(self, args, executable=None, stdin=None, stdout=None, stderr=None, shell=False, cwd=None, env=None, flags=0, extra_handles=None): """Spawn a new child process. The executable to spawn and its arguments are determined by *args*, *executable* and *shell*. When *sh...
python
def spawn(self, args, executable=None, stdin=None, stdout=None, stderr=None, shell=False, cwd=None, env=None, flags=0, extra_handles=None): """Spawn a new child process. The executable to spawn and its arguments are determined by *args*, *executable* and *shell*. When *sh...
[ "def", "spawn", "(", "self", ",", "args", ",", "executable", "=", "None", ",", "stdin", "=", "None", ",", "stdout", "=", "None", ",", "stderr", "=", "None", ",", "shell", "=", "False", ",", "cwd", "=", "None", ",", "env", "=", "None", ",", "flags...
Spawn a new child process. The executable to spawn and its arguments are determined by *args*, *executable* and *shell*. When *shell* is set to ``False`` (the default), *args* is normally a sequence and it contains both the program to execute (at index 0), and its arguments. ...
[ "Spawn", "a", "new", "child", "process", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/process.py#L135-L227
geertj/gruvi
lib/gruvi/process.py
Process.close
def close(self): """Close the process and frees its associated resources. This method waits for the resources to be freed by the event loop. """ if self._process is None: return waitfor = [] if not self._process.closed: self._process.close(self._o...
python
def close(self): """Close the process and frees its associated resources. This method waits for the resources to be freed by the event loop. """ if self._process is None: return waitfor = [] if not self._process.closed: self._process.close(self._o...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_process", "is", "None", ":", "return", "waitfor", "=", "[", "]", "if", "not", "self", ".", "_process", ".", "closed", ":", "self", ".", "_process", ".", "close", "(", "self", ".", "_on_clo...
Close the process and frees its associated resources. This method waits for the resources to be freed by the event loop.
[ "Close", "the", "process", "and", "frees", "its", "associated", "resources", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/process.py#L245-L269
geertj/gruvi
lib/gruvi/process.py
Process.send_signal
def send_signal(self, signum): """Send the signal *signum* to the child. On Windows, SIGTERM, SIGKILL and SIGINT are emulated using TerminateProcess(). This will cause the child to exit unconditionally with status 1. No other signals can be sent on Windows. """ if self._...
python
def send_signal(self, signum): """Send the signal *signum* to the child. On Windows, SIGTERM, SIGKILL and SIGINT are emulated using TerminateProcess(). This will cause the child to exit unconditionally with status 1. No other signals can be sent on Windows. """ if self._...
[ "def", "send_signal", "(", "self", ",", "signum", ")", ":", "if", "self", ".", "_process", "is", "None", ":", "raise", "RuntimeError", "(", "'no child process'", ")", "self", ".", "_process", ".", "kill", "(", "signum", ")" ]
Send the signal *signum* to the child. On Windows, SIGTERM, SIGKILL and SIGINT are emulated using TerminateProcess(). This will cause the child to exit unconditionally with status 1. No other signals can be sent on Windows.
[ "Send", "the", "signal", "*", "signum", "*", "to", "the", "child", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/process.py#L271-L280
geertj/gruvi
lib/gruvi/process.py
Process.terminate
def terminate(self): """Terminate the child process. It is not an error to call this method when the child has already exited. """ try: self.send_signal(signal.SIGTERM) except pyuv.error.ProcessError as e: if e.args[0] != pyuv.errno.UV_ESRCH: ...
python
def terminate(self): """Terminate the child process. It is not an error to call this method when the child has already exited. """ try: self.send_signal(signal.SIGTERM) except pyuv.error.ProcessError as e: if e.args[0] != pyuv.errno.UV_ESRCH: ...
[ "def", "terminate", "(", "self", ")", ":", "try", ":", "self", ".", "send_signal", "(", "signal", ".", "SIGTERM", ")", "except", "pyuv", ".", "error", ".", "ProcessError", "as", "e", ":", "if", "e", ".", "args", "[", "0", "]", "!=", "pyuv", ".", ...
Terminate the child process. It is not an error to call this method when the child has already exited.
[ "Terminate", "the", "child", "process", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/process.py#L282-L291
geertj/gruvi
lib/gruvi/process.py
Process.wait
def wait(self, timeout=-1): """Wait for the child to exit. Wait for at most *timeout* seconds, or indefinitely if *timeout* is None. Return the value of the :attr:`returncode` attribute. """ if self._process is None: raise RuntimeError('no child process') if ...
python
def wait(self, timeout=-1): """Wait for the child to exit. Wait for at most *timeout* seconds, or indefinitely if *timeout* is None. Return the value of the :attr:`returncode` attribute. """ if self._process is None: raise RuntimeError('no child process') if ...
[ "def", "wait", "(", "self", ",", "timeout", "=", "-", "1", ")", ":", "if", "self", ".", "_process", "is", "None", ":", "raise", "RuntimeError", "(", "'no child process'", ")", "if", "timeout", "==", "-", "1", ":", "timeout", "=", "self", ".", "_timeo...
Wait for the child to exit. Wait for at most *timeout* seconds, or indefinitely if *timeout* is None. Return the value of the :attr:`returncode` attribute.
[ "Wait", "for", "the", "child", "to", "exit", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/process.py#L294-L306
geertj/gruvi
lib/gruvi/process.py
Process.communicate
def communicate(self, input=None, timeout=-1): """Communicate with the child and return its output. If *input* is provided, it is sent to the client. Concurrent with sending the input, the child's standard output and standard error are read, until the child exits. The return va...
python
def communicate(self, input=None, timeout=-1): """Communicate with the child and return its output. If *input* is provided, it is sent to the client. Concurrent with sending the input, the child's standard output and standard error are read, until the child exits. The return va...
[ "def", "communicate", "(", "self", ",", "input", "=", "None", ",", "timeout", "=", "-", "1", ")", ":", "if", "self", ".", "_process", "is", "None", ":", "raise", "RuntimeError", "(", "'no child process'", ")", "if", "timeout", "==", "-", "1", ":", "t...
Communicate with the child and return its output. If *input* is provided, it is sent to the client. Concurrent with sending the input, the child's standard output and standard error are read, until the child exits. The return value is a tuple ``(stdout_data, stderr_data)`` containing ...
[ "Communicate", "with", "the", "child", "and", "return", "its", "output", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/process.py#L309-L350
geertj/gruvi
setup.py
get_requirements
def get_requirements(): """Parse a requirements.txt file and return as a list.""" with open(os.path.join(topdir, 'requirements.txt')) as fin: lines = fin.readlines() lines = [line.strip() for line in lines] return lines
python
def get_requirements(): """Parse a requirements.txt file and return as a list.""" with open(os.path.join(topdir, 'requirements.txt')) as fin: lines = fin.readlines() lines = [line.strip() for line in lines] return lines
[ "def", "get_requirements", "(", ")", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "topdir", ",", "'requirements.txt'", ")", ")", "as", "fin", ":", "lines", "=", "fin", ".", "readlines", "(", ")", "lines", "=", "[", "line", ".", "s...
Parse a requirements.txt file and return as a list.
[ "Parse", "a", "requirements", ".", "txt", "file", "and", "return", "as", "a", "list", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/setup.py#L40-L45
geertj/gruvi
lib/gruvi/dllist.py
dllist.remove
def remove(self, node): """Remove a node from the list.""" if not isinstance(node, Node): raise TypeError('expecting Node instance') if node._list is None: return if node._list is not self: raise RuntimeError('node is not contained in list') if...
python
def remove(self, node): """Remove a node from the list.""" if not isinstance(node, Node): raise TypeError('expecting Node instance') if node._list is None: return if node._list is not self: raise RuntimeError('node is not contained in list') if...
[ "def", "remove", "(", "self", ",", "node", ")", ":", "if", "not", "isinstance", "(", "node", ",", "Node", ")", ":", "raise", "TypeError", "(", "'expecting Node instance'", ")", "if", "node", ".", "_list", "is", "None", ":", "return", "if", "node", ".",...
Remove a node from the list.
[ "Remove", "a", "node", "from", "the", "list", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/dllist.py#L97-L114
geertj/gruvi
lib/gruvi/dllist.py
dllist.insert
def insert(self, node, before=None): """Insert a new node in the list. If *before* is specified, the new node is inserted before this node. Otherwise, the node is inserted at the end of the list. """ node._list = self if self._first is None: self._first = sel...
python
def insert(self, node, before=None): """Insert a new node in the list. If *before* is specified, the new node is inserted before this node. Otherwise, the node is inserted at the end of the list. """ node._list = self if self._first is None: self._first = sel...
[ "def", "insert", "(", "self", ",", "node", ",", "before", "=", "None", ")", ":", "node", ".", "_list", "=", "self", "if", "self", ".", "_first", "is", "None", ":", "self", ".", "_first", "=", "self", ".", "_last", "=", "node", "# first node in list",...
Insert a new node in the list. If *before* is specified, the new node is inserted before this node. Otherwise, the node is inserted at the end of the list.
[ "Insert", "a", "new", "node", "in", "the", "list", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/dllist.py#L116-L140
geertj/gruvi
lib/gruvi/dllist.py
dllist.clear
def clear(self): """Remove all nodes from the list.""" node = self._first while node is not None: next_node = node._next node._list = node._prev = node._next = None node = next_node self._size = 0
python
def clear(self): """Remove all nodes from the list.""" node = self._first while node is not None: next_node = node._next node._list = node._prev = node._next = None node = next_node self._size = 0
[ "def", "clear", "(", "self", ")", ":", "node", "=", "self", ".", "_first", "while", "node", "is", "not", "None", ":", "next_node", "=", "node", ".", "_next", "node", ".", "_list", "=", "node", ".", "_prev", "=", "node", ".", "_next", "=", "None", ...
Remove all nodes from the list.
[ "Remove", "all", "nodes", "from", "the", "list", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/dllist.py#L154-L161
welbornprod/colr
colr/colr.py
_build_codes
def _build_codes() -> Dict[str, Dict[str, str]]: """ Build code map, encapsulated to reduce module-level globals. """ built = { 'fore': {}, 'back': {}, 'style': {}, } # type: Dict[str, Dict[str, str]] # Set codes for forecolors (30-37) and backcolors (40-47) # Names are giv...
python
def _build_codes() -> Dict[str, Dict[str, str]]: """ Build code map, encapsulated to reduce module-level globals. """ built = { 'fore': {}, 'back': {}, 'style': {}, } # type: Dict[str, Dict[str, str]] # Set codes for forecolors (30-37) and backcolors (40-47) # Names are giv...
[ "def", "_build_codes", "(", ")", "->", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "str", "]", "]", ":", "built", "=", "{", "'fore'", ":", "{", "}", ",", "'back'", ":", "{", "}", ",", "'style'", ":", "{", "}", ",", "}", "# type: Dict[str,...
Build code map, encapsulated to reduce module-level globals.
[ "Build", "code", "map", "encapsulated", "to", "reduce", "module", "-", "level", "globals", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L170-L202
welbornprod/colr
colr/colr.py
_build_codes_reverse
def _build_codes_reverse( codes: Dict[str, Dict[str, str]]) -> Dict[str, Dict[str, str]]: """ Build a reverse escape-code to name map, based on an existing name to escape-code map. """ built = {} # type: Dict[str, Dict[str, str]] for codetype, codemap in codes.items(): for name,...
python
def _build_codes_reverse( codes: Dict[str, Dict[str, str]]) -> Dict[str, Dict[str, str]]: """ Build a reverse escape-code to name map, based on an existing name to escape-code map. """ built = {} # type: Dict[str, Dict[str, str]] for codetype, codemap in codes.items(): for name,...
[ "def", "_build_codes_reverse", "(", "codes", ":", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "str", "]", "]", ")", "->", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "str", "]", "]", ":", "built", "=", "{", "}", "# type: Dict[str, Dict[...
Build a reverse escape-code to name map, based on an existing name to escape-code map.
[ "Build", "a", "reverse", "escape", "-", "code", "to", "name", "map", "based", "on", "an", "existing", "name", "to", "escape", "-", "code", "map", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L205-L219
welbornprod/colr
colr/colr.py
auto_disable
def auto_disable( enabled: Optional[bool] = True, fds: Optional[Sequence[IO]] = (sys.stdout, sys.stderr)) -> None: """ Automatically decide whether to disable color codes if stdout or stderr are not ttys. Arguments: enabled : Whether to automatically disable color codes...
python
def auto_disable( enabled: Optional[bool] = True, fds: Optional[Sequence[IO]] = (sys.stdout, sys.stderr)) -> None: """ Automatically decide whether to disable color codes if stdout or stderr are not ttys. Arguments: enabled : Whether to automatically disable color codes...
[ "def", "auto_disable", "(", "enabled", ":", "Optional", "[", "bool", "]", "=", "True", ",", "fds", ":", "Optional", "[", "Sequence", "[", "IO", "]", "]", "=", "(", "sys", ".", "stdout", ",", "sys", ".", "stderr", ")", ")", "->", "None", ":", "if"...
Automatically decide whether to disable color codes if stdout or stderr are not ttys. Arguments: enabled : Whether to automatically disable color codes. When set to True, the fds will be checked for ttys. When set to False, enable() is called. ...
[ "Automatically", "decide", "whether", "to", "disable", "color", "codes", "if", "stdout", "or", "stderr", "are", "not", "ttys", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L222-L240
welbornprod/colr
colr/colr.py
_format_code
def _format_code( number: FormatArg, backcolor: Optional[bool] = False, light: Optional[bool] = False, extended: Optional[bool] = False) -> str: """ Return an escape code for a fore/back color, by number. This is a convenience method for handling the different code types ...
python
def _format_code( number: FormatArg, backcolor: Optional[bool] = False, light: Optional[bool] = False, extended: Optional[bool] = False) -> str: """ Return an escape code for a fore/back color, by number. This is a convenience method for handling the different code types ...
[ "def", "_format_code", "(", "number", ":", "FormatArg", ",", "backcolor", ":", "Optional", "[", "bool", "]", "=", "False", ",", "light", ":", "Optional", "[", "bool", "]", "=", "False", ",", "extended", ":", "Optional", "[", "bool", "]", "=", "False", ...
Return an escape code for a fore/back color, by number. This is a convenience method for handling the different code types all in one shot. It also handles some validation. format_fore/format_back wrap this function to reduce code duplication. Arguments: number : ...
[ "Return", "an", "escape", "code", "for", "a", "fore", "/", "back", "color", "by", "number", ".", "This", "is", "a", "convenience", "method", "for", "handling", "the", "different", "code", "types", "all", "in", "one", "shot", ".", "It", "also", "handles",...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L270-L354
welbornprod/colr
colr/colr.py
format_back
def format_back( number: FormatArg, light: Optional[bool] = False, extended: Optional[bool] = False) -> str: """ Return an escape code for a back color, by number. This is a convenience method for handling the different code types all in one shot. It also handles some...
python
def format_back( number: FormatArg, light: Optional[bool] = False, extended: Optional[bool] = False) -> str: """ Return an escape code for a back color, by number. This is a convenience method for handling the different code types all in one shot. It also handles some...
[ "def", "format_back", "(", "number", ":", "FormatArg", ",", "light", ":", "Optional", "[", "bool", "]", "=", "False", ",", "extended", ":", "Optional", "[", "bool", "]", "=", "False", ")", "->", "str", ":", "return", "_format_code", "(", "number", ",",...
Return an escape code for a back color, by number. This is a convenience method for handling the different code types all in one shot. It also handles some validation.
[ "Return", "an", "escape", "code", "for", "a", "back", "color", "by", "number", ".", "This", "is", "a", "convenience", "method", "for", "handling", "the", "different", "code", "types", "all", "in", "one", "shot", ".", "It", "also", "handles", "some", "val...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L357-L371
welbornprod/colr
colr/colr.py
format_fore
def format_fore( number: FormatArg, light: Optional[bool] = False, extended: Optional[bool] = False) -> str: """ Return an escape code for a fore color, by number. This is a convenience method for handling the different code types all in one shot. It also handles some...
python
def format_fore( number: FormatArg, light: Optional[bool] = False, extended: Optional[bool] = False) -> str: """ Return an escape code for a fore color, by number. This is a convenience method for handling the different code types all in one shot. It also handles some...
[ "def", "format_fore", "(", "number", ":", "FormatArg", ",", "light", ":", "Optional", "[", "bool", "]", "=", "False", ",", "extended", ":", "Optional", "[", "bool", "]", "=", "False", ")", "->", "str", ":", "return", "_format_code", "(", "number", ",",...
Return an escape code for a fore color, by number. This is a convenience method for handling the different code types all in one shot. It also handles some validation.
[ "Return", "an", "escape", "code", "for", "a", "fore", "color", "by", "number", ".", "This", "is", "a", "convenience", "method", "for", "handling", "the", "different", "code", "types", "all", "in", "one", "shot", ".", "It", "also", "handles", "some", "val...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L374-L388
welbornprod/colr
colr/colr.py
format_style
def format_style(number: int) -> str: """ Return an escape code for a style, by number. This handles invalid style numbers. """ if str(number) not in _stylenums: raise InvalidStyle(number) return codeformat(number)
python
def format_style(number: int) -> str: """ Return an escape code for a style, by number. This handles invalid style numbers. """ if str(number) not in _stylenums: raise InvalidStyle(number) return codeformat(number)
[ "def", "format_style", "(", "number", ":", "int", ")", "->", "str", ":", "if", "str", "(", "number", ")", "not", "in", "_stylenums", ":", "raise", "InvalidStyle", "(", "number", ")", "return", "codeformat", "(", "number", ")" ]
Return an escape code for a style, by number. This handles invalid style numbers.
[ "Return", "an", "escape", "code", "for", "a", "style", "by", "number", ".", "This", "handles", "invalid", "style", "numbers", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L391-L397
welbornprod/colr
colr/colr.py
get_all_names
def get_all_names() -> Tuple[str]: """ Retrieve a tuple of all known color names, basic and 'known names'. """ names = list(basic_names) names.extend(name_data) return tuple(sorted(set(names)))
python
def get_all_names() -> Tuple[str]: """ Retrieve a tuple of all known color names, basic and 'known names'. """ names = list(basic_names) names.extend(name_data) return tuple(sorted(set(names)))
[ "def", "get_all_names", "(", ")", "->", "Tuple", "[", "str", "]", ":", "names", "=", "list", "(", "basic_names", ")", "names", ".", "extend", "(", "name_data", ")", "return", "tuple", "(", "sorted", "(", "set", "(", "names", ")", ")", ")" ]
Retrieve a tuple of all known color names, basic and 'known names'.
[ "Retrieve", "a", "tuple", "of", "all", "known", "color", "names", "basic", "and", "known", "names", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L400-L405
welbornprod/colr
colr/colr.py
get_code_num
def get_code_num(s: str) -> Optional[int]: """ Get code number from an escape code. Raises InvalidEscapeCode if an invalid number is found. """ if ';' in s: # Extended fore/back codes. numberstr = s.rpartition(';')[-1][:-1] else: # Fore, back, style, codes. number...
python
def get_code_num(s: str) -> Optional[int]: """ Get code number from an escape code. Raises InvalidEscapeCode if an invalid number is found. """ if ';' in s: # Extended fore/back codes. numberstr = s.rpartition(';')[-1][:-1] else: # Fore, back, style, codes. number...
[ "def", "get_code_num", "(", "s", ":", "str", ")", "->", "Optional", "[", "int", "]", ":", "if", "';'", "in", "s", ":", "# Extended fore/back codes.", "numberstr", "=", "s", ".", "rpartition", "(", "';'", ")", "[", "-", "1", "]", "[", ":", "-", "1",...
Get code number from an escape code. Raises InvalidEscapeCode if an invalid number is found.
[ "Get", "code", "number", "from", "an", "escape", "code", ".", "Raises", "InvalidEscapeCode", "if", "an", "invalid", "number", "is", "found", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L408-L427
welbornprod/colr
colr/colr.py
get_code_num_rgb
def get_code_num_rgb(s: str) -> Optional[Tuple[int, int, int]]: """ Get rgb code numbers from an RGB escape code. Raises InvalidRgbEscapeCode if an invalid number is found. """ parts = s.split(';') if len(parts) != 5: raise InvalidRgbEscapeCode(s, reason='Count is off.') rgbparts = p...
python
def get_code_num_rgb(s: str) -> Optional[Tuple[int, int, int]]: """ Get rgb code numbers from an RGB escape code. Raises InvalidRgbEscapeCode if an invalid number is found. """ parts = s.split(';') if len(parts) != 5: raise InvalidRgbEscapeCode(s, reason='Count is off.') rgbparts = p...
[ "def", "get_code_num_rgb", "(", "s", ":", "str", ")", "->", "Optional", "[", "Tuple", "[", "int", ",", "int", ",", "int", "]", "]", ":", "parts", "=", "s", ".", "split", "(", "';'", ")", "if", "len", "(", "parts", ")", "!=", "5", ":", "raise", ...
Get rgb code numbers from an RGB escape code. Raises InvalidRgbEscapeCode if an invalid number is found.
[ "Get", "rgb", "code", "numbers", "from", "an", "RGB", "escape", "code", ".", "Raises", "InvalidRgbEscapeCode", "if", "an", "invalid", "number", "is", "found", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L430-L449
welbornprod/colr
colr/colr.py
get_known_codes
def get_known_codes( s: Union[str, 'Colr'], unique: Optional[bool] = True, rgb_mode: Optional[bool] = False): """ Get all known escape codes from a string, and yield the explanations. """ isdisabled = disabled() orderedcodes = tuple((c, get_known_name(c)) for c in get_codes(s)) ...
python
def get_known_codes( s: Union[str, 'Colr'], unique: Optional[bool] = True, rgb_mode: Optional[bool] = False): """ Get all known escape codes from a string, and yield the explanations. """ isdisabled = disabled() orderedcodes = tuple((c, get_known_name(c)) for c in get_codes(s)) ...
[ "def", "get_known_codes", "(", "s", ":", "Union", "[", "str", ",", "'Colr'", "]", ",", "unique", ":", "Optional", "[", "bool", "]", "=", "True", ",", "rgb_mode", ":", "Optional", "[", "bool", "]", "=", "False", ")", ":", "isdisabled", "=", "disabled"...
Get all known escape codes from a string, and yield the explanations.
[ "Get", "all", "known", "escape", "codes", "from", "a", "string", "and", "yield", "the", "explanations", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L452-L491
welbornprod/colr
colr/colr.py
get_known_name
def get_known_name(s: str) -> Optional[Tuple[str, ColorArg]]: """ Reverse translate a terminal code to a known color name, if possible. Returns a tuple of (codetype, knownname) on success. Returns None on failure. """ if not s.endswith('m'): # All codes end with 'm', so... r...
python
def get_known_name(s: str) -> Optional[Tuple[str, ColorArg]]: """ Reverse translate a terminal code to a known color name, if possible. Returns a tuple of (codetype, knownname) on success. Returns None on failure. """ if not s.endswith('m'): # All codes end with 'm', so... r...
[ "def", "get_known_name", "(", "s", ":", "str", ")", "->", "Optional", "[", "Tuple", "[", "str", ",", "ColorArg", "]", "]", ":", "if", "not", "s", ".", "endswith", "(", "'m'", ")", ":", "# All codes end with 'm', so...", "return", "None", "if", "s", "."...
Reverse translate a terminal code to a known color name, if possible. Returns a tuple of (codetype, knownname) on success. Returns None on failure.
[ "Reverse", "translate", "a", "terminal", "code", "to", "a", "known", "color", "name", "if", "possible", ".", "Returns", "a", "tuple", "of", "(", "codetype", "knownname", ")", "on", "success", ".", "Returns", "None", "on", "failure", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L494-L552
welbornprod/colr
colr/colr.py
in_range
def in_range(x: int, minimum: int, maximum: int) -> bool: """ Return True if x is >= minimum and <= maximum. """ return (x >= minimum and x <= maximum)
python
def in_range(x: int, minimum: int, maximum: int) -> bool: """ Return True if x is >= minimum and <= maximum. """ return (x >= minimum and x <= maximum)
[ "def", "in_range", "(", "x", ":", "int", ",", "minimum", ":", "int", ",", "maximum", ":", "int", ")", "->", "bool", ":", "return", "(", "x", ">=", "minimum", "and", "x", "<=", "maximum", ")" ]
Return True if x is >= minimum and <= maximum.
[ "Return", "True", "if", "x", "is", ">", "=", "minimum", "and", "<", "=", "maximum", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L584-L586
welbornprod/colr
colr/colr.py
parse_colr_arg
def parse_colr_arg( s: str, default: Optional[Any] = None, rgb_mode: Optional[bool] = False) -> ColorArg: """ Parse a user argument into a usable fore/back color value for Colr. If a falsey value is passed, default is returned. Raises InvalidColr if the argument is unusable. ...
python
def parse_colr_arg( s: str, default: Optional[Any] = None, rgb_mode: Optional[bool] = False) -> ColorArg: """ Parse a user argument into a usable fore/back color value for Colr. If a falsey value is passed, default is returned. Raises InvalidColr if the argument is unusable. ...
[ "def", "parse_colr_arg", "(", "s", ":", "str", ",", "default", ":", "Optional", "[", "Any", "]", "=", "None", ",", "rgb_mode", ":", "Optional", "[", "bool", "]", "=", "False", ")", "->", "ColorArg", ":", "if", "not", "s", ":", "return", "default", ...
Parse a user argument into a usable fore/back color value for Colr. If a falsey value is passed, default is returned. Raises InvalidColr if the argument is unusable. Returns: A usable value for Colr(fore/back). This validates basic/extended color names. This validates the range ...
[ "Parse", "a", "user", "argument", "into", "a", "usable", "fore", "/", "back", "color", "value", "for", "Colr", ".", "If", "a", "falsey", "value", "is", "passed", "default", "is", "returned", ".", "Raises", "InvalidColr", "if", "the", "argument", "is", "u...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L589-L660
welbornprod/colr
colr/colr.py
try_parse_int
def try_parse_int( s: str, default: Optional[Any] = None, minimum: Optional[int] = None, maximum: Optional[int] = None) -> Optional[Any]: """ Try parsing a string into an integer. On failure, return `default`. If the number is less then `minimum` or greater than `maxi...
python
def try_parse_int( s: str, default: Optional[Any] = None, minimum: Optional[int] = None, maximum: Optional[int] = None) -> Optional[Any]: """ Try parsing a string into an integer. On failure, return `default`. If the number is less then `minimum` or greater than `maxi...
[ "def", "try_parse_int", "(", "s", ":", "str", ",", "default", ":", "Optional", "[", "Any", "]", "=", "None", ",", "minimum", ":", "Optional", "[", "int", "]", "=", "None", ",", "maximum", ":", "Optional", "[", "int", "]", "=", "None", ")", "->", ...
Try parsing a string into an integer. On failure, return `default`. If the number is less then `minimum` or greater than `maximum`, return `default`. Returns an integer on success.
[ "Try", "parsing", "a", "string", "into", "an", "integer", ".", "On", "failure", "return", "default", ".", "If", "the", "number", "is", "less", "then", "minimum", "or", "greater", "than", "maximum", "return", "default", ".", "Returns", "an", "integer", "on"...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L663-L682
welbornprod/colr
colr/colr.py
Colr._attr_to_method
def _attr_to_method(self, attr): """ Return the correct color function by method name. Uses `partial` to build kwargs on the `chained` func. On failure/unknown name, returns None. """ if attr in codes['fore']: # Fore method return partial(self.cha...
python
def _attr_to_method(self, attr): """ Return the correct color function by method name. Uses `partial` to build kwargs on the `chained` func. On failure/unknown name, returns None. """ if attr in codes['fore']: # Fore method return partial(self.cha...
[ "def", "_attr_to_method", "(", "self", ",", "attr", ")", ":", "if", "attr", "in", "codes", "[", "'fore'", "]", ":", "# Fore method", "return", "partial", "(", "self", ".", "chained", ",", "fore", "=", "attr", ")", "elif", "attr", "in", "codes", "[", ...
Return the correct color function by method name. Uses `partial` to build kwargs on the `chained` func. On failure/unknown name, returns None.
[ "Return", "the", "correct", "color", "function", "by", "method", "name", ".", "Uses", "partial", "to", "build", "kwargs", "on", "the", "chained", "func", ".", "On", "failure", "/", "unknown", "name", "returns", "None", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L850-L877
welbornprod/colr
colr/colr.py
Colr._call_dunder_colr
def _call_dunder_colr(cls, obj): """ Call __colr__ on an object, after some checks. If color is disabled, the object itself is returned. If __colr__ doesn't return a Colr instance, TypeError is raised. On success, a Colr instance is returned from obj.__colr__(). """ ...
python
def _call_dunder_colr(cls, obj): """ Call __colr__ on an object, after some checks. If color is disabled, the object itself is returned. If __colr__ doesn't return a Colr instance, TypeError is raised. On success, a Colr instance is returned from obj.__colr__(). """ ...
[ "def", "_call_dunder_colr", "(", "cls", ",", "obj", ")", ":", "if", "_disabled", ":", "# No colorization when disabled. Just use str.", "return", "obj", "clr", "=", "obj", ".", "__colr__", "(", ")", "if", "not", "isinstance", "(", "clr", ",", "cls", ")", ":"...
Call __colr__ on an object, after some checks. If color is disabled, the object itself is returned. If __colr__ doesn't return a Colr instance, TypeError is raised. On success, a Colr instance is returned from obj.__colr__().
[ "Call", "__colr__", "on", "an", "object", "after", "some", "checks", ".", "If", "color", "is", "disabled", "the", "object", "itself", "is", "returned", ".", "If", "__colr__", "doesn", "t", "return", "a", "Colr", "instance", "TypeError", "is", "raised", "."...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L880-L902
welbornprod/colr
colr/colr.py
Colr._ext_attr_to_partial
def _ext_attr_to_partial(self, name, kwarg_key): """ Convert a string like '233' or 'aliceblue' into partial for self.chained. """ try: intval = int(name) except ValueError: # Try as an extended name_data name. info = name_data.get(name, No...
python
def _ext_attr_to_partial(self, name, kwarg_key): """ Convert a string like '233' or 'aliceblue' into partial for self.chained. """ try: intval = int(name) except ValueError: # Try as an extended name_data name. info = name_data.get(name, No...
[ "def", "_ext_attr_to_partial", "(", "self", ",", "name", ",", "kwarg_key", ")", ":", "try", ":", "intval", "=", "int", "(", "name", ")", "except", "ValueError", ":", "# Try as an extended name_data name.", "info", "=", "name_data", ".", "get", "(", "name", "...
Convert a string like '233' or 'aliceblue' into partial for self.chained.
[ "Convert", "a", "string", "like", "233", "or", "aliceblue", "into", "partial", "for", "self", ".", "chained", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L904-L920
welbornprod/colr
colr/colr.py
Colr._gradient_black_line
def _gradient_black_line( self, text, start, step=1, fore=None, back=None, style=None, reverse=False, rgb_mode=False): """ Yield colorized characters, within the 24-length black gradient. """ if start < 232: start = 232 elif start > 255: ...
python
def _gradient_black_line( self, text, start, step=1, fore=None, back=None, style=None, reverse=False, rgb_mode=False): """ Yield colorized characters, within the 24-length black gradient. """ if start < 232: start = 232 elif start > 255: ...
[ "def", "_gradient_black_line", "(", "self", ",", "text", ",", "start", ",", "step", "=", "1", ",", "fore", "=", "None", ",", "back", "=", "None", ",", "style", "=", "None", ",", "reverse", "=", "False", ",", "rgb_mode", "=", "False", ")", ":", "if"...
Yield colorized characters, within the 24-length black gradient.
[ "Yield", "colorized", "characters", "within", "the", "24", "-", "length", "black", "gradient", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L922-L946
welbornprod/colr
colr/colr.py
Colr._gradient_black_lines
def _gradient_black_lines( self, text, start, step=1, fore=None, back=None, style=None, reverse=False, movefactor=2, rgb_mode=False): """ Yield colorized characters, within the 24-length black gradient, treating each line separately. """ ...
python
def _gradient_black_lines( self, text, start, step=1, fore=None, back=None, style=None, reverse=False, movefactor=2, rgb_mode=False): """ Yield colorized characters, within the 24-length black gradient, treating each line separately. """ ...
[ "def", "_gradient_black_lines", "(", "self", ",", "text", ",", "start", ",", "step", "=", "1", ",", "fore", "=", "None", ",", "back", "=", "None", ",", "style", "=", "None", ",", "reverse", "=", "False", ",", "movefactor", "=", "2", ",", "rgb_mode", ...
Yield colorized characters, within the 24-length black gradient, treating each line separately.
[ "Yield", "colorized", "characters", "within", "the", "24", "-", "length", "black", "gradient", "treating", "each", "line", "separately", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L948-L975
welbornprod/colr
colr/colr.py
Colr._gradient_rgb_line
def _gradient_rgb_line( self, text, start, stop, step=1, fore=None, back=None, style=None): """ Yield colorized characters, morphing from one rgb value to another. """ return self._gradient_rgb_line_from_morph( text, list(self._morph_rg...
python
def _gradient_rgb_line( self, text, start, stop, step=1, fore=None, back=None, style=None): """ Yield colorized characters, morphing from one rgb value to another. """ return self._gradient_rgb_line_from_morph( text, list(self._morph_rg...
[ "def", "_gradient_rgb_line", "(", "self", ",", "text", ",", "start", ",", "stop", ",", "step", "=", "1", ",", "fore", "=", "None", ",", "back", "=", "None", ",", "style", "=", "None", ")", ":", "return", "self", ".", "_gradient_rgb_line_from_morph", "(...
Yield colorized characters, morphing from one rgb value to another.
[ "Yield", "colorized", "characters", "morphing", "from", "one", "rgb", "value", "to", "another", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L977-L989
welbornprod/colr
colr/colr.py
Colr._gradient_rgb_line_from_morph
def _gradient_rgb_line_from_morph( self, text, morphlist, fore=None, back=None, style=None): """ Yield colorized characters, morphing from one rgb value to another. """ try: listlen = len(morphlist) except TypeError: morphlist = list(morphl...
python
def _gradient_rgb_line_from_morph( self, text, morphlist, fore=None, back=None, style=None): """ Yield colorized characters, morphing from one rgb value to another. """ try: listlen = len(morphlist) except TypeError: morphlist = list(morphl...
[ "def", "_gradient_rgb_line_from_morph", "(", "self", ",", "text", ",", "morphlist", ",", "fore", "=", "None", ",", "back", "=", "None", ",", "style", "=", "None", ")", ":", "try", ":", "listlen", "=", "len", "(", "morphlist", ")", "except", "TypeError", ...
Yield colorized characters, morphing from one rgb value to another.
[ "Yield", "colorized", "characters", "morphing", "from", "one", "rgb", "value", "to", "another", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L991-L1019
welbornprod/colr
colr/colr.py
Colr._gradient_rgb_lines
def _gradient_rgb_lines( self, text, start, stop, step=1, fore=None, back=None, style=None, movefactor=None): """ Yield colorized characters, morphing from one rgb value to another. This treats each line separately. """ morphlist = list(self._morph_rgb(start, ...
python
def _gradient_rgb_lines( self, text, start, stop, step=1, fore=None, back=None, style=None, movefactor=None): """ Yield colorized characters, morphing from one rgb value to another. This treats each line separately. """ morphlist = list(self._morph_rgb(start, ...
[ "def", "_gradient_rgb_lines", "(", "self", ",", "text", ",", "start", ",", "stop", ",", "step", "=", "1", ",", "fore", "=", "None", ",", "back", "=", "None", ",", "style", "=", "None", ",", "movefactor", "=", "None", ")", ":", "morphlist", "=", "li...
Yield colorized characters, morphing from one rgb value to another. This treats each line separately.
[ "Yield", "colorized", "characters", "morphing", "from", "one", "rgb", "value", "to", "another", ".", "This", "treats", "each", "line", "separately", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1021-L1063
welbornprod/colr
colr/colr.py
Colr._iter_text_wave
def _iter_text_wave( self, text, numbers, step=1, fore=None, back=None, style=None, rgb_mode=False): """ Yield colorized characters from `text`, using a wave of `numbers`. Arguments: text : String to be colorized. numbers : A list/tuple ...
python
def _iter_text_wave( self, text, numbers, step=1, fore=None, back=None, style=None, rgb_mode=False): """ Yield colorized characters from `text`, using a wave of `numbers`. Arguments: text : String to be colorized. numbers : A list/tuple ...
[ "def", "_iter_text_wave", "(", "self", ",", "text", ",", "numbers", ",", "step", "=", "1", ",", "fore", "=", "None", ",", "back", "=", "None", ",", "style", "=", "None", ",", "rgb_mode", "=", "False", ")", ":", "if", "fore", "and", "back", ":", "...
Yield colorized characters from `text`, using a wave of `numbers`. Arguments: text : String to be colorized. numbers : A list/tuple of numbers (256 colors). step : Number of characters to colorize per color. fore : Fore color t...
[ "Yield", "colorized", "characters", "from", "text", "using", "a", "wave", "of", "numbers", ".", "Arguments", ":", "text", ":", "String", "to", "be", "colorized", ".", "numbers", ":", "A", "list", "/", "tuple", "of", "numbers", "(", "256", "colors", ")", ...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1065-L1108
welbornprod/colr
colr/colr.py
Colr._iter_wave
def _iter_wave(iterable, count=0): """ Move from beginning to end, and then end to beginning, a number of iterations through an iterable (must accept len(iterable)). Example: print(' -> '.join(_iter_wave('ABCD', count=8))) >> A -> B -> C -> D -> C -> B -> ...
python
def _iter_wave(iterable, count=0): """ Move from beginning to end, and then end to beginning, a number of iterations through an iterable (must accept len(iterable)). Example: print(' -> '.join(_iter_wave('ABCD', count=8))) >> A -> B -> C -> D -> C -> B -> ...
[ "def", "_iter_wave", "(", "iterable", ",", "count", "=", "0", ")", ":", "up", "=", "True", "pos", "=", "0", "i", "=", "0", "try", ":", "end", "=", "len", "(", "iterable", ")", "except", "TypeError", ":", "iterable", "=", "list", "(", "iterable", ...
Move from beginning to end, and then end to beginning, a number of iterations through an iterable (must accept len(iterable)). Example: print(' -> '.join(_iter_wave('ABCD', count=8))) >> A -> B -> C -> D -> C -> B -> A -> B If `count` is less than 1, ...
[ "Move", "from", "beginning", "to", "end", "and", "then", "end", "to", "beginning", "a", "number", "of", "iterations", "through", "an", "iterable", "(", "must", "accept", "len", "(", "iterable", "))", ".", "Example", ":", "print", "(", "-", ">", ".", "j...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1111-L1158
welbornprod/colr
colr/colr.py
Colr._morph_rgb
def _morph_rgb(self, rgb1, rgb2, step=1): """ Morph an rgb value into another, yielding each step along the way. """ pos1, pos2 = list(rgb1), list(rgb2) indexes = [i for i, _ in enumerate(pos1)] def step_value(a, b): """ Returns the amount to add to `a` to make it cl...
python
def _morph_rgb(self, rgb1, rgb2, step=1): """ Morph an rgb value into another, yielding each step along the way. """ pos1, pos2 = list(rgb1), list(rgb2) indexes = [i for i, _ in enumerate(pos1)] def step_value(a, b): """ Returns the amount to add to `a` to make it cl...
[ "def", "_morph_rgb", "(", "self", ",", "rgb1", ",", "rgb2", ",", "step", "=", "1", ")", ":", "pos1", ",", "pos2", "=", "list", "(", "rgb1", ")", ",", "list", "(", "rgb2", ")", "indexes", "=", "[", "i", "for", "i", ",", "_", "in", "enumerate", ...
Morph an rgb value into another, yielding each step along the way.
[ "Morph", "an", "rgb", "value", "into", "another", "yielding", "each", "step", "along", "the", "way", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1160-L1192
welbornprod/colr
colr/colr.py
Colr._rainbow_hex_chars
def _rainbow_hex_chars(self, s, freq=0.1, spread=3.0, offset=0): """ Iterate over characters in a string to build data needed for a rainbow effect. Yields tuples of (char, hexcode). Arguments: s : String to colorize. freq : Frequency/"ti...
python
def _rainbow_hex_chars(self, s, freq=0.1, spread=3.0, offset=0): """ Iterate over characters in a string to build data needed for a rainbow effect. Yields tuples of (char, hexcode). Arguments: s : String to colorize. freq : Frequency/"ti...
[ "def", "_rainbow_hex_chars", "(", "self", ",", "s", ",", "freq", "=", "0.1", ",", "spread", "=", "3.0", ",", "offset", "=", "0", ")", ":", "return", "(", "(", "c", ",", "self", ".", "_rainbow_color", "(", "freq", ",", "offset", "+", "i", "/", "sp...
Iterate over characters in a string to build data needed for a rainbow effect. Yields tuples of (char, hexcode). Arguments: s : String to colorize. freq : Frequency/"tightness" of colors in the rainbow. Best results when...
[ "Iterate", "over", "characters", "in", "a", "string", "to", "build", "data", "needed", "for", "a", "rainbow", "effect", ".", "Yields", "tuples", "of", "(", "char", "hexcode", ")", ".", "Arguments", ":", "s", ":", "String", "to", "colorize", ".", "freq", ...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1202-L1219
welbornprod/colr
colr/colr.py
Colr._rainbow_line
def _rainbow_line( self, text, freq=0.1, spread=3.0, offset=0, rgb_mode=False, **colorargs): """ Create rainbow using the same offset for all text. Arguments: text : String to colorize. freq : Frequency/"tightness" of colors in the ...
python
def _rainbow_line( self, text, freq=0.1, spread=3.0, offset=0, rgb_mode=False, **colorargs): """ Create rainbow using the same offset for all text. Arguments: text : String to colorize. freq : Frequency/"tightness" of colors in the ...
[ "def", "_rainbow_line", "(", "self", ",", "text", ",", "freq", "=", "0.1", ",", "spread", "=", "3.0", ",", "offset", "=", "0", ",", "rgb_mode", "=", "False", ",", "*", "*", "colorargs", ")", ":", "fore", "=", "colorargs", ".", "get", "(", "'fore'",...
Create rainbow using the same offset for all text. Arguments: text : String to colorize. freq : Frequency/"tightness" of colors in the rainbow. Best results when in the range 0.0-1.0. Default: 0.1 ...
[ "Create", "rainbow", "using", "the", "same", "offset", "for", "all", "text", ".", "Arguments", ":", "text", ":", "String", "to", "colorize", ".", "freq", ":", "Frequency", "/", "tightness", "of", "colors", "in", "the", "rainbow", ".", "Best", "results", ...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1221-L1269
welbornprod/colr
colr/colr.py
Colr._rainbow_lines
def _rainbow_lines( self, text, freq=0.1, spread=3.0, offset=0, movefactor=0, rgb_mode=False, **colorargs): """ Create rainbow text, using the same offset for each line. Arguments: text : String to colorize. freq : Frequency/"tightn...
python
def _rainbow_lines( self, text, freq=0.1, spread=3.0, offset=0, movefactor=0, rgb_mode=False, **colorargs): """ Create rainbow text, using the same offset for each line. Arguments: text : String to colorize. freq : Frequency/"tightn...
[ "def", "_rainbow_lines", "(", "self", ",", "text", ",", "freq", "=", "0.1", ",", "spread", "=", "3.0", ",", "offset", "=", "0", ",", "movefactor", "=", "0", ",", "rgb_mode", "=", "False", ",", "*", "*", "colorargs", ")", ":", "if", "not", "movefact...
Create rainbow text, using the same offset for each line. Arguments: text : String to colorize. freq : Frequency/"tightness" of colors in the rainbow. Best results when in the range 0.0-1.0. Default: 0.1 ...
[ "Create", "rainbow", "text", "using", "the", "same", "offset", "for", "each", "line", ".", "Arguments", ":", "text", ":", "String", "to", "colorize", ".", "freq", ":", "Frequency", "/", "tightness", "of", "colors", "in", "the", "rainbow", ".", "Best", "r...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1271-L1307
welbornprod/colr
colr/colr.py
Colr._rainbow_rgb
def _rainbow_rgb(self, freq, i): """ Calculate a single rgb value for a piece of a rainbow. Arguments: freq : "Tightness" of colors (see self.rainbow()) i : Index of character in string to colorize. """ # Borrowed from lolcat, translated from ruby...
python
def _rainbow_rgb(self, freq, i): """ Calculate a single rgb value for a piece of a rainbow. Arguments: freq : "Tightness" of colors (see self.rainbow()) i : Index of character in string to colorize. """ # Borrowed from lolcat, translated from ruby...
[ "def", "_rainbow_rgb", "(", "self", ",", "freq", ",", "i", ")", ":", "# Borrowed from lolcat, translated from ruby.", "red", "=", "math", ".", "sin", "(", "freq", "*", "i", "+", "0", ")", "*", "127", "+", "128", "green", "=", "math", ".", "sin", "(", ...
Calculate a single rgb value for a piece of a rainbow. Arguments: freq : "Tightness" of colors (see self.rainbow()) i : Index of character in string to colorize.
[ "Calculate", "a", "single", "rgb", "value", "for", "a", "piece", "of", "a", "rainbow", ".", "Arguments", ":", "freq", ":", "Tightness", "of", "colors", "(", "see", "self", ".", "rainbow", "()", ")", "i", ":", "Index", "of", "character", "in", "string",...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1309-L1319
welbornprod/colr
colr/colr.py
Colr._rainbow_rgb_chars
def _rainbow_rgb_chars(self, s, freq=0.1, spread=3.0, offset=0): """ Iterate over characters in a string to build data needed for a rainbow effect. Yields tuples of (char, (r, g, b)). Arguments: s : String to colorize. freq : Frequency/"...
python
def _rainbow_rgb_chars(self, s, freq=0.1, spread=3.0, offset=0): """ Iterate over characters in a string to build data needed for a rainbow effect. Yields tuples of (char, (r, g, b)). Arguments: s : String to colorize. freq : Frequency/"...
[ "def", "_rainbow_rgb_chars", "(", "self", ",", "s", ",", "freq", "=", "0.1", ",", "spread", "=", "3.0", ",", "offset", "=", "0", ")", ":", "return", "(", "(", "c", ",", "self", ".", "_rainbow_rgb", "(", "freq", ",", "offset", "+", "i", "/", "spre...
Iterate over characters in a string to build data needed for a rainbow effect. Yields tuples of (char, (r, g, b)). Arguments: s : String to colorize. freq : Frequency/"tightness" of colors in the rainbow. Best results wh...
[ "Iterate", "over", "characters", "in", "a", "string", "to", "build", "data", "needed", "for", "a", "rainbow", "effect", ".", "Yields", "tuples", "of", "(", "char", "(", "r", "g", "b", "))", ".", "Arguments", ":", "s", ":", "String", "to", "colorize", ...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1321-L1338
welbornprod/colr
colr/colr.py
Colr.b_rgb
def b_rgb(self, r, g, b, text=None, fore=None, style=None): """ A chained method that sets the back color to an RGB value. Arguments: r : Red value. g : Green value. b : Blue value. text : Text to style if not building up c...
python
def b_rgb(self, r, g, b, text=None, fore=None, style=None): """ A chained method that sets the back color to an RGB value. Arguments: r : Red value. g : Green value. b : Blue value. text : Text to style if not building up c...
[ "def", "b_rgb", "(", "self", ",", "r", ",", "g", ",", "b", ",", "text", "=", "None", ",", "fore", "=", "None", ",", "style", "=", "None", ")", ":", "return", "self", ".", "chained", "(", "text", "=", "text", ",", "fore", "=", "fore", ",", "ba...
A chained method that sets the back color to an RGB value. Arguments: r : Red value. g : Green value. b : Blue value. text : Text to style if not building up color codes. fore : Fore color for the text. ...
[ "A", "chained", "method", "that", "sets", "the", "back", "color", "to", "an", "RGB", "value", ".", "Arguments", ":", "r", ":", "Red", "value", ".", "g", ":", "Green", "value", ".", "b", ":", "Blue", "value", ".", "text", ":", "Text", "to", "style",...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1363-L1373
welbornprod/colr
colr/colr.py
Colr.chained
def chained(self, text=None, fore=None, back=None, style=None): """ Called by the various 'color' methods to colorize a single string. The RESET_ALL code is appended to the string unless text is empty. Raises ValueError on invalid color names. Arguments: text...
python
def chained(self, text=None, fore=None, back=None, style=None): """ Called by the various 'color' methods to colorize a single string. The RESET_ALL code is appended to the string unless text is empty. Raises ValueError on invalid color names. Arguments: text...
[ "def", "chained", "(", "self", ",", "text", "=", "None", ",", "fore", "=", "None", ",", "back", "=", "None", ",", "style", "=", "None", ")", ":", "self", ".", "data", "=", "''", ".", "join", "(", "(", "self", ".", "data", ",", "self", ".", "c...
Called by the various 'color' methods to colorize a single string. The RESET_ALL code is appended to the string unless text is empty. Raises ValueError on invalid color names. Arguments: text : String to colorize, or None for BG/Style change. fore ...
[ "Called", "by", "the", "various", "color", "methods", "to", "colorize", "a", "single", "string", ".", "The", "RESET_ALL", "code", "is", "appended", "to", "the", "string", "unless", "text", "is", "empty", ".", "Raises", "ValueError", "on", "invalid", "color",...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1375-L1390
welbornprod/colr
colr/colr.py
Colr.color
def color( self, text=None, fore=None, back=None, style=None, no_closing=False): """ A method that colorizes strings, not Colr objects. Raises InvalidColr for invalid color names. The 'reset_all' code is appended if text is given. """ has_args = ( ...
python
def color( self, text=None, fore=None, back=None, style=None, no_closing=False): """ A method that colorizes strings, not Colr objects. Raises InvalidColr for invalid color names. The 'reset_all' code is appended if text is given. """ has_args = ( ...
[ "def", "color", "(", "self", ",", "text", "=", "None", ",", "fore", "=", "None", ",", "back", "=", "None", ",", "style", "=", "None", ",", "no_closing", "=", "False", ")", ":", "has_args", "=", "(", "(", "fore", "is", "not", "None", ")", "or", ...
A method that colorizes strings, not Colr objects. Raises InvalidColr for invalid color names. The 'reset_all' code is appended if text is given.
[ "A", "method", "that", "colorizes", "strings", "not", "Colr", "objects", ".", "Raises", "InvalidColr", "for", "invalid", "color", "names", ".", "The", "reset_all", "code", "is", "appended", "if", "text", "is", "given", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1392-L1437
welbornprod/colr
colr/colr.py
Colr.color_code
def color_code(self, fore=None, back=None, style=None): """ Return the codes for this style/colors. """ # Map from style type to raw code formatter function. colorcodes = [] resetcodes = [] userstyles = {'style': style, 'back': back, 'fore': fore} for stype in userstyles:...
python
def color_code(self, fore=None, back=None, style=None): """ Return the codes for this style/colors. """ # Map from style type to raw code formatter function. colorcodes = [] resetcodes = [] userstyles = {'style': style, 'back': back, 'fore': fore} for stype in userstyles:...
[ "def", "color_code", "(", "self", ",", "fore", "=", "None", ",", "back", "=", "None", ",", "style", "=", "None", ")", ":", "# Map from style type to raw code formatter function.", "colorcodes", "=", "[", "]", "resetcodes", "=", "[", "]", "userstyles", "=", "...
Return the codes for this style/colors.
[ "Return", "the", "codes", "for", "this", "style", "/", "colors", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1439-L1460
welbornprod/colr
colr/colr.py
Colr.format
def format(self, *args, **kwargs): """ Like str.format, except it returns a Colr. """ return self.__class__(self.data.format(*args, **kwargs))
python
def format(self, *args, **kwargs): """ Like str.format, except it returns a Colr. """ return self.__class__(self.data.format(*args, **kwargs))
[ "def", "format", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__class__", "(", "self", ".", "data", ".", "format", "(", "*", "args", ",", "*", "*", "kwargs", ")", ")" ]
Like str.format, except it returns a Colr.
[ "Like", "str", ".", "format", "except", "it", "returns", "a", "Colr", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1468-L1470
welbornprod/colr
colr/colr.py
Colr.get_escape_code
def get_escape_code(self, codetype, value): """ Convert user arg to escape code. """ valuefmt = str(value).lower() code = codes[codetype].get(valuefmt, None) if code: # Basic code from fore, back, or style. return code named_funcs = { 'fore': ...
python
def get_escape_code(self, codetype, value): """ Convert user arg to escape code. """ valuefmt = str(value).lower() code = codes[codetype].get(valuefmt, None) if code: # Basic code from fore, back, or style. return code named_funcs = { 'fore': ...
[ "def", "get_escape_code", "(", "self", ",", "codetype", ",", "value", ")", ":", "valuefmt", "=", "str", "(", "value", ")", ".", "lower", "(", ")", "code", "=", "codes", "[", "codetype", "]", ".", "get", "(", "valuefmt", ",", "None", ")", "if", "cod...
Convert user arg to escape code.
[ "Convert", "user", "arg", "to", "escape", "code", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1472-L1523
welbornprod/colr
colr/colr.py
Colr.gradient
def gradient( self, text=None, name=None, fore=None, back=None, style=None, freq=0.1, spread=None, linemode=True, movefactor=2, rgb_mode=False): """ Return a gradient by color name. Uses rainbow() underneath to build the gradients, starting at a known offset. ...
python
def gradient( self, text=None, name=None, fore=None, back=None, style=None, freq=0.1, spread=None, linemode=True, movefactor=2, rgb_mode=False): """ Return a gradient by color name. Uses rainbow() underneath to build the gradients, starting at a known offset. ...
[ "def", "gradient", "(", "self", ",", "text", "=", "None", ",", "name", "=", "None", ",", "fore", "=", "None", ",", "back", "=", "None", ",", "style", "=", "None", ",", "freq", "=", "0.1", ",", "spread", "=", "None", ",", "linemode", "=", "True", ...
Return a gradient by color name. Uses rainbow() underneath to build the gradients, starting at a known offset. Arguments: text : Text to make gradient (self.data when not given). The gradient text is joined to self.data when ...
[ "Return", "a", "gradient", "by", "color", "name", ".", "Uses", "rainbow", "()", "underneath", "to", "build", "the", "gradients", "starting", "at", "a", "known", "offset", ".", "Arguments", ":", "text", ":", "Text", "to", "make", "gradient", "(", "self", ...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1525-L1603
welbornprod/colr
colr/colr.py
Colr.gradient_black
def gradient_black( self, text=None, fore=None, back=None, style=None, start=None, step=1, reverse=False, linemode=True, movefactor=2, rgb_mode=False): """ Return a black and white gradient. Arguments: text : String to colorize. ...
python
def gradient_black( self, text=None, fore=None, back=None, style=None, start=None, step=1, reverse=False, linemode=True, movefactor=2, rgb_mode=False): """ Return a black and white gradient. Arguments: text : String to colorize. ...
[ "def", "gradient_black", "(", "self", ",", "text", "=", "None", ",", "fore", "=", "None", ",", "back", "=", "None", ",", "style", "=", "None", ",", "start", "=", "None", ",", "step", "=", "1", ",", "reverse", "=", "False", ",", "linemode", "=", "...
Return a black and white gradient. Arguments: text : String to colorize. This will always be greater than 0. fore : Foreground color, background will be gradient. back : Background color, foreground will be gradie...
[ "Return", "a", "black", "and", "white", "gradient", ".", "Arguments", ":", "text", ":", "String", "to", "colorize", ".", "This", "will", "always", "be", "greater", "than", "0", ".", "fore", ":", "Foreground", "color", "background", "will", "be", "gradient"...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1605-L1664
welbornprod/colr
colr/colr.py
Colr.gradient_rgb
def gradient_rgb( self, text=None, fore=None, back=None, style=None, start=None, stop=None, step=1, linemode=True, movefactor=0): """ Return a black and white gradient. Arguments: text : String to colorize. fore : Foreground color, ...
python
def gradient_rgb( self, text=None, fore=None, back=None, style=None, start=None, stop=None, step=1, linemode=True, movefactor=0): """ Return a black and white gradient. Arguments: text : String to colorize. fore : Foreground color, ...
[ "def", "gradient_rgb", "(", "self", ",", "text", "=", "None", ",", "fore", "=", "None", ",", "back", "=", "None", ",", "style", "=", "None", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "step", "=", "1", ",", "linemode", "=", "True",...
Return a black and white gradient. Arguments: text : String to colorize. fore : Foreground color, background will be gradient. back : Background color, foreground will be gradient. style : Name of style to use for the gra...
[ "Return", "a", "black", "and", "white", "gradient", ".", "Arguments", ":", "text", ":", "String", "to", "colorize", ".", "fore", ":", "Foreground", "color", "background", "will", "be", "gradient", ".", "back", ":", "Background", "color", "foreground", "will"...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1666-L1721
welbornprod/colr
colr/colr.py
Colr.hex
def hex(self, value, text=None, back=None, style=None, rgb_mode=False): """ A chained method that sets the fore color to an hex value. Arguments: value : Hex value to convert. text : Text to style if not building up color codes. back : Back ...
python
def hex(self, value, text=None, back=None, style=None, rgb_mode=False): """ A chained method that sets the fore color to an hex value. Arguments: value : Hex value to convert. text : Text to style if not building up color codes. back : Back ...
[ "def", "hex", "(", "self", ",", "value", ",", "text", "=", "None", ",", "back", "=", "None", ",", "style", "=", "None", ",", "rgb_mode", "=", "False", ")", ":", "if", "rgb_mode", ":", "try", ":", "colrval", "=", "hex2rgb", "(", "value", ",", "all...
A chained method that sets the fore color to an hex value. Arguments: value : Hex value to convert. text : Text to style if not building up color codes. back : Back color for the text. style : Style for the text. r...
[ "A", "chained", "method", "that", "sets", "the", "fore", "color", "to", "an", "hex", "value", ".", "Arguments", ":", "value", ":", "Hex", "value", "to", "convert", ".", "text", ":", "Text", "to", "style", "if", "not", "building", "up", "color", "codes"...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1723-L1744
welbornprod/colr
colr/colr.py
Colr.join
def join(self, *colrs, **colorkwargs): """ Like str.join, except it returns a Colr. Arguments: colrs : One or more Colrs. If a list or tuple is passed as an argument it will be flattened. Keyword Arguments: fore, back, style... ...
python
def join(self, *colrs, **colorkwargs): """ Like str.join, except it returns a Colr. Arguments: colrs : One or more Colrs. If a list or tuple is passed as an argument it will be flattened. Keyword Arguments: fore, back, style... ...
[ "def", "join", "(", "self", ",", "*", "colrs", ",", "*", "*", "colorkwargs", ")", ":", "flat", "=", "[", "]", "for", "clr", "in", "colrs", ":", "if", "isinstance", "(", "clr", ",", "(", "list", ",", "tuple", ",", "GeneratorType", ")", ")", ":", ...
Like str.join, except it returns a Colr. Arguments: colrs : One or more Colrs. If a list or tuple is passed as an argument it will be flattened. Keyword Arguments: fore, back, style... see color().
[ "Like", "str", ".", "join", "except", "it", "returns", "a", "Colr", ".", "Arguments", ":", "colrs", ":", "One", "or", "more", "Colrs", ".", "If", "a", "list", "or", "tuple", "is", "passed", "as", "an", "argument", "it", "will", "be", "flattened", "."...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1746-L1771
welbornprod/colr
colr/colr.py
Colr.lstrip
def lstrip(self, chars=None): """ Like str.lstrip, except it returns the Colr instance. """ return self.__class__( self._str_strip('lstrip', chars), no_closing=chars and (closing_code in chars), )
python
def lstrip(self, chars=None): """ Like str.lstrip, except it returns the Colr instance. """ return self.__class__( self._str_strip('lstrip', chars), no_closing=chars and (closing_code in chars), )
[ "def", "lstrip", "(", "self", ",", "chars", "=", "None", ")", ":", "return", "self", ".", "__class__", "(", "self", ".", "_str_strip", "(", "'lstrip'", ",", "chars", ")", ",", "no_closing", "=", "chars", "and", "(", "closing_code", "in", "chars", ")", ...
Like str.lstrip, except it returns the Colr instance.
[ "Like", "str", ".", "lstrip", "except", "it", "returns", "the", "Colr", "instance", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1773-L1778
welbornprod/colr
colr/colr.py
Colr.print
def print(self, *args, **kwargs): """ Chainable print method. Prints self.data and then clears it. """ print(self, *args, **kwargs) self.data = '' return self
python
def print(self, *args, **kwargs): """ Chainable print method. Prints self.data and then clears it. """ print(self, *args, **kwargs) self.data = '' return self
[ "def", "print", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "print", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "data", "=", "''", "return", "self" ]
Chainable print method. Prints self.data and then clears it.
[ "Chainable", "print", "method", ".", "Prints", "self", ".", "data", "and", "then", "clears", "it", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1780-L1784
welbornprod/colr
colr/colr.py
Colr.rainbow
def rainbow( self, text=None, fore=None, back=None, style=None, freq=0.1, offset=30, spread=3.0, linemode=True, movefactor=2, rgb_mode=False): """ Make rainbow gradient text. Arguments: text : Text to make gradient. ...
python
def rainbow( self, text=None, fore=None, back=None, style=None, freq=0.1, offset=30, spread=3.0, linemode=True, movefactor=2, rgb_mode=False): """ Make rainbow gradient text. Arguments: text : Text to make gradient. ...
[ "def", "rainbow", "(", "self", ",", "text", "=", "None", ",", "fore", "=", "None", ",", "back", "=", "None", ",", "style", "=", "None", ",", "freq", "=", "0.1", ",", "offset", "=", "30", ",", "spread", "=", "3.0", ",", "linemode", "=", "True", ...
Make rainbow gradient text. Arguments: text : Text to make gradient. Default: self.data fore : Fore color to use (makes back the rainbow). Default: None back : Back color to use (makes...
[ "Make", "rainbow", "gradient", "text", ".", "Arguments", ":", "text", ":", "Text", "to", "make", "gradient", ".", "Default", ":", "self", ".", "data", "fore", ":", "Fore", "color", "to", "use", "(", "makes", "back", "the", "rainbow", ")", ".", "Default...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1786-L1847