2649
2649
# We slightly diverge from LocalConfig here by allowing the no-name
2650
2650
# section as the most generic one and the lower priority.
2651
2651
no_name_section = None
2653
2653
# Filter out the no_name_section so _iter_for_location_by_parts can be
2654
2654
# used (it assumes all sections have a name).
2655
2655
for section in self.store.get_sections():
2656
2656
if section.id is None:
2657
2657
no_name_section = section
2659
sections.append(section)
2659
all_sections.append(section)
2660
2660
# Unfortunately _iter_for_location_by_parts deals with section names so
2661
2661
# we have to resync.
2662
2662
filtered_sections = _iter_for_location_by_parts(
2663
[s.id for s in sections], self.location)
2664
iter_sections = iter(sections)
2663
[s.id for s in all_sections], self.location)
2664
iter_all_sections = iter(all_sections)
2665
2665
matching_sections = []
2666
2666
if no_name_section is not None:
2667
2667
matching_sections.append(
2668
2668
LocationSection(no_name_section, 0, self.location))
2669
2669
for section_id, extra_path, length in filtered_sections:
2670
# a section id is unique for a given store so it's safe to iterate
2672
section = iter_sections.next()
2673
if section_id == section.id:
2674
matching_sections.append(
2675
LocationSection(section, length, extra_path))
2670
# a section id is unique for a given store so it's safe to take the
2671
# first matching section while iterating. Also, all filtered
2672
# sections are part of 'all_sections' and will always be found
2675
section = iter_all_sections.next()
2676
if section_id == section.id:
2677
matching_sections.append(
2678
LocationSection(section, length, extra_path))
2676
2680
return matching_sections
2678
2682
def get_sections(self):