From: Ian Jackson Date: Sun, 16 Jan 2011 17:19:25 +0000 (+0000) Subject: yoweb-scrape: wip new flag and ocean functionality - abolish collect() X-Git-Tag: 6.8.0~4 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-live.git;a=commitdiff_plain;h=4488c88f213df763a009306203e2318e06647c18 yoweb-scrape: wip new flag and ocean functionality - abolish collect() --- diff --git a/yoweb-scrape b/yoweb-scrape index d2557b5..53da06e 100755 --- a/yoweb-scrape +++ b/yoweb-scrape @@ -519,16 +519,14 @@ class FlagInfo(SomethingSoupInfo): #---------- scraper for ocean info incl. embargoes etc. ---------- class IslandBasicInfo(): - # Public members: + # Public data attributes: # ocean # name - # Public members maybe set by caller: + # Public data attributes maybe set by caller: # arch def __init__(self, ocean, islename): self.ocean = ocean self.name = islename - def collect(self): - pass def yppedia(self): def q(x): return urllib.quote(x.replace(' ','_')) url_rhs = q(self.name) + '_(' + q(self.ocean) + ')' @@ -537,15 +535,17 @@ class IslandBasicInfo(): return `(self.ocean, self.name)` class IslandExtendedInfo(IslandBasicInfo): - # Public members (inherited): + # Public data attributes (inherited): # ocean # name - # Public members (additional): + # Public data attributes (additional): # islandid # yoweb_url # flagid - def collect(self): - IslandBasicInfo.collect(self) + def __init__(self, ocean, islename): + IslandBasicInfo.__init__(self, ocean, islename) + self.islandid = None + self.yoweb_url = None self._collect_yoweb() self._collect_flagid() @@ -591,13 +591,13 @@ class IslandExtendedInfo(IslandBasicInfo): self.yoweb_url, self.flagid)` class OceanInfo(): - # Public data attributes (valid after collect()): + # Public data attributes: # oi.islands[islename] = IslandInfo(...) # oi.arches[archname][islename] = IslandInfo(...) def __init__(self, isleclass=IslandBasicInfo): self.isleclass = isleclass self.ocean = fetcher.ocean.lower().capitalize() - def collect(self): + cmdl = ['./yppedia-ocean-scraper'] if opts.localhtml is not None: cmdl += ['--local-html-dir',opts.localhtml] @@ -628,7 +628,6 @@ class OceanInfo(): islename = m.group(1) isle = self.isleclass(self.ocean, islename) isle.arch = archname - isle.collect() self.islands[islename] = isle self.arches[archname][islename] = isle continue @@ -641,6 +640,7 @@ class OceanInfo(): assert(False) oscraper.wait() assert(oscraper.returncode == 0) + def __str__(self): return `(self.islands, self.arches)` @@ -1327,7 +1327,6 @@ def do_ocean(args, bu): if (len(args)): bu('ocean takes no further arguments') fetcher.default_ocean() oi = OceanInfo(IslandExtendedInfo) - oi.collect() print oi for islename in sorted(oi.islands.keys()): isle = oi.islands[islename]