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

All Samples(5)  |  Call(5)  |  Derive(0)  |  Import(0)
Get the language identifier for the given file type string. The search
is case insensitive.
@param desc: unicode (i.e u"Python")
@note: if lookup fails ID_LANG_TXT is returned

        def GetIdFromDescription(desc):
    """Get the language identifier for the given file type string. The search
    is case insensitive.
    @param desc: unicode (i.e u"Python")
    @note: if lookup fails ID_LANG_TXT is returned

    """
    rval = ID_LANG_TXT
    desc = desc.lower()
    # Guard against async code that may be modifying globals
    globs = dict(globals())
    for key, val in globs.iteritems():
        if isinstance(val, unicode):
            if val.lower() == desc and key.startswith('LANG_'):
                rval = globs.get("ID_" + key, ID_LANG_TXT)
                break
    return rval
        


src/e/d/Editra-0.7.20/src/ed_menu.py   Editra(Download)
        mconfig.sort()
        for label in mconfig:
            lid = synglob.GetIdFromDescription(label)
            langmenu.Append(lid, label,
                            _("Switch Lexer to %s") % label, wx.ITEM_CHECK)

src/e/d/Editra-0.7.20/tests/unittests/testSynGlob.py   Editra(Download)
    def testGetIdFromDescription(self):
        """Get getting a language id from its description string"""
        id_ = synglob.GetIdFromDescription(u"Python")
        self.assertEquals(id_, synglob.ID_LANG_PYTHON)
 
        id_ = synglob.GetIdFromDescription(u"python")
        self.assertEquals(id_, synglob.ID_LANG_PYTHON)
 
        id_ = synglob.GetIdFromDescription(u"C")
        self.assertEquals(id_, synglob.ID_LANG_C)
 
        id_ = synglob.GetIdFromDescription(u"SomeFakeLang")
        self.assertEquals(id_, synglob.ID_LANG_TXT)