def form_to_json(form):
	config = dict()
	if form['project_name'] == "":
		raise Exception('Project name cannot be empty.')
	if form['selector_type'] not in ["css", "xpath"]:
		raise Exception('Selector type has to css or xpath')
	config['project_name'] = form['project_name']
	config['selector_type'] = form['selector_type']
	config['scraping'] = dict()
	if form['url'] == "":
		raise Exception('URL cannot be empty')
	config['scraping']['url'] = form['url']
	config['scraping']['data'] = list()
	for i in itertools.count(start=1):
		try:
			data = {
				'field': form['field_' + str(i)],
				'selector': form['selector_' + str(i)],
				'attr': form['attribute_' + str(i)],
				'default': form['default_' + str(i)]
			}
			config['scraping']['data'].append(data)
		except KeyError:
			break
	# TODO : Crawler 'next' parameter handling
	with open(os.path.join(os.getcwd(), form['project_name'] + '.json'), 'w') as f:
		json.dump(config, f)
	return
Ranks the given queryset according to the relevance of the given search text.
dataset/ETHPy150Open AlexMathew/scrapple/scrapple/utils/form.py/form_to_json--crossover with--dataset/ETHPy150Open etianen/django-watson/src/watson/backends.py/SearchBackend.do_filter_ranking