Skip to content

Commit

Permalink
Extract CLI: Add input-dirs alias for input-paths.
Browse files Browse the repository at this point in the history
Just in case some script expects to be able to pass `--input-dirs`.

Fixes python-babel#330
Augments 19957e2
  • Loading branch information
akx committed Feb 2, 2016
1 parent edd83c4 commit b8d7d48
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions babel/messages/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ class extract_messages(Command):
('input-paths=', None,
'files or directories that should be scanned for messages. Separate multiple '
'files or directories with commas(,)'),
('input-dirs=', None, # TODO (3.x): Remove me.
'alias for input-paths (does allow files as well as directories).'),
]
boolean_options = [
'no-default-keywords', 'no-location', 'omit-header', 'no-wrap',
Expand All @@ -271,6 +273,7 @@ def initialize_options(self):
self.no_location = False
self.omit_header = False
self.output_file = None
self.input_dirs = None
self.input_paths = None
self.width = None
self.no_wrap = False
Expand All @@ -284,6 +287,14 @@ def initialize_options(self):
self.strip_comments = False

def finalize_options(self):
if self.input_dirs:
if not self.input_paths:
self.input_paths = self.input_dirs
else:
raise DistutilsOptionError(
'input-dirs and input-paths are mutually exclusive'
)

if self.no_default_keywords and not self.keywords:
raise DistutilsOptionError('you must specify new keywords if you '
'disable the default ones')
Expand Down
13 changes: 13 additions & 0 deletions tests/messages/test_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,19 @@ def test_input_paths_handle_spaces_after_comma(self):

self.assertEqual([this_dir, self.datadir], self.cmd.input_paths)

def test_input_dirs_is_alias_for_input_paths(self):
self.cmd.input_dirs = this_dir
self.cmd.output_file = self._pot_file()
self.cmd.finalize_options()
# Gets listified in `finalize_options`:
assert self.cmd.input_paths == [self.cmd.input_dirs]

def test_input_dirs_is_mutually_exclusive_with_input_paths(self):
self.cmd.input_dirs = this_dir
self.cmd.input_paths = this_dir
self.cmd.output_file = self._pot_file()
self.assertRaises(DistutilsOptionError, self.cmd.finalize_options)

def test_extraction_with_default_mapping(self):
self.cmd.copyright_holder = 'FooBar, Inc.'
self.cmd.msgid_bugs_address = '[email protected]'
Expand Down

1 comment on commit b8d7d48

@jtwang
Copy link

@jtwang jtwang commented on b8d7d48 Feb 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack b8d7d48

::wonders if this will work::

Please sign in to comment.