Skip to content
Browse files

More help on invalid config. Expand tabs moved to setup.py script

  • Loading branch information...
1 parent b78fd78 commit 24eab01b9255af310766ab443653cd0f6bf7afb9 @miohtama committed Apr 11, 2012
Showing with 55 additions and 39 deletions.
  1. +0 −33 scripts/expand_tabs.py
  2. +1 −0 setup.py
  3. +0 −2 validation-options.yaml
  4. +42 −0 vvv/scripts/expandtabs.py
  5. +6 −2 vvv/utils.py
  6. +5 −1 vvv/validators/pylint.py
  7. +1 −1 vvv/validators/tabs.py
View
33 scripts/expand_tabs.py
@@ -1,33 +0,0 @@
-#!/usr/bin/env python
-"""
-Orignal recipe by http://code.activestate.com/recipes/498179-expand_tabspy-expand-tabs-in-files-in-place/
-"""
-import fileinput, optparse, sys
-
-# Command-line parser
-parser = optparse.OptionParser(
- usage="""
-%prog [options] [files]
-Expand tab to spaces, printing to the standard output by default.
-When no files are given, read from the standard input.
-
-Examples:
- expand in one file
- % expand_tabs.py -t 4 file.txt
-
- expand tabs in Python source files
- % find . -name "*.py" | xargs expand_tabs.py -it 4
-""".strip(),
- formatter=optparse.IndentedHelpFormatter(max_help_position=30)
- )
-parser.add_option("-t", "--tabsize", type="int", metavar="SIZE")
-parser.add_option("-i", "--inplace", action="store_true", help="change the files in-place (don't print)")
-parser.add_option("-b", "--backupext", default="", metavar="EXT", help="backup extension to use (default: no backup)")
-
-options, args = parser.parse_args()
-if options.tabsize is None:
- parser.error("tab size not specified")
-
-# Do the work
-for line in fileinput.input(files=args, inplace=options.inplace, backup=options.backupext):
- sys.stdout.write( line.expandtabs(options.tabsize) )
View
1 setup.py
@@ -41,5 +41,6 @@
vvv = vvv.main:entry_point
vvv-install-git-pre-commit-hook = vvv.hooks.git:setup_hook
vvv-validate-rst = vvv.scripts.validaterst:run
+ vvv-expand-tabs = vvv.scripts.expandtabs:run
""",
)
View
2 validation-options.yaml
@@ -9,8 +9,6 @@ pylint:
python3k: true
- command-line: --reports=n
-
configuration: |
[BASIC]
View
42 vvv/scripts/expandtabs.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+"""
+Orignal recipe by http://code.activestate.com/recipes/498179-expand_tabspy-expand-tabs-in-files-in-place/
+"""
+import fileinput, optparse, sys
+
+# E1103: 35,8:run: Instance of 'int' has no 'write' member (but some types could not be inferred)
+# pylint: disable=E1103
+
+def run():
+
+ # Command-line parser
+ parser = optparse.OptionParser(
+ usage="""
+ %prog [options] [files]
+ Expand tab to spaces, printing to the standard output by default.
+ When no files are given, read from the standard input.
+
+ Examples:
+ expand in one file
+ % expand_tabs.py -t 4 file.txt
+
+ expand tabs in Python source files
+ % find . -name "*.py" | xargs expand_tabs.py -it 4
+ """.strip(),
+ formatter=optparse.IndentedHelpFormatter(max_help_position=30)
+ )
+ parser.add_option("-t", "--tabsize", type="int", metavar="SIZE")
+ parser.add_option("-i", "--inplace", action="store_true", help="change the files in-place (don't print)")
+ parser.add_option("-b", "--backupext", default="", metavar="EXT", help="backup extension to use (default: no backup)")
+
+ options, args = parser.parse_args()
+ if options.tabsize is None:
+ parser.error("tab size not specified")
+
+ # Do the work
+ for line in fileinput.input(files=args, inplace=options.inplace, backup=options.backupext):
+ sys.stdout.write( line.expandtabs(options.tabsize) )
+
+
+if __name__ == "__main__":
+ run()
View
8 vvv/utils.py
@@ -83,9 +83,13 @@ def get_match_option(config, section, entry = None, default=[], debug=False):
else:
opt = config.get(section, default)
- # Split space or new line separated list to pieces
- if type(opt) != list:
+ if type(opt) == str:
+ # Split space or new line separated list to pieces
opt = opt.split()
+ elif type(opt) == list:
+ pass
+ else:
+ raise RuntimeError("Bad option data for %s %s" % (section, entry))
g = ExceptionGlobster(opt, debug)
View
6 vvv/validators/pylint.py
@@ -68,6 +68,10 @@
Give pylint command line options.
+Default::
+
+ --reports=n --include-ids=y
+
configuration
+++++++++++++
@@ -161,7 +165,7 @@
from vvv import sysdeps
from vvv import download
-DEFAULT_COMMAND_LINE = "--reports=n"
+DEFAULT_COMMAND_LINE = "--reports=n --include-ids=y"
DEFAULT_CONFIG = """
View
2 vvv/validators/tabs.py
@@ -31,7 +31,7 @@
# Find all ascii files and convert them to use tabs,
# but watch out not to hit Makefile or any other file needing hard tabs!
- find . -name "*" -type f -print | xargs file | grep ASCII | cut -d: -f1 | xargs scripts/expand_tabs.py --inplace --tabsize=4
+ find . -name "*" -type f -print | xargs file | grep ASCII | cut -d: -f1 | vvv-expand-tabs --inplace --tabsize=4
You can also try UNIX ``expand`` command, but it does not do in-place conversion.

0 comments on commit 24eab01

Please sign in to comment.
Something went wrong with that request. Please try again.