Merge pr43: set 'unicode_literals' in most source files
refs (but doesn't close) #30
This commit is contained in:
commit
ef6d704311
|
@ -1,4 +1,4 @@
|
||||||
|
from __future__ import unicode_literals
|
||||||
# This file helps to compute a version number in source trees obtained from
|
# This file helps to compute a version number in source trees obtained from
|
||||||
# git-archive tarball (such as those provided by githubs download-from-tag
|
# git-archive tarball (such as those provided by githubs download-from-tag
|
||||||
# feature). Distribution tarballs (built by setup.py sdist) and build
|
# feature). Distribution tarballs (built by setup.py sdist) and build
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function, unicode_literals
|
||||||
import sys
|
import sys
|
||||||
from weakref import ref
|
from weakref import ref
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function, unicode_literals
|
||||||
import os, six
|
import os, six
|
||||||
from .wordlist import (byte_to_even_word, byte_to_odd_word,
|
from .wordlist import (byte_to_even_word, byte_to_odd_word,
|
||||||
even_words_lowercase, odd_words_lowercase)
|
even_words_lowercase, odd_words_lowercase)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import unicode_literals
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
class ServerError(Exception):
|
class ServerError(Exception):
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
# no unicode_literals
|
||||||
# Find all of our ip addresses. From tahoe's src/allmydata/util/iputil.py
|
# Find all of our ip addresses. From tahoe's src/allmydata/util/iputil.py
|
||||||
|
|
||||||
import os, re, subprocess, errno
|
import os, re, subprocess, errno
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function, unicode_literals
|
||||||
import os, time
|
import os, time
|
||||||
from twisted.python import usage
|
from twisted.python import usage
|
||||||
from twisted.scripts import twistd
|
from twisted.scripts import twistd
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function, unicode_literals
|
||||||
import os, time, json
|
import os, time, json
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from .database import get_db
|
from .database import get_db
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import unicode_literals
|
||||||
import os, sys
|
import os, sys
|
||||||
import sqlite3
|
import sqlite3
|
||||||
from pkg_resources import resource_string
|
from pkg_resources import resource_string
|
||||||
|
@ -10,6 +11,13 @@ def get_schema(version):
|
||||||
"db-schemas/v%d.sql" % version)
|
"db-schemas/v%d.sql" % version)
|
||||||
return schema_bytes.decode("utf-8")
|
return schema_bytes.decode("utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
def dict_factory(cursor, row):
|
||||||
|
d = {}
|
||||||
|
for idx, col in enumerate(cursor.description):
|
||||||
|
d[col[0]] = row[idx]
|
||||||
|
return d
|
||||||
|
|
||||||
def get_db(dbfile, stderr=sys.stderr):
|
def get_db(dbfile, stderr=sys.stderr):
|
||||||
"""Open or create the given db file. The parent directory must exist.
|
"""Open or create the given db file. The parent directory must exist.
|
||||||
Returns the db connection object, or raises DBError.
|
Returns the db connection object, or raises DBError.
|
||||||
|
@ -20,7 +28,7 @@ def get_db(dbfile, stderr=sys.stderr):
|
||||||
db = sqlite3.connect(dbfile)
|
db = sqlite3.connect(dbfile)
|
||||||
except (EnvironmentError, sqlite3.OperationalError) as e:
|
except (EnvironmentError, sqlite3.OperationalError) as e:
|
||||||
raise DBError("Unable to create/open db file %s: %s" % (dbfile, e))
|
raise DBError("Unable to create/open db file %s: %s" % (dbfile, e))
|
||||||
db.row_factory = sqlite3.Row
|
db.row_factory = dict_factory
|
||||||
|
|
||||||
VERSION = 2
|
VERSION = 2
|
||||||
if must_create:
|
if must_create:
|
||||||
|
@ -30,7 +38,7 @@ def get_db(dbfile, stderr=sys.stderr):
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
version = db.execute("SELECT version FROM version").fetchone()[0]
|
version = db.execute("SELECT version FROM version").fetchone()["version"]
|
||||||
except sqlite3.DatabaseError as e:
|
except sqlite3.DatabaseError as e:
|
||||||
# this indicates that the file is not a compatible database format.
|
# this indicates that the file is not a compatible database format.
|
||||||
# Perhaps it was created with an old version, or it might be junk.
|
# Perhaps it was created with an old version, or it might be junk.
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import unicode_literals
|
||||||
from twisted.python import log
|
from twisted.python import log
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
from twisted.application import service
|
from twisted.application import service
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function, unicode_literals
|
||||||
import os, time, random, base64
|
import os, time, random, base64
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from twisted.python import log
|
from twisted.python import log
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import unicode_literals
|
||||||
import time
|
import time
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
from twisted.python import log
|
from twisted.python import log
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function, unicode_literals
|
||||||
import os, sys
|
import os, sys
|
||||||
from .cli_args import parser
|
from .cli_args import parser
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function, unicode_literals
|
||||||
from twisted.python import log
|
from twisted.python import log
|
||||||
from twisted.internet import reactor, endpoints
|
from twisted.internet import reactor, endpoints
|
||||||
from twisted.application import service
|
from twisted.application import service
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function, unicode_literals
|
||||||
import re, time
|
import re, time
|
||||||
from twisted.python import log
|
from twisted.python import log
|
||||||
from twisted.internet import protocol
|
from twisted.internet import protocol
|
||||||
|
|
|
@ -14,6 +14,8 @@ class ServerBase:
|
||||||
self.sp.startService()
|
self.sp.startService()
|
||||||
relayport = allocate_tcp_port()
|
relayport = allocate_tcp_port()
|
||||||
transitport = allocate_tcp_port()
|
transitport = allocate_tcp_port()
|
||||||
|
# need to talk to twisted team about only using unicode in
|
||||||
|
# endpoints.serverFromString
|
||||||
s = RelayServer("tcp:%d:interface=127.0.0.1" % relayport,
|
s = RelayServer("tcp:%d:interface=127.0.0.1" % relayport,
|
||||||
"tcp:%s:interface=127.0.0.1" % transitport,
|
"tcp:%s:interface=127.0.0.1" % transitport,
|
||||||
advertise_version=__version__,
|
advertise_version=__version__,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
from __future__ import unicode_literals
|
||||||
# This is a tiny helper module, to let "python -m wormhole.test.run_trial
|
# This is a tiny helper module, to let "python -m wormhole.test.run_trial
|
||||||
# ARGS" does the same thing as running "trial ARGS" (unfortunately
|
# ARGS" does the same thing as running "trial ARGS" (unfortunately
|
||||||
# twisted/scripts/trial.py does not have a '__name__=="__main__"' clause).
|
# twisted/scripts/trial.py does not have a '__name__=="__main__"' clause).
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function, unicode_literals
|
||||||
import unittest
|
import unittest
|
||||||
from binascii import unhexlify #, hexlify
|
from binascii import unhexlify #, hexlify
|
||||||
from hkdf import Hkdf
|
from hkdf import Hkdf
|
||||||
|
@ -42,4 +42,3 @@ class TestKAT(unittest.TestCase):
|
||||||
|
|
||||||
#if __name__ == '__main__':
|
#if __name__ == '__main__':
|
||||||
# generate_KAT()
|
# generate_KAT()
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function, unicode_literals
|
||||||
import os, sys, re, io, zipfile, six, stat
|
import os, sys, re, io, zipfile, six, stat
|
||||||
import mock
|
import mock
|
||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function, unicode_literals
|
||||||
import json, itertools
|
import json, itertools
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
import mock
|
import mock
|
||||||
|
@ -375,9 +375,9 @@ class Prune(unittest.TestCase):
|
||||||
for messages in [None, OLD, NEW]:
|
for messages in [None, OLD, NEW]:
|
||||||
self.one(nameplate, mailbox, has_listeners, messages)
|
self.one(nameplate, mailbox, has_listeners, messages)
|
||||||
|
|
||||||
#def test_one(self):
|
# def test_one(self):
|
||||||
# # to debug specific problems found by test_lots
|
# # to debug specific problems found by test_lots
|
||||||
# self.one(None, "old", True, None)
|
# self.one(None, "old", False, 'new')
|
||||||
|
|
||||||
def one(self, nameplate, mailbox, has_listeners, messages):
|
def one(self, nameplate, mailbox, has_listeners, messages):
|
||||||
desc = ("nameplate=%s, mailbox=%s, has_listeners=%s,"
|
desc = ("nameplate=%s, mailbox=%s, has_listeners=%s,"
|
||||||
|
@ -427,8 +427,8 @@ class Prune(unittest.TestCase):
|
||||||
messages = None
|
messages = None
|
||||||
messages_survive = False
|
messages_survive = False
|
||||||
|
|
||||||
if (nameplate is NEW or mailbox is NEW
|
if (nameplate == NEW or mailbox == NEW
|
||||||
or has_listeners or messages is NEW):
|
or has_listeners or messages == NEW):
|
||||||
if nameplate is not None:
|
if nameplate is not None:
|
||||||
nameplate_survives = True
|
nameplate_survives = True
|
||||||
if mailbox is not None:
|
if mailbox is not None:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function, unicode_literals
|
||||||
import io
|
import io
|
||||||
from binascii import hexlify, unhexlify
|
from binascii import hexlify, unhexlify
|
||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import unicode_literals
|
||||||
import unicodedata
|
import unicodedata
|
||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
from .. import util
|
from .. import util
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function, unicode_literals
|
||||||
import os, json, re, gc
|
import os, json, re, gc
|
||||||
from binascii import hexlify, unhexlify
|
from binascii import hexlify, unhexlify
|
||||||
import mock
|
import mock
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from __future__ import print_function, absolute_import
|
from __future__ import print_function, absolute_import, unicode_literals
|
||||||
import json, time
|
import json, time
|
||||||
|
|
||||||
class Event:
|
class Event:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function, unicode_literals
|
||||||
import time
|
import time
|
||||||
from twisted.internet.defer import inlineCallbacks, returnValue
|
from twisted.internet.defer import inlineCallbacks, returnValue
|
||||||
from twisted.internet.error import ConnectError
|
from twisted.internet.error import ConnectError
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# no unicode_literals, revisit after twisted patch
|
||||||
from __future__ import print_function, absolute_import
|
from __future__ import print_function, absolute_import
|
||||||
import re, sys, time, socket
|
import re, sys, time, socket
|
||||||
from collections import namedtuple, deque
|
from collections import namedtuple, deque
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
from __future__ import unicode_literals
|
||||||
# The PGP Word List, which maps bytes to phonetically-distinct words. There
|
# The PGP Word List, which maps bytes to phonetically-distinct words. There
|
||||||
# are two lists, even and odd, and encodings should alternate between then to
|
# are two lists, even and odd, and encodings should alternate between then to
|
||||||
# detect dropped words. https://en.wikipedia.org/wiki/PGP_Words
|
# detect dropped words. https://en.wikipedia.org/wiki/PGP_Words
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from __future__ import print_function, absolute_import
|
from __future__ import print_function, absolute_import, unicode_literals
|
||||||
import os, sys, re
|
import os, sys, re
|
||||||
from six.moves.urllib_parse import urlparse
|
from six.moves.urllib_parse import urlparse
|
||||||
from twisted.internet import defer, endpoints, error
|
from twisted.internet import defer, endpoints, error
|
||||||
|
|
Loading…
Reference in New Issue
Block a user