Ejemplo n.º 1
0
    def _parse_guild_characters(self, name, realm, site):
        """Page through a guild, creating characters."""
        character_list = []

        log.debug(name + " " + realm + ": Downloading guild page")

        source = self._download_url( \
            WoWSpyderLib.get_guild_url(name, realm, site, page=1))

        character_list.append(self._parse_guild_file(StringIO.StringIO(source), site))

        return WoWSpyderLib.merge(character_list)
Ejemplo n.º 2
0
    def get_guild_rank(self, guild_name, realm, site, character_name):
        """Returns the rank of a character (not specified by object)
        in a guild.
        
        """
        source = self._download_url( \
            WoWSpyderLib.get_guild_url(guild_name, realm, site, page=1))

        guild_rank_search = re.search("name=\"" + character_name + \
            "\".*rank=\"(\d*)\"", unicode(source, "utf-8"))
        if guild_rank_search:
            return int(guild_rank_search.group(1))

        raise IOError("No character in that guild")
Ejemplo n.º 3
0
    def get_guild(self, name, realm, site, get_characters=False, cached=False):
        """Get a guild. Setting get_characters=False will disable the
        behavior that causes the guild characters to also be created. You
        may want to do this for speed increases.
        
        """
        if name is None or name == "": 
            return None

        guild = self._session.query(Guild).get((name, realm, site))

        if cached and guild:
            return guild

        # cflewis | 2009-04-02 | If the downloading fails, the whole guild
        # couldn't be found, so the exception should propagate up.
        source = self._download_url(\
            WoWSpyderLib.get_guild_url(name, realm, site))
        guild = self._parse_guild(StringIO.StringIO(source), site, get_characters=get_characters)

        return guild
Ejemplo n.º 4
0
    def get_url_page(self, page_number):
        log.debug("Returning URL for " + self.name + "," + self.realm + "," + self.site)

        return WoWSpyderLib.get_guild_url(self.name, self.realm, self.site)