Port to Python 3.

This commit is contained in:
Itamar Turner-Trauring 2021-05-14 09:42:13 -04:00
parent c98d90bf74
commit 250ca3170d
2 changed files with 15 additions and 5 deletions

View File

@ -1,6 +1,15 @@
"""
Ported to Python 3.
"""
from __future__ import unicode_literals
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from past.builtins import unicode
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from six import ensure_binary
try:
@ -25,9 +34,9 @@ def print_keypair(options):
from allmydata.crypto import ed25519
out = options.stdout
private_key, public_key = ed25519.create_signing_keypair()
print("private:", unicode(ed25519.string_from_signing_key(private_key), "ascii"),
print("private:", str(ed25519.string_from_signing_key(private_key), "ascii"),
file=out)
print("public:", unicode(ed25519.string_from_verifying_key(public_key), "ascii"),
print("public:", str(ed25519.string_from_verifying_key(public_key), "ascii"),
file=out)
class DerivePubkeyOptions(BaseOptions):
@ -52,8 +61,8 @@ def derive_pubkey(options):
privkey_vs = options.privkey
privkey_vs = ensure_binary(privkey_vs)
private_key, public_key = ed25519.signing_keypair_from_string(privkey_vs)
print("private:", unicode(ed25519.string_from_signing_key(private_key), "ascii"), file=out)
print("public:", unicode(ed25519.string_from_verifying_key(public_key), "ascii"), file=out)
print("private:", str(ed25519.string_from_signing_key(private_key), "ascii"), file=out)
print("public:", str(ed25519.string_from_verifying_key(public_key), "ascii"), file=out)
return 0
class AdminCommand(BaseOptions):

View File

@ -88,6 +88,7 @@ PORTED_MODULES = [
"allmydata.node",
"allmydata.nodemaker",
"allmydata.scripts",
"allmydata.scripts.admin",
"allmydata.scripts.create_node",
"allmydata.scripts.runner",
"allmydata.scripts.types_",