Skip to content

Commit

Permalink
Remove imports from future and past
Browse files Browse the repository at this point in the history
  • Loading branch information
roshii committed Aug 7, 2023
1 parent da8ab56 commit 4e5d894
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 21 deletions.
9 changes: 4 additions & 5 deletions jmclient/test/test_taker.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from future.utils import iteritems
from commontest import DummyBlockchainInterface
import jmbitcoin as bitcoin
import binascii
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand All @@ -456,15 +455,15 @@ 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]
return 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]
Expand Down
3 changes: 1 addition & 2 deletions scripts/add-utxo.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions scripts/joinmarket-qt.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
from future.utils import iteritems
from typing import Optional

'''
Expand Down Expand Up @@ -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'])
Expand Down
19 changes: 12 additions & 7 deletions scripts/obwatch/ob-watcher.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -549,12 +547,19 @@ 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']))
return cmp(offername_list.index(x['ordertype']),
return _cmp(Decimal(x['cjfee']), Decimal(y['cjfee']))
return _cmp(offername_list.index(x['ordertype']),
offername_list.index(y['ordertype']))

for o in sorted(rows, key=cmp_to_key(orderby_cmp)):
Expand Down Expand Up @@ -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'):
Expand Down
5 changes: 1 addition & 4 deletions scripts/yg-privacyenhanced.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python3
from future.utils import iteritems

import random
import sys

Expand Down Expand Up @@ -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) + \
Expand Down
1 change: 0 additions & 1 deletion setupall.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 4e5d894

Please sign in to comment.