Source code for doot._interface

  1#!/usr/bin/env python3
  2"""
  3
  4
  5"""
  6# ruff: noqa:
  7
  8# Imports:
  9from __future__ import annotations
 10
 11# ##-- stdlib imports
 12import datetime
 13import enum
 14import functools as ftz
 15import itertools as itz
 16import logging as logmod
 17import re
 18import time
 19import types
 20import collections
 21import contextlib
 22import hashlib
 23from copy import deepcopy
 24from uuid import UUID, uuid1
 25from weakref import ref
 26import atexit # for @atexit.register
 27import faulthandler
 28from importlib.resources import files
 29from importlib.metadata import version
 30# ##-- end stdlib imports
 31
 32# ##-- types
 33# isort: off
 34import abc
 35import collections.abc
 36from typing import TYPE_CHECKING, cast, assert_type, assert_never
 37from typing import Generic, NewType
 38# Protocols:
 39from typing import Protocol, runtime_checkable
 40# Typing Decorators:
 41from typing import no_type_check, final, override, overload
 42from jgdv.structs.chainguard import ChainGuard
 43
 44if TYPE_CHECKING:
 45    import pathlib as pl
 46    from typing import Final
 47    from typing import ClassVar, Any, LiteralString
 48    from typing import Never, Self, Literal
 49    from typing import TypeGuard
 50    from collections.abc import Iterable, Iterator, Callable, Generator
 51    from collections.abc import Sequence, Mapping, MutableMapping, Hashable
 52    from importlib.resources.abc import Traversable
 53    from jgdv import Maybe, VerStr
 54
 55    type Loadable = pl.Path | Traversable
 56
 57##--|
 58
 59# isort: on
 60# ##-- end types
 61
 62##-- logging
 63logging = logmod.getLogger(__name__)
 64##-- end logging
 65
 66# Vars:
 67__version__ : Final[str] = version("doot")
 68
 69# -- data
 70data_path                  = files("doot.__data")
 71constants_file : Loadable  = data_path.joinpath("constants.toml")
 72aliases_file   : Loadable  = data_path.joinpath("aliases.toml")
 73template_path  : Loadable  = files("doot.__data.templates")
 74
 75# -- Can't be in doot.constants, because that isn't loaded yet
 76CONSTANT_PREFIX    : Final[str]              = "doot.constants"
 77ALIAS_PREFIX       : Final[str]              = "doot.aliases"
 78TOOL_PREFIX        : Final[str]              = "tool.doot"
 79DOOT_TOML          : Final[str]              = "doot.toml"
 80PYPROJ_TOML        : Final[str]              = "pyproject.toml"
 81DEFAULT_FILENAMES  : Final[tuple[str, ...]]  = (DOOT_TOML, PYPROJ_TOML)
 82
 83fail_prefix        : Final[str]              = "!!!"
 84GLOBAL_STATE_KEY   : Final[str]              = "global"
 85LASTERR            : Final[str]              = "doot.lasterror"
 86
 87##--|
[docs] 88class ExitCodes(enum.IntEnum): 89 SUCCESS = 0 90 UNKNOWN_FAIL = -1 91 NOT_SETUP = -2 92 EARLY = -3 93 MISSING_CONFIG = -4 94 BAD_CONFIG = -5 95 BAD_CMD = -6 96 TASK_FAIL = -7 97 BAD_STATE = -8 98 BAD_STRUCT = -9 99 TRACKING_FAIL = -10 100 BACKEND_FAIL = -11 101 FRONTEND_FAIL = -12 102 DOOT_FAIL = -13 103 NOT_IMPLEMENTED = -14 104 IMPORT_FAIL = -15 105 PYTHON_FAIL = -16 106 107 INITIAL = -99