def __getitem__(self, key):
        key = key.replace("_", " ")
        if key in self._cache:
            return self._cache[key]

        if "/" in key:
            filename = "%s/%s" % (self._path, key.replace("/", "---"))
        else:
            filename = "%s/%s" % (self._path, key)
        page = None
        if os.path.exists(filename):
            try:
                page = pickle.load(open(filename, 'rb'))
            except pickle.UnpicklingError:
                page = None
            except __HOLE__:
                print("Error loading %s" % key)
                page = None
            except ImportError:
                print("Error importing %s" % key)
                page = None

        if page is None:
            if key in self._countries:
                raw = [CachedWikipedia.load_page("%s%s" %
                                                 (x, self._countries[key]))
                                                  for x in kCOUNTRY_SUB]
                raw.append(CachedWikipedia.load_page(key))
                print("%s is a country!" % key)
            else:
                raw = [CachedWikipedia.load_page(key)]

            raw = [x for x in raw if not x is None]

            sleep(.3)
            if raw:
                if len(raw) > 1:
                    print("%i pages for %s" % (len(raw), key))
                page = WikipediaPage("\n".join(unidecode(x.content) for
                                               x in raw),
                                     [y for y in
                                      x.links
                                      for x in raw],
                                     [y for y in
                                      x.categories
                                      for x in raw])

                print("Writing file to %s" % filename)
                pickle.dump(page, open(filename, 'wb'),
                            protocol=pickle.HIGHEST_PROTOCOL)
            else:
                print("Dummy page for %s" % key)
                page = WikipediaPage()
                if self._write_dummy:
                    pickle.dump(page, open(filename, 'wb'),
                                protocol=pickle.HIGHEST_PROTOCOL)

        self._cache[key] = page
        return page
dataset/ETHPy150Open Pinafore/qb/util/cached_wikipedia.py/CachedWikipedia.__getitem__