in python/moz/l10n/resource/l10n_equal.py [0:0]
def l10n_sections(resource: Resource[Any]) -> _L10nData[_L10nData[Any]]:
ls = [
(section.id, section.comment.strip(), l10n_meta(section), l10n_entries(section))
for section in resource.sections
if any(isinstance(entry, Entry) for entry in section.entries)
]
ls.sort()
nonempty_idx = next(
(idx for idx, (id, comment, meta, _) in enumerate(ls) if id or comment or meta),
len(ls),
)
if nonempty_idx > 1:
# Anonymous sections are considered equivalent
first = ls[0]
for sd in ls[1:nonempty_idx]:
first[3].extend(sd[3])
first[3].sort()
del ls[1:nonempty_idx]
return ls