コード例 #1
0
ファイル: achievements.py プロジェクト: zanar/pygw2tools
class Gw2Achievement(Base):
    """Map the achievements endpoint

    This class gives access to v2/achievements enpoint.
    For more informations about this endpoint, see:
        - https://wiki.guildwars2.com/wiki/API:2/achievements
        - https://github.com/arenanet/api-cdi/blob/master/v2/achievements/index.js

    This endpoint shows information about achievements
    """
    __tablename__ = "gw2_misc_achievement"
    __table_args__ = endpoint_def('achievements', locale=True)

    # Columns
    id = Column(Integer, primary_key=True)
    name = Column(String, nullable=False)
    description = Column(String, nullable=False)
    icon = Column(String, default=None)
    requirement = Column(String, nullable=False)
    locked_text = Column(String, nullable=False)
    type = Column(String, nullable=False)
    flags = Column(String, nullable=True)
    point_cap = Column(Integer, nullable=True)

    # Relations
    tiers = relationship(
        "_Gw2AchievementTier",
        uselist=True,
        info=rel_json(_Gw2AchievementTier,
                      fn=lambda j, pj: [dict(ach_id=pj['id'], **x)
                                        for x in j]))

    rewards = relationship(
        "_Gw2AchievementReward",
        uselist=True,
        info=rel_json(_Gw2AchievementReward,
                      fn=lambda j, pj: [dict(ach_id=pj['id'], **x)
                                        for x in j]))

    bits = relationship(
        "_Gw2AchievementBit",
        uselist=True,
        info=rel_json(_Gw2AchievementBit,
                      fn=lambda j, pj: [dict(ach_id=pj['id'], **x)
                                        for x in j]))

    prerequisites = relationship(
        "Gw2Achievement",
        secondary="gw2_misc_achievement_req_rel",
        primaryjoin="_Gw2AchievementRequires.ach_id == Gw2Achievement.id",
        secondaryjoin="_Gw2AchievementRequires.req_id == Gw2Achievement.id",
        uselist=True,
        info=rel_json(_Gw2AchievementRequires,
                      fn=lambda j, pj: [{
                          'ach_id': pj['id'],
                          'req_id': x
                      } for x in j]))
コード例 #2
0
ファイル: recipes.py プロジェクト: zanar/pygw2tools
class Gw2Recipe(Base):
    """Map the recipes endpoint

    This class gives access to v2/recipes enpoint.
    For more informations about this endpoint, see:
        - https://wiki.guildwars2.com/wiki/API:2/recipes
        - https://github.com/arenanet/api-cdi/blob/master/v2/recipes.js

    This endpoint shows information about recipes
    """
    __tablename__ = "gw2_item_recipe"
    __table_args__ = endpoint_def('recipes', workers=10)

    # Columns
    id = Column(Integer, primary_key=True)
    type = Column(String, nullable=False)
    output_item_id = Column(Integer,
                            ForeignKey("gw2_item_item.id"),
                            nullable=False)
    output_item_count = Column(Integer, nullable=False)
    output_upgrade_id = Column(Integer,
                               ForeignKey("gw2_item_guild_upgrade.id"))
    time_to_craft_ms = Column(Integer, nullable=False)
    disciplines = Column(String)
    min_rating = Column(Integer, nullable=False)
    flags = Column(String)
    chat_link = Column(String, nullable=False)

    # Relations
    output_items = relationship("Gw2Item", uselist=False)
    output_upgrade = relationship("Gw2GuildUpgrade", uselist=False)

    ingredients = relationship(
        "_Gw2RecipeIngredient",
        uselist=True,
        info=rel_json(
            _Gw2RecipeIngredient,
            fn=lambda j, pj: [dict(recipe_id=pj['id'], **x) for x in j]))

    guild_ingredients = relationship(
        "_Gw2RecipeGUIngredient",
        uselist=True,
        info=rel_json(
            _Gw2RecipeGUIngredient,
            fn=lambda j, pj: [dict(recipe_id=pj['id'], **x) for x in j]))

    unlocker = relationship(
        "Gw2ConsumableItem",
        primaryjoin="Gw2ConsumableItem.recipe_id == Gw2Recipe.id",
        uselist=False)
コード例 #3
0
ファイル: masteries.py プロジェクト: zanar/pygw2tools
class Gw2Mastery(Base):
    """Map the masteries endpoint

    This class gives access to v2/masteries enpoint.
    For more informations about this endpoint, see:
        - https://wiki.guildwars2.com/wiki/API:2/masteries
        - https://github.com/arenanet/api-cdi/blob/master/v2/masteries.js

    This endpoint shows information about masteries
    """
    __tablename__ = "gw2_pro_mastery"
    __table_args__ = endpoint_def('masteries', locale=True, workers=1)

    id = Column(Integer, primary_key=True)
    name = Column(String, nullable=False)
    requirement = Column(String, nullable=False)
    order = Column(Integer, nullable=False)
    background = Column(String, nullable=False)
    region = Column(String, nullable=False)

    levels = relationship(
        "_Gw2MasteryLevel",
        uselist=True,
        info=rel_json(
            _Gw2MasteryLevel,
            fn=lambda j, pj: [dict(mastery_id=pj['id'], **x) for x in j]))
コード例 #4
0
ファイル: achievements.py プロジェクト: zanar/pygw2tools
class Gw2AchievementGroup(Base):
    """Map the achievements/groups endpoint

    This class gives access to v2/achievements/groups endpoint.
    For more informations about this endpoint, see:
        - https://wiki.guildwars2.com/wiki/API:2/achievements/groups
        - https://github.com/arenanet/api-cdi/blob/master/v2/achievements/groups.js

    This endpoint shows information about achievements groups
    """
    __tablename__ = "gw2_misc_achievement_group"
    __table_args__ = endpoint_def('achievements/groups',
                                  locale=True,
                                  workers=1)

    # Columns
    pkid = Column(Integer, primary_key=True)
    id = Column(String, unique=True, nullable=False)
    name = Column(String, nullable=False)
    description = Column(String, nullable=False)
    order = Column(Integer, nullable=False)

    # Relations
    categories = relationship(
        "Gw2AchievementCategory",
        secondary="gw2_misc_achievement_group_rel",
        uselist=True,
        info=rel_json(_Gw2AchievementGrouping,
                      fn=lambda j, pj:
                      [dict(group_id=pj['id'], category_id=x) for x in j]))
コード例 #5
0
class Gw2Story(Base):
    """Map the stories endpoint

    This class gives access to v2/stories enpoint and subendpoints.
    For more informations about this endpoint, see:
        - https://wiki.guildwars2.com/wiki/API:2/stories
        - https://github.com/arenanet/api-cdi/blob/master/v2/stories/index.js

    This endpoint shows information about stories
    """
    __tablename__ = "gw2_sto_story"
    __table_args__ = endpoint_def('stories', locale=True, workers=1)

    # Columns
    id = Column(Integer, primary_key=True)
    season = Column(String, ForeignKey("gw2_sto_season.id"), nullable=False)
    name = Column(String, nullable=False)
    description = Column(String, nullable=False)
    timeline = Column(String, nullable=False)
    level = Column(Integer, nullable=False)
    order = Column(Integer, nullable=False)
    races = Column(Integer, nullable=True, default='')
    flags = Column(Integer, nullable=True, default='')

    # Relations
    chapters = relationship(
        "_Gw2StoryChapter",
        uselist=True,
        info=rel_json(_Gw2StoryChapter,
                      fn=lambda j, pj: [dict(id=pj['id'], **x) for x in j]))
コード例 #6
0
ファイル: finishers.py プロジェクト: zanar/pygw2tools
class Gw2Finisher(Base):
    """Map the finishers endpoint

    This class gives access to v2/finishers enpoint.
    For more informations about this endpoint, see:
        - https://wiki.guildwars2.com/wiki/API:2/finishers
        - https://github.com/arenanet/api-cdi/blob/master/v2/finishers.js

    This endpoint shows information about finishers
    """
    __tablename__ = "gw2_misc_finisher"
    __table_args__ = endpoint_def('finishers', locale=True, workers=1)

    # Columns
    id = Column(Integer, primary_key=True)
    name = Column(String, nullable=False)
    unlock_details = Column(String, nullable=False)
    order = Column(Integer, nullable=False)
    icon = Column(String, nullable=False)

    # Relations
    unlock_items = relationship("Gw2Item",
                                secondary="gw2_misc_finisher_item_rel",
                                uselist=True,
                                info=rel_json(_Gw2FinisherUnlock,
                                              fn=lambda j, pj: [{'id': pj['id'], 'item_id': x} for x in j]))
コード例 #7
0
class _Gw2CharacterEquipment(Base):
    """Store the character's current equipment"""
    __tablename__ = "gw2_auth_character_equipment"

    pkid = Column(Integer, primary_key=True)
    char_id = Column(Integer,
                     ForeignKey("gw2_auth_character.name"),
                     nullable=False)
    slot = Column(String, nullable=False)
    id = Column(Integer, ForeignKey("gw2_item_item.id"), nullable=False)
    skin_id = Column(Integer,
                     ForeignKey("gw2_item_skin.id"),
                     nullable=True,
                     info=col_json(keys='skin'))
    binding = Column(String, nullable=True)
    bound_to = Column(String, nullable=True)
    charges = Column(Integer, nullable=True)

    item = relationship("Gw2Item", foreign_keys=[id], uselist=False)
    skin = relationship("Gw2Skin", uselist=False)

    infusions = relationship(
        "Gw2UpgradeItem",
        secondary="gw2_auth_character_equipment_item_infusion_rel",
        uselist=True,
        info=rel_json(_Gw2CharacterEquipmentInfusion,
                      fn=lambda j, pj:
                      [dict(eqp_id=pj['pkid'], infusion_id=x) for x in j]))

    upgrades = relationship(
        "Gw2UpgradeItem",
        secondary="gw2_auth_character_equipment_item_upgrade_rel",
        uselist=True,
        info=rel_json(
            _Gw2CharacterEquipmentUpgrade,
            fn=lambda j, pj: [dict(eqp_id=pj['id'], upgrade_id=x) for x in j]))

    stats = relationship(
        "_Gw2CharacterEquipmentStat",
        uselist=False,
        info=rel_json(_Gw2CharacterEquipmentStat,
                      fn=lambda j, pj: dict(eqp_id=pj['id'],
                                            id=j['id'],
                                            **(j['attributes']
                                               if 'attributes' in j else {
                                                   'aze': 'rty'
                                               }))))
コード例 #8
0
class Gw2Trait(Base):
    """Map the traits endpoint

    This class gives access to v2/traits enpoint.
    For more informations about this endpoint, see:
        - https://wiki.guildwars2.com/wiki/API:2/traits
        - https://github.com/arenanet/api-cdi/blob/master/v2/traits/traits.md

    This endpoint shows information about traits
    """
    __tablename__ = "gw2_pro_trait"
    __table_args__ = endpoint_def('traits', locale=True)

    id = Column(Integer, primary_key=True)
    name = Column(String, nullable=False)
    description = Column(String, nullable=False)
    icon = Column(String, nullable=False)
    specialization = Column(Integer,
                            ForeignKey("gw2_pro_specialization.id"),
                            nullable=False)
    tier = Column(Integer, nullable=False)
    order = Column(Integer, nullable=False)
    slot = Column(String, nullable=False)

    facts = relationship(
        "Gw2Fact",
        primaryjoin=
        "Gw2Trait.id == Gw2Fact.trait_id and Gw2Fact.requires_trait == None",
        uselist=True,
        info=rel_json(Gw2Fact,
                      fn=lambda j, pj: [
                          dict(trait_id=pj['id'], is_traited=False, ord=i, **x)
                          for i, x in enumerate(j)
                      ]))

    traited_facts = relationship(
        "Gw2Fact",
        primaryjoin=
        "Gw2Trait.id == Gw2Fact.trait_id and Gw2Fact.requires_trait != None",
        uselist=True,
        info=rel_json(Gw2Fact,
                      fn=lambda j, pj: [
                          dict(trait_id=pj['id'], is_traited=True, ord=i, **x)
                          for i, x in enumerate(j)
                      ]))

    Gw2Fact.trait_id.append_foreign_key(ForeignKey("gw2_pro_trait.id"))
コード例 #9
0
ファイル: accounts.py プロジェクト: zanar/pygw2tools
class _Gw2AccountBank(Base):
    """Map the account/bank endpoint

    This endpoint shows the stored items in the account bank
    """
    __tablename__ = "gw2_auth_account_bank"
    __table_args__ = endpoint_def('account/bank',
                                  ep_type=EPType.sac,
                                  workers=1,
                                  rights=['account', 'inventories'],
                                  parent='Gw2Token')

    pkid = Column(Integer, primary_key=True)
    id = Column(Integer, ForeignKey("gw2_item_item.id"), nullable=False)
    api_key = Column(String,
                     ForeignKey("gw2_auth_account.api_key"),
                     nullable=False)
    count = Column(Integer, nullable=False)
    skin_id = Column(Integer,
                     ForeignKey("gw2_item_skin.id"),
                     nullable=True,
                     info=col_json(fn='skin'))
    binding = Column(String)
    bound_to = Column(String)
    charges = Column(Integer)

    item = relationship("Gw2Item", uselist=False)
    skin = relationship("Gw2Skin", uselist=False)

    upgrades = relationship(
        "Gw2UpgradeItem",
        secondary="gw2_auth_account_bank_upgrade",
        uselist=True,
        info=rel_json(
            _Gw2AccountBankUpgrade,
            fn=lambda j, pj: [dict(id=pj['pkid'], upgrade_id=x) for x in j]))

    infusions = relationship(
        "Gw2UpgradeItem",
        secondary="gw2_auth_account_bank_infusion",
        uselist=True,
        info=rel_json(
            _Gw2AccountBankUpgrade,
            fn=lambda j, pj: [dict(id=pj['pkid'], infusion_id=x) for x in j]))
コード例 #10
0
ファイル: guild.py プロジェクト: zanar/pygw2tools
class Gw2GuildUpgrade(Base):
    """Map the guild upgrades endpoint

    This class gives access to v2/guild/upgrades enpoint.
    For more informations about this endpoint, see:
        - https://wiki.guildwars2.com/wiki/API:2/guild/upgrades
        - https://github.com/arenanet/api-cdi/blob/master/v2/guild/upgrades.js

    This endpoint shows information about guild upgrades
    """
    __tablename__ = "gw2_item_guild_upgrade"
    __table_args__ = endpoint_def('guild/upgrades', locale=True)

    # Columns
    id = Column(Integer, primary_key=True)
    name = Column(String, nullable=False)
    description = Column(String, nullable=False)
    type = Column(String, nullable=False)
    icon = Column(String, nullable=False)

    bag_max_items = Column(Integer, nullable=True)
    bag_max_coins = Column(Integer, nullable=True)

    build_time = Column(Integer, nullable=False)
    required_level = Column(Integer, nullable=False)
    experience = Column(Integer, nullable=False)

    # Relations
    prerequisites = relationship(
        "Gw2GuildUpgrade",
        secondary="gw2_item_guild_upgrade_req_rel",
        primaryjoin="_Gw2GuildUpgradeReq.id == Gw2GuildUpgrade.id",
        secondaryjoin="_Gw2GuildUpgradeReq.req_id == Gw2GuildUpgrade.id",
        uselist=True,
        info=rel_json(
            _Gw2GuildUpgradeReq,
            fn=lambda j, pj: [dict(id=pj['id'], req_id=x) for x in j]))

    costs = relationship(
        "_Gw2GuildUpgradeCost",
        uselist=True,
        info=rel_json(_Gw2GuildUpgradeCost,
                      fn=lambda j, pj: [dict(id=pj['id'], **x) for x in j]))
コード例 #11
0
ファイル: professions.py プロジェクト: zanar/pygw2tools
class Gw2Profession(Base):
    """Map the professions endpoint

    This class gives access to v2/professions enpoint.
    For more informations about this endpoint, see:
        - https://wiki.guildwars2.com/wiki/API:2/professions
        - https://github.com/arenanet/api-cdi/blob/master/v2/professions.js

    This endpoint shows information about professions
    """
    __tablename__ = "gw2_pro_profession"
    __table_args__ = endpoint_def('professions', locale=True, workers=1)

    pkid = Column(Integer, primary_key=True)
    id = Column(String, unique=True, nullable=False)
    name = Column(String, nullable=False)
    icon = Column(String, nullable=False)
    icon_big = Column(String, nullable=False)

    specializations = relationship("Gw2Specialization", uselist=True)
    training = relationship(
        "_Gw2Training",
        uselist=True,
        info=rel_json(
            _Gw2Training,
            fn=lambda j, pj: [dict(profession=pj['id'], **x) for x in j]))

    weapons = relationship(
        "_Gw2ProfWeapon",
        uselist=True,
        info=rel_json(
            _Gw2ProfWeapon,
            fn=lambda j, pj:
            [dict(prof_id=pj['id'], name=k, **v) for k, v in j.items()]))

    skills = relationship("Gw2Skill",
                          secondary="gw2_pro_profession_skill_rel",
                          uselist=True)
コード例 #12
0
ファイル: professions.py プロジェクト: zanar/pygw2tools
class _Gw2Training(Base):
    __tablename__ = "gw2_pro_training"

    id = Column(Integer, primary_key=True)
    profession = Column(String,
                        ForeignKey("gw2_pro_profession.id"),
                        primary_key=True)
    category = Column(String, nullable=False)
    name = Column(String, nullable=False)

    track = relationship(
        "_Gw2TrainingTrack",
        uselist=True,
        info=rel_json(
            _Gw2TrainingTrack,
            fn=lambda j, pj: [dict(train_id=pj['id'], **x) for x in j]))
コード例 #13
0
ファイル: professions.py プロジェクト: zanar/pygw2tools
class _Gw2ProfWeapon(Base):
    __tablename__ = "gw2_pro_profession_weapon"

    prof_id = Column(Integer,
                     ForeignKey("gw2_pro_profession.pkid"),
                     primary_key=True)
    name = Column(String, primary_key=True)
    spec_id = Column(Integer,
                     ForeignKey("gw2_pro_specialization.id"),
                     nullable=True,
                     info=col_json(fn='specialization'))

    specialization = relationship("Gw2Specialization", uselist=False)
    skills = relationship(
        "_Gw2ProfWeaponSkill",
        uselist=True,
        info=rel_json(
            _Gw2ProfWeaponSkill,
            fn=lambda j, pj:
            [dict(prof_id=pj['prof_id'], weapon=pj['name'], **x) for x in j]))
コード例 #14
0
class Gw2EmblemBackground(Base):
    """Map the emblem/backgrounds endpoint

    This class gives access to v2/emblem/backgrounds enpoint.
    For more informations about this endpoint, see:
        - https://wiki.guildwars2.com/wiki/API:2/emblem
        - https://github.com/arenanet/api-cdi/blob/master/v2/emblems/emblems.js

    This endpoint shows information about emblems backgrounds
    """
    __tablename__ = "gw2_misc_emblem_back"
    __table_args__ = endpoint_def('emblem/backgrounds', workers=1)

    # Columns
    id = Column(Integer, primary_key=True)

    # Relations
    layers = relationship(
        "_Gw2EmblemBackgroundLayer",
        uselist=True,
        info=rel_json(
            _Gw2EmblemBackgroundLayer,
            fn=lambda j, pj: [dict(emblem_id=pj['id'], layer=x) for x in j]))
コード例 #15
0
ファイル: materials.py プロジェクト: zanar/pygw2tools
class Gw2Material(Base):
    """Map the materials endpoint

    This class gives access to v2/colors enpoint.
    For more informations about this endpoint, see:
        - https://wiki.guildwars2.com/wiki/API:2/materials
        - https://github.com/arenanet/api-cdi/blob/master/v2/materials.js

    This endpoint shows information about materials
    """
    __tablename__ = "gw2_item_material"
    __table_args__ = endpoint_def('materials', locale=True, workers=1)

    # Columns
    id = Column(Integer, primary_key=True)
    name = Column(String, nullable=False)
    order = Column(Integer, nullable=False)

    # Relations
    items = relationship("Gw2Item",
                         secondary="gw2_item_material_item_rel",
                         uselist=True,
                         info=rel_json(_Gw2MaterialItem,
                                       fn=lambda j, pj: [dict(material_id=pj['id'], item_id=x) for x in j]))
コード例 #16
0
class Gw2Dye(Base):
    """Map the colors endpoint

    This class gives access to v2/colors enpoint.
    For more informations about this endpoint, see:
        - https://wiki.guildwars2.com/wiki/API:2/colors
        - https://github.com/arenanet/api-cdi/blob/master/v2/colors.js

    This endpoint shows information about a dye
    """
    __tablename__ = "gw2_item_dye"
    __table_args__ = endpoint_def('colors', locale=True, workers=1)

    # Columns
    id = Column(Integer, primary_key=True)
    name = Column(String, nullable=False)
    item = Column(Integer, ForeignKey("gw2_item_item.id"), nullable=True)

    red = Column(Integer,
                 nullable=False,
                 info=col_json(keys='base_rgb', fn=lambda j, pj: j[0]),
                 default=0)
    green = Column(Integer,
                   nullable=False,
                   info=col_json(keys='base_rgb', fn=lambda j, pj: j[1]),
                   default=0)
    blue = Column(Integer,
                  nullable=False,
                  info=col_json(keys='base_rgb', fn=lambda j, pj: j[2]),
                  default=0)

    hue = Column(String,
                 info=col_json(keys='categories',
                               fn=lambda j, pj: _intersect(j, _dye_hue)),
                 nullable=True)
    material = Column(String,
                      info=col_json(keys='categories',
                                    fn=lambda j, pj: _intersect(j, _dye_mat)),
                      nullable=True)
    rarity = Column(String,
                    info=col_json(keys='categories',
                                  fn=lambda j, pj: _intersect(j, _dye_rar)),
                    nullable=True)

    # Relations
    cloth = relationship(
        "_Gw2DyeDetail",
        primaryjoin=
        "_Gw2DyeDetail.id == Gw2Dye.id and _Gw2DyeDetail.type == 'cloth'",
        uselist=False,
        info=rel_json(_Gw2DyeDetail,
                      fn=lambda j, pj: dict(id=pj['id'], type='cloth', **j)))

    leather = relationship(
        "_Gw2DyeDetail",
        primaryjoin=
        "_Gw2DyeDetail.id == Gw2Dye.id and _Gw2DyeDetail.type == 'leather'",
        uselist=False,
        info=rel_json(_Gw2DyeDetail,
                      fn=lambda j, pj: dict(id=pj['id'], type='leather', **j)))

    metal = relationship(
        "_Gw2DyeDetail",
        primaryjoin=
        "_Gw2DyeDetail.id == Gw2Dye.id and _Gw2DyeDetail.type == 'metal'",
        uselist=False,
        info=rel_json(_Gw2DyeDetail,
                      fn=lambda j, pj: dict(id=pj['id'], type='metal', **j)))
コード例 #17
0
class Gw2Character(Base):
    """Map the characters endpoint

    This class gives access to v2/characters enpoint.
    For more informations about this endpoint, see:
        - https://wiki.guildwars2.com/wiki/API:2/characters
        - https://github.com/arenanet/api-cdi/blob/master/v2/characters/characters.js

    This endpoint shows the informations of a character
    """
    __tablename__ = "gw2_auth_character"
    __table_args__ = endpoint_def('characters',
                                  ep_type=EPType.ac,
                                  workers=3,
                                  rights=['characters'],
                                  parent='Gw2Token')

    id = Column(Integer, primary_key=True)
    name = Column(String, unique=True, nullable=False)
    api_key = Column(String,
                     ForeignKey("gw2_auth_token.api_key"),
                     nullable=False)
    race = Column(String, nullable=False)
    gender = Column(String, nullable=False)
    prof_id = Column(String,
                     ForeignKey("gw2_pro_profession.id"),
                     nullable=False,
                     info=col_json(keys='profession'))
    level = Column(Integer, nullable=False)
    # guild_id = Column(Integer, ForeignKey("gw2_auth_guild.id"), nullable=True)
    age = Column(Integer, nullable=False)
    created = Column(DateTime,
                     nullable=False,
                     info=col_json(keys='created', fn=gw2_to_orm_date))
    deaths = Column(Integer, nullable=False)
    title_id = Column(Integer,
                      ForeignKey("gw2_misc_title.id"),
                      nullable=True,
                      info=col_json(keys='title'))

    backstory = relationship(
        "Gw2BackstoryAnswer",
        secondary="gw2_auth_character_backstory",
        uselist=True,
        info=rel_json(
            _Gw2CharacterBackStory,
            fn=lambda j, pj: [dict(char_id=pj['name'], ans_id=x) for x in j]))
    crafting = relationship(
        "_Gw2CharacterCraft",
        uselist=True,
        info=rel_json(
            _Gw2CharacterCraft,
            fn=lambda j, pj: [dict(char_id=pj['name'], **x) for x in j]))
    equipment = relationship(
        "_Gw2CharacterEquipment",
        uselist=True,
        info=rel_json(
            _Gw2CharacterEquipment,
            fn=lambda j, pj:
            [dict(char_id=pj['name'], **x) for x in j if x is not None]))
    # guild = relationship("Gw2Guild", uselist=False)
    inventory = relationship("_Gw2CharacterInventory",
                             uselist=True,
                             info=rel_json(_Gw2CharacterInventory,
                                           keys='bags',
                                           fn=lambda j, pj: [
                                               dict(char_id=pj['name'], **inv)
                                               for bag in j if bag is not None
                                               for inv in bag['inventory']
                                               if inv is not None
                                           ]))
    profession = relationship("Gw2Profession", uselist=False)
    skills = relationship(
        "_Gw2CharacterSkill",
        uselist=True,
        info=rel_json(
            _Gw2CharacterSkill,
            fn=lambda j, pj:
            [dict(char_id=pj['name'], type=k, **v) for k, v in j.items()]))
    specializations = relationship(
        "_Gw2CharacterSpecialization",
        uselist=True,
        info=rel_json(_Gw2CharacterSpecialization,
                      fn=lambda j, pj: [
                          dict(char_id=pj['name'], type=k, **_v)
                          for k, v in j.items() for _v in v if _v is not None
                      ]))
    title = relationship("Gw2Title", uselist=False)
    training = relationship(
        "_Gw2CharacterTrain",
        uselist=True,
        info=rel_json(
            _Gw2CharacterTrain,
            fn=lambda j, pj: [dict(char_id=pj['name'], **x) for x in j]))
コード例 #18
0
class Gw2Skill(Base):
    """Map the skills endpoint

    This class gives access to v2/skills enpoint.
    For more informations about this endpoint, see:
        - https://wiki.guildwars2.com/wiki/API:2/skills
        - https://github.com/arenanet/api-cdi/blob/master/v2/skills/skills.js

    This endpoint shows information about skills
    """
    __tablename__ = "gw2_pro_skill"
    __table_args__ = endpoint_def('skills', locale=True)

    id = Column(Integer, primary_key=True)
    name = Column(String, nullable=False)
    description = Column(String, nullable=True)
    icon = Column(String, nullable=False)
    chat_link = Column(String, nullable=False)
    type = Column(String, nullable=False)
    weapon_type = Column(String, nullable=False)
    slot = Column(String, nullable=False)
    flags = Column(String, nullable=True)
    attunement = Column(String, nullable=True)
    cost = Column(Integer, nullable=True)
    categories = Column(String, nullable=True)
    initiative = Column(Integer, nullable=True)
    dual_wield = Column(String, nullable=True)
    flip_skill = Column(Integer, ForeignKey("gw2_pro_skill.id"), nullable=True)
    next_chain = Column(Integer, ForeignKey("gw2_pro_skill.id"), nullable=True)
    prev_chain = Column(Integer, ForeignKey("gw2_pro_skill.id"), nullable=True)
    toolbelt_skill = Column(Integer, ForeignKey("gw2_pro_skill.id"), nullable=True)

    professions = relationship("Gw2Profession",
                               secondary="gw2_pro_profession_skill_rel",
                               uselist=True,
                               info=rel_json(_Gw2ProfSkill,
                                             fn=lambda j, pj: [dict(skill_id=pj['id'], prof_id=x) for x in j]))

    flip = relationship("Gw2Skill", foreign_keys=[flip_skill], remote_side=[id], uselist=False)

    next = relationship("Gw2Skill", foreign_keys=[next_chain], remote_side=[id], uselist=False)

    facts = relationship("Gw2Fact",
                         primaryjoin="Gw2Skill.id == Gw2Fact.skill_id and Gw2Fact.requires_trait == None",
                         uselist=True,
                         info=rel_json(Gw2Fact,
                                       fn=lambda j, pj: [dict(skill_id=pj['id'], is_traited=False, ord=i, **x) for i, x in enumerate(j)]))

    traited_facts = relationship("Gw2Fact",
                                 primaryjoin="Gw2Skill.id == Gw2Fact.skill_id and Gw2Fact.requires_trait != None",
                                 uselist=True,
                                 info=rel_json(Gw2Fact,
                                               fn=lambda j, pj: [dict(skill_id=pj['id'], is_traited=True, ord=i, **x) for i, x in enumerate(j)]))

    bundle_skills = relationship("Gw2Skill",
                                 secondary="gw2_pro_skill_bundle_skill_rel",
                                 primaryjoin="_Gw2BundleSkill.skill_id == Gw2Skill.id",
                                 secondaryjoin="_Gw2BundleSkill.bundle_id == Gw2Skill.id",
                                 uselist=True,
                                 info=rel_json(_Gw2BundleSkill,
                                               fn=lambda j, pj: [dict(skill_id=pj['id'], bundle_id=x) for x in list(set(j))]))

    transform_skills = relationship("Gw2Skill",
                                    secondary="gw2_pro_skill_transform_skill_rel",
                                    primaryjoin="_Gw2TransformSkill.skill_id == Gw2Skill.id",
                                    secondaryjoin="_Gw2TransformSkill.trans_id == Gw2Skill.id",
                                    uselist=True,
                                    info=rel_json(_Gw2TransformSkill,
                                                  fn=lambda j, pj: [dict(skill_id=pj['id'], trans_id=x) for x in list(set(j))]))

    toolbelt = relationship("Gw2Skill",
                            foreign_keys=[toolbelt_skill],
                            remote_side=[id],
                            uselist=False)

    Gw2Fact.skill_id.append_foreign_key(ForeignKey("gw2_pro_skill.id"))
コード例 #19
0
class Gw2Guild(Base):
    """Map the guild/:id endpoint

    This class gives access to v2/guild/:id enpoint.
    For more informations about this endpoint, see:
        - https://wiki.guildwars2.com/wiki/API:2/guild/:id
        - https://github.com/arenanet/api-cdi/blob/master/v2/guild/details.js

    This endpoint shows the informations of a guild
    """
    __tablename__ = "gw2_auth_guild"
    __table_args__ = endpoint_def('guild/%s',
                                  EPType.psac,
                                  workers=3,
                                  parent='Gw2Account')

    pkid = Column(Integer, primary_key=True)
    id = Column(String, primary_key=True)
    api_key = Column(String,
                     ForeignKey("gw2_auth_account.api_key"),
                     primary_key=True)
    name = Column(String, nullable=False)
    tag = Column(String, nullable=False)
    level = Column(Integer)
    motd = Column(String)
    influence = Column(Integer)
    aetherium = Column(Integer)
    favor = Column(Integer)
    emblem_bid = Column(Integer,
                        ForeignKey("gw2_misc_emblem_back_layer.emblem_id"),
                        nullable=False,
                        info=col_json(keys=['emblem', 'background', 'id']))
    emblem_fid = Column(Integer,
                        ForeignKey("gw2_misc_emblem_fore_layer.emblem_id"),
                        nullable=False,
                        info=col_json(keys=['emblem', 'foreground', 'id']))
    emblem_flags = Column(String,
                          nullable=False,
                          info=col_json(keys=['emblem', 'flags']))

    emblem_back = relationship("_Gw2EmblemBackgroundLayer", uselist=True)
    emblem_back_colors = relationship(
        "Gw2Dye",
        secondary="gw2_auth_guild_emblem_back_color",
        info=rel_json(_Gw2GuildEmblemBackColor,
                      keys=['emblem', 'background', 'colors'],
                      fn=lambda j, pj: [{
                          'color_id': x,
                          'order': i,
                          'guild_pkid': pj['pkid']
                      } for i, x in enumerate(j)]))
    emblem_fore = relationship("_Gw2EmblemForegroundLayer", uselist=True)
    emblem_fore_colors = relationship(
        "Gw2Dye",
        secondary="gw2_auth_guild_emblem_fore_color",
        info=rel_json(_Gw2GuildEmblemForeColor,
                      keys=['emblem', 'foreground', 'colors'],
                      fn=lambda j, pj: [{
                          'color_id': x,
                          'order': i,
                          'guild_pkid': pj['pkid']
                      } for i, x in enumerate(j)]))

    @staticmethod
    def from_parent(_pjson):
        ids = [(x, ) for x in _pjson['guild_leader']]
        ids.extend([(x, ) for x in _pjson['guilds']
                    if x not in _pjson['guild_leader']])
        return (ids, None)