mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-06 09:20:57 +01:00
adding dummy history backend
This commit is contained in:
parent
d77a6cb76c
commit
dbf6d17dbd
2 changed files with 31 additions and 2 deletions
|
@ -3,11 +3,13 @@
|
|||
import builtins
|
||||
import time
|
||||
|
||||
from xonsh.history.dummy import History as DummyHistory
|
||||
from xonsh.history.json import History as JsonHistory
|
||||
from xonsh.history.json import history_main
|
||||
from xonsh.history.sqlite import History as SqliteHistory
|
||||
|
||||
_BACKENDS = {
|
||||
'dummy': DummyHistory,
|
||||
'json': JsonHistory,
|
||||
'sqlite': SqliteHistory,
|
||||
}
|
||||
|
@ -15,8 +17,7 @@ _BACKENDS = {
|
|||
|
||||
def get_history_backend(env, ts, locked, gc=True, filename=None):
|
||||
env = builtins.__xonsh_env__
|
||||
backend = env.get('XONSH_HISTORY_BACKEND', 'sqlite')
|
||||
print('backend str: {}'.format(backend))
|
||||
backend = env.get('XONSH_HISTORY_BACKEND', 'json')
|
||||
try:
|
||||
kls_history = _BACKENDS[backend]
|
||||
except KeyError:
|
||||
|
|
28
xonsh/history/dummy.py
Normal file
28
xonsh/history/dummy.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""Implements the xonsh history backend."""
|
||||
import threading
|
||||
|
||||
|
||||
class HistoryGC(threading.Thread):
|
||||
pass
|
||||
|
||||
|
||||
class History:
|
||||
def __init__(self, gc=True, **kwargs):
|
||||
self.gc = HistoryGC() if gc else None
|
||||
self.rtns = None
|
||||
self.last_cmd_rtn = None
|
||||
self.last_cmd_out = None
|
||||
|
||||
def __iter__(self):
|
||||
for cmd, ts, index in []:
|
||||
yield (cmd, ts, index)
|
||||
|
||||
def append(self, cmd):
|
||||
print('DummyHistory append cmd: {}'.format(cmd))
|
||||
|
||||
def flush(self, at_exit=False):
|
||||
print('DummyHistory flush() called')
|
||||
|
||||
def get_history_items(self):
|
||||
return [{'inp': 'dummy in action\n'}]
|
Loading…
Add table
Reference in a new issue