fixes for addfield overwriting existant fields\n saucebrush sopr example fixed
This commit is contained in:
		
							parent
							
								
									c114d482da
								
							
						
					
					
						commit
						e8da52e486
					
				
					 2 changed files with 10 additions and 12 deletions
				
			
		|  | @ -9,7 +9,7 @@ from saucebrush.emitters import DjangoModelEmitter, DebugEmitter | |||
| import lobbyists | ||||
| 
 | ||||
| def process_sopr_filing(sopr_xml_file): | ||||
|     from sunlightapi import settings as DJ_SETTINGS | ||||
|     from sunlightapi import live_settings as DJ_SETTINGS | ||||
|     DJ_APPLABEL = 'lobbyists' | ||||
|      | ||||
|     saucebrush.run_recipe(lobbyists.parse_filings(sopr_xml_file), | ||||
|  | @ -22,9 +22,7 @@ def process_sopr_filing(sopr_xml_file): | |||
|          | ||||
|         # process names & dates | ||||
|         FieldAdder('client_contact_name', ''), | ||||
|         FieldAdder('registrant_name', ''), | ||||
|         NameCleaner('client_contact_name', prefix='client_', nomatch_name='client_raw_contact_name'), | ||||
|         NameCleaner('registrant_name', prefix='registrant_', nomatch_name='registrant_raw_name'), | ||||
|         NameCleaner('client_contact_name', prefix='client_contact_', nomatch_name='client_raw_contact_name'), | ||||
|         FieldModifier('filing_date', lambda x: x.split('.')[0]), | ||||
|         DateCleaner('filing_date', from_format='%Y-%m-%dT%H:%M:%S', to_format='%Y-%m-%d'), | ||||
|          | ||||
|  | @ -37,8 +35,7 @@ def process_sopr_filing(sopr_xml_file): | |||
|         saucebrush.filters.Splitter({ | ||||
|           'issues':[DjangoModelEmitter(DJ_SETTINGS, DJ_APPLABEL, 'issue')], | ||||
|           'lobbyists':[FieldRemover(['indicator', 'status']), | ||||
|                        NameCleaner(['name']), | ||||
|                        FieldRenamer({'raw_name': 'name'}), | ||||
|                        NameCleaner('name', nomatch_name='raw_name'), | ||||
|                        Unique(),    # remove some duplicate lobbyists on a form | ||||
|                        DjangoModelEmitter(DJ_SETTINGS, DJ_APPLABEL, 'lobbyist') | ||||
|                        ], | ||||
|  |  | |||
|  | @ -197,6 +197,7 @@ class FieldAdder(Filter): | |||
|         self._field_value = field_value | ||||
| 
 | ||||
|     def process_record(self, record): | ||||
|         if self._field_name not in record: | ||||
|             if callable(self._field_value): | ||||
|                 record[self._field_name] = self._field_value() | ||||
|             else: | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 James Turk
						James Turk