Hello Uwe,

On 3/18/25 12:03, Uwe Kleine-König wrote:
> On Tue, Mar 18, 2025 at 09:25:04AM +0100, Ahmad Fatoum wrote:
>>      fsw.end_node()
>> -    seq = 0
>>      with fsw.add_node('configurations'):
>> -        for model, compat, files in entries:
>> -            seq += 1
>> -            with fsw.add_node(f'conf-{seq}'):
>> +        for dtbname, model, compat, files in entries:
>> +            with fsw.add_node(f'conf-{dtbname}'):
> 
> Funny/surprising semantic of fsw.add_node (i.e. fsw refers to the new
> node in the with-body?)

Yes. I suspect it's to ensure that a node end tag is inserted
after the properties.

>> -        entries.append([model, compat, files_seq])
>> +        dtbname = os.path.basename(fname)
>> +        ndtbs_seen = len(dtbs_seen)
>> +        dtbs_seen.add(dtbname)
>> +        if len(dtbs_seen) == ndtbs_seen:
>> +            raise RuntimeError(f"Duplicate file name '{dtbname}' during FIT 
>> creation")
>> +
>> +        entries.append([dtbname, model, compat, files_seq])
> 
>       dtbname = os.path.basename(fname)
>       if dtbname in dtbs_seen:
>           raise RuntimeError(...)
>       dtbs_seen.add(dtbname)
>       entries.append(...)
> 
> looks more pythonic (to me).

I dislike iterating twice over the dtbs. I wrote it this way,
because I assumed calling len on the set is O(1).

> Acked-by: Uwe Kleine-König <u...@kleine-koenig.org>
> 
> for the idea of this patch.

Thanks,
Ahmad

> 
> Best regards
> Uwe


Reply via email to