Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Unified Diff: src/caterpillar.py

Issue 1645873003: Decoded command-line inputs to Unicode strings. Resolves #24. (Closed) Base URL: git@github.com:chromium/caterpillar.git@master
Patch Set: Response to CR Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/caterpillar.py
diff --git a/src/caterpillar.py b/src/caterpillar.py
index 4a0a8b5c38e4e035c8b1953a6cd4babbfe734961..cf1cf4baea62bfeb934bd0411bca0a4cd056e7cf 100755
--- a/src/caterpillar.py
+++ b/src/caterpillar.py
@@ -706,6 +706,14 @@ class Formatter(logging.Formatter):
return style + super(Formatter, self).format(record)
+def unicode_arg(arg):
+ """Converts a bytestring command-line argument into a Unicode string."""
+ if sys.stdin.encoding:
+ return arg.decode(sys.stdin.encoding)
+
+ return arg.decode(sys.getfilesystemencoding())
+
+
def main():
"""Executes the script and handles command line arguments."""
# Set up parsers, then parse the command line arguments.
@@ -717,17 +725,19 @@ def main():
parser_convert = subparsers.add_parser(
'convert', help='Convert a Chrome App into a progressive web app.')
- parser_convert.add_argument('input', help='Chrome App input directory')
parser_convert.add_argument(
- 'output', help='Progressive web app output directory')
+ 'input', help='Chrome App input directory', type=unicode_arg)
+ parser_convert.add_argument(
+ 'output', help='Progressive web app output directory', type=unicode_arg)
parser_convert.add_argument('-c', '--config', help='Configuration file',
- required=True, metavar='config')
+ required=True, metavar='config', type=unicode_arg)
parser_convert.add_argument('-f', '--force', help='Force output overwrite',
action='store_true')
parser_config = subparsers.add_parser(
'config', help='Print a default configuration file to stdout.')
- parser_config.add_argument('output', help='Output config file path')
+ parser_config.add_argument('output', help='Output config file path',
+ type=unicode_arg)
parser_config.add_argument('-i', '--interactive',
help='Whether to interactively generate the config file',
action='store_true')
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698