Make PyLint even happier.

This commit is contained in:
Pedro Algarvio 2013-12-11 10:43:51 +00:00
parent ea0a07b985
commit 2b6ae8428b

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*-
'''\ '''\
Welcome to the Salt repl which exposes the execution environment of a minion in Welcome to the Salt repl which exposes the execution environment of a minion in
a pre-configured Python shell a pre-configured Python shell
@ -19,18 +20,15 @@ A history file is maintained in ~/.saltsh_history.
completion behavior can be customized via the ~/.inputrc file. completion behavior can be customized via the ~/.inputrc file.
''' '''
import atexit
# Import python libs
import atexit import atexit
import os import os
import pprint
import readline import readline
import rlcompleter
import sys import sys
from code import InteractiveConsole from code import InteractiveConsole
import jinja2 # Import salt libs
import yaml
import salt.client import salt.client
import salt.config import salt.config
import salt.loader import salt.loader
@ -38,10 +36,22 @@ import salt.output
import salt.pillar import salt.pillar
import salt.runner import salt.runner
HISTFILE = "{HOME}/.saltsh_history".format(**os.environ) # Import 3rd party libs
import jinja2
# pylint: disable=W0611
# These are imported to be available in the spawmed shell
import yaml
import pprint
# pylint: enable=W0611
HISTFILE = '{HOME}/.saltsh_history'.format(**os.environ)
def savehist(): def savehist():
'''
Save the history file
'''
readline.write_history_file(HISTFILE) readline.write_history_file(HISTFILE)
@ -71,7 +81,7 @@ def get_salt_vars():
__opts__.get('environment'), __opts__.get('environment'),
).compile_pillar() ).compile_pillar()
JINJA = lambda x, **y: jinja2.Template(x).render( JINJA = lambda x, **y: jinja2.Template(x).render( # pylint: disable=C0103,W0612
grains=__grains__, grains=__grains__,
salt=__salt__, salt=__salt__,
opts=__opts__, opts=__opts__,
@ -82,6 +92,9 @@ def get_salt_vars():
def main(): def main():
'''
The main entry point
'''
salt_vars = get_salt_vars() salt_vars = get_salt_vars()
def salt_outputter(value): def salt_outputter(value):
@ -106,7 +119,7 @@ def main():
readline.read_history_file(HISTFILE) readline.read_history_file(HISTFILE)
atexit.register(savehist) atexit.register(savehist)
atexit.register(lambda: sys.stdout.write("Salt you later!\n")) atexit.register(lambda: sys.stdout.write('Salt you later!\n'))
saltrepl = InteractiveConsole(locals=salt_vars) saltrepl = InteractiveConsole(locals=salt_vars)
saltrepl.interact(banner=__doc__) saltrepl.interact(banner=__doc__)