コード例 #1
0
ファイル: utils.py プロジェクト: J4LP/mumble
def get_alliance_id_by_name(name):
    if not redis.exists('alliances'):
        eve = evelink.eve.EVE()
        alliance_map = {}
        for alliance_id, alliance in iteritems(eve.alliances()[0]):
            alliance_map[alliance['name'].lower()] = alliance_id
        redis.hmset('alliances', alliance_map)
    alliance_id = redis.hget('alliances', name.lower())
    if not alliance_id:
        raise InvalidAllianceError(name)
    return int(alliance_id)
コード例 #2
0
ファイル: utils.py プロジェクト: J4LP/mumble
def get_alliance_id_by_name(name):
    if not redis.exists('alliances'):
        eve = evelink.eve.EVE()
        alliance_map = {}
        for alliance_id, alliance in iteritems(eve.alliances()[0]):
            alliance_map[alliance['name'].lower()] = alliance_id
        redis.hmset('alliances', alliance_map)
    alliance_id = redis.hget('alliances', name.lower())
    if not alliance_id:
        raise InvalidAllianceError(name)
    return int(alliance_id)
コード例 #3
0
ファイル: utils.py プロジェクト: J4LP/mumble
def get_corporation_id_by_name(name):
    corporation_id = redis.hget('corporations', name.lower())
    if not corporation_id:
        eve = evelink.eve.EVE()
        corporation_id = eve.character_id_from_name(name)[0]
        if corporation_id == 0:
            raise InvalidCorporationError(name)
        try:
            api = evelink.api.API()
            corp = evelink.corp.Corp(api)
            sheet = corp.corporation_sheet(corp_id=corporation_id)[0]
        except evelink.api.APIError:
            raise InvalidCorporationError(name)
        redis.hset('corporations', sheet['name'], sheet['id'])
    return int(corporation_id)
コード例 #4
0
ファイル: utils.py プロジェクト: J4LP/mumble
def get_corporation_id_by_name(name):
    corporation_id = redis.hget('corporations', name.lower())
    if not corporation_id:
        eve = evelink.eve.EVE()
        corporation_id = eve.character_id_from_name(name)[0]
        if corporation_id == 0:
            raise InvalidCorporationError(name)
        try:
            api = evelink.api.API()
            corp = evelink.corp.Corp(api)
            sheet = corp.corporation_sheet(corp_id=corporation_id)[0]
        except evelink.api.APIError:
            raise InvalidCorporationError(name)
        redis.hset('corporations', sheet['name'], sheet['id'])
    return int(corporation_id)