示例#1
0
        def data2config(data, cached_config):
                if content_type(list).find('opml')>=0:
                    opml.opml2config(data, cached_config)
                elif content_type(list).find('foaf')>=0:
                    foaf.foaf2config(data, cached_config)
                else:
                    from planet import shell
                    import StringIO
                    cached_config.readfp(StringIO.StringIO(shell.run(
                        content_type(list), data.getvalue(), mode="filter")))

                if cached_config.sections() in [[], [list]]: 
                    raise Exception
示例#2
0
        def data2config(data, cached_config):
            if content_type(list).find('opml')>=0:
                opml.opml2config(data, cached_config)
            elif content_type(list).find('foaf')>=0:
                foaf.foaf2config(data, cached_config)
            elif content_type(list).find('csv')>=0:
                csv_config.csv2config(data, cached_config)
            elif content_type(list).find('config')>=0:
                cached_config.readfp(data)
            else:
                from planet import shell
                import StringIO
                cached_config.readfp(StringIO.StringIO(shell.run(
                    content_type(list), data.getvalue(), mode="filter")))

            if cached_config.sections() in [[], [list]]: 
                raise Exception
示例#3
0
 def test_invalid_xml_after(self):
     test = test_foaf_document.strip()[:-1]
     foaf2config(test, self.config)
     self.assertEqual('Danny Ayers', self.config.get(testfeed, 'name'))
示例#4
0
 def test_invalid_xml_before(self):
     test = '\n<?xml version="1.0" encoding="UTF-8"?>' + test_foaf_document
     foaf2config(test, self.config)
     self.assertFalse(self.config.has_section(testfeed))
示例#5
0
 def test_no_weblog(self):
     test = test_foaf_document.replace('rdfs:seeAlso', 'rdfs:seealso')
     foaf2config(test, self.config)
     self.assertFalse(self.config.has_section(testfeed))
示例#6
0
 def test_no_foaf_name(self):
     test = test_foaf_document.replace('foaf:name', 'foaf:title')
     foaf2config(test, self.config)
     self.assertEqual('Raw Blog by Danny Ayers',
                      self.config.get(testfeed, 'name'))
示例#7
0
 def test_foaf_document(self):
     foaf2config(test_foaf_document, self.config)
     self.assertEqual('Danny Ayers', self.config.get(testfeed, 'name'))
示例#8
0
 def test_invalid_xml_after(self):
     test = test_foaf_document.strip()[:-1]
     foaf2config(test, self.config)
     self.assertEqual('Danny Ayers', self.config.get(testfeed, 'name'))
示例#9
0
 def test_invalid_xml_before(self):
     test = '\n<?xml version="1.0" encoding="UTF-8"?>' + test_foaf_document
     foaf2config(test, self.config)
     self.assertFalse(self.config.has_section(testfeed))
示例#10
0
 def test_no_weblog(self):
     test = test_foaf_document.replace('rdfs:seeAlso','rdfs:seealso')
     foaf2config(test, self.config)
     self.assertFalse(self.config.has_section(testfeed))
示例#11
0
 def test_no_foaf_name(self):
     test = test_foaf_document.replace('foaf:name','foaf:title')
     foaf2config(test, self.config)
     self.assertEqual('Raw Blog by Danny Ayers',
        self.config.get(testfeed, 'name'))
示例#12
0
 def test_foaf_document(self):
     foaf2config(test_foaf_document, self.config)
     self.assertEqual('Danny Ayers', self.config.get(testfeed, 'name'))