mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 16:34:47 +01:00
Merge branch 'debug-level-print' of https://github.com/mitnk/xonsh into mitnk-debug-level-print
This commit is contained in:
commit
06e6c449b2
7 changed files with 32 additions and 11 deletions
13
news/xonsh-debug-level.rst
Normal file
13
news/xonsh-debug-level.rst
Normal file
|
@ -0,0 +1,13 @@
|
|||
**Added:** None
|
||||
|
||||
**Changed:**
|
||||
|
||||
* Updated the effectivity of ``$XONSH_DEBUG`` on debug messages.
|
||||
|
||||
**Deprecated:** None
|
||||
|
||||
**Removed:** None
|
||||
|
||||
**Fixed:** None
|
||||
|
||||
**Security:** None
|
|
@ -298,7 +298,7 @@ def DEFAULT_VALUES():
|
|||
'XONSH_COLOR_STYLE': 'default',
|
||||
'XONSH_CONFIG_DIR': xonsh_config_dir,
|
||||
'XONSH_DATA_DIR': xonsh_data_dir,
|
||||
'XONSH_DEBUG': False,
|
||||
'XONSH_DEBUG': 0,
|
||||
'XONSH_ENCODING': DEFAULT_ENCODING,
|
||||
'XONSH_ENCODING_ERRORS': 'surrogateescape',
|
||||
'XONSH_HISTORY_BACKEND': 'json',
|
||||
|
@ -615,10 +615,13 @@ def DEFAULT_DOCS():
|
|||
'This is the location where xonsh configuration information is stored.',
|
||||
configurable=False, default="``$XDG_CONFIG_HOME/xonsh``"),
|
||||
'XONSH_DEBUG': VarDocs(
|
||||
'Sets the xonsh debugging level. This may be an integer or a boolean, '
|
||||
'with higher values cooresponding to higher debuging levels and more '
|
||||
'information presented. Setting this variable prior to stating xonsh '
|
||||
'will supress amalgamated imports.', configurable=False),
|
||||
'Sets the xonsh debugging level. This may be an integer or a boolean. '
|
||||
'Setting this variable prior to stating xonsh to ``1`` or ``True`` '
|
||||
'will supress amalgamated imports. Setting it to ``2`` will get some '
|
||||
'basic information like input transformation, command replacement. '
|
||||
'With ``3`` or a higher number will make more debugging information '
|
||||
'presented, like PLY parsing messages.',
|
||||
configurable=False),
|
||||
'XONSH_DATA_DIR': VarDocs(
|
||||
'This is the location where xonsh data files are stored, such as '
|
||||
'history.', default="``$XDG_DATA_HOME/xonsh``"),
|
||||
|
|
|
@ -54,7 +54,7 @@ class Execer(object):
|
|||
filename = self.filename
|
||||
if not transform:
|
||||
return self.parser.parse(input, filename=filename, mode=mode,
|
||||
debug_level=(self.debug_level > 1))
|
||||
debug_level=(self.debug_level > 2))
|
||||
|
||||
# Parsing actually happens in a couple of phases. The first is a
|
||||
# shortcut for a context-free parser. Normally, all subprocess
|
||||
|
@ -161,7 +161,7 @@ class Execer(object):
|
|||
tree = self.parser.parse(input,
|
||||
filename=filename,
|
||||
mode=mode,
|
||||
debug_level=(self.debug_level > 1))
|
||||
debug_level=(self.debug_level > 2))
|
||||
parsed = True
|
||||
except IndentationError as e:
|
||||
if original_error is None:
|
||||
|
@ -221,7 +221,7 @@ class Execer(object):
|
|||
# anything
|
||||
raise original_error
|
||||
else:
|
||||
if self.debug_level:
|
||||
if self.debug_level > 1:
|
||||
msg = ('{0}:{1}:{2}{3} - {4}\n'
|
||||
'{0}:{1}:{2}{3} + {5}')
|
||||
mstr = '' if maxcol is None else ':' + str(maxcol)
|
||||
|
|
|
@ -584,7 +584,7 @@ def load_foreign_aliases(shells=None, config=None, issue_warning=True):
|
|||
shaliases = {} if shaliases is None else shaliases
|
||||
for alias in set(shaliases) & set(xonsh_aliases):
|
||||
del shaliases[alias]
|
||||
if builtins.__xonsh_env__.get('XONSH_DEBUG'):
|
||||
if builtins.__xonsh_env__.get('XONSH_DEBUG') > 1:
|
||||
print('aliases: ignoring alias {!r} of shell {!r} '
|
||||
'which tries to override xonsh alias.'
|
||||
''.format(alias, shell['shell']),
|
||||
|
|
|
@ -49,7 +49,8 @@ def fire_precommand(src, show_diff=True):
|
|||
print_exception('Modifcations to source input took more than '
|
||||
'the recursion limit number of interations to '
|
||||
'converge.')
|
||||
if show_diff and builtins.__xonsh_env__.get('XONSH_DEBUG') and src != raw:
|
||||
debug_level = builtins.__xonsh_env__.get('XONSH_DEBUG')
|
||||
if show_diff and debug_level > 1 and src != raw:
|
||||
sys.stderr.writelines(difflib.unified_diff(
|
||||
raw.splitlines(keepends=True),
|
||||
src.splitlines(keepends=True),
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
"you might find them useful if you have strong muscle memory.\n\n",
|
||||
"**Warning:** This xontrib may modify user command line input to implement ",
|
||||
"its behavior. To see the modifications as they are applied (in unified diff",
|
||||
"format), please set ``$XONSH_DEBUG = True``."]
|
||||
"format), please set ``$XONSH_DEBUG`` to ``2`` or higher."]
|
||||
},
|
||||
{"name": "distributed",
|
||||
"package": "xonsh",
|
||||
|
|
|
@ -3,4 +3,8 @@
|
|||
|
||||
@events.on_precommand
|
||||
def bash_preproc(cmd):
|
||||
if not __xonsh_history__.inps:
|
||||
if cmd.strip() == '!!':
|
||||
return ''
|
||||
return cmd
|
||||
return cmd.replace('!!', __xonsh_history__.inps[-1].strip())
|
||||
|
|
Loading…
Add table
Reference in a new issue