repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
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...
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...
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...
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. ...
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...
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...
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: ...
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.
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 ...
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*.
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)
Write *data* to the transport. This method will block if the transport's write buffer is at capacity.
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...
Write the elements of the sequence *seq* to the transport. This method will block if the transport's write buffer is at capacity.
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()
Close the write direction of the transport. This method will block if the transport's write buffer is at capacity.
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...
Close the stream. If *autoclose* was passed to the constructor then the underlying transport will be closed as well.
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()
Run a function that uses blocking IO. The function is run in the IO thread pool.
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...
Wait for one or more waitable objects, yielding them as they become ready. This is the iterator/generator version of :func:`wait`.
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 ...
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 ...
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)
Return whether this future was successfully cancelled.
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...
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...
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): ...
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.
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 =...
Wait for the async function to complete and return its exception. If the function did not raise an exception this returns ``None``.
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. ...
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...
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...
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.
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...
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...
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...
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.
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]: """ ...
FFT the channel, log transform output, find local maxima, then return locally sensitive hashes. #
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))...
Hash list structure: sha1_hash[0:20] time_offset [(e05b341a9b77a51fd26, 32), ... ]
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....
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.
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...
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.
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'']
Send a potentially "ragged" EOF. This method will raise an SSL_ERROR_EOF exception if the EOF is unexpected.
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...
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...
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 ...
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...
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 ...
Return transport specific data. The following fields are available, in addition to the information exposed by :meth:`Transport.get_extra_info`. ====================== =============================================== Name Description ====================== ==...
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...
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...
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 ...
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...
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()
Cleanly shut down the SSL protocol and close the transport.
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:...
Return whether a lock is locked. Suppors :class:`Lock`, :class:`RLock`, :class:`threading.Lock` and :class:`threading.RLock` instances.
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')
Acquire a lock and restore its state.
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')
Release a lock and return its state.
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')
Return the thread lock for *lock*.
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 ...
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.
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') ...
Release the lock.
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)
Set the internal flag, and wake up any fibers blocked on :meth:`wait`.
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() ...
If the internal flag is set, return immediately. Otherwise block until the flag gets set by another fiber calling :meth:`set`.
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') ...
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.
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...
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.
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 ...
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 ...
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)
Equivalent of ``put(item, False)``.
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...
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...
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() ...
Mark a task as done.
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...
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. ...
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...
Close the process and frees its associated resources. This method waits for the resources to be freed by the event loop.
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._...
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.
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: ...
Terminate the child process. It is not an error to call this method when the child has already exited.
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 ...
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.
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...
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 ...
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
Parse a requirements.txt file and return as a list.
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...
Remove a node from the list.
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...
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.
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
Remove all nodes from the list.
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...
Build code map, encapsulated to reduce module-level globals.
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,...
Build a reverse escape-code to name map, based on an existing name to escape-code map.
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...
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. ...
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 ...
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 : ...
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...
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.
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...
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.
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)
Return an escape code for a style, by number. This handles invalid style numbers.
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)))
Retrieve a tuple of all known color names, basic and 'known names'.
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...
Get code number from an escape code. Raises InvalidEscapeCode if an invalid number is found.
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...
Get rgb code numbers from an RGB escape code. Raises InvalidRgbEscapeCode if an invalid number is found.
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)) ...
Get all known escape codes from a string, and yield the explanations.
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...
Reverse translate a terminal code to a known color name, if possible. Returns a tuple of (codetype, knownname) on success. Returns None on failure.
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)
Return True if x is >= minimum and <= maximum.
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. ...
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 ...
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...
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.
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...
Return the correct color function by method name. Uses `partial` to build kwargs on the `chained` func. On failure/unknown name, returns None.
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__(). """ ...
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__().
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...
Convert a string like '233' or 'aliceblue' into partial for self.chained.
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: ...
Yield colorized characters, within the 24-length black gradient.
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. """ ...
Yield colorized characters, within the 24-length black gradient, treating each line separately.
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...
Yield colorized characters, morphing from one rgb value to another.
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...
Yield colorized characters, morphing from one rgb value to another.
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, ...
Yield colorized characters, morphing from one rgb value to another. This treats each line separately.
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 ...
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...
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 -> ...
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, ...
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...
Morph an rgb value into another, yielding each step along the way.
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...
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...
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 ...
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 ...
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...
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 ...
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...
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.
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/"...
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...
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...
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. ...
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...
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 ...
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 = ( ...
A method that colorizes strings, not Colr objects. Raises InvalidColr for invalid color names. The 'reset_all' code is appended if text is given.
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:...
Return the codes for this style/colors.
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))
Like str.format, except it returns a Colr.
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': ...
Convert user arg to escape code.
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. ...
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 ...
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. ...
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...
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, ...
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...
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 ...
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...
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... ...
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().
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), )
Like str.lstrip, except it returns the Colr instance.
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
Chainable print method. Prints self.data and then clears it.
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. ...
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...
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1786-L1847