234 defaults.update(settings_locals) |
234 defaults.update(settings_locals) |
235 |
235 |
236 return defaults |
236 return defaults |
237 |
237 |
238 |
238 |
239 def readPythonSettingsOrDie(parser=None, |
239 def readPythonSettingsOrDie(parser=None, **kwargs): |
240 defaults={}, # {} OK since defaults is always copied |
|
241 settings_dir=DEF_SETTINGS_FILE_DIR, |
|
242 settings_file=DEF_SETTINGS_FILE_NAME): |
|
243 """Calls readPythonSettings(), calling sys.exit() on any errors. |
240 """Calls readPythonSettings(), calling sys.exit() on any errors. |
244 |
241 |
245 Args: |
242 Args: |
246 parser: if supplied, an OptionParser instance used to call print_help() |
243 parser: if supplied, an OptionParser instance used to call print_help() |
247 to print usage information if errors occur |
244 to print usage information if errors occur |
248 defaults, settings_dir, settings_file: see readPythonSettings() |
245 **kwargs: see readPythonSettings() |
249 |
246 |
250 Returns: |
247 Returns: |
251 On success, returns results of readPythonSettings(). |
248 On success, returns results of readPythonSettings(). |
252 |
249 |
253 Exits: |
250 Exits: |
254 On any error from readPythonSettings(), prints error messages to stderr, |
251 On any error from readPythonSettings(), prints error messages to stderr, |
255 possibly prints usage information, and calls sys.exit(1). |
252 possibly prints usage information, and calls sys.exit(1). |
256 """ |
253 """ |
257 try: |
254 try: |
258 return readPythonSettings(defaults=defaults, settings_dir=settings_dir, |
255 return readPythonSettings(**kwargs) |
259 settings_file=settings_file) |
|
260 except Error, error: |
256 except Error, error: |
261 if parser: |
257 if parser: |
262 sys.exit(printErrorsAndUsage(error.args, parser)) |
258 sys.exit(printErrorsAndUsage(error.args, parser)) |
263 else: |
259 else: |
264 sys.exit(printErrors(error.args)) |
260 sys.exit(printErrors(error.args)) |
303 |
299 |
304 |
300 |
305 def checkCommonSvnOptions(options): |
301 def checkCommonSvnOptions(options): |
306 """Checks a common subset of command-line options. |
302 """Checks a common subset of command-line options. |
307 |
303 |
308 Multiple scripts accept a subset of common command-line options. |
304 Multiple scripts accept a subset of common command-line options. This |
|
305 function does some sanity checks on these flags. These checks are collected |
|
306 here because they were being duplicated in multiple scripts. |
309 |
307 |
310 Args: |
308 Args: |
311 options: OptionParser.parse_args() options instance to check |
309 options: OptionParser.parse_args() options instance to check |
312 |
310 |
313 Returns: |
311 Returns: |