1717from . import util
1818
1919
20- class CheckArgValue ( object ) :
20+ class CheckArgValue :
2121 def __init__ (self , efuses , name ):
2222 self .efuses = efuses
2323 self .name = name
@@ -85,7 +85,7 @@ def check_arg_value(efuse, new_value):
8585 return check_arg_value (efuse , new_value )
8686
8787
88- class EfuseProtectBase ( object ) :
88+ class EfuseProtectBase :
8989 # This class is used by EfuseBlockBase and EfuseFieldBase
9090 read_disable_bit : int | list [int ] | None
9191 write_disable_bit : int | list [int ] | None
@@ -214,9 +214,7 @@ def get_block_len(self):
214214 elif coding_scheme == self .parent .REGS .CODING_SCHEME_RS :
215215 return self .len * 4
216216 else :
217- raise esptool .FatalError (
218- "Coding scheme (%d) not supported" % (coding_scheme )
219- )
217+ raise esptool .FatalError (f"Coding scheme ({ coding_scheme } ) not supported" )
220218
221219 def get_coding_scheme (self ):
222220 if self .id == 0 :
@@ -255,7 +253,7 @@ def read(self, print_info=True):
255253 words = self .get_words ()
256254 data = BitArray ()
257255 for word in reversed (words ):
258- data .append ("uint:32=%d" % word )
256+ data .append (f "uint:32={ word } " )
259257 self .bitarray .overwrite (data , pos = 0 )
260258 if print_info :
261259 self .print_block (self .bitarray , "read_regs" )
@@ -264,13 +262,13 @@ def print_block(self, bit_string, comment, debug=False):
264262 if self .parent .debug or debug :
265263 bit_string .pos = 0
266264 log .print (
267- "%- 15s (%-16s) [%-2d] %s: "
268- % ( self . name , " " . join ( self .alias )[: 16 ], self . id , comment ) ,
265+ f" { self . name :< 15s} ( { ' ' . join ( self . alias )[: 16 ]:<16s } ) "
266+ f"[ { self .id :<2d } ] { comment } :" ,
269267 " " .join (
270268 [
271- "% 08x" % word
269+ f" { word : 08x} "
272270 for word in bit_string .readlist (
273- "%d*uint:32" % (bit_string .len / 32 )
271+ f" { int (bit_string .len / 32 )} *uint:32"
274272 )[::- 1 ]
275273 ]
276274 ),
@@ -285,8 +283,8 @@ def check_wr_data(self):
285283 return False
286284 if len (wr_data .bytes ) != len (self .bitarray .bytes ):
287285 raise esptool .FatalError (
288- "Data does not fit: the block%d size is %d bytes, data is %d bytes "
289- % ( self . id , len (self .bitarray .bytes ), len (wr_data .bytes ))
286+ f "Data does not fit: block{ self . id } size "
287+ f" { len (self .bitarray .bytes )} bytes, data { len (wr_data .bytes )} bytes"
290288 )
291289 self .check_wr_rd_protect ()
292290
@@ -468,7 +466,7 @@ def burn(self):
468466 self .wr_bitarray .set (0 )
469467
470468
471- class EspEfusesBase ( object ) :
469+ class EspEfusesBase :
472470 """
473471 Wrapper object to manage the efuse fields in a connected ESP bootloader
474472 """
@@ -674,8 +672,9 @@ def burn_block(block, postponed_efuses):
674672 @staticmethod
675673 def confirm (action , do_not_confirm ):
676674 log .print (
677- "%s%s\n This is an irreversible operation!"
678- % (action , "" if action .endswith ("\n " ) else ". " )
675+ "{}{}\n This is an irreversible operation!" .format (
676+ action , "" if action .endswith ("\n " ) else ". "
677+ )
679678 )
680679 if not do_not_confirm :
681680 log .print ("Type 'BURN' (all capitals) to continue." , flush = True )
0 commit comments