Browse Source

Fix Python code: remove imports from `python-future`.

I missed in 3d6ba937a5a5046b3d531c17691d5d1155daae71 that `future`
also provides the modules `past` and `builtins`.
Imports of `builtins` can simply be removed for Python-3-only code.
`past.old_div` had to be replaces by the "old" div-operatot `//`,
while `past.xrange` was unused.
Hartmut Goebel 5 years ago
parent
commit
1b292596c1

+ 0 - 1
contrib/scripts/gdb-iterate-dll.py

@@ -1,4 +1,3 @@
-from builtins import str
 from gdb import *
 
 

+ 2 - 6
contrib/scripts/gnunet-chk.py.in

@@ -21,10 +21,6 @@
 # Brief:   Computes GNUNET style Content Hash Key for a given file
 # Author:  Sree Harsha Totakura
 
-from builtins import str
-from builtins import range
-from past.utils import old_div
-from builtins import object
 from hashlib import sha512
 import logging
 import os
@@ -252,7 +248,7 @@ def compute_chk_offset_(depth, end_offset):
     bds = compute_tree_size_(depth)
     if (depth > 0):
         end_offset -= 1
-    ret = old_div(end_offset, bds)
+    ret = end_offset // bds
     return ret % CHK_PER_INODE
 
 
@@ -276,7 +272,7 @@ def compute_iblock_size_(depth, offset):
         ret = CHK_PER_INODE
     else:
         bds /= CHK_PER_INODE
-        ret = old_div(mod, bds)
+        ret = mod // bds
         if (mod % bds) is not 0:
             ret += 1
     return ret

+ 0 - 1
contrib/scripts/gnunet_pyexpect.py.in

@@ -19,7 +19,6 @@
 #
 # Testcase for gnunet-peerinfo
 
-from builtins import object
 import os
 import re
 import subprocess

+ 0 - 1
contrib/scripts/terminate.py.in

@@ -21,7 +21,6 @@
 # For other platforms it's equivalent to Popen.kill ()
 # Requires pywin32 on W32.
 
-from builtins import object
 import sys
 import subprocess
 import os

+ 2 - 6
src/consensus/consensus-simulation.py.in

@@ -17,13 +17,9 @@
 #
 # SPDX-License-Identifier: AGPL3.0-or-later
 
-from builtins import str
-from builtins import range
-from past.utils import old_div
 import argparse
 import random
 from math import ceil, log, floor
-from past.builtins import xrange
 
 
 def bsc(n):
@@ -40,7 +36,7 @@ def bsc(n):
 
 def simulate(k, n, verbose):
     assert k < n
-    largest_arc = old_div(int(2**ceil(log(n, 2))), 2)
+    largest_arc = int(2**ceil(log(n, 2))) // 2
     num_ghosts = (2 * largest_arc) - n
     if verbose:
         print("we have", num_ghosts, "ghost peers")
@@ -106,4 +102,4 @@ if __name__ == "__main__":
     sum = 0.0
     for n in range(0, args.r):
         sum += simulate(args.k, args.n, args.verbose)
-    print(old_div(sum, args.r))
+    print(sum // args.r)

+ 0 - 1
src/integration-tests/gnunet_pyexpect.py.in

@@ -19,7 +19,6 @@
 #
 # Testcase for gnunet-peerinfo
 
-from builtins import object
 import os
 import re
 import subprocess

+ 0 - 2
src/integration-tests/gnunet_testing.py.in

@@ -19,8 +19,6 @@
 #
 # Functions for integration testing
 
-from builtins import object
-from builtins import str
 import os
 import subprocess
 import sys

+ 0 - 1
src/revocation/test_local_revocation.py.in

@@ -19,7 +19,6 @@
 #
 # Testcase for ego revocation
 
-from builtins import str
 import sys
 import os
 import subprocess