artipy

Submodules

artipy.data_gen

Module that handles JSON data for the stats module.

class artipy.data_gen.DataGen(file_name: str)[source]

Bases: object

Handle JSON data.

This is a singleton class that manages JSON data. Each instance of this class is associated with a specific JSON file, and the data from that file is loaded when the instance is created. The data is stored as a list of SimpleNamespace objects, which allows for easy attribute-style access.

_instances

A dictionary that maps file names to DataGen instances.

Type:

dict[str, DataGen]

_data

The data loaded from the JSON file.

Type:

list[SimpleNamespace]

__init__(file_name: str) None[source]

Load the data from the JSON file.

Parameters:

file_name (str) – The name of the file to load.

static __new__(cls, file_name: str) DataGen[source]

Create a new instance of the class if an instance with the same file name does not exist.

Parameters:

file_name (str) – The name of the file to load.

Returns:

The instance of the class.

Return type:

DataGen

artipy.data_gen.camel_to_snake_case(s: str) str[source]

Convert a camel case string to snake case.

Used by in the recursive_namespace function to make attribute names snake_case.

Parameters:

s (str) – The string to convert.

Returns:

The converted string.

Return type:

str

artipy.data_gen.json_to_dict(file_name: str) dict[str, Any][source]

Load JSON data from a file and return it as a dictionary.

Sometimes we just want to load the JSON data as a dictionary instead of a list of SimpleNamespace objects. This function provides a way to do that.

Parameters:

file_name (str) – The name of the file to load.

Returns:

The data from the JSON file.

Return type:

dict[str, Any]

artipy.data_gen.recursive_namespace(data: Any) Any | SimpleNamespace[source]

Recursively convert a dictionary to a SimpleNamespace.

Convert any attribute names from camelCase to snake_case for consistency.

Parameters:

data (Any) – The data to convert.

Returns:

The converted data.

Return type:

Any | SimpleNamespace

artipy.types

Module containing the types used in the artipy package.

class artipy.types.ArtifactSet(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

The artifact sets in Genshin Impact.

ADVENTURER = 'Adventurer'
ARCHAIC_PETRA = 'Archaic Petra'
BERSERKER = 'Berserker'
BLIZZARD_STRAYER = 'Blizzard Strayer'
BLOODSTAINED_CHIVALRY = 'Bloodstained Chivalry'
BRAVE_HEART = 'Brave Heart'
CRIMSON_WITCH_OF_FLAMES = 'Crimson Witch of Flames'
DEEPWOOD_MEMORIES = 'Deepwood Memories'
DEFENDERS_WILL = "Defender's Will"
DESERT_PAVILION_CHRONICLE = 'Desert Pavilion Chronicle'
ECHOES_OF_AN_OFFERING = 'Echoes of an Offering'
EMBLEM_OF_SEVERED_FATE = 'Emblem of Severed Fate'
FLOWER_OF_PARADISE_LOST = 'Flower of Paradise Lost'
GAMBLER = 'Gambler'
GILDED_DREAMS = 'Gilded Dreams'
GLADIATORS_FINALE = "Gladiator's Finale"
GOLDEN_TROUPE = 'Golden Troupe'
HEART_OF_DEPTH = 'Heart of Depth'
HUSK_OF_OPULENT_DREAMS = 'Husk of Opulent Dreams'
INSTRUCTOR = 'Instructor'
LAVAWALKER = 'Lavawalker'
LUCKY_DOG = 'Lucky Dog'
MAIDEN_BELOVED = 'Maiden Beloved'
MARECHAUSSEE_HUNTER = 'Marechaussee Hunter'
MARTIAL_ARTIST = 'Martial Artist'
NIGHTTIME_WHISPERS_IN_THE_ECHOING_WOODS = 'Nighttime Whispers in the Echoing Woods'
NOBLESSE_OBLIGE = 'Noblesse Oblige'
NYMPHS_DREAM = "Nymph's Dream"
OCEAN_HUED_CLAM = 'Ocean-Hued Clam'
PALE_FLAME = 'Pale Flame'
PRAYERS_FOR_DESTINY = 'Prayers for Destiny'
PRAYERS_FOR_ILLUMINATION = 'Prayers for Illumination'
PRAYERS_FOR_WISDOM = 'Prayers for Wisdom'
PRAYERS_TO_SPRINGTIME = 'Prayers to Springtime'
RESOLUTION_OF_SOJOURNER = 'Resolution of Sojourner'
RETRACING_BOLIDE = 'Retracing Bolide'
SCHOLAR = 'Scholar'
SHIMENAWAS_REMINISCENCE = "Shimenawa's Reminiscence"
SONG_OF_DAYS_PAST = 'Song of Days Past'
TENACITY_OF_THE_MILLELITH = 'Tenacity of the Millelith'
THE_EXILE = 'The Exile'
THUNDERING_FURY = 'Thundering Fury'
THUNDERSOOTHER = 'Thundersoother'
TINY_MIRACLE = 'Tiny Miracle'
TRAVELING_DOCTOR = 'Traveling Doctor'
VERMILLION_HEREAFTER = 'Vermillion Hereafter'
VIRIDESCENT_VENERER = 'Viridescent Venerer'
VOURUKASHAS_GLOW = "Vourukasha's Glow"
WANDERERS_TROUPE = "Wanderer's Troupe"
static _generate_next_value_(name, start, count, last_values)

Return the lower-cased version of the member name.

class artipy.types.ArtifactSetData(*, set_name: str, set_effects: dict[str, str], pieces: dict[ArtifactSlot, dict[str, str]])[source]

Bases: object

Data class representing an artifact set in Genshin Impact.

pieces: dict[ArtifactSlot, dict[str, str]]
set_effects: dict[str, str]
set_name: str
class artipy.types.ArtifactSlot(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

Enum representing the artifact slots in Genshin Impact.

CIRCLET = 'circlet'
FLOWER = 'flower'
GOBLET = 'goblet'
PLUME = 'plume'
SANDS = 'sands'
static _generate_next_value_(name, start, count, last_values)

Return the lower-cased version of the member name.

class artipy.types.RollMagnitude(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

The roll magnitude of a substat. This is a measure of how much the substat has been increased in relation to its maximum potential value.

HIGH = 'high'
LOW = 'low'
MAX = 'max'
MEDIUM = 'medium'
static _generate_next_value_(name, start, count, last_values)

Return the lower-cased version of the member name.

classmethod closest(value: Decimal | float | int) RollMagnitude[source]

The closest roll magnitude to a value.

Parameters:

value (Decimal | float | int) – The value to find the closest roll magnitude

Returns:

The closest roll magnitude to the value.

Return type:

RollMagnitude

property magnitude: Decimal

Get the magnitude of the roll magnitude.

Returns:

The magnitude of the roll magnitude.

Return type:

Decimal

class artipy.types.StatType(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

Enumeration of stat types in Genshin Impact.

ANEMO_DMG = 'FIGHT_PROP_WIND_ADD_HURT'
ATK = 'FIGHT_PROP_ATTACK'
ATK_PERCENT = 'FIGHT_PROP_ATTACK_PERCENT'
CRIT_DMG = 'FIGHT_PROP_CRITICAL_HURT'
CRIT_RATE = 'FIGHT_PROP_CRITICAL'
CRYO_DMG = 'FIGHT_PROP_ICE_ADD_HURT'
DEF = 'FIGHT_PROP_DEFENSE'
DEF_PERCENT = 'FIGHT_PROP_DEFENSE_PERCENT'
DENDRO_DMG = 'FIGHT_PROP_GRASS_ADD_HURT'
ELECTRO_DMG = 'FIGHT_PROP_ELEC_ADD_HURT'
ELEMENTAL_MASTERY = 'FIGHT_PROP_ELEMENT_MASTERY'
ENERGY_RECHARGE = 'FIGHT_PROP_CHARGE_EFFICIENCY'
GEO_DMG = 'FIGHT_PROP_ROCK_ADD_HURT'
HEALING_BONUS = 'FIGHT_PROP_HEAL_ADD'
HP = 'FIGHT_PROP_HP'
HP_PERCENT = 'FIGHT_PROP_HP_PERCENT'
HYDRO_DMG = 'FIGHT_PROP_WATER_ADD_HURT'
PHYSICAL_DMG = 'FIGHT_PROP_PHYSICAL_ADD_HURT'
PYRO_DMG = 'FIGHT_PROP_FIRE_ADD_HURT'
static _generate_next_value_(name, start, count, last_values)

Return the lower-cased version of the member name.

property is_pct: bool
artipy.types.generate_artifact_sets() None[source]

Use this if artifactNames_gen.json ever changes.

artipy.types.key_to_constant(key: str) str[source]

Get a constant name from a key i.e: PascalCase -> PASCAL_CASE

Parameters:

key (str) – The key to convert.

Returns:

The converted key.

Return type:

str

artipy.types.make_artifact_sets() Iterator[ArtifactSetData][source]

Make artifact sets from the artifact data.

Yields:

Iterator[ArtifactSetData] – The artifact set data.