chiark / gitweb /
yoweb-scrape: wip new flag and ocean functionality - IslandFlagInfo
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 16 Jan 2011 17:21:15 +0000 (17:21 +0000)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 16 Jan 2011 17:21:15 +0000 (17:21 +0000)
yoweb-scrape

index 53da06e..a2add10 100755 (executable)
@@ -590,6 +590,19 @@ class IslandExtendedInfo(IslandBasicInfo):
                return `(self.ocean, self.islandid, self.name,
                        self.yoweb_url, self.flagid)`
 
+class IslandFlagInfo(IslandExtendedInfo):
+       def __init__(self, ocean, islename):
+               IslandExtendedInfo.__init__(self, ocean, islename)
+               self.flag = None
+               self._collect_flag()
+
+       def _collect_flag(self):
+               if self.flagid is None: return
+               self.flag = FlagInfo(self.flagid, 1800)
+
+       def __str__(self):
+               return IslandExtendedInfo.__str__(self) + '; ' + str(self.flag)
+
 class OceanInfo():
        # Public data attributes:
        #   oi.islands[islename] = IslandInfo(...)
@@ -1326,7 +1339,7 @@ def do_standings_crew_of(args, bu):
 def do_ocean(args, bu):
        if (len(args)): bu('ocean takes no further arguments')
        fetcher.default_ocean()
-       oi = OceanInfo(IslandExtendedInfo)
+       oi = OceanInfo(IslandFlagInfo)
        print oi
        for islename in sorted(oi.islands.keys()):
                isle = oi.islands[islename]