Skip to content

Commit

Permalink
style: apply black to create_app
Browse files Browse the repository at this point in the history
  • Loading branch information
alexppg committed Oct 31, 2020
1 parent 1fb46ce commit ed104b4
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions pyms/flask/app/create_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def example():
Current services are swagger, request, tracer, metrics
"""

config_resource = CONFIG_BASE
services: List[str] = []
application = Flask
Expand Down Expand Up @@ -105,7 +106,9 @@ def init_services(self) -> None:
"""
services_resources = ServicesResource()
for service_name, service in services_resources.get_services():
if service_name not in self.services or not getattr(self, service_name, False):
if service_name not in self.services or not getattr(
self, service_name, False
):
self.services.append(service_name)
setattr(self, service_name, service)

Expand Down Expand Up @@ -150,7 +153,7 @@ def init_logger(self) -> None:
:return:
"""
self.application.logger = logger
os.environ['WERKZEUG_RUN_MAIN'] = "true"
os.environ["WERKZEUG_RUN_MAIN"] = "true"

formatter = CustomJsonFormatter()
formatter.add_service_name(self.application.config["APP_NAME"])
Expand All @@ -172,11 +175,16 @@ def init_app(self) -> Flask:
:return: None
"""
if self.swagger:
application = self.swagger.init_app(config=self.config.to_flask(), path=self.path)
application = self.swagger.init_app(
config=self.config.to_flask(), path=self.path
)
else:
check_package_exists("flask")
application = Flask(__name__, static_folder=os.path.join(self.path, 'static'),
template_folder=os.path.join(self.path, 'templates'))
application = Flask(
__name__,
static_folder=os.path.join(self.path, "static"),
template_folder=os.path.join(self.path, "templates"),
)

application.root_path = self.path

Expand All @@ -192,8 +200,7 @@ def init_metrics(self) -> None:
if self.metrics:
self.application.register_blueprint(self.metrics.metrics_blueprint)
self.metrics.add_logger_handler(
self.application.logger,
self.application.config["APP_NAME"]
self.application.logger, self.application.config["APP_NAME"]
)
self.metrics.monitor(self.application.config["APP_NAME"], self.application)

Expand Down Expand Up @@ -230,7 +237,9 @@ def create_app(self) -> Flask:

self.init_metrics()

logger.debug("Started app with PyMS and this services: {}".format(self.services))
logger.debug(
"Started app with PyMS and this services: {}".format(self.services)
)

return self.application

Expand Down

0 comments on commit ed104b4

Please sign in to comment.