Skip to content
This repository was archived by the owner on Mar 27, 2026. It is now read-only.

Commit a808603

Browse files
committed
Upgrade version of Black
1 parent 5f74a1b commit a808603

7 files changed

Lines changed: 24 additions & 26 deletions

File tree

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
flake8==3.8.4
2-
black==20.8b1
2+
black==21.10b0
33
pytest==6.1.2

emv/card.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@
1616

1717

1818
class Card(object):
19-
""" High-level card manipulation API """
19+
"""High-level card manipulation API"""
2020

2121
def __init__(self, connection):
2222
self.tp = TransmissionProtocol(connection)
2323

2424
def get_mf(self):
25-
""" Get the master file (MF). """
25+
"""Get the master file (MF)."""
2626
return self.tp.exchange(SelectCommand(file_identifier=[0x3F, 0x00]))
2727

2828
def get_pse(self):
29-
""" Get the Payment System Environment (PSE) file """
29+
"""Get the Payment System Environment (PSE) file"""
3030
return self.tp.exchange(SelectCommand("1PAY.SYS.DDF01"))
3131

3232
def list_applications(self):
33-
""" List applications on the card """
33+
"""List applications on the card"""
3434
try:
3535
return self._list_applications_sfi()
3636
except ErrorResponse:
@@ -146,15 +146,15 @@ def get_application_data(self, afl):
146146
return data
147147

148148
def verify_pin(self, pin):
149-
""" Verify the PIN, raising an exception if it fails."""
149+
"""Verify the PIN, raising an exception if it fails."""
150150
res = self.tp.exchange(VerifyCommand(pin))
151151
if type(res) == WarningResponse:
152152
raise InvalidPINException(str(res))
153153

154154
return res
155155

156156
def generate_cap_value(self, pin, challenge=None, value=None):
157-
""" Perform a transaction to generate the EMV CAP (Pinsentry) value. """
157+
"""Perform a transaction to generate the EMV CAP (Pinsentry) value."""
158158
apps = self.list_applications()
159159

160160
if len(apps) == 0:
@@ -182,7 +182,9 @@ def generate_cap_value(self, pin, challenge=None, value=None):
182182
# It appears that Belgian cards use their own silliness.
183183
# https://github.com/zoobab/EMVCAP/blob/master/EMV-CAP#L512
184184
if Tag.IPB not in app_data:
185-
raise EMVProtocolError("Issuer Proprietary Bitmap not found in application file")
185+
raise EMVProtocolError(
186+
"Issuer Proprietary Bitmap not found in application file"
187+
)
186188

187189
self.verify_pin(pin)
188190

emv/command/client.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def get_reader(reader):
4242

4343

4444
def run():
45-
" Command line entrypoint "
45+
"Command line entrypoint"
4646
cli(obj={})
4747

4848

@@ -138,9 +138,7 @@ def info(ctx):
138138
"1PAY.SYS.DDF01 not available (this is normal on some cards)", fg="yellow"
139139
)
140140
except Exception as e:
141-
click.secho(
142-
"Error reading 1PAY.SYS.DDF01 (may be normal): " + str(e), fg="red"
143-
)
141+
click.secho("Error reading 1PAY.SYS.DDF01 (may be normal): " + str(e), fg="red")
144142

145143
click.secho("\n2PAY.SYS.DDF01 (Index of apps for contactless payments)", bold=True)
146144
try:
@@ -150,9 +148,7 @@ def info(ctx):
150148
"2PAY.SYS.DDF01 not available (this is normal on some cards)", fg="yellow"
151149
)
152150
except Exception as e:
153-
click.secho(
154-
"Error reading 2PAY.SYS.DDF01 (may be normal): " + str(e), fg="red"
155-
)
151+
click.secho("Error reading 2PAY.SYS.DDF01 (may be normal): " + str(e), fg="red")
156152

157153
for app in apps:
158154
click.secho(

emv/protocol/command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def __init__(self, pin):
188188

189189

190190
class GenerateApplicationCryptogramCommand(CAPDU):
191-
""" Defined in: EMV 4.3 Book 3 section 6.5.5 """
191+
"""Defined in: EMV 4.3 Book 3 section 6.5.5"""
192192

193193
name = "Generate Application Cryptogram"
194194

@@ -211,7 +211,7 @@ def __init__(self, crypto_type, data, cda_sig=False):
211211

212212

213213
class GetProcessingOptions(CAPDU):
214-
""" Defined in: EMV 4.3 Book 3 section 6.5.8 """
214+
"""Defined in: EMV 4.3 Book 3 section 6.5.8"""
215215

216216
name = "Get Processing Opts"
217217

emv/protocol/data.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ def is_two_byte(val):
2424

2525

2626
def is_continuation(val):
27-
""" Any subsequent byte is a continuation byte if the MSB is set. """
27+
"""Any subsequent byte is a continuation byte if the MSB is set."""
2828
return val & 0b10000000 == 0b10000000
2929

3030

3131
def is_constructed(val):
32-
""" Check if a tag represents a "constructed" value, i.e. another TLV """
32+
"""Check if a tag represents a "constructed" value, i.e. another TLV"""
3333
return val & 0b00100000 == 0b00100000
3434

3535

@@ -74,7 +74,7 @@ def read_length(data):
7474

7575
@total_ordering
7676
class Tag(object):
77-
""" Represents a data tag. Provides ordering and pretty rendering."""
77+
"""Represents a data tag. Provides ordering and pretty rendering."""
7878

7979
def __init__(self, value):
8080
if type(value) in (list, tuple) and len(value) == 1:

emv/protocol/structures.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class DOL(OrderedDict):
140140

141141
@classmethod
142142
def unmarshal(cls, data):
143-
""" Construct a DOL object from the binary representation (as a list of bytes) """
143+
"""Construct a DOL object from the binary representation (as a list of bytes)"""
144144
dol = cls()
145145
i = 0
146146
while i < len(data):
@@ -152,11 +152,11 @@ def unmarshal(cls, data):
152152
return dol
153153

154154
def size(self):
155-
""" Total size of the resulting structure in bytes. """
155+
"""Total size of the resulting structure in bytes."""
156156
return sum(self.values())
157157

158158
def unserialise(self, data):
159-
""" Parse an input stream of bytes and return a TLV object. """
159+
"""Parse an input stream of bytes and return a TLV object."""
160160
if self.size() != len(data):
161161
raise Exception(
162162
"Incorrect input size (expecting %s bytes, got %s)"
@@ -190,7 +190,7 @@ def serialise(self, data):
190190

191191

192192
class TagList(list):
193-
""" A list of tags. """
193+
"""A list of tags."""
194194

195195
@classmethod
196196
def unmarshal(cls, data):
@@ -204,7 +204,7 @@ def unmarshal(cls, data):
204204

205205

206206
class CVMRule(object):
207-
""" EMV 4.3 book 3 appendix C3 """
207+
"""EMV 4.3 book 3 appendix C3"""
208208

209209
RULES = {
210210
# 0b00000000: "Fail CVM processing",

emv/transmission.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class TransmissionProtocol(object):
1111
"""
1212

1313
def __init__(self, connection):
14-
""" Connection should be a pyscard connection. """
14+
"""Connection should be a pyscard connection."""
1515
self.log = logging.getLogger(__name__)
1616
self.connection = connection
1717
self.connection.connect(connection.T0_protocol)

0 commit comments

Comments
 (0)