django_importer/importers/base.py
def parse_item(self, item):
        """
        Receives an item and returns a dictionary of field values.
        """
        # Create a dictionary from values for each field
        parsed_data = {}
        
        for field_name in self.fields:
            # A field-name may be mapped to another identifier on the source,
            # it could be a XML path or a CSV column name / position.
            # Defaults to the field-name itself.
            source_name = self.field_map.get(field_name, field_name)
            
            # Uses a custom method "parse_%(field_name)"
            # or get the value from the item
            parse = getattr(self, 'parse_%s' % field_name, None)
            if parse:
                value = parse(item, field_name, source_name)
            else:
                value = self.get_value(item, source_name)
                
            # Add the value to the parsed data
            parsed_data[field_name] = value
        return parsed_data
def parse_item(self, item):
        # Create a dictionary from values for each field
        parsed_data = {}
        
        for field_name in self.fields:
            # A field-name may be mapped to another identifier on the source,
            # it could be a XML path or a CSV column name / position.
            # Defaults to the field-name itself.
            source_name = self.field_map.get(field_name, field_name)
            
            # Uses a custom method "parse_%(field_name)"
            # or get the value from the item
            parse = getattr(self, 'parse_%s' % field_name, None)
            if parse:
                value = parse(item, field_name, source_name)
            else:
                value = self.get_value(item, source_name)
                
            # Add the value to the parsed data
            parsed_data[field_name] = value
        return parsed_data
def parse_item ( self , item ) : # Create a dictionary from values for each field parsed_data = { } for field_name in self . fields : # A field-name may be mapped to another identifier on the source, # it could be a XML path or a CSV column name / position. # Defaults to the field-name itself. source_name = self . field_map . get ( field_name , field_name ) # Uses a custom method "parse_%(field_name)" # or get the value from the item parse = getattr ( self , 'parse_%s' % field_name , None ) if parse : value = parse ( item , field_name , source_name ) else : value = self . get_value ( item , source_name ) # Add the value to the parsed data parsed_data [ field_name ] = value return parsed_data
Receives an item and returns a dictionary of field values.
Receives an item and returns a dictionary of field values .