Пример #1
0
 def test_py26_fallback_on_ordereddict(self):
     p = soup("""<p><b>a</b> 1<br/>
             <b>b</b> 2 <b>c</b> 3""").select('p')[0]
     defs = parse_homemade_dl(p)
     self.assertSequenceEqual([('a', '1'), ('b', '2'), ('c', '3')],
                              list(defs.items()))
     self.assertEqual(True, getattr(defs, '_fake', False))
Пример #2
0
 def test_py26_fallback_on_ordereddict(self):
     p = soup("""<p><b>a</b> 1<br/>
             <b>b</b> 2 <b>c</b> 3""").select('p')[0]
     defs = parse_homemade_dl(p)
     self.assertSequenceEqual([('a', '1'), ('b', '2'), ('c', '3')],
             list(defs.items()))
     self.assertEqual(True, getattr(defs, '_fake', False))
Пример #3
0
 def populate(self, soup, session, **kw):
     content = soup.select('#courseRightContent')[0]
     attrs = parse_homemade_dl(content.select('p small')[0])
     self.title = attrs.get('titre')
     self.begin = attrs.get('du')
     self.end = attrs.get('au')
     self.submission_type = attrs.get('type de soumission')
     self.work_type = attrs.get('type de travail')
     self.visibility = attrs.get(u'visibilit\xe9 de la soumission')
     self.assig_id = parse_query(self.path)['assigId'][0]
Пример #4
0
 def populate(self, soup, session, **kw):
     content = soup.select('#courseRightContent')[0]
     attrs = parse_homemade_dl(content.select('p small')[0])
     self.title = attrs.get('titre')
     self.begin = attrs.get('du')
     self.end = attrs.get('au')
     self.submission_type = attrs.get('type de soumission')
     self.work_type = attrs.get('type de travail')
     self.visibility = attrs.get(u'visibilit\xe9 de la soumission')
     self.assig_id = parse_qs(urlparse(self.path).query)['assigId'][0]
Пример #5
0
 def test_parse_homemade_dl_with_colon_in_key(self):
     p = soup("<p><b>yo :</b> FOO</p>").select('p')[0]
     defs = parse_homemade_dl(p)
     self.assertSequenceEqual([('yo :', 'FOO')], list(defs.items()))
Пример #6
0
 def test_parse_homemade_dl_uppercase_value(self):
     p = soup("<p><b>yo</b> FOO</p>").select('p')[0]
     defs = parse_homemade_dl(p)
     self.assertSequenceEqual([('yo', 'FOO')], list(defs.items()))
Пример #7
0
 def test_parse_homemade_dl_uppercase_key(self):
     p = soup("<p><b>Yo</b> foo</p>").select('p')[0]
     defs = parse_homemade_dl(p)
     self.assertSequenceEqual([('yo', 'foo')], list(defs.items()))
Пример #8
0
 def test_parse_homemade_dl_one_def_child_value(self):
     p = soup("<p>yo <b>foo</b> <i>bar</i></p>").select('p')[0]
     defs = parse_homemade_dl(p)
     self.assertSequenceEqual([('foo', 'bar')], list(defs.items()))
Пример #9
0
 def test_parse_homemade_dl_def_no_val(self):
     p = soup("<p>yo <b>title:</b></p>").select('p')[0]
     defs = parse_homemade_dl(p)
     self.assertSequenceEqual([], list(defs.items()))
Пример #10
0
 def test_parse_homemade_dl_no_defs2(self):
     p = soup("<p>very <i>simple</i> text.</p>").select('p')[0]
     defs = parse_homemade_dl(p)
     self.assertSequenceEqual([], list(defs.items()))
Пример #11
0
 def test_parse_homemade_dl_one_def_child_value(self):
     p = soup("<p>yo <b>foo</b> <i>bar</i></p>").select('p')[0]
     defs = parse_homemade_dl(p)
     self.assertSequenceEqual([('foo', 'bar')], list(defs.items()))
Пример #12
0
 def test_parse_homemade_dl_no_defs(self):
     p = BeautifulSoup("<p>simple text.</p>").select('p')[0]
     defs = parse_homemade_dl(p)
     self.assertSequenceEqual([], list(defs.items()))
Пример #13
0
 def test_parse_homemade_dl_no_defs2(self):
     p = soup("<p>very <i>simple</i> text.</p>").select('p')[0]
     defs = parse_homemade_dl(p)
     self.assertSequenceEqual([], list(defs.items()))
Пример #14
0
 def test_parse_homemade_dl(self):
     p = soup("""<p><b>a</b> 1<br/>
             <b>b</b> 2 <b>c</b> 3""").select('p')[0]
     defs = parse_homemade_dl(p)
     self.assertSequenceEqual([('a', '1'), ('b', '2'), ('c', '3')],
                              list(defs.items()))
Пример #15
0
 def test_parse_homemade_dl_with_colon_in_key(self):
     p = soup("<p><b>yo :</b> FOO</p>").select('p')[0]
     defs = parse_homemade_dl(p)
     self.assertSequenceEqual([('yo :', 'FOO')], list(defs.items()))
Пример #16
0
 def test_parse_homemade_dl_uppercase_value(self):
     p = soup("<p><b>yo</b> FOO</p>").select('p')[0]
     defs = parse_homemade_dl(p)
     self.assertSequenceEqual([('yo', 'FOO')], list(defs.items()))
Пример #17
0
 def test_parse_homemade_dl_uppercase_key(self):
     p = soup("<p><b>Yo</b> foo</p>").select('p')[0]
     defs = parse_homemade_dl(p)
     self.assertSequenceEqual([('yo', 'foo')], list(defs.items()))
Пример #18
0
 def test_parse_homemade_dl(self):
     p = soup("""<p><b>a</b> 1<br/>
             <b>b</b> 2 <b>c</b> 3""").select('p')[0]
     defs = parse_homemade_dl(p)
     self.assertSequenceEqual([('a', '1'), ('b', '2'), ('c', '3')],
             list(defs.items()))
Пример #19
0
 def test_parse_homemade_dl_no_defs(self):
     p = BeautifulSoup("<p>simple text.</p>").select('p')[0]
     defs = parse_homemade_dl(p)
     self.assertSequenceEqual([], list(defs.items()))
Пример #20
0
 def test_parse_homemade_dl_def_no_val(self):
     p = soup("<p>yo <b>title:</b></p>").select('p')[0]
     defs = parse_homemade_dl(p)
     self.assertSequenceEqual([], list(defs.items()))