~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Vincent Ladeuil
  • Date: 2011-09-07 08:23:49 UTC
  • mto: (6123.1.13 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6124.
  • Revision ID: v.ladeuil+lp@free.fr-20110907082349-1ly8p12duy1exzn3
Provide config.IdMatcher for config files defining secion names as unique ids

Show diffs side-by-side

added added

removed removed

Lines of Context:
2891
2891
class SectionMatcher(object):
2892
2892
    """Select sections into a given Store.
2893
2893
 
2894
 
    This intended to be used to postpone getting an iterable of sections from a
2895
 
    store.
 
2894
    This is intended to be used to postpone getting an iterable of sections
 
2895
    from a store.
2896
2896
    """
2897
2897
 
2898
2898
    def __init__(self, store):
2907
2907
            if self.match(s):
2908
2908
                yield s
2909
2909
 
2910
 
    def match(self, secion):
 
2910
    def match(self, section):
 
2911
        """Does the proposed section match.
 
2912
 
 
2913
        :param section: A Section object.
 
2914
 
 
2915
        :returns: True if the section matches, False otherwise.
 
2916
        """
2911
2917
        raise NotImplementedError(self.match)
2912
2918
 
2913
2919
 
 
2920
class IdMatcher(SectionMatcher):
 
2921
 
 
2922
    def __init__(self, store, section_id):
 
2923
        super(IdMatcher, self).__init__(store)
 
2924
        self.section_id = section_id
 
2925
 
 
2926
    def match(self, section):
 
2927
        return section.id == self.section_id
 
2928
 
 
2929
 
2914
2930
class LocationSection(Section):
2915
2931
 
2916
2932
    def __init__(self, section, length, extra_path):