@@ -251,7 +251,9 @@ def _get_fdt(self) -> Optional[Fdt]:
251251 return FdtBlobParse (io .BytesIO (data [start :end ])).to_fdt ()
252252 return None
253253
254- def open (self , section : Section ) -> SectionFile :
254+ def open (self , section : Union [Section , str ]) -> SectionFile :
255+ if isinstance (section , str ):
256+ section = self [section ]
255257 self ._open_files += 1
256258 return SectionFile (self ._fd , section , self ._fdclose )
257259
@@ -278,7 +280,7 @@ def get_uboot_info(self) -> tuple[Optional[str], Optional[str], Optional[str]]:
278280 return version , compiler , linker
279281
280282 def get_kernel_image_header (self ) -> Optional [LegacyImageHeader ]:
281- with self .open (self [ "kernel" ] ) as f :
283+ with self .open ("kernel" ) as f :
282284 data = f .read (sizeof (LegacyImageHeader ))
283285 if FileType .from_magic (data [:4 ]) == FileType .UIMAGE :
284286 return LegacyImageHeader .from_buffer_copy (data )
@@ -309,7 +311,7 @@ def get_vendor(self) -> Optional[str]:
309311 if self .fdt_json is not None :
310312 key = self .fdt_json ["compatible" ][1 ].split (',' )[0 ]
311313 return map_ .get (key .lower (), key )
312- with self .open (self [ "uboot" ] ) as f :
314+ with self .open ("uboot" ) as f :
313315 if re .match (b"GM[0-9]{4}" , f .read (6 )):
314316 return "Grain Media"
315317 if re .search (b"HISILICON LOGO MAGIC" , self .uboot_section ) is not None :
0 commit comments