File: __init__.py

package info (click to toggle)
python-phx-class-registry 4.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 260 kB
  • sloc: python: 886; makefile: 19
file content (51 lines) | stat: -rw-r--r-- 920 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
class Pokemon(object):
    """
    A basic class with some attributes that we can use to test out class
    registries.
    """
    element = None

    def __init__(self, name=None):
        super(Pokemon, self).__init__()

        self.name = name


# Define some classes that we can register.
class Charmander(Pokemon):
    element = 'fire'


class Charmeleon(Pokemon):
    element = 'fire'


class Squirtle(Pokemon):
    element = 'water'


class Wartortle(Pokemon):
    element = 'water'


class Bulbasaur(Pokemon):
    element = 'grass'


class Ivysaur(Pokemon):
    element = 'grass'


class Mew(Pokemon):
    element = 'psychic'


class PokemonFactory(object):
    """
    A factory that can produce new pokémon on demand.  Used to test how
    registries behave when a function is registered instead of a class.
    """

    @classmethod
    def create_psychic_pokemon(cls, name=None):
        return Mew(name)