#---------- 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) + ')'
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()
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]
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
assert(False)
oscraper.wait()
assert(oscraper.returncode == 0)
+
def __str__(self):
return `(self.islands, self.arches)`
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]