def handle(self, *args, **options): verbosity = int(options['verbosity']) processor = FiltersProcessor( stdout=self.stdout, stderr=self.stderr, verbosity=verbosity) for filter_name, filter_data in ALL_FILTERS.iteritems(): if verbosity > 0: self.stderr.write('Processing %s filter\n' % filter_name) if filter_name in DATE_ATTRIBUTES: continue if filter_data.get('searchForNewOptions', False): processor.find_new_options( filter_name=filter_name, options=filter_data['filters']) if processor.new_options_count: # non zero exit code raise CommandError('%d new options were found.' % processor.new_options_count)
def handle(self, *args, **options): verbosity = int(options['verbosity']) processor = FiltersProcessor( stdout=self.stdout, stderr=self.stderr, verbosity=verbosity) for filter_name, filter_data in ALL_FILTERS.iteritems(): if verbosity > 0: self.stderr.write('Processing %s filter\n' % filter_name) if filter_name in DATE_ATTRIBUTES: continue options = processor.process( filter_name=filter_name, options=filter_data['filters'], select_options=filter_data.get('selectOptions', True)) filter_data['filters'] = options # write filters found to filters_storage.json with open(JSON_FILTERS_FILE_NAME, 'w') as f: json.dump([DATE_FILTERS_HTML_IDS, ALL_FILTERS], f, indent=2) if verbosity > 0: self.stderr.write('\nWrote to %s.\n' % JSON_FILTERS_FILE_NAME)