LEFT | RIGHT |
1 # This Source Code Form is subject to the terms of the Mozilla Public | 1 # This Source Code Form is subject to the terms of the Mozilla Public |
2 # License, v. 2.0. If a copy of the MPL was not distributed with this | 2 # License, v. 2.0. If a copy of the MPL was not distributed with this |
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
4 | 4 |
5 import argparse | 5 import argparse |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import re | 8 import re |
9 import shutil | 9 import shutil |
10 import subprocess | 10 import subprocess |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 logging.error('No metadata file found in this repository. Expecting ' | 89 logging.error('No metadata file found in this repository. Expecting ' |
90 'one or more of {} to be present.'.format( | 90 'one or more of {} to be present.'.format( |
91 ', '.join('metadata.' + p for p in KNOWN_PLATFORMS))) | 91 ', '.join('metadata.' + p for p in KNOWN_PLATFORMS))) |
92 build_available_subcommands._result = False | 92 build_available_subcommands._result = False |
93 return False | 93 return False |
94 | 94 |
95 for command_params in ALL_COMMANDS: | 95 for command_params in ALL_COMMANDS: |
96 platforms = types.intersection(command_params.pop('valid_platforms')) | 96 platforms = types.intersection(command_params.pop('valid_platforms')) |
97 if len(platforms) > 1: | 97 if len(platforms) > 1: |
98 command_params['arguments'] += ( | 98 command_params['arguments'] += ( |
99 make_argument('-t', '--type', dest='platform', | 99 make_argument('-t', '--type', dest='platform', required=True, |
100 choices=platforms), | 100 choices=platforms), |
101 ) | 101 ) |
102 make_subcommand(**command_params) | 102 make_subcommand(**command_params) |
103 elif len(platforms) == 1: | 103 elif len(platforms) == 1: |
104 sub_parser = make_subcommand(**command_params) | 104 sub_parser = make_subcommand(**command_params) |
105 sub_parser.set_defaults(platform=platforms.pop()) | 105 sub_parser.set_defaults(platform=platforms.pop()) |
106 | 106 |
107 build_available_subcommands._result = True | 107 build_available_subcommands._result = True |
108 return True | 108 return True |
109 | 109 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 locale_config = read_locale_config(base_dir, platform, metadata) | 289 locale_config = read_locale_config(base_dir, platform, metadata) |
290 | 290 |
291 import buildtools.localeTools as localeTools | 291 import buildtools.localeTools as localeTools |
292 localeTools.getTranslations(locale_config, basename, project_key) | 292 localeTools.getTranslations(locale_config, basename, project_key) |
293 | 293 |
294 | 294 |
295 @argparse_command( | 295 @argparse_command( |
296 valid_platforms={'chrome'}, | 296 valid_platforms={'chrome'}, |
297 arguments=( | 297 arguments=( |
298 make_argument('target_dir'), | 298 make_argument('target_dir'), |
299 make_argument('-q', '--quiet', help='Suppress JsDoc output'), | 299 make_argument('-q', '--quiet', help='Suppress JsDoc output', |
| 300 action='store_true', default=False), |
300 ) | 301 ) |
301 ) | 302 ) |
302 def docs(base_dir, target_dir, quiet, platform, **kwargs): | 303 def docs(base_dir, target_dir, quiet, platform, **kwargs): |
303 """ | 304 """ |
304 Generate documentation (requires node.js). | 305 Generate documentation (requires node.js). |
305 | 306 |
306 Generate documentation files and write them into the specified directory. | 307 Generate documentation files and write them into the specified directory. |
307 """ | 308 """ |
308 source_dir = os.path.join(base_dir, 'lib') | 309 source_dir = os.path.join(base_dir, 'lib') |
309 | 310 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 if build_available_subcommands(base_dir): | 392 if build_available_subcommands(base_dir): |
392 MAIN_PARSER.set_defaults(base_dir=base_dir) | 393 MAIN_PARSER.set_defaults(base_dir=base_dir) |
393 | 394 |
394 # If no args are provided, this module is run directly from the command | 395 # If no args are provided, this module is run directly from the command |
395 # line. argparse will take care of consuming sys.argv. | 396 # line. argparse will take care of consuming sys.argv. |
396 arguments = MAIN_PARSER.parse_args(args if len(args) > 0 else None) | 397 arguments = MAIN_PARSER.parse_args(args if len(args) > 0 else None) |
397 | 398 |
398 function = arguments.function | 399 function = arguments.function |
399 del arguments.function | 400 del arguments.function |
400 function(**vars(arguments)) | 401 function(**vars(arguments)) |
LEFT | RIGHT |