MCPcopy Create free account
hub / github.com/BVLC/caffe / ParseArguments

Function ParseArguments

scripts/cpp_lint.py:4783–4850  ·  view source on GitHub ↗

Parses the command line arguments. This may set the output format and verbosity level as side-effects. Args: args: The command line arguments: Returns: The list of filenames to lint.

(args)

Source from the content-addressed store, hash-verified

4781
4782
4783def ParseArguments(args):
4784 """Parses the command line arguments.
4785
4786 This may set the output format and verbosity level as side-effects.
4787
4788 Args:
4789 args: The command line arguments:
4790
4791 Returns:
4792 The list of filenames to lint.
4793 """
4794 try:
4795 (opts, filenames) = getopt.getopt(args, '', ['help', 'output=', 'verbose=',
4796 'counting=',
4797 'filter=',
4798 'root=',
4799 'linelength=',
4800 'extensions='])
4801 except getopt.GetoptError:
4802 PrintUsage('Invalid arguments.')
4803
4804 verbosity = _VerboseLevel()
4805 output_format = _OutputFormat()
4806 filters = ''
4807 counting_style = ''
4808
4809 for (opt, val) in opts:
4810 if opt == '--help':
4811 PrintUsage(None)
4812 elif opt == '--output':
4813 if val not in ('emacs', 'vs7', 'eclipse'):
4814 PrintUsage('The only allowed output formats are emacs, vs7 and eclipse.')
4815 output_format = val
4816 elif opt == '--verbose':
4817 verbosity = int(val)
4818 elif opt == '--filter':
4819 filters = val
4820 if not filters:
4821 PrintCategories()
4822 elif opt == '--counting':
4823 if val not in ('total', 'toplevel', 'detailed'):
4824 PrintUsage('Valid counting options are total, toplevel, and detailed')
4825 counting_style = val
4826 elif opt == '--root':
4827 global _root
4828 _root = val
4829 elif opt == '--linelength':
4830 global _line_length
4831 try:
4832 _line_length = int(val)
4833 except ValueError:
4834 PrintUsage('Line length must be digits.')
4835 elif opt == '--extensions':
4836 global _valid_extensions
4837 try:
4838 _valid_extensions = set(val.split(','))
4839 except ValueError:
4840 PrintUsage('Extensions must be comma separated list.')

Callers 1

mainFunction · 0.85

Calls 8

PrintUsageFunction · 0.85
_VerboseLevelFunction · 0.85
_OutputFormatFunction · 0.85
PrintCategoriesFunction · 0.85
_SetOutputFormatFunction · 0.85
_SetVerboseLevelFunction · 0.85
_SetFiltersFunction · 0.85
_SetCountingStyleFunction · 0.85

Tested by

no test coverage detected