summaryrefslogtreecommitdiff
path: root/sqlparse
diff options
context:
space:
mode:
authorVik <vmuriart@gmail.com>2016-06-23 11:37:46 -0700
committerGitHub <noreply@github.com>2016-06-23 11:37:46 -0700
commit78fb2041aef1068eb6c4bac3caad5dd012186868 (patch)
treedb402888277a06ca450eba2e57dd6f94c9b369ad /sqlparse
parentc56652ef9fdac111dd59e26b913765719eaf1141 (diff)
parent85349e68592964e66e5dfe7e48e9f76cb93d48fd (diff)
downloadsqlparse-78fb2041aef1068eb6c4bac3caad5dd012186868.tar.gz
Merge pull request #263 from vmuriart/clean-tests
Clean-up tests. Fully migrate to Py.test
Diffstat (limited to 'sqlparse')
-rw-r--r--sqlparse/cli.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/sqlparse/cli.py b/sqlparse/cli.py
index 03a4f8f..80d547d 100644
--- a/sqlparse/cli.py
+++ b/sqlparse/cli.py
@@ -123,7 +123,8 @@ def create_parser():
def _error(msg):
"""Print msg and optionally exit with return code exit_."""
- sys.stderr.write('[ERROR] %s\n' % msg)
+ sys.stderr.write('[ERROR] {0}\n'.format(msg))
+ return 1
def main(args=None):
@@ -137,15 +138,13 @@ def main(args=None):
# TODO: Needs to deal with encoding
data = ''.join(open(args.filename).readlines())
except IOError as e:
- _error('Failed to read %s: %s' % (args.filename, e))
- return 1
+ return _error('Failed to read {0}: {1}'.format(args.filename, e))
if args.outfile:
try:
stream = open(args.outfile, 'w')
except IOError as e:
- _error('Failed to open %s: %s' % (args.outfile, e))
- return 1
+ return _error('Failed to open {0}: {1}'.format(args.outfile, e))
else:
stream = sys.stdout
@@ -153,8 +152,7 @@ def main(args=None):
try:
formatter_opts = sqlparse.formatter.validate_options(formatter_opts)
except SQLParseError as e:
- _error('Invalid options: %s' % e)
- return 1
+ return _error('Invalid options: {0}'.format(e))
s = sqlparse.format(data, **formatter_opts)
if PY2: