From bc7657d39c77ca236312e61bf1c3eeba3baf0c03 Mon Sep 17 00:00:00 2001 From: roshii Date: Fri, 4 Aug 2023 16:28:57 +0200 Subject: [PATCH] Remove imports from future and past --- jmclient/test/test_taker.py | 9 ++++----- scripts/add-utxo.py | 3 +-- scripts/joinmarket-qt.py | 3 +-- scripts/obwatch/ob-watcher.py | 15 ++++++++++----- scripts/yg-privacyenhanced.py | 5 +---- setupall.py | 1 - 6 files changed, 17 insertions(+), 19 deletions(-) diff --git a/jmclient/test/test_taker.py b/jmclient/test/test_taker.py index c475dc817..8d20a4331 100644 --- a/jmclient/test/test_taker.py +++ b/jmclient/test/test_taker.py @@ -1,4 +1,3 @@ -from future.utils import iteritems from commontest import DummyBlockchainInterface import jmbitcoin as bitcoin import binascii @@ -135,7 +134,7 @@ def get_key_from_addr(self, addr): """ for p in privs: addrs[p] = BTC_P2PKH.privkey_to_address(p) - for p, a in iteritems(addrs): + for p, a in addrs.items(): if a == addr: return p raise ValueError("No such keypair") @@ -437,7 +436,7 @@ def clean_up(): return clean_up() if schedule[0][1] == 199599800: #need to force negative fees to make this feasible - for k, v in iteritems(taker.orderbook): + for k, v in taker.orderbook.items(): v['cjfee'] = '-0.002' # change_amount = (total_input - self.cjamount - # self.orderbook[nick]['txfee'] + real_cjfee) @@ -456,7 +455,7 @@ def clean_up(): #TODO note this test is not adequate, because the code is not; #the code does not *DO* anything if a condition is unexpected. taker.input_utxos = copy.deepcopy(t_utxos_by_mixdepth)[0] - for k,v in iteritems(taker.input_utxos): + for k,v in taker.input_utxos.items(): v["value"] = int(0.999805228 * v["value"]) res = taker.receive_utxos(maker_response) assert res[0] @@ -464,7 +463,7 @@ def clean_up(): if schedule[0][3] == "mteaYsGsLCL9a4cftZFTpGEWXNwZyDt5KS": # as above, but small -ve change instead of +ve. taker.input_utxos = copy.deepcopy(t_utxos_by_mixdepth)[0] - for k,v in iteritems(taker.input_utxos): + for k,v in taker.input_utxos.items(): v["value"] = int(0.999805028 * v["value"]) res = taker.receive_utxos(maker_response) assert res[0] diff --git a/scripts/add-utxo.py b/scripts/add-utxo.py index 3675cb992..2c595e334 100755 --- a/scripts/add-utxo.py +++ b/scripts/add-utxo.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -from future.utils import iteritems """A very simple command line tool to import utxos to be used as commitments into joinmarket's commitments.json file, allowing users to retry transactions more often without getting banned by @@ -207,7 +206,7 @@ def main(): except: jmprint("Failed to read json from " + options.in_json, "error") sys.exit(EXIT_FAILURE) - for u, pva in iteritems(utxo_json): + for u, pva in utxo_json.items(): utxobin, priv = get_utxo_info(",".join([u, pva["privkey"]]), utxo_binary=True) if not utxobin: diff --git a/scripts/joinmarket-qt.py b/scripts/joinmarket-qt.py index f9151b7ad..3b3cefb90 100755 --- a/scripts/joinmarket-qt.py +++ b/scripts/joinmarket-qt.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -from future.utils import iteritems from typing import Optional ''' @@ -993,7 +992,7 @@ def checkOffers(self, offers_fee, cjamount): mbinfo.append(" ") mbinfo.append("Counterparties chosen:") mbinfo.append('Name, Order id, Coinjoin fee (sat.)') - for k, o in iteritems(offers): + for k, o in offers.items(): if o['ordertype'] in ['sw0reloffer', 'swreloffer', 'reloffer']: display_fee = int(self.taker.cjamount * float(o['cjfee'])) - int(o['txfee']) diff --git a/scripts/obwatch/ob-watcher.py b/scripts/obwatch/ob-watcher.py index 2321ecf49..0f03ef1eb 100755 --- a/scripts/obwatch/ob-watcher.py +++ b/scripts/obwatch/ob-watcher.py @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -from future.utils import iteritems -from past.builtins import cmp from functools import cmp_to_key import http.server @@ -12,7 +10,7 @@ import hashlib import os import sys -from future.moves.urllib.parse import parse_qs +from urllib.parse import parse_qs from decimal import Decimal from optparse import OptionParser from twisted.internet import reactor @@ -549,8 +547,15 @@ def create_orderbook_table(self, btc_unit, rel_unit): ('maxsize', satoshi_to_unit), ('bondvalue', do_nothing)) - # somewhat complex sorting to sort by cjfee but with swabsoffers on top + def cmp(x, y): + if x < y: + return -1 + elif x > y: + return 1 + else: + return 0 + # somewhat complex sorting to sort by cjfee but with swabsoffers on top def orderby_cmp(x, y): if x['ordertype'] == y['ordertype']: return cmp(Decimal(x['cjfee']), Decimal(y['cjfee'])) @@ -665,7 +670,7 @@ def do_GET(self): replacements = {} orderbook_fmt = json.dumps(self.create_orderbook_obj()) orderbook_page = orderbook_fmt - for key, rep in iteritems(replacements): + for key, rep in replacements.items(): orderbook_page = orderbook_page.replace(key, rep) self.send_response(200) if self.path.endswith('.json'): diff --git a/scripts/yg-privacyenhanced.py b/scripts/yg-privacyenhanced.py index d87bf552a..4c4e8404b 100755 --- a/scripts/yg-privacyenhanced.py +++ b/scripts/yg-privacyenhanced.py @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -from future.utils import iteritems - import random import sys @@ -54,8 +52,7 @@ def create_my_orders(self): f = self.cjfee_r elif self.ordertype in ['swabsoffer', 'sw0absoffer']: f = str(self.txfee_contribution + self.cjfee_a) - mix_balance = dict([(m, b) for m, b in iteritems(mix_balance) - if b > self.minsize]) + mix_balance = dict([(m, b) for m, b in mix_balance.items() if b > self.minsize]) if len(mix_balance) == 0: jlog.error('You do not have the minimum required amount of coins' ' to be a maker: ' + str(self.minsize) + \ diff --git a/setupall.py b/setupall.py index c4db920e1..580849876 100644 --- a/setupall.py +++ b/setupall.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -from __future__ import print_function import sys, os, subprocess """A script to install in one of 3 modes: