Port to Python 3.

This commit is contained in:
Itamar Turner-Trauring 2021-03-31 10:53:02 -04:00
parent 1ef33d3d69
commit 8439f2820b
2 changed files with 16 additions and 3 deletions

View File

@ -115,6 +115,7 @@ PORTED_MODULES = [
"allmydata.util.base62",
"allmydata.util.configutil",
"allmydata.util.connection_status",
"allmydata.util.consumer",
"allmydata.util.deferredutil",
"allmydata.util.dictutil",
"allmydata.util.eliotutil",

View File

@ -1,11 +1,22 @@
"""This file defines a basic download-to-memory consumer, suitable for use in
a filenode's read() method. See download_to_data() for an example of its use.
"""
This file defines a basic download-to-memory consumer, suitable for use in
a filenode's read() method. See download_to_data() for an example of its use.
Ported to Python 3.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
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 zope.interface import implementer
from twisted.internet.interfaces import IConsumer
@implementer(IConsumer)
class MemoryConsumer(object):
@ -28,6 +39,7 @@ class MemoryConsumer(object):
def unregisterProducer(self):
self.done = True
def download_to_data(n, offset=0, size=None):
"""
Return Deferred that fires with results of reading from the given filenode.