Skip to content

Commit

Permalink
Python3: use list comprehension
Browse files Browse the repository at this point in the history
Replace map() + lambda expression to list comprehension
  • Loading branch information
LudovicRousseau authored and moreati committed Jun 30, 2015
1 parent 4e7cbdd commit f7db52b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
ID_TEXT_SW2,
ID_TEXTCTRL_SW2,
ID_CARDSTATE,
ID_TRANSMIT] = map(lambda x: wx.NewId(), range(11))
ID_TRANSMIT] = [wx.NewId() for x in range(11)]


class SampleAPDUManagerPanel(wx.Panel, SimpleSCardAppEventObserver):
Expand Down
4 changes: 2 additions & 2 deletions smartcard/pcsc/PCSCCardConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def doTransmit(self, bytes, protocol=None):
sw1 = (response[-2] + 256) % 256
sw2 = (response[-1] + 256) % 256

data = map(lambda x: (x + 256) % 256, response[:-2])
data = [(x + 256) % 256 for x in response[:-2]]
return list(data), sw1, sw2

def doControl(self, controlCode, bytes=[]):
Expand All @@ -226,7 +226,7 @@ def doControl(self, controlCode, bytes=[]):
raise SmartcardException(
'Failed to control ' + SCardGetErrorMessage(hresult))

data = map(lambda x: (x + 256) % 256, response)
data = [(x + 256) % 256 for x in response]
return list(data)

def doGetAttrib(self, attribId):
Expand Down
4 changes: 2 additions & 2 deletions smartcard/test/framework/testcase_CardType.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def testcase_ATRCardTypeWithMask(self):

for reader in readers():
if [] != expectedATRinReader[str(reader)]:
mask = map(lambda x: 0xFF, expectedATRinReader[str(reader)])
mask = [0xFF for x in expectedATRinReader[str(reader)]]
# don't look to the last byte
mask[-1] = 0x00
ct = ATRCardType(expectedATRinReader[str(reader)], mask)
Expand All @@ -117,7 +117,7 @@ def testcase_ATRCardTypeWithMaskMismatch(self):

for reader in readers():
if [] != expectedATRinReader[str(reader)]:
mask = map(lambda x: 0xFF, expectedATRinReader[str(reader)])
mask = [0xFF for x in expectedATRinReader[str(reader)]]
# don't look to the last byte
mask[0] = mask[-1] = 0x00
ct = ATRCardType(expectedATRinReader[str(reader)], mask)
Expand Down
2 changes: 1 addition & 1 deletion smartcard/wx/APDUTracerPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

[
wxID_APDUTEXTCTRL,
] = map(lambda x: wx.NewId(), range(1))
] = [wx.NewId() for x in range(1)]


class APDUTracerPanel(wx.Panel, CardConnectionObserver):
Expand Down
2 changes: 1 addition & 1 deletion smartcard/wx/SimpleSCardAppFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

[
wxID_SIMPLESCARDAPP_FRAME,
] = map(lambda x: wx.NewId(), range(1))
] = [wx.NewId() for x in range(1)]


class BlankPanel(wx.Panel, SimpleSCardAppEventObserver):
Expand Down

0 comments on commit f7db52b

Please sign in to comment.