pymunge.util package¶
Submodules¶
pymunge.util.diagnostic module¶
- class pymunge.util.diagnostic.Diagnostic(logger: ~util.logging.ScopedLogger = <ScopedLogger pymunge.util.diagnostic (INFO)>)¶
Bases:
object
The
Diagnostic
class is used to record diagnostic messages and report them to the user.- report(message: DiagnosticMessage)¶
- summary()¶
- class pymunge.util.diagnostic.DiagnosticMessage(text: str | None = None)¶
Bases:
object
The
DiagnosticMessage
records an issue that occurred during the munge process. Thescope
determines the module or topic in which the issue occurred. Thescope
should be set during the definition of the diagnostic message and contain a 3 character wide unique identifier.- code = 1¶
- name = 'DiagnosticMessageMeta'¶
- print()¶
- scope = ' '¶
- severity: str = 'I'¶
- class pymunge.util.diagnostic.DiagnosticMessageMeta(name, bases, dct)¶
Bases:
type
The
DiagnosticMessageMeta
class automatically increases the diagnostic code for a new type of diagnostic message. In addition the diagnostic message name is saved.- Codes = {'E': 1, 'I': 2, 'W': 1}¶
- class pymunge.util.diagnostic.ErrorMessage(text: str | None = None)¶
Bases:
DiagnosticMessage
- code = 1¶
- name = 'DiagnosticMessageMeta'¶
- severity: str = 'E'¶
- text: str | None¶
- class pymunge.util.diagnostic.InfoMessage(text: str | None = None)¶
Bases:
DiagnosticMessage
- code = 2¶
- name = 'DiagnosticMessageMeta'¶
- severity: str = 'I'¶
- text: str | None¶
pymunge.util.enum module¶
pymunge.util.logging module¶
- class pymunge.util.logging.Ansi¶
Bases:
object
- BackgroundColors = [40, 41, 42, 43, 44, 45, 46, 47, 48, 49]¶
- BlackBackground = 40¶
- BlackForeground = 30¶
- BlueBackground = 44¶
- BlueForeground = 34¶
- Bold = 1¶
- CyanBackground = 46¶
- CyanForeground = 36¶
- DefaultBackground = 49¶
- DefaultForeground = 39¶
- Escape = '\x1b[{}m'¶
- ForegroundColors = [30, 31, 32, 33, 34, 35, 36, 37, 38, 39]¶
- GrayBackground = 48¶
- GrayForeground = 38¶
- GreenBackground = 42¶
- GreenForeground = 32¶
- Italic = 3¶
- MagentaBackground = 45¶
- MagentaForeground = 35¶
- RedBackground = 41¶
- RedForeground = 31¶
- Reset = 0¶
- ResetBold = 22¶
- ResetItalic = 23¶
- ResetUnderline = 24¶
- Resets = [0, 22, 23, 24]¶
- Styles = [1, 3, 4]¶
- Underline = 4¶
- WhiteBackground = 47¶
- WhiteForeground = 37¶
- YellowBackground = 43¶
- YellowForeground = 33¶
- static bold(string: str)¶
- static color_bg(color: int, string: str, reset_color: int = 49)¶
- static color_fg(color: int, string: str, reset_color: int = 39)¶
- static italic(string: str)¶
- static style(set_style: int, reset_style: int, string: str)¶
- static underline(string: str)¶
- class pymunge.util.logging.ColorFormatter(format: str, datefmt: str, *args, **kwargs)¶
Bases:
Formatter
- LevelStyle = {'critical': (31, 1), 'debug': (32, 3), 'error': (31,), 'info': (36,), 'warning': (33,)}¶
- format(record)¶
Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.
- class pymunge.util.logging.LogLevel¶
Bases:
Enum
- Critical = 'critical'¶
- Debug = 'debug'¶
- Error = 'error'¶
- Info = 'info'¶
- Warning = 'warning'¶
- class pymunge.util.logging.ScopedLogger(logger)¶
Bases:
LoggerAdapter
- add()¶
- process(msg: str, kwargs)¶
Process the logging message and keyword arguments passed in to a logging call to insert contextual information. You can either manipulate the message itself, the keyword args or both. Return the message and kwargs modified (or not) to suit your needs.
Normally, you’ll only need to override this one method in a LoggerAdapter subclass for your specific needs.
- sub()¶
- pymunge.util.logging.get_logger(name: str, path: Path = PosixPath('.'), level: str = 'info', ansi_style: bool = False)¶
pymunge.util.status module¶
pymunge.util.time module¶
- pymunge.util.time.duration(d: int)¶
- pymunge.util.time.measure(f: callable, *args, **kwargs)¶