2
2
#
3
3
# SPDX-License-Identifier: Apache-2.0
4
4
5
- from textwrap import dedent
6
5
import struct
6
+ from textwrap import dedent
7
7
8
8
from west .commands import WestCommand
9
9
10
-
11
10
try :
12
11
from elftools .elf .elffile import ELFFile
13
12
from intelhex import IntelHex
@@ -28,7 +27,7 @@ def convert_from_uf2(cmd, buf):
28
27
block = buf [ptr :ptr + 512 ]
29
28
hd = struct .unpack (b'<IIIIIIII' , block [0 :32 ])
30
29
if hd [0 ] != UF2_MAGIC_START0 or hd [1 ] != UF2_MAGIC_START1 :
31
- cmd .inf ('Skipping block at ' + ptr + ' ; bad magic' )
30
+ cmd .inf (f 'Skipping block at { ptr } ; bad magic' )
32
31
continue
33
32
if hd [2 ] & 1 :
34
33
# NO-flash flag set; skip block
@@ -124,7 +123,8 @@ def do_add_parser(self, parser_adder):
124
123
search_parser = subparsers .add_parser ('search' , help = 'Search for a specific descriptor' )
125
124
search_parser .add_argument ('descriptor' , type = str , help = 'Descriptor name' )
126
125
search_parser .add_argument ('file' , type = str , help = 'Executable file' )
127
- search_parser .add_argument ('--file-type' , type = str , choices = self .EXTENSIONS , help = 'File type' )
126
+ search_parser .add_argument ('--file-type' , type = str , choices = self .EXTENSIONS ,
127
+ help = 'File type' )
128
128
search_parser .add_argument ('-b' , '--big-endian' , action = 'store_true' ,
129
129
help = 'Target CPU is big endian' )
130
130
search_parser .set_defaults (subcmd = 'search' , big_endian = False )
@@ -144,7 +144,8 @@ def do_add_parser(self, parser_adder):
144
144
list_parser = subparsers .add_parser ('list' , help = 'List all known descriptors' )
145
145
list_parser .set_defaults (subcmd = 'list' , big_endian = False )
146
146
147
- get_offset_parser = subparsers .add_parser ('get_offset' , help = 'Get the offset of the descriptors' )
147
+ get_offset_parser = subparsers .add_parser ('get_offset' ,
148
+ help = 'Get the offset of the descriptors' )
148
149
get_offset_parser .add_argument ('file' , type = str , help = 'Executable file' )
149
150
get_offset_parser .add_argument ('--file-type' , type = str , choices = self .EXTENSIONS ,
150
151
help = 'File type' )
@@ -329,5 +330,5 @@ def align(x, alignment):
329
330
def bindesc_repr (value ):
330
331
if isinstance (value , str ):
331
332
return f'"{ value } "'
332
- if isinstance (value , ( int , bytes ) ):
333
+ if isinstance (value , int | bytes ):
333
334
return f'{ value } '
0 commit comments