futurize uri.py and test_uri.py

This commit is contained in:
Maciej Fijalkowski 2020-08-04 15:49:17 +02:00
parent 9e4eda6912
commit 9f77bf7d60
2 changed files with 19 additions and 3 deletions

View File

@ -1,4 +1,12 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from future import standard_library
standard_library.install_aliases()
from builtins import str
from builtins import *
import os import os
from twisted.trial import unittest from twisted.trial import unittest
from allmydata import uri from allmydata import uri

View File

@ -1,4 +1,12 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from future import standard_library
standard_library.install_aliases()
from builtins import *
from builtins import object
import re import re
from zope.interface import implementer from zope.interface import implementer
@ -80,7 +88,7 @@ class CHKFileURI(_BaseURI):
def to_string(self): def to_string(self):
assert isinstance(self.needed_shares, int) assert isinstance(self.needed_shares, int)
assert isinstance(self.total_shares, int) assert isinstance(self.total_shares, int)
assert isinstance(self.size, (int,long)) assert isinstance(self.size, int)
return ('URI:CHK:%s:%s:%d:%d:%d' % return ('URI:CHK:%s:%s:%d:%d:%d' %
(base32.b2a(self.key), (base32.b2a(self.key),
@ -136,7 +144,7 @@ class CHKFileVerifierURI(_BaseURI):
def to_string(self): def to_string(self):
assert isinstance(self.needed_shares, int) assert isinstance(self.needed_shares, int)
assert isinstance(self.total_shares, int) assert isinstance(self.total_shares, int)
assert isinstance(self.size, (int,long)) assert isinstance(self.size, int)
return ('URI:CHK-Verifier:%s:%s:%d:%d:%d' % return ('URI:CHK-Verifier:%s:%s:%d:%d:%d' %
(si_b2a(self.storage_index), (si_b2a(self.storage_index),
@ -876,7 +884,7 @@ def pack_extension(data):
pieces = [] pieces = []
for k in sorted(data.keys()): for k in sorted(data.keys()):
value = data[k] value = data[k]
if isinstance(value, (int, long)): if isinstance(value, int):
value = "%d" % value value = "%d" % value
assert isinstance(value, str), k assert isinstance(value, str), k
assert re.match(r'^[a-zA-Z_\-]+$', k) assert re.match(r'^[a-zA-Z_\-]+$', k)