aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHartmut Goebel <h.goebel@crazy-compilers.com>2019-03-10 21:17:39 +0100
committerHartmut Goebel <h.goebel@crazy-compilers.com>2019-03-10 21:17:39 +0100
commit1b292596c1cbb211c22542607f6f5d15f2dc0465 (patch)
treeae4d64f525c43bb81ad601f1e76287d383ba1b31
parent3d6ba937a5a5046b3d531c17691d5d1155daae71 (diff)
downloadgnunet-1b292596c1cbb211c22542607f6f5d15f2dc0465.tar.gz
gnunet-1b292596c1cbb211c22542607f6f5d15f2dc0465.zip
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.
-rw-r--r--contrib/scripts/gdb-iterate-dll.py1
-rwxr-xr-xcontrib/scripts/gnunet-chk.py.in8
-rw-r--r--contrib/scripts/gnunet_pyexpect.py.in1
-rw-r--r--contrib/scripts/terminate.py.in1
-rw-r--r--src/consensus/consensus-simulation.py.in8
-rw-r--r--src/integration-tests/gnunet_pyexpect.py.in1
-rw-r--r--src/integration-tests/gnunet_testing.py.in2
-rw-r--r--src/revocation/test_local_revocation.py.in1
8 files changed, 4 insertions, 19 deletions
diff --git a/contrib/scripts/gdb-iterate-dll.py b/contrib/scripts/gdb-iterate-dll.py
index 9e6478e9f..79d46aa96 100644
--- a/contrib/scripts/gdb-iterate-dll.py
+++ b/contrib/scripts/gdb-iterate-dll.py
@@ -1,4 +1,3 @@
1from builtins import str
2from gdb import * 1from gdb import *
3 2
4 3
diff --git a/contrib/scripts/gnunet-chk.py.in b/contrib/scripts/gnunet-chk.py.in
index ab0bc635f..0fb591627 100755
--- a/contrib/scripts/gnunet-chk.py.in
+++ b/contrib/scripts/gnunet-chk.py.in
@@ -21,10 +21,6 @@
21# Brief: Computes GNUNET style Content Hash Key for a given file 21# Brief: Computes GNUNET style Content Hash Key for a given file
22# Author: Sree Harsha Totakura 22# Author: Sree Harsha Totakura
23 23
24from builtins import str
25from builtins import range
26from past.utils import old_div
27from builtins import object
28from hashlib import sha512 24from hashlib import sha512
29import logging 25import logging
30import os 26import os
@@ -252,7 +248,7 @@ def compute_chk_offset_(depth, end_offset):
252 bds = compute_tree_size_(depth) 248 bds = compute_tree_size_(depth)
253 if (depth > 0): 249 if (depth > 0):
254 end_offset -= 1 250 end_offset -= 1
255 ret = old_div(end_offset, bds) 251 ret = end_offset // bds
256 return ret % CHK_PER_INODE 252 return ret % CHK_PER_INODE
257 253
258 254
@@ -276,7 +272,7 @@ def compute_iblock_size_(depth, offset):
276 ret = CHK_PER_INODE 272 ret = CHK_PER_INODE
277 else: 273 else:
278 bds /= CHK_PER_INODE 274 bds /= CHK_PER_INODE
279 ret = old_div(mod, bds) 275 ret = mod // bds
280 if (mod % bds) is not 0: 276 if (mod % bds) is not 0:
281 ret += 1 277 ret += 1
282 return ret 278 return ret
diff --git a/contrib/scripts/gnunet_pyexpect.py.in b/contrib/scripts/gnunet_pyexpect.py.in
index 9611fc0ae..188436f51 100644
--- a/contrib/scripts/gnunet_pyexpect.py.in
+++ b/contrib/scripts/gnunet_pyexpect.py.in
@@ -19,7 +19,6 @@
19# 19#
20# Testcase for gnunet-peerinfo 20# Testcase for gnunet-peerinfo
21 21
22from builtins import object
23import os 22import os
24import re 23import re
25import subprocess 24import subprocess
diff --git a/contrib/scripts/terminate.py.in b/contrib/scripts/terminate.py.in
index 9ed356502..161b4db61 100644
--- a/contrib/scripts/terminate.py.in
+++ b/contrib/scripts/terminate.py.in
@@ -21,7 +21,6 @@
21# For other platforms it's equivalent to Popen.kill () 21# For other platforms it's equivalent to Popen.kill ()
22# Requires pywin32 on W32. 22# Requires pywin32 on W32.
23 23
24from builtins import object
25import sys 24import sys
26import subprocess 25import subprocess
27import os 26import os
diff --git a/src/consensus/consensus-simulation.py.in b/src/consensus/consensus-simulation.py.in
index 23639b195..39daf81c6 100644
--- a/src/consensus/consensus-simulation.py.in
+++ b/src/consensus/consensus-simulation.py.in
@@ -17,13 +17,9 @@
17# 17#
18# SPDX-License-Identifier: AGPL3.0-or-later 18# SPDX-License-Identifier: AGPL3.0-or-later
19 19
20from builtins import str
21from builtins import range
22from past.utils import old_div
23import argparse 20import argparse
24import random 21import random
25from math import ceil, log, floor 22from math import ceil, log, floor
26from past.builtins import xrange
27 23
28 24
29def bsc(n): 25def bsc(n):
@@ -40,7 +36,7 @@ def bsc(n):
40 36
41def simulate(k, n, verbose): 37def simulate(k, n, verbose):
42 assert k < n 38 assert k < n
43 largest_arc = old_div(int(2**ceil(log(n, 2))), 2) 39 largest_arc = int(2**ceil(log(n, 2))) // 2
44 num_ghosts = (2 * largest_arc) - n 40 num_ghosts = (2 * largest_arc) - n
45 if verbose: 41 if verbose:
46 print("we have", num_ghosts, "ghost peers") 42 print("we have", num_ghosts, "ghost peers")
@@ -106,4 +102,4 @@ if __name__ == "__main__":
106 sum = 0.0 102 sum = 0.0
107 for n in range(0, args.r): 103 for n in range(0, args.r):
108 sum += simulate(args.k, args.n, args.verbose) 104 sum += simulate(args.k, args.n, args.verbose)
109 print(old_div(sum, args.r)) 105 print(sum // args.r)
diff --git a/src/integration-tests/gnunet_pyexpect.py.in b/src/integration-tests/gnunet_pyexpect.py.in
index 000b8f99a..d757634a5 100644
--- a/src/integration-tests/gnunet_pyexpect.py.in
+++ b/src/integration-tests/gnunet_pyexpect.py.in
@@ -19,7 +19,6 @@
19# 19#
20# Testcase for gnunet-peerinfo 20# Testcase for gnunet-peerinfo
21 21
22from builtins import object
23import os 22import os
24import re 23import re
25import subprocess 24import subprocess
diff --git a/src/integration-tests/gnunet_testing.py.in b/src/integration-tests/gnunet_testing.py.in
index 667c3fff5..c3596d232 100644
--- a/src/integration-tests/gnunet_testing.py.in
+++ b/src/integration-tests/gnunet_testing.py.in
@@ -19,8 +19,6 @@
19# 19#
20# Functions for integration testing 20# Functions for integration testing
21 21
22from builtins import object
23from builtins import str
24import os 22import os
25import subprocess 23import subprocess
26import sys 24import sys
diff --git a/src/revocation/test_local_revocation.py.in b/src/revocation/test_local_revocation.py.in
index 979a55d83..4cc6119ca 100644
--- a/src/revocation/test_local_revocation.py.in
+++ b/src/revocation/test_local_revocation.py.in
@@ -19,7 +19,6 @@
19# 19#
20# Testcase for ego revocation 20# Testcase for ego revocation
21 21
22from builtins import str
23import sys 22import sys
24import os 23import os
25import subprocess 24import subprocess