Skip to content

Commit 3f9ce38

Browse files
committed
Merge pull request #101 from fau-fablab/refactor-hasKey
REFACTOR replace .hasKey with in
2 parents 5358fa0 + 935fa30 commit 3f9ce38

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

FabLabKasse/cashPayment/cashState.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ def printFormatted(output):
615615
dev = row[0]
616616
# state: compute delta, because the DB only stores the total
617617
currentState = CashState.fromJSON(row[2])
618-
if previousStates.has_key(dev):
618+
if dev in previousStates:
619619
delta = currentState - previousStates[dev]
620620
delta = delta.toVerboseString()
621621
else:

FabLabKasse/cashPayment/server/mdbCash/mdb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ def dispenseValue(self, maximumDispense):
544544
# get number of avail. coins by value
545545
coinsAvailable = {}
546546
for [coinType, coinValue] in sortedCoinValues:
547-
if not coinsAvailable.has_key(coinValue):
547+
if coinValue not in coinsAvailable:
548548
coinsAvailable[coinValue] = 0
549549
coinsAvailable[coinValue] += tubeStatus[coinType]["count"]
550550

@@ -553,7 +553,7 @@ def shouldSplit(coinValue):
553553
so that the coin storage does not run short of often paid out coins (like 1€)
554554
this will only happen if more than enough of the smaller coins (like 50c) are present
555555
"""
556-
if not coinsAvailable.has_key(coinValue / 2):
556+
if (coinValue / 2) not in coinsAvailable:
557557
# there is no "half" coin of the currently used value
558558
# TODO implement something for splitting 50c -> 20c+10c
559559
return False

FabLabKasse/shopping/backend/oerp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def create_order(self):
128128
partner_id = self.cfg.getint('openerp', 'anonymous_partner_id')
129129
order_data = self.oerp.execute('sale.order', 'onchange_partner_id', [], partner_id)
130130
print order_data
131-
assert not order_data.has_key('warning'), u"failed getting default values for sale.order: {}".format(order_data['warning'])
131+
assert 'warning' not in order_data, u"failed getting default values for sale.order: {}".format(order_data['warning'])
132132
order_data = order_data['value']
133133
order_data.update({'partner_id': partner_id,
134134
'order_policy': 'manual',

FabLabKasse/shopping/backend/offline_base.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,21 @@ def __init__(self, root_category_id, categories=None, products=None, generate_ro
7777
for i in products:
7878
self.add_product(i)
7979

80-
assert self.categories.has_key(self.root_category_id), "missing root category"
80+
assert self.root_category_id in self.categories, "missing root category"
8181
cfg = scriptHelper.getConfig()
82-
assert self.products.has_key(
83-
cfg.getint('payup_methods', 'overpayment_product_id')), "missing product for overpayment"
84-
assert self.products.has_key(
85-
cfg.getint('payup_methods', 'payout_impossible_product_id')), "missing product for payout_impossible"
82+
assert cfg.getint('payup_methods', 'overpayment_product_id') in self.products, "missing product for overpayment"
83+
assert cfg.getint('payup_methods', 'payout_impossible_product_id') in self.products,\
84+
"missing product for payout_impossible"
8685

8786
def add_category(self, category):
8887
categ_id = category.categ_id
89-
assert not self.categories.has_key(categ_id), "Category {} {} already exists: {}".format(categ_id, repr(category.name), repr(self.categories[categ_id].name))
88+
assert categ_id not in self.categories, "Category {} {} already exists: {}".format(
89+
categ_id, repr(category.name), repr(self.categories[categ_id].name))
9090
self.categories[categ_id] = category
9191

9292
def add_product(self, product):
9393
prod_id = product.prod_id
94-
assert not self.products.has_key(prod_id), "Product already exists"
94+
assert prod_id not in self.products, "Product already exists"
9595
self.products[prod_id] = product
9696

9797
def get_root_category(self):
@@ -152,7 +152,7 @@ def get_product(self, prod_id):
152152

153153
def get_category_path(self, categ_id):
154154
path = []
155-
assert self.categories.has_key(categ_id), "invalid category id {}".format(categ_id)
155+
assert categ_id in self.categories, "invalid category id {}".format(categ_id)
156156
while categ_id not in [None, self.root_category_id]:
157157
try:
158158
path.insert(0, self.categories[categ_id])

0 commit comments

Comments
 (0)