From 0398c6e723501d8131af8195e0eceefc345862fa Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Wed, 27 Jun 2018 13:56:39 +0300 Subject: [PATCH] Clean up module imports Example: * import lemur.common.utils -> from lemur.common import utils * import sqlalchemy.types as types -> from sqlalchemy import types --- lemur/auth/views.py | 2 +- lemur/certificates/models.py | 6 ++---- lemur/pending_certificates/models.py | 5 ++--- lemur/utils.py | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/lemur/auth/views.py b/lemur/auth/views.py index 347f0393..7a1bb34c 100644 --- a/lemur/auth/views.py +++ b/lemur/auth/views.py @@ -21,7 +21,7 @@ from lemur.common.utils import get_psuedo_random_string from lemur.users import service as user_service from lemur.roles import service as role_service from lemur.auth.service import create_token, fetch_token_header, get_rsa_public_key -import lemur.auth.ldap as ldap +from lemur.auth import ldap mod = Blueprint('auth', __name__) diff --git a/lemur/certificates/models.py b/lemur/certificates/models.py index ad6949b1..f5b60ad5 100644 --- a/lemur/certificates/models.py +++ b/lemur/certificates/models.py @@ -23,13 +23,11 @@ from sqlalchemy import event, Integer, ForeignKey, String, PassiveDefault, func, from sqlalchemy_utils.types.arrow import ArrowType from werkzeug.utils import cached_property -import lemur.common.utils - from lemur.database import db from lemur.extensions import sentry from lemur.utils import Vault -from lemur.common import defaults +from lemur.common import defaults, utils from lemur.plugins.base import plugins @@ -188,7 +186,7 @@ class Certificate(db.Model): @cached_property def parsed_cert(self): assert self.body, "Certificate body not set" - return lemur.common.utils.parse_certificate(self.body) + return utils.parse_certificate(self.body) @property def active(self): diff --git a/lemur/pending_certificates/models.py b/lemur/pending_certificates/models.py index f8ebc7ab..a43834d4 100644 --- a/lemur/pending_certificates/models.py +++ b/lemur/pending_certificates/models.py @@ -10,9 +10,8 @@ from sqlalchemy import Integer, ForeignKey, String, PassiveDefault, func, Column from sqlalchemy_utils.types.arrow import ArrowType from sqlalchemy_utils import JSONType -import lemur.common.utils from lemur.certificates.models import get_or_increase_name -from lemur.common import defaults +from lemur.common import defaults, utils from lemur.database import db from lemur.utils import Vault @@ -81,7 +80,7 @@ class PendingCertificate(db.Model): dt.now(), dt.now(), False), self.external_id) self.rename = True - self.cn = defaults.common_name(lemur.common.utils.parse_csr(self.csr)) + self.cn = defaults.common_name(utils.parse_csr(self.csr)) self.owner = kwargs['owner'] self.number_attempts = 0 diff --git a/lemur/utils.py b/lemur/utils.py index 6c82657c..1661e3f7 100644 --- a/lemur/utils.py +++ b/lemur/utils.py @@ -9,7 +9,7 @@ import os import tempfile from contextlib import contextmanager -import sqlalchemy.types as types +from sqlalchemy import types from cryptography.fernet import Fernet, MultiFernet from flask import current_app