# Path: battlenet/enums.py
# RACE = {
#     1: 'Human',
#     2: 'Orc',
#     3: 'Dwarf',
#     4: 'Night Elf',
#     5: 'Undead',
#     6: 'Tauren',
#     7: 'Gnome',
#     8: 'Troll',
#     9: 'Goblin',
#     10: 'Blood Elf',
#     11: 'Draenei',
#     22: 'Worgen',
# }
# 
# CLASS = {
#     1: 'Warrior',
#     2: 'Paladin',
#     3: 'Hunter',
#     4: 'Rogue',
#     5: 'Priest',
#     7: 'Shaman',
#     8: 'Mage',
#     9: 'Warlock',
#     11: 'Druid',
#     6: 'Death Knight',
# }
# 
# QUALITY = {
#     1: 'Common',
#     2: 'Uncommon',
#     3: 'Rare',
#     4: 'Epic',
#     5: 'Legendary',
# }
# 
# RACE_TO_FACTION = {
#     1: 'Alliance',
#     2: 'Horde',
#     3: 'Alliance',
#     4: 'Alliance',
#     5: 'Horde',
#     6: 'Horde',
#     7: 'Alliance',
#     8: 'Horde',
#     9: 'Horde',
#     10: 'Horde',
#     11: 'Alliance',
#     22: 'Alliance',
# }
# 
# Path: battlenet/utils.py
# def make_icon_url(region, icon, size='large'):
#     if not icon:
#         return ''
# 
#     if size == 'small':
#         size = 18
#     else:
#         size = 56
# 
#     return 'http://%s.media.blizzard.com/wow/icons/%d/%s.jpg' % (region, size, icon)
# 
# def normalize(name):
#     if not isinstance(name, unicode):
#         name = name.decode('utf8')
# 
#     return unicodedata.normalize('NFKC', name).encode('utf8')
# 
# def make_connection():
#     if not hasattr(make_connection, 'Connection'):
#         from .connection import Connection
#         make_connection.Connection = Connection
# 
#     return make_connection.Connection()


import operator
import collections
import datetime
    import simplejson as json
    import json
from .enums import RACE, CLASS, QUALITY, RACE_TO_FACTION
from .utils import make_icon_url, normalize, make_connection
            and self.get_realm_name() == other.get_realm_name()

    def _populate_data(self, data):
        self._data = data

        self.name = normalize(data['name'])
        self.level = data['level']
        self.class_ = data['class']
        self.race = data['race']
        self.thumbnail = data['thumbnail']
        self.gender = data['gender']
        self.achievement_points = data['achievementPoints']
        self.faction = RACE_TO_FACTION[self.race]

        if Character.GUILD in self._fields and Character.GUILD not in self._data:
            self._data[Character.GUILD] = None

        if 'lastModified' in data:
            self.last_modified = datetime.datetime.fromtimestamp(data['lastModified'] / 1000)
        else:
            self.last_modified = None

        if 'pets' in data:
            self.pets = [Pet(pet) for pet in self._data['pets']]

    @property
    def realm(self):
        if not hasattr(self, '_realm'):
            self._realm = Realm(self.region, self._data['realm'], connection=self.connection)


# Path: battlenet/enums.py
# RACE = {
#     1: 'Human',
#     2: 'Orc',
#     3: 'Dwarf',
#     4: 'Night Elf',
#     5: 'Undead',
#     6: 'Tauren',
#     7: 'Gnome',
#     8: 'Troll',
#     9: 'Goblin',
#     10: 'Blood Elf',
#     11: 'Draenei',
#     22: 'Worgen',
# }
# 
# CLASS = {
#     1: 'Warrior',
#     2: 'Paladin',
#     3: 'Hunter',
#     4: 'Rogue',
#     5: 'Priest',
#     7: 'Shaman',
#     8: 'Mage',
#     9: 'Warlock',
#     11: 'Druid',
#     6: 'Death Knight',
# }
# 
# QUALITY = {
#     1: 'Common',
#     2: 'Uncommon',
#     3: 'Rare',
#     4: 'Epic',
#     5: 'Legendary',
# }
# 
# RACE_TO_FACTION = {
#     1: 'Alliance',
#     2: 'Horde',
#     3: 'Alliance',
#     4: 'Alliance',
#     5: 'Horde',
#     6: 'Horde',
#     7: 'Alliance',
#     8: 'Horde',
#     9: 'Horde',
#     10: 'Horde',
#     11: 'Alliance',
#     22: 'Alliance',
# }
# 
# Path: battlenet/utils.py
# def make_icon_url(region, icon, size='large'):
#     if not icon:
#         return ''
# 
#     if size == 'small':
#         size = 18
#     else:
#         size = 56
# 
#     return 'http://%s.media.blizzard.com/wow/icons/%d/%s.jpg' % (region, size, icon)
# 
# def normalize(name):
#     if not isinstance(name, unicode):
#         name = name.decode('utf8')
# 
#     return unicodedata.normalize('NFKC', name).encode('utf8')
# 
# def make_connection():
#     if not hasattr(make_connection, 'Connection'):
#         from .connection import Connection
#         make_connection.Connection = Connection
# 
#     return make_connection.Connection()


# Path: battlenet/things.py
import operator
import collections
import datetime
    import simplejson as json
    import json
from .enums import RACE, CLASS, QUALITY, RACE_TO_FACTION
from .utils import make_icon_url, normalize, make_connection

            and self.get_realm_name() == other.get_realm_name()

    def _populate_data(self, data):
        self._data = data

        self.name = normalize(data['name'])
        self.level = data['level']
        self.class_ = data['class']
        self.race = data['race']
        self.thumbnail = data['thumbnail']
        self.gender = data['gender']
        self.achievement_points = data['achievementPoints']
        self.faction = RACE_TO_FACTION[self.race]

        if Character.GUILD in self._fields and Character.GUILD not in self._data:
            self._data[Character.GUILD] = None

        if 'lastModified' in data:
            self.last_modified = datetime.datetime.fromtimestamp(data['lastModified'] / 1000)
        else:
            self.last_modified = None

        if 'pets' in data:
            self.pets = [Pet(pet) for pet in self._data['pets']]

    @property
    def realm(self):
        if not hasattr(self, '_realm'):
            self._realm = Realm(self.region, self._data['realm'], connection=self.connection)


        return self._realm