Example #1
0
def scan_projects(projects_port):
	log = task.logger
	conf = task.conf

	log.info("Creating combination folders ...")

	create_combination_folders(conf)

	if "files" in conf:
		single_project(projects_port)
	elif "scan_paths" in conf:
		multiple_projects(projects_port)
	else:
		raise InternalError("Either 'files' or 'scan_paths' configuration parameter is required")
Example #2
0
def begin():
	log = task.logger
	conf = task.conf

	log.info("Creating combination folders ...")

	create_combination_folders(conf)

	log.info("Checking classifiers ...")

	if CONF_KEY in conf:
		classifiers = conf[CONF_KEY].to_native()
	else:
		classifiers = []

	if not isinstance(classifiers, list):
		log.error("'{0}' should be a list".format(CONF_KEY))
		return -1

	results = []

	if len(classifiers) == 0:
		log.warn("No classifiers have been defined !!!")
		log.warn("Specify them in the configuration with '{0}'".format(CONF_KEY))

	for index, classifier in enumerate(classifiers):
		if not isinstance(classifier, dict):
			raise Exception("Classifier at index {0} should be a dictionary".format(index))

		if "id" not in classifier:
			classifier["id"] = str(index)

		classifier_id = classifier["id"]

		if "name" not in classifier:
			classifier["name"] = "Classifier {0}".format(index)

		if "keys" not in classifier:
			classifier["keys"] = []
		elif not isinstance(classifier["keys"], list):
			raise Exception("'keys' for classifier at index {0} should be a list".format(classifier_id))

		keys_len = len(classifier["keys"])

		if "default_key_values" not in classifier:
			classifier["default_key_values"] = [""] * keys_len
		elif not isinstance(classifier["default_key_values"], list):
			raise Exception("'default_key_values' for classifier {0} should be a list".format(classifier_id))
		elif len(classifier["default_key_values"]) != keys_len:
			raise Exception("Number of values for 'default_key_values' should be the same of 'keys' in classifier '{0}'".format(classifier_id))
		
		if "short_names" not in classifier:
			classifier["short_names"] = classifier["keys"]
		elif not isinstance(classifier["short_names"], list):
			raise Exception("'short_names' for classifier {0} should be a list".format(classifier_id))
		elif len(classifier["short_names"]) != keys_len:
			raise Exception("Number of keys for 'short_names' should be the same of 'keys' in classifier '{0}'".format(classifier_id))

		if "default_short_values" not in classifier:
			classifier["default_short_values"] = classifier["default_key_values"]
		elif not isinstance(classifier["default_short_values"], list):
			raise Exception("'default_short_values' for classifier {0} should be a list".format(classifier_id))
		elif len(classifier["default_short_values"]) != keys_len:
			raise Exception("Number of values for 'default_short_values' should be the same of 'keys' in classifier '{0}'".format(classifier_id))
		
		if "long_names" not in classifier:
			classifier["long_names"] = classifier["short_names"]
		elif not isinstance(classifier["long_names"], list):
			raise Exception("'long_names' for classifier {0} should be a list".format(classifier_id))
		elif len(classifier["long_names"]) != keys_len:
			raise Exception("Number of keys for 'long_names' should be the same of 'keys' in classifier '{0}'".format(classifier["id"]))

		if "default_long_values" not in classifier:
			classifier["default_long_values"] = classifier["default_key_values"]
		elif not isinstance(classifier["default_long_values"], list):
			raise Exception("'default_long_values' for classifier {0} should be a list".format(classifier_id))
		elif len(classifier["default_long_values"]) != keys_len:
			raise Exception("Number of values for 'default_long_values' should be the same of 'keys' in classifier '{0}'".format(classifier_id))

		results += [{}]

	task.context["classifiers"] = classifiers
	task.context["results"] = results