Fixed bug in item.attribute

--HG--
extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40432
This commit is contained in:
elpolilla 2008-11-26 16:09:39 +00:00
parent 40b3f06f0b
commit 8eab5802cd
1 changed files with 4 additions and 5 deletions

View File

@ -44,16 +44,15 @@ class ScrapedItem(object):
if val or val is False:
curr_val = getattr(self, attrname, None)
if not curr_val:
newval = val
setattr(self, attrname, val)
else:
if override:
newval = val
setattr(self, attrname, val)
elif add:
if all(isinstance(var, basestring) for var in (curr_val, val)):
newval = '%s %s' % (curr_val, val)
setattr(self, attrname, '%s\t%s' % (curr_val, val))
elif all(hasattr(var, '__iter__') for var in (curr_val, val)):
newval = curr_val + val
setattr(self, attrname, newval)
setattr(self, attrname, curr_val + val)
elif value:
setattr(self, attrname, value)