mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-20 21:43:09 +00:00
Port to Python 3.
This commit is contained in:
parent
bf133be195
commit
1b87312652
@ -1,7 +1,14 @@
|
||||
from __future__ import print_function
|
||||
"""
|
||||
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
|
||||
|
||||
import os.path
|
||||
import codecs
|
||||
@ -37,7 +44,7 @@ def add_line_to_aliasfile(aliasfile, alias, cap):
|
||||
def add_alias(options):
|
||||
nodedir = options['node-directory']
|
||||
alias = options.alias
|
||||
precondition(isinstance(alias, unicode), alias=alias)
|
||||
precondition(isinstance(alias, str), alias=alias)
|
||||
cap = options.cap
|
||||
stdout = options.stdout
|
||||
stderr = options.stderr
|
||||
@ -54,7 +61,7 @@ def add_alias(options):
|
||||
show_output(stderr, "Alias {alias} already exists!", alias=alias)
|
||||
return 1
|
||||
aliasfile = os.path.join(nodedir, "private", "aliases")
|
||||
cap = unicode(uri.from_string_dirnode(cap).to_string(), 'utf-8')
|
||||
cap = str(uri.from_string_dirnode(cap).to_string(), 'utf-8')
|
||||
|
||||
add_line_to_aliasfile(aliasfile, alias, cap)
|
||||
show_output(stdout, "Alias {alias} added", alias=alias)
|
||||
@ -64,7 +71,7 @@ def create_alias(options):
|
||||
# mkdir+add_alias
|
||||
nodedir = options['node-directory']
|
||||
alias = options.alias
|
||||
precondition(isinstance(alias, unicode), alias=alias)
|
||||
precondition(isinstance(alias, str), alias=alias)
|
||||
stdout = options.stdout
|
||||
stderr = options.stderr
|
||||
if u":" in alias:
|
||||
@ -94,7 +101,7 @@ def create_alias(options):
|
||||
|
||||
# probably check for others..
|
||||
|
||||
add_line_to_aliasfile(aliasfile, alias, unicode(new_uri, "utf-8"))
|
||||
add_line_to_aliasfile(aliasfile, alias, str(new_uri, "utf-8"))
|
||||
show_output(stdout, "Alias {alias} created", alias=alias)
|
||||
return 0
|
||||
|
||||
@ -114,7 +121,7 @@ def show_output(fp, template, **kwargs):
|
||||
``encoding`` attribute at all (eg StringIO.StringIO) by writing
|
||||
utf-8-encoded bytes.
|
||||
"""
|
||||
assert isinstance(template, unicode)
|
||||
assert isinstance(template, str)
|
||||
|
||||
# On Python 3 fp has an encoding attribute under all real usage. On
|
||||
# Python 2, the encoding attribute is None if stdio is not a tty. The
|
||||
|
@ -101,6 +101,7 @@ PORTED_MODULES = [
|
||||
"allmydata.scripts.default_nodedir",
|
||||
"allmydata.scripts.runner",
|
||||
"allmydata.scripts.slow_operation",
|
||||
"allmydata.scripts.tahoe_add_alias",
|
||||
"allmydata.scripts.types_",
|
||||
"allmydata.stats",
|
||||
"allmydata.storage_client",
|
||||
|
Loading…
Reference in New Issue
Block a user