def test_replacement(self, s):
        output = to_storage_name(s)
        self.assertNotIn('..', output)
        j = 0

        if output == '':
            self.assertTrue(set(s) <= set(removables + endottables + ['.']))
            return

        for c in s:
            if c in removables or (c in endottables + ['.'] and (
                        j == 0 or j == len(output))):
                # removables get removed - should not compare
                # leading and trailing dots also get removed
                continue
            elif c in endottables + ['.']:
                # either the current should be dot or the prev should be
                if output[j] == '.':
                    j += 1
                else:
                    self.assertEqual(output[j-1], '.')
                    # do not increment j, we haven't moved on yet
            else:
                self.assertEqual(output[j], c.lower(),
                    'from %r got %r removing %r and %r[%r] != %r' % (
                    s, output, removables, output, j, c))
                j += 1
def load_page(content):
    by_series = defaultdict(lambda: defaultdict(dict))
    by_name = defaultdict(lambda: defaultdict(dict))

    soup = BeautifulSoup(content, 'lxml')
    rows = soup.findAll('tr')[5:-4]

    for row in rows:
        tds = row.findAll('td')
        year_tvdbepno = tds[0].getText()
        epname_eng = tds[1].getText().strip()

        year = year_tvdbepno.split('x')[0].strip()
        tvdb_epno = year_tvdbepno.split('x')[1].strip()

        by_series[year][tvdb_epno] = epname_eng
        by_name[to_storage_name(epname_eng)] = EpInfo(year, tvdb_epno, epname_eng)

    return by_series, by_name
 def test_removal(self, s):
     self.assertEqual(to_storage_name(s), '')