runtimepy.util
index
/home/vkottler/src/vkottler/workspace/runtimepy/runtimepy/util.py

A module implementing package utilities.

 
Modules
       
logging
re

 
Classes
       
builtins.object
Identifier
builtins.tuple(builtins.object)
StrToBool
logging.Handler(logging.Filterer)
ListLogger

 
class Identifier(builtins.object)
    Identifier() -> None
 
A simple message indentifier interface.
 
  Methods defined here:
__call__(self) -> int
Get the next identifier.
__init__(self) -> None
Initialize this instance.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class ListLogger(logging.Handler)
    ListLogger(level=0)
 
An interface facilitating sending log messages to browser tabs.
 
 
Method resolution order:
ListLogger
logging.Handler
logging.Filterer
builtins.object

Methods defined here:
__bool__(self) -> bool
Evaluate this instance as boolean.
drain(self) -> list[logging.LogRecord]
Drain messages.
drain_str(self) -> list[str]
Drain formatted messages.
emit(self, record: logging.LogRecord) -> None
Send the log message.

Static methods defined here:
create() -> 'ListLogger'
Create an instance of this handler.

Data and other attributes defined here:
__annotations__ = {'log_messages': list[logging.LogRecord]}

Methods inherited from logging.Handler:
__init__(self, level=0)
Initializes the instance - basically setting the formatter to None
and the filter list to empty.
__repr__(self)
Return repr(self).
acquire(self)
Acquire the I/O thread lock.
close(self)
Tidy up any resources used by the handler.
 
This version removes the handler from an internal map of handlers,
_handlers, which is used for handler lookup by name. Subclasses
should ensure that this gets called from overridden close()
methods.
createLock(self)
Acquire a thread lock for serializing access to the underlying I/O.
flush(self)
Ensure all logging output has been flushed.
 
This version does nothing and is intended to be implemented by
subclasses.
format(self, record)
Format the specified record.
 
If a formatter is set, use it. Otherwise, use the default formatter
for the module.
get_name(self)
handle(self, record)
Conditionally emit the specified logging record.
 
Emission depends on filters which may have been added to the handler.
Wrap the actual emission of the record with acquisition/release of
the I/O thread lock.
 
Returns an instance of the log record that was emitted
if it passed all filters, otherwise a false value is returned.
handleError(self, record)
Handle errors which occur during an emit() call.
 
This method should be called from handlers when an exception is
encountered during an emit() call. If raiseExceptions is false,
exceptions get silently ignored. This is what is mostly wanted
for a logging system - most users will not care about errors in
the logging system, they are more interested in application errors.
You could, however, replace this with a custom handler if you wish.
The record which was being processed is passed in to this method.
release(self)
Release the I/O thread lock.
setFormatter(self, fmt)
Set the formatter for this handler.
setLevel(self, level)
Set the logging level of this handler.  level must be an int or a str.
set_name(self, name)

Data descriptors inherited from logging.Handler:
name

Methods inherited from logging.Filterer:
addFilter(self, filter)
Add the specified filter to this handler.
filter(self, record)
Determine if a record is loggable by consulting all the filters.
 
The default is to allow the record to be logged; any filter can veto
this by returning a false value.
If a filter attached to a handler returns a log record instance,
then that instance is used in place of the original log record in
any further processing of the event by that handler.
If a filter returns any other true value, the original log record
is used in any further processing of the event by that handler.
 
If none of the filters return false values, this method returns
a log record.
If any of the filters return a false value, this method returns
a false value.
 
.. versionchanged:: 3.2
 
   Allow filters to be just callables.
 
.. versionchanged:: 3.12
   Allow filters to return a LogRecord instead of
   modifying it in place.
removeFilter(self, filter)
Remove the specified filter from this handler.

Data descriptors inherited from logging.Filterer:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class StrToBool(builtins.tuple)
    StrToBool(result: bool, valid: bool)
 
A container for results when converting strings to boolean.
 
 
Method resolution order:
StrToBool
builtins.tuple
builtins.object

Methods defined here:
__getnewargs__(self)
Return self as a plain tuple.  Used by copy and pickle.
__repr__(self)
Return a nicely formatted representation string
_asdict(self)
Return a new dict which maps field names to their values.
_replace(self, /, **kwds)
Return a new StrToBool object replacing specified fields with new values

Class methods defined here:
_make(iterable) from builtins.type
Make a new StrToBool object from a sequence or iterable

Static methods defined here:
__new__(_cls, result: bool, valid: bool)
Create new instance of StrToBool(result, valid)
parse(data: str) -> 'StrToBool'
Parse a string to boolean.

Data descriptors defined here:
result
Alias for field number 0
valid
Alias for field number 1

Data and other attributes defined here:
__annotations__ = {'result': <class 'bool'>, 'valid': <class 'bool'>}
__match_args__ = ('result', 'valid')
__orig_bases__ = (<function NamedTuple>,)
_field_defaults = {}
_fields = ('result', 'valid')

Methods inherited from builtins.tuple:
__add__(self, value, /)
Return self+value.
__contains__(self, key, /)
Return bool(key in self).
__eq__(self, value, /)
Return self==value.
__ge__(self, value, /)
Return self>=value.
__getattribute__(self, name, /)
Return getattr(self, name).
__getitem__(self, key, /)
Return self[key].
__gt__(self, value, /)
Return self>value.
__hash__(self, /)
Return hash(self).
__iter__(self, /)
Implement iter(self).
__le__(self, value, /)
Return self<=value.
__len__(self, /)
Return len(self).
__lt__(self, value, /)
Return self<value.
__mul__(self, value, /)
Return self*value.
__ne__(self, value, /)
Return self!=value.
__rmul__(self, value, /)
Return value*self.
count(self, value, /)
Return number of occurrences of value.
index(self, value, start=0, stop=9223372036854775807, /)
Return first index of value.
 
Raises ValueError if the value is not present.

Class methods inherited from builtins.tuple:
__class_getitem__(...) from builtins.type
See PEP 585

 
Functions
       
import_str_and_item(module_path: str) -> tuple[str, str]
Treat the last entry in a '.' delimited string as the item to import from
the module in the string preceding it.
name_search(names: Iterable[str], pattern: str, exact: bool = False) -> Iterator[str]
A simple name searching method.

 
Data
        DEFAULT_TIME_FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
Iterable = typing.Iterable
Iterator = typing.Iterator