def _convert_item(self, item):
        """
        take a parsed item as input and returns a python dictionary
        the keys will be saved into the Node model
        either in their respective fields or in the hstore "data" field

        :param item: object representing parsed item
        """
        item = self.parse_item(item)

        # name is required
        if not item['name']:
            raise Exception('Expected property %s not found in item %s.' % (self.keys['name'], item))
        elif len(item['name']) > 75:
            item['name'] = item['name'][:75]

        if not item['status']:
            item['status'] = self.default_status

        # get status or get default status or None
        try:
            item['status'] = Status.objects.get(slug__iexact=item['status'])
        except Status.DoesNotExist:
            try:
                item['status'] = Status.objects.create(name=item['status'],
                                                       slug=slugify(item['status']),
                                                       description=item['status'],
                                                       is_default=False)
            except Exception as e:
                logger.exception(e)
                item['status'] = None

        # slugify slug
        item['slug'] = slugify(item['name'])

        if not item['address']:
            item['address'] = ''

        if not item['is_published']:
            item['is_published'] = ''

        User = get_user_model()
        # get user or None
        try:
            item['user'] = User.objects.get(username=item['user'])
        except User.DoesNotExist:
            item['user'] = None

        if not item['elev']:
            item['elev'] = None

        if not item['description']:
            item['description'] = ''

        if not item['notes']:
            item['notes'] = ''

        if item['added']:
            # convert dates to python datetime
            try:
                item['added'] = parser.parse(item['added'])
            except Exception as e:
                print "Exception while parsing 'added' date: %s" % e
        if item['updated']:
            try:
                item['updated'] = parser.parse(item['updated'])
            except Exception as e:
                print "Exception while parsing 'updated' date: %s" % e

        result = {
            "name": item['name'],
            "slug": item['slug'],
            "status": item['status'],
            "address": item['address'],
            "is_published": item['is_published'],
            "user": item['user'],
            "geometry": item['geometry'],
            "elev": item['elev'],
            "description": item['description'],
            "notes": item['notes'],
            "added": item['added'],
            "updated": item['updated'],
            "data": {}
        }

        # ensure all additional data items are strings
        for key, value in item['data'].items():
            result["data"][key] = value

        return result
def _convert_item ( self , item ) : item = self . parse_item ( item ) if not item [ 'name' ] : raise Exception ( 'Expected property %s not found in item %s.' % ( self . keys [ 'name' ] , item ) ) elif len ( item [ 'name' ] ) > 75 : item [ 'name' ] = item [ 'name' ] [ : 75 ] if not item [ 'status' ] : item [ 'status' ] = self . default_status try : item [ 'status' ] = Status . objects . get ( slug__iexact = item [ 'status' ] ) except Status . DoesNotExist : try : item [ 'status' ] = Status . objects . create ( name = item [ 'status' ] , slug = slugify ( item [ 'status' ] ) , description = item [ 'status' ] , is_default = False ) except Exception as e : logger . exception ( e ) item [ 'status' ] = None item [ 'slug' ] = slugify ( item [ 'name' ] ) if not item [ 'address' ] : item [ 'address' ] = '' if not item [ 'is_published' ] : item [ 'is_published' ] = '' User = get_user_model ( ) try : item [ 'user' ] = User . objects . get ( username = item [ 'user' ] ) except User . DoesNotExist : item [ 'user' ] = None if not item [ 'elev' ] : item [ 'elev' ] = None if not item [ 'description' ] : item [ 'description' ] = '' if not item [ 'notes' ] : item [ 'notes' ] = '' if item [ 'added' ] : try : item [ 'added' ] = parser . parse ( item [ 'added' ] ) except Exception as e : print "Exception while parsing 'added' date: %s" % e if item [ 'updated' ] : try : item [ 'updated' ] = parser . parse ( item [ 'updated' ] ) except Exception as e : print "Exception while parsing 'updated' date: %s" % e result = { "name" : item [ 'name' ] , "slug" : item [ 'slug' ] , "status" : item [ 'status' ] , "address" : item [ 'address' ] , "is_published" : item [ 'is_published' ] , "user" : item [ 'user' ] , "geometry" : item [ 'geometry' ] , "elev" : item [ 'elev' ] , "description" : item [ 'description' ] , "notes" : item [ 'notes' ] , "added" : item [ 'added' ] , "updated" : item [ 'updated' ] , "data" : { } } for key , value in item [ 'data' ] . items ( ) : result [ "data" ] [ key ] = value return result
take a parsed item as input and returns a python dictionary
        the keys will be saved into the Node model
        either in their respective fields or in the hstore "data" field

        :param item: object representing parsed item