@@ -427,7 +427,7 @@ def _read_annot_ctab_old_format(fobj, n_entries):
427
427
for i in range (n_entries ):
428
428
# structure name length + string
429
429
name_length = np .fromfile (fobj , dt , 1 )[0 ]
430
- name = np .fromfile (fobj , '|S%d' % name_length , 1 )[0 ]
430
+ name = np .fromfile (fobj , f '|S{ name_length } ' , 1 )[0 ]
431
431
names .append (name )
432
432
# read RGBT for this entry
433
433
ctab [i , :4 ] = np .fromfile (fobj , dt , 4 )
@@ -465,13 +465,13 @@ def _read_annot_ctab_new_format(fobj, ctab_version):
465
465
dt = _ANNOT_DT
466
466
# This code works with a file version == 2, nothing else
467
467
if ctab_version != 2 :
468
- raise Exception ('Unrecognised .annot file version (%i)' , ctab_version )
468
+ raise Exception (f 'Unrecognised .annot file version ({ ctab_version } )' )
469
469
# maximum LUT index present in the file
470
470
max_index = np .fromfile (fobj , dt , 1 )[0 ]
471
471
ctab = np .zeros ((max_index , 5 ), dt )
472
472
# orig_tab string length + string
473
473
length = np .fromfile (fobj , dt , 1 )[0 ]
474
- np .fromfile (fobj , '|S%d' % length , 1 )[0 ] # Orig table path
474
+ np .fromfile (fobj , f '|S{ length } ' , 1 )[0 ] # Orig table path
475
475
# number of LUT entries present in the file
476
476
entries_to_read = np .fromfile (fobj , dt , 1 )[0 ]
477
477
names = list ()
@@ -480,7 +480,7 @@ def _read_annot_ctab_new_format(fobj, ctab_version):
480
480
idx = np .fromfile (fobj , dt , 1 )[0 ]
481
481
# structure name length + string
482
482
name_length = np .fromfile (fobj , dt , 1 )[0 ]
483
- name = np .fromfile (fobj , '|S%d' % name_length , 1 )[0 ]
483
+ name = np .fromfile (fobj , f '|S{ name_length } ' , 1 )[0 ]
484
484
names .append (name )
485
485
# RGBT
486
486
ctab [idx , :4 ] = np .fromfile (fobj , dt , 4 )
@@ -525,7 +525,7 @@ def write(num, dtype=dt):
525
525
def write_string (s ):
526
526
s = (s if isinstance (s , bytes ) else s .encode ()) + b'\x00 '
527
527
write (len (s ))
528
- write (s , dtype = '|S%d' % len (s ))
528
+ write (s , dtype = f '|S{ len (s )} ' )
529
529
530
530
# Generate annotation values for each ctab entry
531
531
if fill_ctab :
0 commit comments