Commits

Ian Cordasco committed 477d59b

Further simplification thanks to pep8

Comments (0)

Files changed (2)

 import pyflakes.checker
 import select
 from flake8 import mccabe
-from flake8.util import (_initpep8, skip_file, get_parser, read_config,
-                         Flake8Reporter)
+from flake8.util import _initpep8, skip_file, get_parser, Flake8Reporter
 
 pep8style = None
 
+if sys.platform.startswith('win'):
+    pep8.DEFAULT_CONFIG = os.path.expanduser(r'~\.flake8')
+else:
+    pep8.DEFAULT_CONFIG = os.path.join(
+        os.getenv('XDG_CONFIG_HOME') or os.path.expanduser('~/.config'),
+        'flake8'
+    )
+
+PROJECT_CONFIG = ['.flake8']
+PROJECT_CONFIG.extend(pep8.PROJECT_CONFIG)
+pep8.PROJECT_CONFIG = tuple(PROJECT_CONFIG)
+
 
 def main():
     global pep8style
         from flake8.hooks import install_hook
         install_hook()
 
-    read_config(opts, parser)
-
     warnings = 0
     stdin = None
 
     parser.add_option('-V', '--version', action='callback',
                       callback=version,
                       help='Print the version info for flake8')
+    parser.prog = os.path.basename(sys.argv[0])
     return parser
 
 
-def read_config(opts, opt_parser):
-    configs = ('.flake8', '.pep8', 'tox.ini', 'setup.cfg',
-               os.path.expanduser(r'~\.flake8'),
-               os.path.join(os.path.expanduser('~/.config'), 'flake8'))
-    parser = ConfigParser()
-    files_found = parser.read(configs)
-    if not (files_found and parser.has_section('flake8')):
-        return
-
-    if opts.verbose:
-        print("Found local configuration file(s): {0}".format(
-            ', '.join(files_found)))
-
-    option_list = dict([(o.dest, o.type or o.action)
-                        for o in opt_parser.option_list])
-
-    for o in parser.options('flake8'):
-        v = parser.get('flake8', o)
-
-        if opts.verbose > 1:
-            print(" {0} = {1}".format(o, v))
-
-        normed = o.replace('-', '_')
-        if normed not in option_list:
-            print("Unknown option: {0}".format(o))
-
-        opt_type = option_list[normed]
-
-        if opt_type in ('int', 'count'):
-            v = int(v)
-        elif opt_type in ('store_true', 'store_false'):
-            v = True if v == 'True' else False
-
-        setattr(opts, normed, v)
-
-    for attr in ('filename', 'exclude', 'ignore', 'select'):
-        val = getattr(opts, attr)
-        if hasattr(val, 'split'):
-            setattr(opts, attr, val.split(','))
-
-
 def skip_warning(warning, ignore=[]):
     # XXX quick dirty hack, just need to keep the line in the warning
     if not hasattr(warning, 'message') or ignore is None: