Esempio n. 1
0
def construct_history(**kwargs):
    """Construct the history backend object."""
    env = builtins.__xonsh_env__
    backend = env.get('XONSH_HISTORY_BACKEND')
    if isinstance(backend, str) and backend in HISTORY_BACKENDS:
        kls_history = HISTORY_BACKENDS[backend]
    elif xt.is_class(backend):
        kls_history = backend
    elif isinstance(backend, History):
        return backend
    else:
        print('Unknown history backend: {}. Using JSON version'.format(
            backend), file=sys.stderr)
        kls_history = JsonHistory
    return kls_history(**kwargs)
Esempio n. 2
0
def construct_history(**kwargs):
    """Construct the history backend object."""
    env = builtins.__xonsh_env__
    backend = env.get('XONSH_HISTORY_BACKEND')
    if isinstance(backend, str) and backend in HISTORY_BACKENDS:
        kls_history = HISTORY_BACKENDS[backend]
    elif xt.is_class(backend):
        kls_history = backend
    elif isinstance(backend, History):
        return backend
    else:
        print('Unknown history backend: {}. Using JSON version'.format(
            backend), file=sys.stderr)
        kls_history = JsonHistory
    return kls_history(**kwargs)
Esempio n. 3
0
def construct_history(backend=None, **kwargs) -> "History":
    """Construct the history backend object."""
    env = XSH.env
    backend = backend or env.get("XONSH_HISTORY_BACKEND", "json")
    if isinstance(backend, str) and backend in HISTORY_BACKENDS:
        kls_history = HISTORY_BACKENDS[backend]
    elif xt.is_class(backend):
        kls_history = backend
    elif isinstance(backend, History):
        return backend
    else:
        print(
            f"Unknown history backend: {backend}. Using JSON version",
            file=sys.stderr,
        )
        kls_history = JsonHistory
    return kls_history(**kwargs)