11""" Parse arguments from command line and configuration files. """
2+
23import fnmatch
34from os import getcwd , path
45from re import compile as re
1516#: A default checkers
1617DEFAULT_LINTERS = 'pep8' , 'pyflakes' , 'mccabe'
1718
18- #: A default complexity for mccabe checker
19- DEFAULT_COMPLEXITY = 10
20-
2119CURDIR = getcwd ()
2220DEFAULT_INI_PATH = path .join (CURDIR , 'pylama.ini' )
2321
2422
2523def parse_options (
2624 args = None , async = False , select = '' , ignore = '' , linters = DEFAULT_LINTERS ,
27- complexity = DEFAULT_COMPLEXITY , options = DEFAULT_INI_PATH ):
25+ options = DEFAULT_INI_PATH ):
2826 """ Parse options from command line and configuration files.
2927
3028 :return argparse.Namespace:
@@ -37,10 +35,9 @@ def parse_options(
3735 async = _Default (async ), format = _Default ('pep8' ),
3836 select = _Default (select ), ignore = _Default (ignore ),
3937 report = _Default (None ), verbose = _Default (False ),
40- linters = _Default (',' .join (linters )), complexity = _Default (complexity ),
41- options = _Default (options ))
38+ linters = _Default (',' .join (linters )), options = _Default (options ))
4239
43- if not ( args is None ) :
40+ if not args is None :
4441 options = parser .parse_args (args )
4542
4643 # Parse options from ini file
@@ -72,13 +69,18 @@ def parse_options(
7269
7370 # Parse file related options
7471 options .file_params = dict ()
72+ options .linter_params = dict ()
7573 for k , s in config .sections .items ():
76- if k != config .default_section :
77- mask = re (fnmatch .translate (k ))
78- options .file_params [mask ] = dict (s )
79- options .file_params [mask ]['lint' ] = int (
80- options .file_params [mask ].get ('lint' , 1 )
81- )
74+ if k == config .default_section :
75+ continue
76+ if k in LINTERS :
77+ options .linter_params [k ] = dict (s )
78+ continue
79+ mask = re (fnmatch .translate (k ))
80+ options .file_params [mask ] = dict (s )
81+ options .file_params [mask ]['lint' ] = int (
82+ options .file_params [mask ].get ('lint' , 1 )
83+ )
8284
8385 return options
8486
@@ -147,10 +149,6 @@ def parse_linters(csp_str):
147149 type = lambda s : [re (fnmatch .translate (p )) for p in s .split (',' ) if p ],
148150 help = "Skip files by masks (comma-separated, Ex. */messages.py)" )
149151
150- parser .add_argument (
151- "--complexity" , "-c" , default = _Default (DEFAULT_COMPLEXITY ), type = int ,
152- help = "Set mccabe complexity." )
153-
154152 parser .add_argument ("--report" , "-r" , help = "Filename for report." )
155153 parser .add_argument (
156154 "--hook" , action = "store_true" , help = "Install Git (Mercurial) hook." )
0 commit comments