Optimize imports

* PEP8: Fix module level import not at top of file
* Remove unused imports
* Remove simplejson
* Replace mimetools with email
This commit is contained in:
Labrys 2016-06-04 22:10:26 -04:00
commit 382d108db2
10 changed files with 25 additions and 25 deletions

View file

@ -33,10 +33,12 @@ from core.autoProcess.autoProcessMusic import autoProcessMusic
from core.autoProcess.autoProcessTV import autoProcessTV from core.autoProcess.autoProcessTV import autoProcessTV
from core import logger, versionCheck, nzbToMediaDB from core import logger, versionCheck, nzbToMediaDB
from core.nzbToMediaConfig import config from core.nzbToMediaConfig import config
from core.nzbToMediaUtil import category_search, sanitizeName, copy_link, parse_args, flatten, getDirs, \ from core.nzbToMediaUtil import (
rmReadOnly, rmDir, pause_torrent, resume_torrent, remove_torrent, listMediaFiles, \ category_search, sanitizeName, copy_link, parse_args, flatten, getDirs,
extractFiles, cleanDir, update_downloadInfoStatus, get_downloadInfo, WakeUp, makeDir, cleanDir, \ rmReadOnly, rmDir, pause_torrent, resume_torrent, remove_torrent, listMediaFiles,
create_torrent_class, listMediaFiles, RunningProcess extractFiles, cleanDir, update_downloadInfoStatus, get_downloadInfo, WakeUp, makeDir, cleanDir,
create_torrent_class, listMediaFiles, RunningProcess,
)
from core.transcoder import transcoder from core.transcoder import transcoder
from core.databases import mainDB from core.databases import mainDB

View file

@ -1,5 +1,5 @@
# coding=utf-8 # coding=utf-8
import core
from core import logger, nzbToMediaDB from core import logger, nzbToMediaDB
from core.nzbToMediaUtil import backupVersionedFile from core.nzbToMediaUtil import backupVersionedFile

View file

@ -1,5 +1,5 @@
# coding=utf-8 # coding=utf-8
import json
import requests import requests

View file

@ -1,7 +1,8 @@
# coding=utf-8 # coding=utf-8
import urllib
import core
import requests import requests
import core
from core import logger from core import logger

View file

@ -15,10 +15,9 @@ Example usage:
download_location = client.core.get_config_value("download_location").get() download_location = client.core.get_config_value("download_location").get()
""" """
from core.synchronousdeluge.exceptions import DelugeRPCError
__title__ = "synchronous-deluge" __title__ = "synchronous-deluge"
__version__ = "0.1" __version__ = "0.1"
__author__ = "Christian Dale" __author__ = "Christian Dale"
from core.synchronousdeluge.exceptions import DelugeRPCError

View file

@ -19,6 +19,10 @@ rencode module versions, so you should check that you are using the
same rencode version throughout your project. same rencode version throughout your project.
""" """
import struct
from threading import Lock
__version__ = '1.0.1' __version__ = '1.0.1'
__all__ = ['dumps', 'loads'] __all__ = ['dumps', 'loads']
@ -62,9 +66,6 @@ __all__ = ['dumps', 'loads']
# (The rencode module is licensed under the above license as well). # (The rencode module is licensed under the above license as well).
# #
import struct
from threading import Lock
# Default number of bits for serialized floats, either 32 or 64 (also a parameter for dumps()). # Default number of bits for serialized floats, either 32 or 64 (also a parameter for dumps()).
DEFAULT_FLOAT_BITS = 32 DEFAULT_FLOAT_BITS = 32

View file

@ -3,8 +3,6 @@ import errno
import os import os
import platform import platform
import subprocess import subprocess
import urllib2
import traceback
import core import core
import json import json
import shutil import shutil

View file

@ -2,10 +2,13 @@
# Copyright (c) 2008-2013 Erik Svensson <erik.public@gmail.com> # Copyright (c) 2008-2013 Erik Svensson <erik.public@gmail.com>
# Licensed under the MIT license. # Licensed under the MIT license.
import socket, datetime, logging, constants import constants
import datetime
import logging
import socket
from collections import namedtuple from collections import namedtuple
from constants import LOGGER
from constants import LOGGER
from six import string_types, iteritems from six import string_types, iteritems
UNITS = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB'] UNITS = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB']

View file

@ -4,14 +4,10 @@ import urllib
import urllib2 import urllib2
import urlparse import urlparse
import cookielib import cookielib
import json
import re import re
import StringIO import StringIO
try:
import json
except ImportError:
import simplejson as json
from core.utorrent.upload import MultiPartForm from core.utorrent.upload import MultiPartForm

View file

@ -1,8 +1,8 @@
# coding=utf-8 # coding=utf-8
# code copied from http://www.doughellmann.com/PyMOTW/urllib2/ # code copied from http://www.doughellmann.com/PyMOTW/urllib2/
from email.generator import _make_boundary as make_boundary
import itertools import itertools
import mimetools
import mimetypes import mimetypes
@ -12,7 +12,7 @@ class MultiPartForm(object):
def __init__(self): def __init__(self):
self.form_fields = [] self.form_fields = []
self.files = [] self.files = []
self.boundary = mimetools.choose_boundary() self.boundary = make_boundary()
return return
def get_content_type(self): def get_content_type(self):