CacheManager
pokelance.cache.cache_manager
⚓︎
Base
⚓︎
Base class for all caches.
Attributes:
Name | Type | Description |
---|---|---|
max_size |
int
|
The maximum cache size. |
set_client(client)
⚓︎
Set the client for the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
PokeLance
|
The client to set. |
required |
Source code in pokelance/cache/cache_manager.py
set_size(max_size=100)
⚓︎
Set the maximum cache size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_size |
int
|
The maximum cache size. |
100
|
Source code in pokelance/cache/cache_manager.py
BaseCache(max_size=100)
⚓︎
Bases: MutableMapping[_KT, _VT]
Base class for all caches.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_size |
int
|
The maximum size of the cache. |
100
|
Attributes:
Name | Type | Description |
---|---|---|
_max_size |
int
|
The maximum size of the cache. |
_cache |
Dict[_KT, _VT]
|
The cache itself. |
_endpoints |
Dict[str, int]
|
The endpoints that are cached. |
_endpoints_cached |
bool
|
Whether or not the endpoints are cached. |
_client |
PokeLance
|
The client that this cache is for. |
Examples:
>>> import asyncio
>>> from pokelance import PokeLance
>>>
>>> async def main():
... client = PokeLance()
... print(await client.ping())
... await asyncio.sleep(5) # Wait for all the endpoints to load automatically. If not just load them manually.
... # from pokelance.http import Endpoint
... # data = await client.http.request(Endpoint.get_berry_endpoints())
... # client.berry._cache.load_documents(str(client.berry.__class__.__name__).lower(), "berry", data)
... # print(client.berry.cache.berry.endpoints)
... # await client.berry.cache.berry.load_all(client.http)
... print(client.berry.cache.berry)
... await client.berry.cache.berry.save('temp') # Save the cache to a file.
... await client.berry.cache.berry.load('temp') # Load the cache from a file.
... print(client.berry.cache.berry)
... await client.close()
>>>
>>> asyncio.run(main())
Source code in pokelance/cache/cache.py
cache: t.Dict[_KT, _VT]
property
⚓︎
endpoints: t.Dict[str, Endpoint]
property
⚓︎
load(path='.')
async
⚓︎
Load the cache from a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
The path to load the cache from. |
'.'
|
Source code in pokelance/cache/cache.py
load_all()
async
⚓︎
Load all documents/data from api into the cache. (Endpoints must be cached first)
Source code in pokelance/cache/cache.py
load_documents(data)
⚓︎
Load documents into the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
List[Dict[str, str]]
|
The data to load. |
required |
Source code in pokelance/cache/cache.py
save(path='.')
async
⚓︎
Save the cache to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
The path to save the cache to. |
'.'
|
Source code in pokelance/cache/cache.py
wait_until_ready()
async
⚓︎
Wait until the all the endpoints are cached.
Berry
⚓︎
Bases: Base
Cache for berry related endpoints.
Attributes:
Name | Type | Description |
---|---|---|
max_size |
int
|
The maximum cache size. |
berry |
BerryCache
|
The berry. |
berry_firmness |
BerryFirmnessCache
|
The berry firmness. |
berry_flavor |
BerryFlavorCache
|
The berry flavor. |
set_client(client)
⚓︎
Set the client for the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
PokeLance
|
The client to set. |
required |
Source code in pokelance/cache/cache_manager.py
set_size(max_size=100)
⚓︎
Set the maximum cache size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_size |
int
|
The maximum cache size. |
100
|
Source code in pokelance/cache/cache_manager.py
Cache
⚓︎
Cache for all endpoints.
Attributes:
Name | Type | Description |
---|---|---|
client |
PokeLance
|
The pokelance client. |
max_size |
int
|
The maximum cache size. |
berry |
Berry
|
The berry cache. |
contest |
Contest
|
The contest cache. |
encounter |
Encounter
|
The encounter cache. |
evolution |
Evolution
|
The evolution cache. |
game |
Game
|
The game cache. |
item |
Item
|
The item cache. |
location |
Location
|
The location cache. |
machine |
Machine
|
The machine cache. |
move |
Move
|
The move cache. |
pokemon |
Pokemon
|
The pokemon cache. |
load_documents(category, _type, data)
⚓︎
Loads the endpoint data into the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
category |
str
|
The category of the endpoint. |
required |
_type |
str
|
The type of the endpoint. |
required |
data |
List[Dict[str, str]]
|
The data to load. |
required |
Source code in pokelance/cache/cache_manager.py
set_size(max_size=100)
⚓︎
Set the maximum cache size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_size |
int
|
The maximum cache size. |
100
|
Source code in pokelance/cache/cache_manager.py
Contest
⚓︎
Bases: Base
Cache for contest related endpoints.
Attributes:
Name | Type | Description |
---|---|---|
max_size |
int
|
The maximum cache size. |
contest_type |
ContestTypeCache
|
The contest type. |
contest_effect |
ContestEffectCache
|
The contest effect. |
super_contest_effect |
SuperContestEffectCache
|
The super contest effect. |
set_client(client)
⚓︎
Set the client for the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
PokeLance
|
The client to set. |
required |
Source code in pokelance/cache/cache_manager.py
set_size(max_size=100)
⚓︎
Set the maximum cache size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_size |
int
|
The maximum cache size. |
100
|
Source code in pokelance/cache/cache_manager.py
Encounter
⚓︎
Bases: Base
Cache for encounter related endpoints.
Attributes:
Name | Type | Description |
---|---|---|
max_size |
int
|
The maximum cache size. |
encounter_method |
EncounterMethodCache
|
The method in which the encounter happens. |
encounter_condition |
EncounterConditionCache
|
The condition in which the encounter happens. |
encounter_condition_value |
EncounterConditionValueCache
|
The condition value in which the encounter happens. |
set_client(client)
⚓︎
Set the client for the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
PokeLance
|
The client to set. |
required |
Source code in pokelance/cache/cache_manager.py
set_size(max_size=100)
⚓︎
Set the maximum cache size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_size |
int
|
The maximum cache size. |
100
|
Source code in pokelance/cache/cache_manager.py
Evolution
⚓︎
Bases: Base
Cache for evolution related endpoints.
Attributes:
Name | Type | Description |
---|---|---|
max_size |
int
|
The maximum cache size. |
evolution_chain |
EvolutionChainCache
|
The evolution chain of a Pokemon. |
evolution_trigger |
EvolutionTriggerCache
|
The trigger in which the evolution happens. |
set_client(client)
⚓︎
Set the client for the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
PokeLance
|
The client to set. |
required |
Source code in pokelance/cache/cache_manager.py
set_size(max_size=100)
⚓︎
Set the maximum cache size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_size |
int
|
The maximum cache size. |
100
|
Source code in pokelance/cache/cache_manager.py
Game
⚓︎
Bases: Base
Cache for game related endpoints.
Attributes:
Name | Type | Description |
---|---|---|
max_size |
int
|
The maximum cache size. |
generation |
GamesGenerationCache
|
The generation of a game. |
pokedex |
GamesPokedexCache
|
The pokedex of a game. |
version |
GamesVersionCache
|
The version of a game. |
version_group |
GamesVersionGroupCache
|
The version group of a game. |
set_client(client)
⚓︎
Set the client for the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
PokeLance
|
The client to set. |
required |
Source code in pokelance/cache/cache_manager.py
set_size(max_size=100)
⚓︎
Set the maximum cache size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_size |
int
|
The maximum cache size. |
100
|
Source code in pokelance/cache/cache_manager.py
Item
⚓︎
Bases: Base
Cache for item related endpoints.
Attributes:
Name | Type | Description |
---|---|---|
max_size |
int
|
The maximum cache size. |
item |
ItemCache
|
The item. |
item_attribute |
ItemAttributeCache
|
The attribute of an item. |
item_category |
ItemCategoryCache
|
The category of an item. |
item_fling_effect |
ItemFlingEffectCache
|
The fling effect of an item. |
item_pocket |
ItemPocketCache
|
The pocket of an item. |
set_client(client)
⚓︎
Set the client for the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
PokeLance
|
The client to set. |
required |
Source code in pokelance/cache/cache_manager.py
set_size(max_size=100)
⚓︎
Set the maximum cache size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_size |
int
|
The maximum cache size. |
100
|
Source code in pokelance/cache/cache_manager.py
Location
⚓︎
Bases: Base
Cache for location related endpoints.
Attributes:
Name | Type | Description |
---|---|---|
max_size |
int
|
The maximum cache size. |
location |
LocationCache
|
The location. |
location_area |
LocationAreaCache
|
The location area. |
set_client(client)
⚓︎
Set the client for the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
PokeLance
|
The client to set. |
required |
Source code in pokelance/cache/cache_manager.py
set_size(max_size=100)
⚓︎
Set the maximum cache size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_size |
int
|
The maximum cache size. |
100
|
Source code in pokelance/cache/cache_manager.py
Machine
⚓︎
Bases: Base
Cache for machine related endpoints.
Attributes:
Name | Type | Description |
---|---|---|
max_size |
int
|
The maximum cache size. |
machine |
MachineCache
|
The machine that teaches a move. |
set_client(client)
⚓︎
Set the client for the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
PokeLance
|
The client to set. |
required |
Source code in pokelance/cache/cache_manager.py
set_size(max_size=100)
⚓︎
Set the maximum cache size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_size |
int
|
The maximum cache size. |
100
|
Source code in pokelance/cache/cache_manager.py
Move
⚓︎
Bases: Base
Cache for move related endpoints.
Attributes:
Name | Type | Description |
---|---|---|
max_size |
int
|
The maximum cache size. |
move |
MoveCache
|
The move. |
move_ailment |
MoveAilmentCache
|
The ailment of a move. |
move_battle_style |
MoveBattleStyleCache
|
The battle style of a move. |
move_category |
MoveCategoryCache
|
The category of a move. |
move_damage_class |
MoveDamageClassCache
|
The damage class of a move. |
move_learn_method |
MoveLearnMethodCache
|
The learn method of a move. |
move_target |
MoveTargetCache
|
The target of a move. |
set_client(client)
⚓︎
Set the client for the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
PokeLance
|
The client to set. |
required |
Source code in pokelance/cache/cache_manager.py
set_size(max_size=100)
⚓︎
Set the maximum cache size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_size |
int
|
The maximum cache size. |
100
|
Source code in pokelance/cache/cache_manager.py
Pokemon
⚓︎
Bases: Base
Cache for pokemon related endpoints.
Attributes:
Name | Type | Description |
---|---|---|
max_size |
int
|
The maximum cache size. |
ability |
AbilityCache
|
The ability. |
characteristic |
CharacteristicCache
|
The characteristic. |
egg_group |
EggGroupCache
|
The egg group. |
gender |
GenderCache
|
The gender cache. |
growth_rate |
GrowthRateCache
|
The growth rate. |
nature |
NatureCache
|
The nature. |
pokeathlon_stat |
PokeathlonStatCache
|
The pokeathlon stat. |
pokemon |
PokemonCache
|
The pokemon. |
pokemon_color |
PokemonColorCache
|
The color of a pokemon. |
pokemon_form |
PokemonFormCache
|
The form of a pokemon. |
pokemon_habitat |
PokemonHabitatCache
|
The habitat of a pokemon. |
pokemon_shape |
PokemonShapeCache
|
The shape of a pokemon. |
pokemon_species |
PokemonSpeciesCache
|
The species of a pokemon. |
stat |
StatCache
|
The stat. |
type |
TypeCache
|
The type. |
set_client(client)
⚓︎
Set the client for the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
PokeLance
|
The client to set. |
required |
Source code in pokelance/cache/cache_manager.py
set_size(max_size=100)
⚓︎
Set the maximum cache size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_size |
int
|
The maximum cache size. |
100
|