Move the rest of pokedex.util.get to pokedex.db.util
[zzz-pokedex.git] / pokedex / util / simple.py
1 """Simple lists of things for simple scripts
2
3 If you want to get a pokemon list, and you don't want it to include three
4 Wormadams and a whole bunch of Rotoms because of how the database is
5 structured, this module is for you.
6
7 The returned queries basically contain what a pokedex would show you.
8 You should make no other assumptions about them.
9
10 If you need to make assumptions, feel free to use these functions as examples
11 of what to watch out for.
12 """
13
14 from pokedex.db import tables
15 from pokedex.db.util import filter_base_forms, order_by_name
16
17 def pokemon(session):
18 """Get a "sane" list of pokemon
19
20 WARNING: The result of this function is not very well defined.
21 If you want something specific, build that specific query yourself.
22
23 Currently, all base forms are returned, in evolution-preserving order
24 """
25 query = session.query(tables.Pokemon)
26 query = query.order_by(tables.Pokemon.order)
27 query = filter_base_forms(query)
28 return query
29
30 def moves(session):
31 """Get a "sane" list of moves
32
33 WARNING: The result of this function is not very well defined.
34 If you want something specific, build that specific query yourself.
35
36 Currently, moves from mainline games are returned, sored by name
37 """
38 query = session.query(tables.Move)
39 query = order_by_name(query, tables.Move)
40 query = query.filter(tables.Move.id < 10000)
41 return query
42
43 def types(session):
44 """Get a "sane" list of types
45
46 WARNING: The result of this function is not very well defined.
47 If you want something specific, build that specific query yourself.
48
49 Currently, generation V types are returned, sored by name
50 """
51 query = session.query(tables.Type)
52 query = order_by_name(query, tables.Type)
53 query = query.filter(tables.Type.id < 10000)
54 return query
55
56 def items(session):
57 """Get a "sane" list of items
58
59 WARNING: The result of this function is not very well defined.
60 If you want something specific, build that specific query yourself.
61
62 Currently, items are sored by name
63 """
64 query = session.query(tables.Item)
65 query = order_by_name(query, tables.Item)
66 return query