From 6f35da4096770a668c4944c3024cd7ddb34be092 Mon Sep 17 00:00:00 2001 From: lakshyacis Date: Fri, 24 Jan 2020 19:33:13 +0530 Subject: [PATCH] Imported packages sequencing and formatting --- src/addresses.py | 1 - src/api.py | 3 +-- src/bitmessagecli.py | 10 +++++----- src/bitmessagemain.py | 2 +- src/bmconfigparser.py | 2 +- src/build_osx.py | 2 +- src/class_addressGenerator.py | 16 ++++++++-------- src/class_objectProcessor.py | 30 ++++++++++++++---------------- src/class_singleCleaner.py | 2 +- src/class_sqlThread.py | 15 +++++++-------- src/helper_ackPayload.py | 2 +- src/helper_msgcoding.py | 10 +++++----- src/helper_random.py | 2 ++ src/helper_sql.py | 2 +- src/inventory.py | 2 +- src/l10n.py | 1 - src/main.py | 2 +- src/namecoin.py | 4 ++-- src/openclpow.py | 6 +++--- src/paths.py | 1 - src/protocol.py | 2 +- src/qidenticon.py | 4 ++-- src/shared.py | 7 ++++--- src/threads.py | 12 ++++++------ 24 files changed, 68 insertions(+), 72 deletions(-) diff --git a/src/addresses.py b/src/addresses.py index 2895e256..0d3d4400 100644 --- a/src/addresses.py +++ b/src/addresses.py @@ -8,7 +8,6 @@ from struct import pack, unpack from debug import logger - ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" diff --git a/src/api.py b/src/api.py index 6652657f..70da0cda 100644 --- a/src/api.py +++ b/src/api.py @@ -18,8 +18,6 @@ from binascii import hexlify, unhexlify from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler, SimpleXMLRPCServer from struct import pack -from version import softwareVersion - import defaults import helper_inbox import helper_sent @@ -42,6 +40,7 @@ from helper_ackPayload import genAckPayload from helper_sql import SqlBulkExecute, sqlExecute, sqlQuery, sqlStoredProcedure from inventory import Inventory from network.threads import StoppableThread +from version import softwareVersion str_chan = '[chan]' diff --git a/src/bitmessagecli.py b/src/bitmessagecli.py index 02fed7e9..01dbc9bb 100644 --- a/src/bitmessagecli.py +++ b/src/bitmessagecli.py @@ -13,15 +13,15 @@ TODO: fix the following (currently ignored) violations: """ -import xmlrpclib import datetime import imghdr -import ntpath import json -import socket -import time -import sys +import ntpath import os +import socket +import sys +import time +import xmlrpclib from bmconfigparser import BMConfigParser diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 770173b9..d6cb289b 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -33,8 +33,8 @@ from struct import pack import defaults import shared -import state import shutdown +import state from bmconfigparser import BMConfigParser from debug import logger # this should go before any threads from helper_startup import ( diff --git a/src/bmconfigparser.py b/src/bmconfigparser.py index abef971a..328cf0c7 100644 --- a/src/bmconfigparser.py +++ b/src/bmconfigparser.py @@ -3,8 +3,8 @@ BMConfigParser class definition and default configuration settings """ import ConfigParser -import shutil import os +import shutil from datetime import datetime import state diff --git a/src/build_osx.py b/src/build_osx.py index c929f48a..83d2f280 100644 --- a/src/build_osx.py +++ b/src/build_osx.py @@ -1,6 +1,6 @@ """Building osx.""" -from glob import glob import os +from glob import glob from PyQt4 import QtCore from setuptools import setup diff --git a/src/class_addressGenerator.py b/src/class_addressGenerator.py index 5fbf7633..3df6501f 100644 --- a/src/class_addressGenerator.py +++ b/src/class_addressGenerator.py @@ -1,22 +1,22 @@ """ A thread for creating addresses """ -import time import hashlib +import time from binascii import hexlify -from pyelliptic import arithmetic -from pyelliptic.openssl import OpenSSL -import tr -import queues -import state -import shared import defaults import highlevelcrypto -from bmconfigparser import BMConfigParser +import queues +import shared +import state +import tr from addresses import decodeAddress, encodeAddress, encodeVarint +from bmconfigparser import BMConfigParser from fallback import RIPEMD160Hash from network import StoppableThread +from pyelliptic import arithmetic +from pyelliptic.openssl import OpenSSL class addressGenerator(StoppableThread): diff --git a/src/class_objectProcessor.py b/src/class_objectProcessor.py index a2151482..824580c2 100644 --- a/src/class_objectProcessor.py +++ b/src/class_objectProcessor.py @@ -12,31 +12,29 @@ import time from binascii import hexlify from subprocess import call # nosec -import highlevelcrypto -import knownnodes -import shared -from addresses import ( - calculateInventoryHash, decodeAddress, decodeVarint, encodeAddress, - encodeVarint, varintDecodeError -) -from bmconfigparser import BMConfigParser - import helper_bitcoin import helper_inbox import helper_msgcoding import helper_sent -from helper_sql import SqlBulkExecute, sqlExecute, sqlQuery -from helper_ackPayload import genAckPayload -from network import bmproto -from network.node import Peer - +import highlevelcrypto +import knownnodes +import l10n import protocol import queues +import shared import state import tr +from addresses import ( + calculateInventoryHash, decodeAddress, decodeVarint, + encodeAddress, encodeVarint, varintDecodeError +) +from bmconfigparser import BMConfigParser from fallback import RIPEMD160Hash - -import l10n +from helper_ackPayload import genAckPayload +from helper_sql import SqlBulkExecute, sqlExecute, sqlQuery +from network import bmproto +from network.node import Peer +# pylint: disable=too-many-locals, too-many-return-statements, too-many-branches, too-many-statements logger = logging.getLogger('default') diff --git a/src/class_singleCleaner.py b/src/class_singleCleaner.py index 68a5e727..b9fe3d1c 100644 --- a/src/class_singleCleaner.py +++ b/src/class_singleCleaner.py @@ -29,7 +29,7 @@ import shared import state import tr from bmconfigparser import BMConfigParser -from helper_sql import sqlQuery, sqlExecute +from helper_sql import sqlExecute, sqlQuery from inventory import Inventory from network import BMConnectionPool, StoppableThread diff --git a/src/class_sqlThread.py b/src/class_sqlThread.py index 78d70f79..7e9eb6c5 100644 --- a/src/class_sqlThread.py +++ b/src/class_sqlThread.py @@ -2,15 +2,12 @@ sqlThread is defined here """ -import threading -from bmconfigparser import BMConfigParser - -import sqlite3 -import time -import shutil # used for moving the messages.dat file -import sys import os -from debug import logger +import shutil # used for moving the messages.dat file +import sqlite3 +import sys +import threading +import time import helper_sql import helper_startup @@ -18,6 +15,8 @@ import paths import queues import state import tr +from bmconfigparser import BMConfigParser +from debug import logger # pylint: disable=attribute-defined-outside-init,protected-access diff --git a/src/helper_ackPayload.py b/src/helper_ackPayload.py index dcce3153..d30f4c0d 100644 --- a/src/helper_ackPayload.py +++ b/src/helper_ackPayload.py @@ -5,8 +5,8 @@ This module is for generating ack payload from binascii import hexlify from struct import pack -import highlevelcrypto import helper_random +import highlevelcrypto from addresses import encodeVarint diff --git a/src/helper_msgcoding.py b/src/helper_msgcoding.py index ae2bf80b..76dad423 100644 --- a/src/helper_msgcoding.py +++ b/src/helper_msgcoding.py @@ -5,6 +5,11 @@ Message encoding end decoding functions import string import zlib +import messagetypes +from bmconfigparser import BMConfigParser +from debug import logger +from tr import _translate + try: import msgpack except ImportError: @@ -13,11 +18,6 @@ except ImportError: except ImportError: import fallback.umsgpack.umsgpack as msgpack -import messagetypes -from bmconfigparser import BMConfigParser -from debug import logger -from tr import _translate - BITMESSAGE_ENCODING_IGNORE = 0 BITMESSAGE_ENCODING_TRIVIAL = 1 BITMESSAGE_ENCODING_SIMPLE = 2 diff --git a/src/helper_random.py b/src/helper_random.py index 0785c737..9a29d5e2 100644 --- a/src/helper_random.py +++ b/src/helper_random.py @@ -2,7 +2,9 @@ import os import random + from pyelliptic.openssl import OpenSSL + NoneType = type(None) diff --git a/src/helper_sql.py b/src/helper_sql.py index e7f2a60e..9b5dc29d 100644 --- a/src/helper_sql.py +++ b/src/helper_sql.py @@ -16,8 +16,8 @@ SQLite objects can only be used from one thread. or isn't thread-safe. """ -import threading import Queue +import threading sqlSubmitQueue = Queue.Queue() """the queue for SQL""" diff --git a/src/inventory.py b/src/inventory.py index 4b9ad226..fc06e455 100644 --- a/src/inventory.py +++ b/src/inventory.py @@ -1,8 +1,8 @@ """The Inventory singleton""" # TODO make this dynamic, and watch out for frozen, like with messagetypes -import storage.sqlite import storage.filesystem +import storage.sqlite from bmconfigparser import BMConfigParser from singleton import Singleton diff --git a/src/l10n.py b/src/l10n.py index bdfb03b3..7a78525b 100644 --- a/src/l10n.py +++ b/src/l10n.py @@ -7,7 +7,6 @@ import time from bmconfigparser import BMConfigParser - logger = logging.getLogger('default') diff --git a/src/main.py b/src/main.py index 969dbe56..71a4cb50 100644 --- a/src/main.py +++ b/src/main.py @@ -1,6 +1,6 @@ """This module is for thread start.""" -from bitmessagemain import main import state +from bitmessagemain import main if __name__ == '__main__': state.kivy = True diff --git a/src/namecoin.py b/src/namecoin.py index 63ca5653..ae2bde79 100644 --- a/src/namecoin.py +++ b/src/namecoin.py @@ -10,11 +10,11 @@ import os import socket import sys -from addresses import decodeAddress -from debug import logger import defaults import tr # translate +from addresses import decodeAddress from bmconfigparser import BMConfigParser +from debug import logger configSection = "bitmessagesettings" diff --git a/src/openclpow.py b/src/openclpow.py index fad25fa3..35bf46d2 100644 --- a/src/openclpow.py +++ b/src/openclpow.py @@ -2,14 +2,14 @@ """ Module for Proof of Work using OpenCL """ -from struct import pack, unpack import hashlib import os +from struct import pack, unpack -from bmconfigparser import BMConfigParser import paths -from state import shutdown +from bmconfigparser import BMConfigParser from debug import logger +from state import shutdown libAvailable = True ctx = False diff --git a/src/paths.py b/src/paths.py index 59bc5e42..e2f8c97e 100644 --- a/src/paths.py +++ b/src/paths.py @@ -8,7 +8,6 @@ import sys from datetime import datetime from shutil import move - logger = logging.getLogger('default') # When using py2exe or py2app, the variable frozen is added to the sys diff --git a/src/protocol.py b/src/protocol.py index cdd50dce..4f2d0856 100644 --- a/src/protocol.py +++ b/src/protocol.py @@ -11,7 +11,7 @@ import socket import sys import time from binascii import hexlify -from struct import pack, unpack, Struct +from struct import Struct, pack, unpack import defaults import highlevelcrypto diff --git a/src/qidenticon.py b/src/qidenticon.py index deafc570..6eab09cd 100644 --- a/src/qidenticon.py +++ b/src/qidenticon.py @@ -11,8 +11,8 @@ Return a PIL Image class instance which have generated identicon image. """ from PyQt4 import QtGui -from PyQt4.QtCore import QSize, QPointF, Qt -from PyQt4.QtGui import QPixmap, QPainter, QPolygonF +from PyQt4.QtCore import QPointF, QSize, Qt +from PyQt4.QtGui import QPainter, QPixmap, QPolygonF class IdenticonRendererBase(object): diff --git a/src/shared.py b/src/shared.py index dfc86ab6..beed52ed 100644 --- a/src/shared.py +++ b/src/shared.py @@ -10,12 +10,11 @@ from __future__ import division # Libraries. import hashlib import os -import sys import stat -import threading import subprocess +import sys +import threading from binascii import hexlify -from pyelliptic import arithmetic # Project imports. import highlevelcrypto @@ -25,6 +24,8 @@ from bmconfigparser import BMConfigParser from debug import logger from helper_sql import sqlQuery +from pyelliptic import arithmetic + verbose = 1 # This is obsolete with the change to protocol v3 diff --git a/src/threads.py b/src/threads.py index 08d61196..b7471508 100644 --- a/src/threads.py +++ b/src/threads.py @@ -15,6 +15,12 @@ There are also other threads in the `.network` package. import threading +from class_addressGenerator import addressGenerator +from class_objectProcessor import objectProcessor +from class_singleCleaner import singleCleaner +from class_singleWorker import singleWorker +from class_sqlThread import sqlThread + try: import prctl except ImportError: @@ -33,12 +39,6 @@ else: threading.Thread.__bootstrap_original__ = threading.Thread._Thread__bootstrap threading.Thread._Thread__bootstrap = _thread_name_hack -from class_addressGenerator import addressGenerator -from class_objectProcessor import objectProcessor -from class_singleCleaner import singleCleaner -from class_singleWorker import singleWorker -from class_sqlThread import sqlThread - __all__ = [ "addressGenerator", "objectProcessor", "singleCleaner", "singleWorker",