use six.moves
This commit is contained in:
parent
81a6bdb223
commit
a11df0c583
|
@ -2,7 +2,7 @@
|
|||
|
||||
import collectd
|
||||
import json
|
||||
import xmlrpclib
|
||||
from six.moves import xmlrpc_client as xmlrpclib
|
||||
|
||||
pybmurl = ""
|
||||
api = ""
|
||||
|
|
|
@ -70,6 +70,7 @@ from struct import pack, unpack
|
|||
|
||||
import six
|
||||
from six.moves import configparser, http_client, xmlrpc_server
|
||||
from six.moves.reprlib import repr
|
||||
|
||||
import helper_inbox
|
||||
import helper_sent
|
||||
|
|
|
@ -21,7 +21,8 @@ import os
|
|||
import socket
|
||||
import sys
|
||||
import time
|
||||
import xmlrpclib
|
||||
from six.moves import xmlrpc_client as xmlrpclib
|
||||
from six.moves import input as raw_input
|
||||
|
||||
from bmconfigparser import config
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ Bitmessage commandline interface
|
|||
# * python2-pythondialog
|
||||
# * dialog
|
||||
|
||||
import ConfigParser
|
||||
from six.moves import configparser
|
||||
import curses
|
||||
import os
|
||||
import sys
|
||||
|
@ -673,7 +673,7 @@ def handlech(c, stdscr):
|
|||
elif t == "2" and m is False:
|
||||
try:
|
||||
mn = config.get(a, "mailinglistname")
|
||||
except ConfigParser.NoOptionError:
|
||||
except configparser.NoOptionError:
|
||||
mn = ""
|
||||
r, t = d.inputbox("Mailing list name", init=mn)
|
||||
if r == d.DIALOG_OK:
|
||||
|
|
|
@ -6,6 +6,7 @@ import os
|
|||
import shutil
|
||||
import tempfile
|
||||
from time import time, sleep
|
||||
from six.moves import getcwdb
|
||||
|
||||
from telenium.tests import TeleniumTestCase
|
||||
from telenium.client import TeleniumHttpException
|
||||
|
@ -32,7 +33,7 @@ def cleanup(files=_files):
|
|||
|
||||
class TeleniumTestProcess(TeleniumTestCase):
|
||||
"""Setting Screen Functionality Testing"""
|
||||
cmd_entrypoint = [os.path.join(os.path.abspath(os.getcwd()), 'src', 'mockbm', 'kivy_main.py')]
|
||||
cmd_entrypoint = [os.path.join(os.path.abspath(getcwdb()), 'src', 'mockbm', 'kivy_main.py')]
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
|
|
@ -15,6 +15,7 @@ import time
|
|||
from datetime import datetime, timedelta
|
||||
from sqlite3 import register_adapter
|
||||
import six
|
||||
from six.moves import range as xrange
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from PyQt4.QtNetwork import QLocalSocket, QLocalServer
|
||||
|
|
|
@ -3,7 +3,7 @@ Address validator module.
|
|||
"""
|
||||
# pylint: disable=too-many-branches,too-many-arguments
|
||||
|
||||
from Queue import Empty
|
||||
from six.moves.queue import Empty
|
||||
|
||||
from PyQt4 import QtGui
|
||||
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
|
||||
import inspect
|
||||
import re
|
||||
from HTMLParser import HTMLParser
|
||||
from six.moves.html_parser import HTMLParser
|
||||
|
||||
from urllib import quote_plus
|
||||
from urlparse import urlparse
|
||||
from six.moves.urllib.parse import quote_plus, urlparse
|
||||
|
||||
|
||||
class SafeHTMLParser(HTMLParser):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""
|
||||
This module setting file is for settings
|
||||
"""
|
||||
import ConfigParser
|
||||
from six.moves import configparser
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
|
@ -29,9 +29,9 @@ from tr import _translate
|
|||
def getSOCKSProxyType(config):
|
||||
"""Get user socksproxytype setting from *config*"""
|
||||
try:
|
||||
result = ConfigParser.SafeConfigParser.get(
|
||||
result = configparser.SafeConfigParser.get(
|
||||
config, 'bitmessagesettings', 'socksproxytype')
|
||||
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
|
||||
except (configparser.NoSectionError, configparser.NoOptionError):
|
||||
return None
|
||||
else:
|
||||
if result.lower() in ('', 'none', 'false'):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""Common definitions for bitmessageqt tests"""
|
||||
|
||||
import Queue
|
||||
from six.moves import queue as Queue
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ config_ready = Event()
|
|||
|
||||
class BMConfigParser(SafeConfigParser):
|
||||
"""
|
||||
Singleton class inherited from :class:`ConfigParser.SafeConfigParser`
|
||||
Singleton class inherited from :class:`configparser.SafeConfigParser`
|
||||
with additional methods specific to bitmessage config.
|
||||
"""
|
||||
# pylint: disable=too-many-ancestors
|
||||
|
|
|
@ -30,6 +30,7 @@ from bmconfigparser import config
|
|||
from helper_sql import sqlExecute, sqlQuery
|
||||
from network import knownnodes, StoppableThread
|
||||
from six.moves import configparser, queue
|
||||
from six.moves.reprlib import repr
|
||||
|
||||
|
||||
def sizeof_fmt(num, suffix='h/s'):
|
||||
|
|
|
@ -4,9 +4,9 @@ SMTP client thread for delivering emails
|
|||
# pylint: disable=unused-variable
|
||||
|
||||
import smtplib
|
||||
import urlparse
|
||||
from six.moves.urllib import parse as urlparse
|
||||
from email.header import Header
|
||||
from email.mime.text import MIMEText
|
||||
from six.moves import email_mime_text
|
||||
|
||||
import queues
|
||||
import state
|
||||
|
@ -55,7 +55,7 @@ class smtpDeliver(StoppableThread):
|
|||
u = urlparse.urlparse(dest)
|
||||
to = urlparse.parse_qs(u.query)['to']
|
||||
client = smtplib.SMTP(u.hostname, u.port)
|
||||
msg = MIMEText(body, 'plain', 'utf-8')
|
||||
msg = email_mime_text(body, 'plain', 'utf-8')
|
||||
msg['Subject'] = Header(subject, 'utf-8')
|
||||
msg['From'] = fromAddress + '@' + SMTPDOMAIN
|
||||
toLabel = map(
|
||||
|
|
|
@ -8,6 +8,7 @@ import sqlite3
|
|||
import sys
|
||||
import threading
|
||||
import time
|
||||
from six.moves.reprlib import repr
|
||||
|
||||
try:
|
||||
import helper_sql
|
||||
|
|
|
@ -49,7 +49,8 @@ License: MIT
|
|||
# pylint: disable=too-many-lines,too-many-branches,too-many-statements,global-statement,too-many-return-statements
|
||||
# pylint: disable=unused-argument
|
||||
|
||||
import collections
|
||||
from six.moves import collections_abc as collections
|
||||
from six.moves import range as xrange
|
||||
import struct
|
||||
import sys
|
||||
import six
|
||||
|
|
|
@ -3,7 +3,7 @@ A queue with multiple internal subqueues.
|
|||
Elements are added into a random subqueue, and retrieval rotates
|
||||
"""
|
||||
|
||||
from collections import deque
|
||||
from six.moves.collections_abc import deque
|
||||
|
||||
from six.moves import queue
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ Namecoin queries
|
|||
# pylint: disable=too-many-branches,protected-access
|
||||
|
||||
import base64
|
||||
import httplib
|
||||
from six.moves import http_client as httplib
|
||||
import json
|
||||
import os
|
||||
import socket
|
||||
|
|
|
@ -18,6 +18,7 @@ from errno import (
|
|||
ENOTCONN, ENOTSOCK, EPIPE, ESHUTDOWN, ETIMEDOUT, EWOULDBLOCK, errorcode
|
||||
)
|
||||
from threading import current_thread
|
||||
from six.moves.reprlib import repr
|
||||
|
||||
import helper_random
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""
|
||||
Thread to send inv annoucements
|
||||
"""
|
||||
import Queue
|
||||
from six.moves import queue as Queue
|
||||
import random
|
||||
from time import time
|
||||
|
||||
|
|
|
@ -10,10 +10,7 @@ import os
|
|||
import pickle # nosec B403
|
||||
import threading
|
||||
import time
|
||||
try:
|
||||
from collections.abc import Iterable
|
||||
except ImportError:
|
||||
from collections import Iterable
|
||||
from six.moves.collections_abc import Iterable
|
||||
import six
|
||||
|
||||
import state
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""
|
||||
Named tuples representing the network peers
|
||||
"""
|
||||
import collections
|
||||
from six.moves import collections_abc as collections
|
||||
|
||||
Peer = collections.namedtuple('Peer', ['host', 'port'])
|
||||
Node = collections.namedtuple('Node', ['services', 'host', 'port'])
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Process data incoming from network
|
||||
"""
|
||||
import errno
|
||||
import Queue
|
||||
from six.moves import queue as Queue
|
||||
import socket
|
||||
|
||||
import connectionpool
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
A menu plugin showing QR-Code for bitmessage address in modal dialog.
|
||||
"""
|
||||
|
||||
import urllib
|
||||
from six.moves.urllib.parse import urlencode
|
||||
|
||||
import qrcode
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
@ -93,7 +93,7 @@ def connect_plugin(form):
|
|||
return
|
||||
dialog.render(
|
||||
'bitmessage:%s' % account.address + (
|
||||
'?' + urllib.urlencode({'label': label.encode('utf-8')})
|
||||
'?' + urlencode({'label': label.encode('utf-8')})
|
||||
if label != account.address else '')
|
||||
)
|
||||
dialog.exec_()
|
||||
|
|
|
@ -14,6 +14,7 @@ import stat
|
|||
import subprocess # nosec B404
|
||||
import sys
|
||||
from binascii import hexlify
|
||||
from six.moves.reprlib import repr
|
||||
|
||||
# Project imports.
|
||||
import highlevelcrypto
|
||||
|
|
|
@ -4,10 +4,7 @@ Storing inventory items
|
|||
|
||||
from abc import abstractmethod
|
||||
from collections import namedtuple
|
||||
try:
|
||||
from collections import MutableMapping # pylint: disable=deprecated-class
|
||||
except ImportError:
|
||||
from collections.abc import MutableMapping
|
||||
from six.moves.collections_abc import MutableMapping # pylint: disable=deprecated-class
|
||||
|
||||
|
||||
InventoryItem = namedtuple('InventoryItem', 'type stream payload expires tag')
|
||||
|
|
|
@ -6,7 +6,7 @@ Tests for core and those that do not work outside
|
|||
import atexit
|
||||
import os
|
||||
import pickle # nosec
|
||||
import Queue
|
||||
from six.moves import queue as Queue
|
||||
import random # nosec
|
||||
import shutil
|
||||
import socket
|
||||
|
|
|
@ -4,13 +4,13 @@ Complete UPnP port forwarding implementation in separate thread.
|
|||
Reference: http://mattscodecave.com/posts/using-python-and-upnp-to-forward-a-port
|
||||
"""
|
||||
|
||||
import httplib
|
||||
from six.moves import http_client as httplib
|
||||
import re
|
||||
import socket
|
||||
import time
|
||||
import urllib2
|
||||
from six.moves.urllib.request import urlopen
|
||||
from random import randint
|
||||
from urlparse import urlparse
|
||||
from six.moves.urllib.parse import urlparse
|
||||
from xml.dom.minidom import Document # nosec B408
|
||||
from defusedxml.minidom import parseString
|
||||
|
||||
|
@ -108,7 +108,7 @@ class Router: # pylint: disable=old-style-class
|
|||
logger.error("UPnP: missing location header")
|
||||
|
||||
# get the profile xml file and read it into a variable
|
||||
directory = urllib2.urlopen(header['location']).read()
|
||||
directory = urlopen(header['location']).read()
|
||||
|
||||
# create a DOM object that represents the `directory` document
|
||||
dom = parseString(directory)
|
||||
|
|
Reference in New Issue
Block a user