From 766c4838fdabb50b6aa9a2594f091ec43750f691 Mon Sep 17 00:00:00 2001 From: Duda Dornelles Date: Thu, 11 Dec 2014 08:33:28 -0200 Subject: optmizing python imports --- service/pixelated/adapter/mail.py | 2 +- service/pixelated/adapter/mail_sender.py | 2 +- service/pixelated/controllers/__init__.py | 1 + service/pixelated/controllers/attachments_controller.py | 1 + service/pixelated/controllers/mails_controller.py | 1 + service/pixelated/runserver.py | 4 +++- service/pixelated/support/date.py | 2 +- service/pixelated/support/encrypted_file_storage.py | 3 +-- service/pixelated/support/ext_protobuf.py | 4 +++- service/pixelated/support/ext_sqlcipher.py | 4 +++- service/test/functional/features/environment.py | 4 +--- service/test/functional/features/steps/common.py | 2 +- service/test/integration/drafts_test.py | 2 -- service/test/perf/mails/test_Mails.py | 1 - service/test/perf/tags/test_Tags.py | 1 - service/test/support/integration/app_test_client.py | 3 +-- service/test/support/integration/model.py | 1 + service/test/unit/adapter/soledad_querier_test.py | 7 ++++--- service/test/unit/bitmask_libraries/smtp_test.py | 3 ++- service/test/unit/config/app_factory_test.py | 2 +- service/test/unit/controllers/mails_controller_test.py | 2 +- service/test/unit/controllers/sync_info_controller_test.py | 3 ++- service/test/unit/runserver_test.py | 2 +- 23 files changed, 31 insertions(+), 26 deletions(-) (limited to 'service') diff --git a/service/pixelated/adapter/mail.py b/service/pixelated/adapter/mail.py index 96fd8038..25e86cf3 100644 --- a/service/pixelated/adapter/mail.py +++ b/service/pixelated/adapter/mail.py @@ -15,6 +15,7 @@ # along with Pixelated. If not, see . import json from uuid import uuid4 +from email.mime.text import MIMEText from leap.mail.imap.fields import fields import leap.mail.walk as walk @@ -22,7 +23,6 @@ import dateutil.parser as dateparser from pixelated.adapter.status import Status import pixelated.support.date from email.MIMEMultipart import MIMEMultipart -from email.mime.text import MIMEText from pycryptopp.hash import sha256 import re diff --git a/service/pixelated/adapter/mail_sender.py b/service/pixelated/adapter/mail_sender.py index 6fad2b6f..50c17ba5 100644 --- a/service/pixelated/adapter/mail_sender.py +++ b/service/pixelated/adapter/mail_sender.py @@ -14,9 +14,9 @@ # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see . from StringIO import StringIO + from twisted.internet.defer import Deferred from twisted.mail.smtp import SMTPSenderFactory - from twisted.internet import reactor from pixelated.support.functional import flatten diff --git a/service/pixelated/controllers/__init__.py b/service/pixelated/controllers/__init__.py index 33da02b8..6bc8e7c2 100644 --- a/service/pixelated/controllers/__init__.py +++ b/service/pixelated/controllers/__init__.py @@ -29,6 +29,7 @@ def respond_json_deferred(entity, request, status_code=200): request.write(json_response) request.finish() + import json from home_controller import HomeController diff --git a/service/pixelated/controllers/attachments_controller.py b/service/pixelated/controllers/attachments_controller.py index d6d2f5e7..b3fed903 100644 --- a/service/pixelated/controllers/attachments_controller.py +++ b/service/pixelated/controllers/attachments_controller.py @@ -15,6 +15,7 @@ # along with Pixelated. If not, see . import io + import re from twisted.protocols.basic import FileSender from twisted.python.log import err diff --git a/service/pixelated/controllers/mails_controller.py b/service/pixelated/controllers/mails_controller.py index d84018dc..f990bcc2 100644 --- a/service/pixelated/controllers/mails_controller.py +++ b/service/pixelated/controllers/mails_controller.py @@ -15,6 +15,7 @@ # along with Pixelated. If not, see . import json + from pixelated.adapter.mail import InputMail from pixelated.controllers import respond_json diff --git a/service/pixelated/runserver.py b/service/pixelated/runserver.py index b53a682b..37a55582 100644 --- a/service/pixelated/runserver.py +++ b/service/pixelated/runserver.py @@ -14,12 +14,14 @@ # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see . -import os import sys import logging import json + +import os from klein import Klein + klein_app = Klein() import ConfigParser diff --git a/service/pixelated/support/date.py b/service/pixelated/support/date.py index 8a2daaf0..e7cdbb30 100644 --- a/service/pixelated/support/date.py +++ b/service/pixelated/support/date.py @@ -14,8 +14,8 @@ # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see . import datetime -import dateutil.parser +import dateutil.parser from dateutil.tz import tzlocal diff --git a/service/pixelated/support/encrypted_file_storage.py b/service/pixelated/support/encrypted_file_storage.py index 2fae9942..c6549c06 100644 --- a/service/pixelated/support/encrypted_file_storage.py +++ b/service/pixelated/support/encrypted_file_storage.py @@ -15,10 +15,9 @@ # along with Pixelated. If not, see . import io -import os +import os from whoosh.filedb.filestore import FileStorage - from whoosh.filedb.structfile import StructFile, BufferFile from cryptography.fernet import Fernet from whoosh.util import random_name diff --git a/service/pixelated/support/ext_protobuf.py b/service/pixelated/support/ext_protobuf.py index 8a8e05e6..337829ba 100644 --- a/service/pixelated/support/ext_protobuf.py +++ b/service/pixelated/support/ext_protobuf.py @@ -15,9 +15,11 @@ # along with Pixelated. If not, see . from __future__ import print_function -import protobuf.socketrpc.server from sys import platform as _platform +import protobuf.socketrpc.server + + # protobuf throws a lot of 'Socket is not connected' exceptions on OSX but they are not an issue. # refer too https://code.google.com/p/protobuf-socket-rpc/issues/detail?id=10 and diff --git a/service/pixelated/support/ext_sqlcipher.py b/service/pixelated/support/ext_sqlcipher.py index bd01e610..fae1df72 100644 --- a/service/pixelated/support/ext_sqlcipher.py +++ b/service/pixelated/support/ext_sqlcipher.py @@ -14,9 +14,11 @@ # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see . -import leap.soledad.client.sqlcipher from sys import platform as _platform +import leap.soledad.client.sqlcipher + + # WAL is breaking for the debian sqlcipher package so we need to disable it # refer to https://leap.se/code/issues/5562 diff --git a/service/test/functional/features/environment.py b/service/test/functional/features/environment.py index 4c9af63e..a3c28a9b 100644 --- a/service/test/functional/features/environment.py +++ b/service/test/functional/features/environment.py @@ -13,13 +13,11 @@ # # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see . -import time -import multiprocessing import logging + from test.support.integration import AppTestClient from selenium import webdriver from pixelated.controllers.features_controller import FeaturesController -import pixelated def before_all(context): diff --git a/service/test/functional/features/steps/common.py b/service/test/functional/features/steps/common.py index b7aee7d6..0294293d 100644 --- a/service/test/functional/features/steps/common.py +++ b/service/test/functional/features/steps/common.py @@ -16,7 +16,7 @@ from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.wait import WebDriverWait -from selenium.common.exceptions import NoSuchElementException, TimeoutException +from selenium.common.exceptions import TimeoutException from hamcrest import * diff --git a/service/test/integration/drafts_test.py b/service/test/integration/drafts_test.py index 7fd0a46b..2ba14dfd 100644 --- a/service/test/integration/drafts_test.py +++ b/service/test/integration/drafts_test.py @@ -14,8 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see . -import unittest - from test.support.integration import * diff --git a/service/test/perf/mails/test_Mails.py b/service/test/perf/mails/test_Mails.py index b24ca5f4..a7a918ad 100644 --- a/service/test/perf/mails/test_Mails.py +++ b/service/test/perf/mails/test_Mails.py @@ -16,7 +16,6 @@ import unittest from funkload.FunkLoadTestCase import FunkLoadTestCase - from test.support.integration import AppTestClient diff --git a/service/test/perf/tags/test_Tags.py b/service/test/perf/tags/test_Tags.py index 7892398b..8f62b4c9 100644 --- a/service/test/perf/tags/test_Tags.py +++ b/service/test/perf/tags/test_Tags.py @@ -16,7 +16,6 @@ import unittest from funkload.FunkLoadTestCase import FunkLoadTestCase - from test.support.integration import AppTestClient diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py index 80baf4c8..b2824770 100644 --- a/service/test/support/integration/app_test_client.py +++ b/service/test/support/integration/app_test_client.py @@ -17,8 +17,8 @@ import json import multiprocessing import shutil import time -from pixelated.config.routes import setup_routes +from pixelated.config.routes import setup_routes from klein.test_resource import requestMock, _render from leap.mail.imap.account import SoledadBackedAccount from leap.soledad.client import Soledad @@ -29,7 +29,6 @@ from pixelated.adapter.mail_service import MailService from pixelated.adapter.mailboxes import Mailboxes from pixelated.adapter.soledad_querier import SoledadQuerier from pixelated.adapter.tag_service import TagService -from pixelated.config import app_factory from pixelated.controllers import FeaturesController, HomeController, MailsController, TagsController, \ SyncInfoController, AttachmentsController, ContactsController import pixelated.runserver diff --git a/service/test/support/integration/model.py b/service/test/support/integration/model.py index 17c29c2b..79552dad 100644 --- a/service/test/support/integration/model.py +++ b/service/test/support/integration/model.py @@ -14,6 +14,7 @@ # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see . import json + from pixelated.adapter.mail import InputMail from pixelated.adapter.status import Status diff --git a/service/test/unit/adapter/soledad_querier_test.py b/service/test/unit/adapter/soledad_querier_test.py index d07fdb00..561c4cb8 100644 --- a/service/test/unit/adapter/soledad_querier_test.py +++ b/service/test/unit/adapter/soledad_querier_test.py @@ -14,13 +14,14 @@ # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see . import unittest -from pixelated.adapter.soledad_querier import SoledadQuerier -from mockito import mock, when, any import json -import os import base64 import quopri +from pixelated.adapter.soledad_querier import SoledadQuerier +from mockito import mock, when, any +import os + class SoledadQuerierTest(unittest.TestCase): diff --git a/service/test/unit/bitmask_libraries/smtp_test.py b/service/test/unit/bitmask_libraries/smtp_test.py index ca8a89e4..b00a0af6 100644 --- a/service/test/unit/bitmask_libraries/smtp_test.py +++ b/service/test/unit/bitmask_libraries/smtp_test.py @@ -13,8 +13,9 @@ # # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see . -import os import sys + +import os from mock import MagicMock, patch from abstract_leap_test import AbstractLeapTest from pixelated.bitmask_libraries.smtp import LeapSmtp diff --git a/service/test/unit/config/app_factory_test.py b/service/test/unit/config/app_factory_test.py index 29739ab1..a42c7c83 100644 --- a/service/test/unit/config/app_factory_test.py +++ b/service/test/unit/config/app_factory_test.py @@ -1,7 +1,7 @@ import unittest + from mock import patch, MagicMock, ANY import pixelated - from pixelated.config.app_factory import create_app diff --git a/service/test/unit/controllers/mails_controller_test.py b/service/test/unit/controllers/mails_controller_test.py index 3e28e6b0..ab87c205 100644 --- a/service/test/unit/controllers/mails_controller_test.py +++ b/service/test/unit/controllers/mails_controller_test.py @@ -14,8 +14,8 @@ # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see . import json - import unittest + from klein.test_resource import requestMock from mock import MagicMock from mockito import * diff --git a/service/test/unit/controllers/sync_info_controller_test.py b/service/test/unit/controllers/sync_info_controller_test.py index ce9a0dff..cd3aeb02 100644 --- a/service/test/unit/controllers/sync_info_controller_test.py +++ b/service/test/unit/controllers/sync_info_controller_test.py @@ -14,10 +14,11 @@ # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see . import unittest +import json + from mock import MagicMock from pixelated.controllers import SyncInfoController from mockito import * -import json class SyncInfoControllerTest(unittest.TestCase): diff --git a/service/test/unit/runserver_test.py b/service/test/unit/runserver_test.py index 57359259..99b502f1 100644 --- a/service/test/unit/runserver_test.py +++ b/service/test/unit/runserver_test.py @@ -16,10 +16,10 @@ import unittest import sys -import os import thread import json +import os import pixelated.config.app_factory import pixelated.runserver from mockito import * -- cgit v1.2.3