示例#1
0
    def getAccountTitle(self, alias):
        simplified = Account.simplifyAlias(alias)
              
        # if the alias when simplified is exactly a key to the map
        # then return the title of the account        
        if simplified in self.map_alias_to_title.keys():
            #print "matches exactly", simplified
            return self.map_alias_to_title[simplified]

        # check to see if key appears at the beginning of simplified
        for key in self.map_alias_to_title.keys():                
            if simplified.find(key) == 0:
                #print "The key,", key, "matches at the beginning of", simplified
                return self.map_alias_to_title[key]
                
        # check to see if key appears somewhere in simplified
        for key in self.map_alias_to_title.keys():                
            if simplified.find(key) > 0:
                #print "The key,", key, "matches somewhere the simplified alias", simplified
                return self.map_alias_to_title[key]
        
        #print "The simplified alias does not match any key:", simplified
        return "UNKNOWN_ACCOUNT"

        # if the alias when simplified is a key to the map
        # then return title        
        if simplified in self.map_alias_to_title.keys():
            return self.map_alias_to_title[simplified]

        # if a key to the map is a leading substring of the alias when simplified 
        # then return title        
        else:
            found = None
            for key in self.map_alias_to_title.keys():
                len_key = len(key)
                if simplified[0:len_key] == key:
                    found = key
                    break
                
        if found == None:
            return "UNKNOWN_ACCOUNT"
        else:
            return self.map_alias_to_title[found]

                           
示例#2
0
 def getKey(self, full_alias):
     simplified = Account.simplifyAlias(full_alias)
     for key in self.map_alias_to_title.keys():                
         if (simplified.find(key) == 0):
             return key
     return 'KEYNOTFOUND'