Esempio n. 1
0
    # diot_transform=_key_transform,
    # Warn about failure to get ast node
    warn_astnode_failure=True,
    # All piping mode:
    # - Assume all verbs are using PIPING_VERB env
    # - Assume all data functions are using PIPING env
    # - Assume all non-data functions are using PIPING verbs
    # This is useful when source code is not available.
    assume_all_piping=False,
    # The backend for datar
    backend="pandas",  # or "modin"
)
OPTIONS = Diot(
    Config.load(
        OPTIONS,
        OPTION_FILE_HOME,
        OPTION_FILE_CWD,
        ignore_nonexist=True,
    ),
    diot_transform=_key_transform,
)


def apply_init_callbacks():
    """Apply the callbacks when options are initialized"""
    for key in OPTION_CALLBACKS:
        OPTION_CALLBACKS[key](OPTIONS[key])


def options(
    *args: Union[str, Mapping[str, Any]],
    _return: bool = None,
Esempio n. 2
0
    non-existing values to None."""
    def __getattr__(self, name: str) -> Any:
        try:
            return super().__getattr__(name)
        except (KeyError, AttributeError):
            return None

    def __getitem__(self, name: str) -> Any:
        try:
            return super().__getitem__(name)
        except (KeyError, AttributeError):
            return None


config_profiles = [
    {
        "path": {
            "tmpdir": gettempdir()
        }
    },
    DEFAULT_CONFIG_FILE,
    USER_CONFIG_FILE,
    PROJ_CONFIG_FILE,
]
# scan sys.argv to see if +config <config file> passed in
if "+config" in sys.argv:
    cindex = sys.argv.index("+config")
    config_profiles.append(sys.argv[cindex + 1])

config = ConfigItems(Config.load(*config_profiles, ignore_nonexist=True))