<commit_before>enyo.kind({
	name: "ProjectToolkit",
	kind: "enyo.Component",
	events: {
		onLoginFailed: "",
		onBuildStarted: ""
	},
	debug: false,
	/**
	 * @private
	 */
	create: function() {
		if (this.debug) this.log();
		this.inherited(arguments);
		this.config = {};
	},
	/**
	 * Set project toolkit base parameters.
	 *
	 * This method is not expected to be called by anyone else but
	 * {ServiceRegistry}.
	 * @param {Object} inConfig
	 * @see ServiceRegistry.js
	 */
	setConfig: function(inConfig) {
		var self = this;

		if (this.debug) this.log("config:", this.config, "+", inConfig);
		this.config = ares.extend(this.config, inConfig);
		if (this.debug) this.log("=> config:", this.config);

		if (this.config.origin && this.config.pathname) {
			this.url = this.config.origin + this.config.pathname;
			if (this.debug) this.log("url:", this.url);
		}

		// Populate the repositories on nodejs
		for(var repoId in inConfig.projectTemplateRepositories) {
			var repository = inConfig.projectTemplateRepositories[repoId];
			repository.id = repoId;
			this.createRepo(repository);		// TODO: handle the answer
		}
	},
	/**
	 * @return {Object} the configuration this service was configured by
	 */
	getConfig: function() {
		return this.config;
	},
	getTemplates: function() {
		if (this.debug) this.log();

		var req = new enyo.Ajax({
			url: this.url + '/templates'
		});
		return req.go();
	},
	generate: function(templateId, options) {
		if (this.debug) this.log();

		var data = "templateId=" + encodeURIComponent(templateId);
		data +=	("&options=" + encodeURIComponent(JSON.stringify(options)));

		var userreq = new enyo.Async();

		var req = new enyo.Ajax({
			url: this.url + '/generate',
			method: 'POST',
			handleAs: "text",
			postBody: data,
			mimeType: 'text/plain; charset=x-user-defined'
		});

		req.response(this, function(inSender, inData) {
			userreq.respond({ctype: req.xhrResponse.headers['x-content-type'], content: inData});
		});
		req.error(this, function(inSender, inError) {
			this.log("Unable to get the template files (" + inError + ")");
			userreq.fail(inError);
		});
		req.go();
		return userreq;
	},
	createRepo: function(repo) {
		if (this.debug) this.log();
		var data = "url=" + encodeURIComponent(repo.url);

		var req = new enyo.Ajax({
			url: this.url + '/template-repos/' + repo.id,
			method: 'POST',
			postBody: data
		});
		return req.go();
	}
});<commit_msg>ENYO-2053: Take into account only non empty projectTemplateRepositories entries<commit_after>enyo.kind({
	name: "ProjectToolkit",
	kind: "enyo.Component",
	events: {
		onLoginFailed: "",
		onBuildStarted: ""
	},
	debug: false,
	/**
	 * @private
	 */
	create: function() {
		if (this.debug) this.log();
		this.inherited(arguments);
		this.config = {};
	},
	/**
	 * Set project toolkit base parameters.
	 *
	 * This method is not expected to be called by anyone else but
	 * {ServiceRegistry}.
	 * @param {Object} inConfig
	 * @see ServiceRegistry.js
	 */
	setConfig: function(inConfig) {
		var self = this;

		if (this.debug) this.log("config:", this.config, "+", inConfig);
		this.config = ares.extend(this.config, inConfig);
		if (this.debug) this.log("=> config:", this.config);

		if (this.config.origin && this.config.pathname) {
			this.url = this.config.origin + this.config.pathname;
			if (this.debug) this.log("url:", this.url);
		}

		// Populate the repositories on nodejs
		for(var repoId in inConfig.projectTemplateRepositories) {
			var repository = inConfig.projectTemplateRepositories[repoId];
			repository.id = repoId;
			if (repository.url) {
				this.createRepo(repository);		// TODO: handle the answer
			}
		}
	},
	/**
	 * @return {Object} the configuration this service was configured by
	 */
	getConfig: function() {
		return this.config;
	},
	getTemplates: function() {
		if (this.debug) this.log();

		var req = new enyo.Ajax({
			url: this.url + '/templates'
		});
		return req.go();
	},
	generate: function(templateId, options) {
		if (this.debug) this.log();

		var data = "templateId=" + encodeURIComponent(templateId);
		data +=	("&options=" + encodeURIComponent(JSON.stringify(options)));

		var userreq = new enyo.Async();

		var req = new enyo.Ajax({
			url: this.url + '/generate',
			method: 'POST',
			handleAs: "text",
			postBody: data,
			mimeType: 'text/plain; charset=x-user-defined'
		});

		req.response(this, function(inSender, inData) {
			userreq.respond({ctype: req.xhrResponse.headers['x-content-type'], content: inData});
		});
		req.error(this, function(inSender, inError) {
			this.log("Unable to get the template files (" + inError + ")");
			userreq.fail(inError);
		});
		req.go();
		return userreq;
	},
	createRepo: function(repo) {
		if (this.debug) this.log(repo);
		var data = "url=" + encodeURIComponent(repo.url);

		var req = new enyo.Ajax({
			url: this.url + '/template-repos/' + repo.id,
			method: 'POST',
			postBody: data
		});
		return req.go();
	}
});
{'fraction_non_alphanumeric': 0.1657559198542805, 'fraction_numerical': 0.0008095527221210282, 'mean_word_length': 3.6622641509433964, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3497804', 'n_tokens_mistral': 1864, 'n_tokens_neox': 1680, 'n_words': 394}