Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(1)  |  Call(1)  |  Derive(0)  |  Import(0)
Given a feature name and a subclass of _ConfigFile, check whether
the feature exists, and return a sec/name tuple that, when passed to
_ConfigFile.getFeature, gives the value of the appropriate feature.
Raises a UIError if the feature name is invalid.

A feature is either: a special string handled by the class (like
'caps' for ServerInfo), a special string handled outside the class
(like 'status' for ClientDirectory), a Section:Entry string, or an
Entry string.  (If the Entry string is not unique within a section,
raises UIError.)  All features are case-insensitive.(more...)

        def resolveFeatureName(name, klass):
    """Given a feature name and a subclass of _ConfigFile, check whether
       the feature exists, and return a sec/name tuple that, when passed to
       _ConfigFile.getFeature, gives the value of the appropriate feature.
       Raises a UIError if the feature name is invalid.

       A feature is either: a special string handled by the class (like
       'caps' for ServerInfo), a special string handled outside the class
       (like 'status' for ClientDirectory), a Section:Entry string, or an
       Entry string.  (If the Entry string is not unique within a section,
       raises UIError.)  All features are case-insensitive.

       Example features are: 'caps', 'status', 'Incoming/MMTP:Version',
         'hostname'.
       """
    syn = klass._syntax
    name = name.lower()
    if klass._features.has_key(name):
        return "-", name
    elif ':' in name:
        idx = name.index(':')
        sec, ent = name[:idx], name[idx+1:]
        goodSection = None
        for section, entries in syn.items():
            if section.lower() == sec:
                goodSection = section
                for entry in entries.keys():
                    if entry.lower() == ent:
                        return section, entry
        if goodSection:
            raise UIError("Section %s has no entry %r"%(goodSection,ent))
        else:
            raise UIError("No such section as %s"%sec)
    else:
        result =  []
        for secname, secitems in syn.items():
            if secname.lower() == name:
                raise UIError("No key given for section %s"%secname)
            for entname in secitems.keys():
                if entname.lower() == name:
                    result.append((secname, entname))
        if len(result) == 0:
            raise UIError("No key named %r found"%name)
        elif len(result) > 1:
            secs = [ "%s:%s"%(secname,entname) for secname,entname
                     in result ]
            raise UIError("%r is ambiguous.  Did you mean %s?"%(
                          name, englishSequence(secs,compound="or")))
        else:
            return result[0]
        


src/m/i/mixminion-HEAD/lib/mixminion/ClientDirectory.py   mixminion(Download)
                else:
                    feature = mixminion.Config.resolveFeatureName(
                        f, mixminion.ServerInfo.ServerInfo)
                    resFeatures.append((f, feature))
            for sd in self.allServers: