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
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
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'))
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))
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))
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'))
def test_foaf_document(self): foaf2config(test_foaf_document, self.config) self.assertEqual('Danny Ayers', self.config.get(testfeed, 'name'))
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))
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'))