Run the individual methods in Application#initialize

We need to initialize part of the Application so we can set options
passed by the user, but we also want to delay making things, e.g.,

- Formatter
- Style Guide
- etc.

Until we have the options solidified so we don't have to do annoying
things.
This commit is contained in:
Ian Cordasco 2016-07-14 07:45:03 -05:00
parent 4d6929c8ab
commit dc05fce516
No known key found for this signature in database
GPG key ID: 656D3395E4A9791A
2 changed files with 12 additions and 1 deletions

View file

@ -11,7 +11,12 @@ LOG = logging.getLogger(__name__)
def get_style_guide(**kwargs):
"""Stub out the only function I'm aware of people using."""
application = app.Application()
application.initialize([])
application.find_plugins()
application.register_plugin_options()
application.parse_configuration_and_cli([])
# We basically want application.initialize to be called but with these
# options set instead before we make our formatter, notifier, internal
# style guide and file checker manager.
options = application.options
for key, value in kwargs.items():
try:
@ -19,6 +24,10 @@ def get_style_guide(**kwargs):
setattr(options, key, value)
except AttributeError:
LOG.error('Could not update option "%s"', key)
application.make_formatter()
application.make_notifier()
application.make_guide()
application.make_file_checker_manager()
return StyleGuide(application)

View file

@ -270,6 +270,8 @@ class Application(object):
This finds the plugins, registers their options, and parses the
command-line arguments.
"""
# NOTE(sigmavirus24): When updating this, make sure you also update
# our legacy API calls to these same methods.
self.find_plugins()
self.register_plugin_options()
self.parse_configuration_and_cli(argv)