futurize --stage1 src/**/*.py -w

This commit is contained in:
Chapman Shoop 2019-08-04 15:55:52 -07:00
parent b9cd75a7de
commit 6751ff9adc
38 changed files with 140 additions and 97 deletions

View File

@ -1,3 +1,4 @@
from __future__ import print_function
# Copyright (c) 2014 Luke Montalvo <lukemontalvo@gmail.com>
# This file adds a alternative commandline interface, feel free to critique and fork
#

View File

@ -1,4 +1,6 @@
import kivy_helper_search
from __future__ import print_function
from __future__ import absolute_import
from . import kivy_helper_search
import os
import queues
import shutdown
@ -308,7 +310,7 @@ class Create(Screen):
message = self.ids.message.text
subject = self.ids.subject.text
encoding = 3
print("message: ", self.ids.message.text)
print(("message: ", self.ids.message.text))
sendMessageToPeople = True
if sendMessageToPeople:
if toAddress != '':

View File

@ -1,6 +1,7 @@
"""
PyQt based UI for bitmessage, the main module
"""
from __future__ import absolute_import
import hashlib
import locale
@ -21,41 +22,41 @@ from debug import logger
from tr import _translate
from addresses import decodeAddress, addBMIfNotPresent
import shared
from bitmessageui import Ui_MainWindow
from .bitmessageui import Ui_MainWindow
from bmconfigparser import BMConfigParser
import defaults
import namecoin
from messageview import MessageView
from migrationwizard import Ui_MigrationWizard
from foldertree import (
from .messageview import MessageView
from .migrationwizard import Ui_MigrationWizard
from .foldertree import (
AccountMixin, Ui_FolderWidget, Ui_AddressWidget, Ui_SubscriptionWidget,
MessageList_AddressWidget, MessageList_SubjectWidget,
Ui_AddressBookWidgetItemLabel, Ui_AddressBookWidgetItemAddress)
from settings import Ui_settingsDialog
import settingsmixin
import support
from .settings import Ui_settingsDialog
from . import settingsmixin
from . import support
import debug
from helper_ackPayload import genAckPayload
from helper_sql import sqlQuery, sqlExecute, sqlExecuteChunked, sqlStoredProcedure
import helper_search
import l10n
import openclpow
from utils import str_broadcast_subscribers, avatarize
from account import (
from .utils import str_broadcast_subscribers, avatarize
from .account import (
getSortedAccounts, getSortedSubscriptions, accountClass, BMAccount,
GatewayAccount, MailchuckAccount, AccountColor)
import dialogs
from . import dialogs
from network.stats import pendingDownload, pendingUpload
from uisignaler import UISignaler
from .uisignaler import UISignaler
import knownnodes
import paths
from proofofwork import getPowType
import queues
import shutdown
import state
from statusbar import BMStatusBar
from .statusbar import BMStatusBar
from network.asyncore_pollchoose import set_rates
import sound
from . import sound
try:

View File

@ -3,6 +3,7 @@ src/bitmessageqt/address_dialogs.py
===================================
"""
from __future__ import absolute_import
# pylint: disable=attribute-defined-outside-init
import hashlib
@ -10,11 +11,11 @@ import hashlib
from PyQt4 import QtCore, QtGui
import queues
import widgets
from account import AccountMixin, GatewayAccount, MailchuckAccount, accountClass, getSortedAccounts
from . import widgets
from .account import AccountMixin, GatewayAccount, MailchuckAccount, accountClass, getSortedAccounts
from addresses import addBMIfNotPresent, decodeAddress, encodeVarint
from inventory import Inventory
from retranslateui import RetranslateMixin
from .retranslateui import RetranslateMixin
from tr import _translate

View File

@ -1,11 +1,12 @@
from __future__ import absolute_import
from PyQt4 import QtGui
from Queue import Empty
from addresses import decodeAddress, addBMIfNotPresent
from account import getSortedAccounts
from .account import getSortedAccounts
from queues import apiAddressGeneratorReturnQueue, addressGeneratorQueue
from tr import _translate
from utils import str_chan
from .utils import str_chan
class AddressPassPhraseValidatorMixin():
def setParams(self, passPhraseObject=None, addressObject=None, feedBackObject=None, buttonBox=None, addressMandatory=True):

View File

@ -7,14 +7,15 @@
#
# WARNING! All changes made in this file will be lost!
from __future__ import absolute_import
from PyQt4 import QtCore, QtGui
from bmconfigparser import BMConfigParser
from foldertree import AddressBookCompleter
from messageview import MessageView
from messagecompose import MessageCompose
import settingsmixin
from networkstatus import NetworkStatus
from blacklist import Blacklist
from .foldertree import AddressBookCompleter
from .messageview import MessageView
from .messagecompose import MessageCompose
from . import settingsmixin
from .networkstatus import NetworkStatus
from .blacklist import Blacklist
try:
_fromUtf8 = QtCore.QString.fromUtf8
@ -771,7 +772,7 @@ class Ui_MainWindow(object):
self.actionDeleteAllTrashedMessages.setText(_translate("MainWindow", "Delete all trashed messages", None))
self.actionJoinChan.setText(_translate("MainWindow", "Join / Create chan", None))
import bitmessage_icons_rc
from . import bitmessage_icons_rc
if __name__ == "__main__":
import sys

View File

@ -1,15 +1,16 @@
from __future__ import absolute_import
from PyQt4 import QtCore, QtGui
import widgets
from . import widgets
from addresses import addBMIfNotPresent
from bmconfigparser import BMConfigParser
from dialogs import AddAddressDialog
from .dialogs import AddAddressDialog
from helper_sql import sqlExecute, sqlQuery
from queues import UISignalQueue
from retranslateui import RetranslateMixin
from .retranslateui import RetranslateMixin
from tr import _translate
from uisignaler import UISignaler
from utils import avatarize
from .uisignaler import UISignaler
from .utils import avatarize
class Blacklist(QtGui.QWidget, RetranslateMixin):

View File

@ -2,19 +2,20 @@
src/bitmessageqt/dialogs.py
===========================
"""
from __future__ import absolute_import
from PyQt4 import QtGui
from version import softwareVersion
import paths
import widgets
from address_dialogs import (
from . import widgets
from .address_dialogs import (
AddAddressDialog, EmailGatewayDialog, NewAddressDialog, NewSubscriptionDialog, RegenerateAddressesDialog,
SpecialAddressBehaviorDialog
)
from newchandialog import NewChanDialog
from retranslateui import RetranslateMixin
from .newchandialog import NewChanDialog
from .retranslateui import RetranslateMixin
from tr import _translate
__all__ = [

View File

@ -2,6 +2,7 @@
src/bitmessageqt/foldertree.py
==============================
"""
from __future__ import absolute_import
# pylint: disable=too-many-arguments,bad-super-call,attribute-defined-outside-init
from cgi import escape
@ -10,9 +11,9 @@ from PyQt4 import QtCore, QtGui
from bmconfigparser import BMConfigParser
from helper_sql import sqlExecute, sqlQuery
from settingsmixin import SettingsMixin
from .settingsmixin import SettingsMixin
from tr import _translate
from utils import avatarize
from .utils import avatarize
# for pylupdate
_translate("MainWindow", "inbox")

View File

@ -3,10 +3,11 @@ src/bitmessageqt/messageview.py
===============================
"""
from __future__ import absolute_import
from PyQt4 import QtCore, QtGui
from safehtmlparser import SafeHTMLParser
from .safehtmlparser import SafeHTMLParser
class MessageView(QtGui.QTextBrowser):

View File

@ -3,6 +3,7 @@ src/bitmessageqt/networkstatus.py
=================================
"""
from __future__ import absolute_import
import time
@ -12,12 +13,12 @@ import knownnodes
import l10n
import network.stats
import shared
import widgets
from . import widgets
from inventory import Inventory
from network.connectionpool import BMConnectionPool
from retranslateui import RetranslateMixin
from .retranslateui import RetranslateMixin
from tr import _translate
from uisignaler import UISignaler
from .uisignaler import UISignaler
class NetworkStatus(QtGui.QWidget, RetranslateMixin):

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python2.7
from __future__ import print_function
from PyQt4 import QtCore, QtGui
class NewAddressWizardIntroPage(QtGui.QWizardPage):
@ -234,7 +235,7 @@ class NewAddressWizardWaitPage(QtGui.QWizardPage):
self.wizard().button(QtGui.QWizard.NextButton).click()
return
elif i == 101:
print "haha"
print("haha")
return
self.progressBar.setValue(i)
if i == 50:
@ -347,8 +348,8 @@ if __name__ == '__main__':
wizard = Ui_NewAddressWizard(["a", "b", "c", "d"])
if (wizard.exec_()):
print "Email: " + ("yes" if wizard.field("emailAsWell").toBool() else "no")
print "BM: " + ("yes" if wizard.field("onlyBM").toBool() else "no")
print("Email: " + ("yes" if wizard.field("emailAsWell").toBool() else "no"))
print("BM: " + ("yes" if wizard.field("onlyBM").toBool() else "no"))
else:
print "Wizard cancelled"
print("Wizard cancelled")
sys.exit()

View File

@ -3,16 +3,17 @@ src/bitmessageqt/newchandialog.py
=================================
"""
from __future__ import absolute_import
from PyQt4 import QtCore, QtGui
import widgets
from . import widgets
from addresses import addBMIfNotPresent
from addressvalidator import AddressValidator, PassPhraseValidator
from .addressvalidator import AddressValidator, PassPhraseValidator
from queues import UISignalQueue, addressGeneratorQueue, apiAddressGeneratorReturnQueue
from retranslateui import RetranslateMixin
from .retranslateui import RetranslateMixin
from tr import _translate
from utils import str_chan
from .utils import str_chan
class NewChanDialog(QtGui.QDialog, RetranslateMixin):

View File

@ -1,7 +1,8 @@
from __future__ import absolute_import
from os import path
from PyQt4 import QtGui
from debug import logger
import widgets
from . import widgets
class RetranslateMixin(object):
def retranslateUi(self):

View File

@ -1,14 +1,15 @@
from __future__ import absolute_import
import ctypes
from PyQt4 import QtCore, QtGui
import ssl
import sys
import time
import account
from . import account
from bmconfigparser import BMConfigParser
from debug import logger
import defaults
from foldertree import AccountMixin
from .foldertree import AccountMixin
from helper_sql import *
from l10n import getTranslationLanguage
from openclpow import openclAvailable, openclEnabled

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
from kivy.lang import Builder
from kivy.uix.modalview import ModalView
from kivymd.label import MDLabel

View File

@ -50,6 +50,7 @@ control than multi-threaded programming. The module documented here solves
many of the difficult problems for you, making the task of building
sophisticated high-performance network servers and clients a snap.
"""
from __future__ import print_function
import os
import select
@ -788,7 +789,7 @@ class dispatcher:
def log_info(self, message, log_type='info'):
"""Conditionally print a message"""
if log_type not in self.ignore_log_types:
print '%s: %s' % (log_type, message)
print('%s: %s' % (log_type, message))
def handle_read_event(self):
"""Handle a read event"""

View File

@ -1,3 +1,4 @@
from __future__ import absolute_import
import base64
import hashlib
import socket
@ -6,7 +7,7 @@ import time
from binascii import hexlify
import addresses
import connectionpool
from . import connectionpool
import knownnodes
import protocol
import state
@ -21,7 +22,7 @@ from network.bmobject import (
BMObjectInvalidError, BMObjectAlreadyHaveError)
from network.node import Node
from network.proxy import ProxyError
from objectracker import missingObjects, ObjectTracker
from .objectracker import missingObjects, ObjectTracker
from queues import objectProcessorQueue, portCheckerQueue, invQueue, addrQueue
from randomtrackingdict import RandomTrackingDict

View File

@ -1,22 +1,23 @@
from __future__ import absolute_import
import errno
import re
import socket
import time
import asyncore_pollchoose as asyncore
from . import asyncore_pollchoose as asyncore
import helper_bootstrap
import helper_random
import knownnodes
import protocol
import state
from bmconfigparser import BMConfigParser
from connectionchooser import chooseConnection
from .connectionchooser import chooseConnection
from debug import logger
from proxy import Proxy
from .proxy import Proxy
from singleton import Singleton
from tcp import (
from .tcp import (
TCPServer, Socks5BMConnection, Socks4aBMConnection, TCPConnection)
from udp import UDPSocket
from .udp import UDPSocket
@Singleton

View File

@ -1,9 +1,10 @@
from __future__ import absolute_import
from collections import namedtuple
from random import choice, sample, expovariate
from threading import RLock
from time import time
import connectionpool
from . import connectionpool
import state
from debug import logging
from queues import invQueue

View File

@ -1,15 +1,16 @@
from __future__ import absolute_import
import threading
import time
import addresses
import helper_random
import protocol
from dandelion import Dandelion
from .dandelion import Dandelion
from debug import logger
from helper_threading import StoppableThread
from inventory import Inventory
from network.connectionpool import BMConnectionPool
from objectracker import missingObjects
from .objectracker import missingObjects
class DownloadThread(threading.Thread, StoppableThread):

View File

@ -1,3 +1,4 @@
from __future__ import print_function
import asyncore
import socket
import time
@ -43,7 +44,7 @@ if __name__ == "__main__":
if (len(asyncore.socket_map) < parallel):
for i in range(parallel - len(asyncore.socket_map)):
HTTPClient('127.0.0.1', '/')
print "Active connections: %i" % (len(asyncore.socket_map))
print("Active connections: %i" % (len(asyncore.socket_map)))
asyncore.loop(count=len(asyncore.socket_map)/2)
if requestCount % 100 == 0:
print "Processed %i total messages" % (requestCount)
print("Processed %i total messages" % (requestCount))

View File

@ -1,10 +1,12 @@
from __future__ import print_function
from __future__ import absolute_import
import socket
from advanceddispatcher import AdvancedDispatcher
import asyncore_pollchoose as asyncore
from proxy import Proxy, ProxyError, GeneralProxyError
from socks5 import Socks5Connection, Socks5Resolver, Socks5AuthError, Socks5Error
from socks4a import Socks4aConnection, Socks4aResolver, Socks4aError
from .advanceddispatcher import AdvancedDispatcher
from . import asyncore_pollchoose as asyncore
from .proxy import Proxy, ProxyError, GeneralProxyError
from .socks5 import Socks5Connection, Socks5Resolver, Socks5AuthError, Socks5Error
from .socks4a import Socks4aConnection, Socks4aResolver, Socks4aError
class HttpError(ProxyError): pass
@ -16,17 +18,17 @@ class HttpConnection(AdvancedDispatcher):
self.destination = (host, 80)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.connect(self.destination)
print "connecting in background to %s:%i" % (self.destination[0], self.destination[1])
print("connecting in background to %s:%i" % (self.destination[0], self.destination[1]))
def state_init(self):
self.append_write_buf("GET %s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n" % (self.path, self.destination[0]))
print "Sending %ib" % (len(self.write_buf))
print("Sending %ib" % (len(self.write_buf)))
self.set_state("http_request_sent", 0)
return False
def state_http_request_sent(self):
if len(self.read_buf) > 0:
print "Received %ib" % (len(self.read_buf))
print("Received %ib" % (len(self.read_buf)))
self.read_buf = b""
if not self.connected:
self.set_state("close", 0)
@ -59,13 +61,13 @@ if __name__ == "__main__":
for host in ("bootstrap8080.bitmessage.org", "bootstrap8444.bitmessage.org"):
proxy = Socks5Resolver(host=host)
while len(asyncore.socket_map) > 0:
print "loop %s, len %i" % (proxy.state, len(asyncore.socket_map))
print("loop %s, len %i" % (proxy.state, len(asyncore.socket_map)))
asyncore.loop(timeout=1, count=1)
proxy.resolved()
proxy = Socks4aResolver(host=host)
while len(asyncore.socket_map) > 0:
print "loop %s, len %i" % (proxy.state, len(asyncore.socket_map))
print("loop %s, len %i" % (proxy.state, len(asyncore.socket_map)))
asyncore.loop(timeout=1, count=1)
proxy.resolved()

View File

@ -1,7 +1,8 @@
from __future__ import absolute_import
import asyncore
import socket
from tls import TLSHandshake
from .tls import TLSHandshake
class HTTPRequestHandler(asyncore.dispatcher):
response = """HTTP/1.0 200 OK\r

View File

@ -1,8 +1,9 @@
from __future__ import absolute_import
import asyncore
from http import HTTPClient
from .http import HTTPClient
import paths
from tls import TLSHandshake
from .tls import TLSHandshake
# self.sslSock = ssl.wrap_socket(self.sock, keyfile = os.path.join(paths.codePath(), 'sslkeys', 'key.pem'), certfile = os.path.join(paths.codePath(), 'sslkeys', 'cert.pem'), server_side = not self.initiatedConnection, ssl_version=ssl.PROTOCOL_TLSv1, do_handshake_on_connect=False, ciphers='AECDH-AES256-SHA')

View File

@ -1,9 +1,10 @@
from __future__ import absolute_import
import socket
import time
import asyncore_pollchoose as asyncore
from . import asyncore_pollchoose as asyncore
import state
from advanceddispatcher import AdvancedDispatcher
from .advanceddispatcher import AdvancedDispatcher
from bmconfigparser import BMConfigParser
from debug import logger

View File

@ -1,7 +1,9 @@
from __future__ import print_function
from __future__ import absolute_import
import socket
import struct
from proxy import Proxy, ProxyError, GeneralProxyError
from .proxy import Proxy, ProxyError, GeneralProxyError
class Socks4aError(ProxyError):
@ -135,4 +137,4 @@ class Socks4aResolver(Socks4a):
PyBitmessage, a callback needs to be implemented which hasn't
been done yet.
"""
print "Resolved %s as %s" % (self.host, self.proxy_sock_name())
print("Resolved %s as %s" % (self.host, self.proxy_sock_name()))

View File

@ -3,12 +3,14 @@ src/network/socks5.py
=====================
"""
from __future__ import print_function
from __future__ import absolute_import
# pylint: disable=attribute-defined-outside-init
import socket
import struct
from proxy import GeneralProxyError, Proxy, ProxyError
from .proxy import GeneralProxyError, Proxy, ProxyError
class Socks5AuthError(ProxyError):
@ -226,4 +228,4 @@ class Socks5Resolver(Socks5):
To use this within PyBitmessage, a callback needs to be
implemented which hasn't been done yet.
"""
print "Resolved %s as %s" % (self.host, self.proxy_sock_name())
print("Resolved %s as %s" % (self.host, self.proxy_sock_name()))

View File

@ -1,8 +1,9 @@
from __future__ import absolute_import
import time
import asyncore_pollchoose as asyncore
from . import asyncore_pollchoose as asyncore
from network.connectionpool import BMConnectionPool
from objectracker import missingObjects
from .objectracker import missingObjects
lastReceivedTimestamp = time.time()
lastReceivedBytes = 0

View File

@ -3,6 +3,7 @@
src/network/tcp.py
==================
"""
from __future__ import absolute_import
import math
import random
@ -10,8 +11,8 @@ import socket
import time
import addresses
import asyncore_pollchoose as asyncore
import connectionpool
from . import asyncore_pollchoose as asyncore
from . import connectionpool
import helper_random
import knownnodes
import protocol

View File

@ -1,11 +1,12 @@
from __future__ import absolute_import
import time
import socket
import state
import protocol
from bmproto import BMProto
from .bmproto import BMProto
from debug import logger
from objectracker import ObjectTracker
from .objectracker import ObjectTracker
from queues import receiveDataQueue

View File

@ -1,3 +1,5 @@
from __future__ import print_function
from __future__ import absolute_import
from binascii import hexlify, unhexlify
from os import listdir, makedirs, path, remove, rmdir
import string
@ -6,7 +8,7 @@ import time
import traceback
from paths import lookupAppdataFolder
from storage import InventoryStorage, InventoryItem
from .storage import InventoryStorage, InventoryItem
class FilesystemInventory(InventoryStorage):
topDir = "inventory"
@ -108,7 +110,7 @@ class FilesystemInventory(InventoryStorage):
newInventory[streamNumber] = {}
newInventory[streamNumber][hashId] = InventoryItem(objectType, streamNumber, None, expiresTime, tag)
except KeyError:
print "error loading %s" % (hexlify(hashId))
print("error loading %s" % (hexlify(hashId)))
pass
self._inventory = newInventory
# for i, v in self._inventory.items():

View File

@ -1,3 +1,4 @@
from __future__ import absolute_import
import collections
from threading import current_thread, enumerate as threadingEnumerate, RLock
import Queue
@ -5,7 +6,7 @@ import sqlite3
import time
from helper_sql import *
from storage import InventoryStorage, InventoryItem
from .storage import InventoryStorage, InventoryItem
class SqliteInventory(InventoryStorage):
def __init__(self):

View File

@ -3,11 +3,12 @@
Utility configured as apinotifypath in bitmessagesettings
when pybitmessage started in test mode.
"""
from __future__ import absolute_import
import sys
import tempfile
from test_process import put_signal_file
from .test_process import put_signal_file
if __name__ == '__main__':

View File

@ -2,6 +2,7 @@
Tests for core and those that do not work outside
(because of import error for example)
"""
from __future__ import print_function
import os
import pickle # nosec

View File

@ -1,13 +1,14 @@
"""
Tests using API.
"""
from __future__ import absolute_import
import base64
import json
import time
import xmlrpclib # nosec
from test_process import TestProcessProto, TestProcessShutdown
from .test_process import TestProcessProto, TestProcessShutdown
class TestAPIProto(TestProcessProto):

View File

@ -1,12 +1,13 @@
"""
Various tests for config
"""
from __future__ import absolute_import
import os
import unittest
from pybitmessage.bmconfigparser import BMConfigParser
from test_process import TestProcessProto
from .test_process import TestProcessProto
class TestConfig(unittest.TestCase):

View File

@ -1,6 +1,7 @@
"""
Common reusable code for tests and tests for pybitmessage process.
"""
from __future__ import print_function
import os
import signal