diff options
| author | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-06-30 08:27:32 -0500 |
|---|---|---|
| committer | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-06-30 08:27:32 -0500 |
| commit | 6a2ad045fa3aeff24fbcf11b2abf8ae27035b9f1 (patch) | |
| tree | 780b68350dc393621e649ca36a9a91b68a820596 /src/flake8 | |
| parent | f963641e932daed5ca5d71efa7293a9b756b8f76 (diff) | |
| download | flake8-6a2ad045fa3aeff24fbcf11b2abf8ae27035b9f1.tar.gz | |
Add the skeleton for the LegacyStyleGuide
Diffstat (limited to 'src/flake8')
| -rw-r--r-- | src/flake8/api/style_guide.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/flake8/api/style_guide.py b/src/flake8/api/style_guide.py new file mode 100644 index 0000000..4e8595c --- /dev/null +++ b/src/flake8/api/style_guide.py @@ -0,0 +1,47 @@ +"""Module containing shims around Flake8 2.0 behaviour.""" +import os.path + +from flake8.formatting import base as formatter + + +class LegacyStyleGuide(object): + """Public facing object that mimic's Flake8 2.0's StyleGuide.""" + + def __init__(self, application): + self._application = application + self._file_checker_manager = application.file_checker_manager + + @property + def options(self): + """The parsed options. + + An instance of :class:`optparse.Values` containing parsed options. + """ + return self._application.options + + @property + def paths(self): + """The extra arguments passed as paths.""" + return self._application.paths + + def check_files(self, paths=None): + raise NotImplementedError('This should be easy') + + def excluded(self, filename, parent=None): + return (self._file_checker_manager.is_path_excluded(filename) or + (parent and + self._file_checker_manager.is_path_excluded( + os.path.join(parent, filename)))) + + def init_report(self, reporter=None): + if (reporter is not None and + isinstance(reporter, formatter.BaseFormatter)): + self._application.formatter = reporter + self._application.guide = None + # NOTE(sigmavirus24): This isn't the intended use of + # Application#make_guide but it works pretty well. + # Stop cringing... I know it's gross. + self._application.make_guide() + + def input_file(self, filename, lines=None, expected=None, line_offset=0): + raise NotImplementedError('This should be a pain') |
