# HG changeset patch # User Sylvain Thénault # Date 1311691802 -7200 # Node ID 0010dde5352a4bc3bf86649e06740df32a8b43d0 # Parent d07cde311630c2773e89ae1a5c1dcc28d6837107 [datafeed] closes #1875322: empty tag means None value diff -r d07cde311630 -r 0010dde5352a sobjects/parsers.py --- a/sobjects/parsers.py Tue Jul 26 16:49:10 2011 +0200 +++ b/sobjects/parsers.py Tue Jul 26 16:50:02 2011 +0200 @@ -75,7 +75,10 @@ if rschema == 'eid': continue attrtype = eschema.destination(rschema) - typeddict[rschema.type] = converters[attrtype](stringdict[rschema]) + value = stringdict[rschema] + if value is not None: + value = converters[attrtype](value) + typeddict[rschema.type] = value return typeddict def rtype_role_rql(rtype, role): @@ -294,9 +297,12 @@ # relation related = rels.setdefault(role, {}).setdefault(child.tag, []) related += [ritem for ritem, _ in self.parser.parse_etree(child)] - else: + elif child.text: # attribute item[child.tag] = unicode(child.text) + else: + # None attribute (empty tag) + item[child.tag] = None return item, rels diff -r d07cde311630 -r 0010dde5352a sobjects/test/unittest_parsers.py --- a/sobjects/test/unittest_parsers.py Tue Jul 26 16:49:10 2011 +0200 +++ b/sobjects/test/unittest_parsers.py Tue Jul 26 16:50:02 2011 +0200 @@ -261,7 +261,7 @@ self.assertEqual(user.cwuri, 'http://pouet.org/5') self.assertEqual(user.cw_source[0].name, 'myfeed') - def test_missing_fti_attribute(self): + def test_noerror_missing_fti_attribute(self): dfsource = self.repo.sources_by_uri['myfeed'] session = self.repo.internal_session() parser = dfsource._get_parser(session) @@ -273,6 +273,21 @@ '''], raise_on_error=True) + def test_noerror_unspecified_date(self): + dfsource = self.repo.sources_by_uri['myfeed'] + session = self.repo.internal_session() + parser = dfsource._get_parser(session) + dfsource.process_urls(parser, [''' + + + how-to + how-to + how-to + + + +'''], raise_on_error=True) + if __name__ == '__main__': from logilab.common.testlib import unittest_main unittest_main()