use flake8 for style checks
Change-Id: I25af2e978a8d11b84b930308516d597c75b387e0 Signed-off-by: Doug Hellmann <doug.hellmann@dreamhost.com>
This commit is contained in:
parent
5233a27fe5
commit
18f649c229
16
cliff/app.py
16
cliff/app.py
|
@ -94,45 +94,45 @@ class App(object):
|
|||
description=description,
|
||||
add_help=False,
|
||||
**argparse_kwargs
|
||||
)
|
||||
)
|
||||
parser.add_argument(
|
||||
'--version',
|
||||
action='version',
|
||||
version='%(prog)s {0}'.format(version),
|
||||
)
|
||||
)
|
||||
parser.add_argument(
|
||||
'-v', '--verbose',
|
||||
action='count',
|
||||
dest='verbose_level',
|
||||
default=self.DEFAULT_VERBOSE_LEVEL,
|
||||
help='Increase verbosity of output. Can be repeated.',
|
||||
)
|
||||
)
|
||||
parser.add_argument(
|
||||
'--log-file',
|
||||
action='store',
|
||||
default=None,
|
||||
help='Specify a file to log output. Disabled by default.',
|
||||
)
|
||||
)
|
||||
parser.add_argument(
|
||||
'-q', '--quiet',
|
||||
action='store_const',
|
||||
dest='verbose_level',
|
||||
const=0,
|
||||
help='suppress output except warnings and errors',
|
||||
)
|
||||
)
|
||||
parser.add_argument(
|
||||
'-h', '--help',
|
||||
action=HelpAction,
|
||||
nargs=0,
|
||||
default=self, # tricky
|
||||
help="show this help message and exit",
|
||||
)
|
||||
)
|
||||
parser.add_argument(
|
||||
'--debug',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help='show tracebacks on errors',
|
||||
)
|
||||
)
|
||||
return parser
|
||||
|
||||
def configure_logging(self):
|
||||
|
@ -145,7 +145,7 @@ class App(object):
|
|||
if self.options.log_file:
|
||||
file_handler = logging.FileHandler(
|
||||
filename=self.options.log_file,
|
||||
)
|
||||
)
|
||||
formatter = logging.Formatter(self.LOG_FILE_MESSAGE_FORMAT)
|
||||
file_handler.setFormatter(formatter)
|
||||
root_logger.addHandler(file_handler)
|
||||
|
|
|
@ -28,7 +28,7 @@ class Command(object):
|
|||
parser = argparse.ArgumentParser(
|
||||
description=self.get_description(),
|
||||
prog=prog_name,
|
||||
)
|
||||
)
|
||||
return parser
|
||||
|
||||
@abc.abstractmethod
|
||||
|
|
|
@ -39,7 +39,9 @@ class CommandManager(object):
|
|||
def _load_commands(self):
|
||||
for ep in pkg_resources.iter_entry_points(self.namespace):
|
||||
LOG.debug('found command %r', ep.name)
|
||||
cmd_name = ep.name.replace('_', ' ') if self.convert_underscores else ep.name
|
||||
cmd_name = (ep.name.replace('_', ' ')
|
||||
if self.convert_underscores
|
||||
else ep.name)
|
||||
self.commands[cmd_name] = ep
|
||||
return
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class DisplayCommandBase(Command):
|
|||
formatter_group = parser.add_argument_group(
|
||||
title='output formatters',
|
||||
description='output formatter options',
|
||||
)
|
||||
)
|
||||
formatter_choices = sorted(self.formatters.keys())
|
||||
formatter_default = self.formatter_default
|
||||
if formatter_default not in formatter_choices:
|
||||
|
@ -56,7 +56,7 @@ class DisplayCommandBase(Command):
|
|||
choices=formatter_choices,
|
||||
default=formatter_default,
|
||||
help='the output format, defaults to %s' % formatter_default,
|
||||
)
|
||||
)
|
||||
formatter_group.add_argument(
|
||||
'-c', '--column',
|
||||
action='append',
|
||||
|
@ -64,7 +64,7 @@ class DisplayCommandBase(Command):
|
|||
dest='columns',
|
||||
metavar='COLUMN',
|
||||
help='specify the column(s) to include, can be repeated',
|
||||
)
|
||||
)
|
||||
for name, formatter in sorted(self.formatters.items()):
|
||||
formatter.add_argument_group(parser)
|
||||
return parser
|
||||
|
|
|
@ -13,7 +13,7 @@ class CSVLister(ListFormatter):
|
|||
'minimal': csv.QUOTE_MINIMAL,
|
||||
'nonnumeric': csv.QUOTE_NONNUMERIC,
|
||||
'none': csv.QUOTE_NONE,
|
||||
}
|
||||
}
|
||||
|
||||
def add_argument_group(self, parser):
|
||||
group = parser.add_argument_group('CSV Formatter')
|
||||
|
@ -23,7 +23,7 @@ class CSVLister(ListFormatter):
|
|||
dest='quote_mode',
|
||||
default='nonnumeric',
|
||||
help='when to include quotes, defaults to nonnumeric',
|
||||
)
|
||||
)
|
||||
|
||||
def emit_list(self, column_names, data, stdout, parsed_args):
|
||||
writer = csv.writer(stdout,
|
||||
|
|
|
@ -10,7 +10,7 @@ class ShellFormatter(SingleFormatter):
|
|||
group = parser.add_argument_group(
|
||||
title='shell formatter',
|
||||
description='a format a UNIX shell can parse (variable="value")',
|
||||
)
|
||||
)
|
||||
group.add_argument(
|
||||
'--variable',
|
||||
action='append',
|
||||
|
@ -18,14 +18,14 @@ class ShellFormatter(SingleFormatter):
|
|||
dest='variables',
|
||||
metavar='VARIABLE',
|
||||
help='specify the variable(s) to include, can be repeated',
|
||||
)
|
||||
)
|
||||
group.add_argument(
|
||||
'--prefix',
|
||||
action='store',
|
||||
default='',
|
||||
dest='prefix',
|
||||
help='add a prefix to all variable names',
|
||||
)
|
||||
)
|
||||
|
||||
def emit_one(self, column_names, data, stdout, parsed_args):
|
||||
variable_names = [c.lower().replace(' ', '_')
|
||||
|
|
|
@ -12,7 +12,7 @@ class TableFormatter(ListFormatter, SingleFormatter):
|
|||
int: 'r',
|
||||
str: 'l',
|
||||
float: 'r',
|
||||
}
|
||||
}
|
||||
try:
|
||||
ALIGNMENTS[unicode] = 'l'
|
||||
except NameError:
|
||||
|
|
|
@ -49,7 +49,7 @@ class HelpCommand(Command):
|
|||
try:
|
||||
the_cmd = self.app.command_manager.find_command(
|
||||
parsed_args.cmd,
|
||||
)
|
||||
)
|
||||
cmd_factory, cmd_name, search_args = the_cmd
|
||||
except ValueError:
|
||||
# Did not find an exact match
|
||||
|
|
|
@ -72,8 +72,8 @@ class InteractiveApp(cmd2.Cmd):
|
|||
['do'],
|
||||
itertools.takewhile(lambda x: not x.startswith('-'),
|
||||
arg_parts)
|
||||
)
|
||||
)
|
||||
)
|
||||
# Have the command manager version of the help
|
||||
# command produce the help text since cmd and
|
||||
# cmd2 do not provide help for "help"
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
# cliff documentation build configuration file, created by
|
||||
# sphinx-quickstart on Wed Apr 25 11:14:29 2012.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its containing dir.
|
||||
# This file is execfile()d with the current directory set to its
|
||||
# containing dir.
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
|
@ -11,20 +12,22 @@
|
|||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys, os
|
||||
import datetime
|
||||
import subprocess
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# -- General configuration -----------------------------------------------------
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo']
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
|
@ -41,14 +44,18 @@ master_doc = 'index'
|
|||
|
||||
# General information about the project.
|
||||
project = u'cliff'
|
||||
copyright = u'2012, Doug Hellmann'
|
||||
copyright = u'2012-%s, Doug Hellmann' % datetime.datetime.today().year
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '1.3.1'
|
||||
version = subprocess.check_output([
|
||||
'sh', '-c',
|
||||
'cd ../..; python setup.py --version',
|
||||
])
|
||||
version = version.strip()
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = version
|
||||
|
||||
|
@ -66,7 +73,8 @@ release = version
|
|||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = []
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
# The reST default role (used for this markup: `text`) to use for all
|
||||
# documents.
|
||||
#default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
|
@ -87,7 +95,7 @@ pygments_style = 'sphinx'
|
|||
#modindex_common_prefix = []
|
||||
|
||||
|
||||
# -- Options for HTML output ---------------------------------------------------
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
|
@ -167,24 +175,25 @@ html_static_path = ['_static']
|
|||
htmlhelp_basename = 'cliffdoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
# -- Options for LaTeX output ------------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
# (source start file, target name, title, author,
|
||||
# documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'cliff.tex', u'cliff Documentation',
|
||||
u'Doug Hellmann', 'manual'),
|
||||
('index', 'cliff.tex', u'cliff Documentation',
|
||||
u'Doug Hellmann', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
|
@ -208,7 +217,7 @@ latex_documents = [
|
|||
#latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output --------------------------------------------
|
||||
# -- Options for manual page output ------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
|
@ -221,15 +230,15 @@ man_pages = [
|
|||
#man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output ------------------------------------------------
|
||||
# -- Options for Texinfo output ----------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'cliff', u'cliff Documentation',
|
||||
u'Doug Hellmann', 'cliff', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
('index', 'cliff', u'cliff Documentation',
|
||||
u'Doug Hellmann', 'cliff', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
|
|
|
@ -8,6 +8,9 @@ dev
|
|||
method to allow underscores to be used in command names. This optional
|
||||
argument is defaulted to True to maintain current behavior.
|
||||
(contributed by Joe Server)
|
||||
- Use flake8_ for style checking.
|
||||
|
||||
.. _flake8: https://pypi.python.org/pypi/flake8
|
||||
|
||||
1.3.1
|
||||
|
||||
|
|
8
tox.ini
8
tox.ini
|
@ -1,5 +1,5 @@
|
|||
[tox]
|
||||
envlist = py26,py27,py32,pep8
|
||||
envlist = py26,py27,py32,style
|
||||
|
||||
[testenv]
|
||||
commands = nosetests -d --with-coverage --cover-inclusive --cover-package cliff []
|
||||
|
@ -8,6 +8,6 @@ deps =
|
|||
mock
|
||||
coverage
|
||||
|
||||
[testenv:pep8]
|
||||
deps = pep8
|
||||
commands = pep8 --repeat --ignore=E501 --ignore=E123 --show-source cliff
|
||||
[testenv:style]
|
||||
deps = flake8
|
||||
commands = flake8 cliff docs/source/conf.py
|
||||
|
|
Loading…
Reference in New Issue