<commit_before>function UserManager() {

	this.factory = {
		'preferences' : this.getFactoryFile('factory.json'),
		'searchDictionary' : this.getFactoryFile('search-dictionary.json')
	}
	
	// We'll only use one user for now.
	this.user = new User('Oryoki', this.factory);

	// Allow for renderer to use preferences
	ipcMain.on('get-preference', function(event, name) {
	  event.returnValue = this.getPreferenceByName(name);
	}.bind(this));

	// Allow for renderer to use user paths
	ipcMain.on('get-user-path', function(event, name) {
		// @if NODE_ENV='development'
		c.log('Returning path: '+this.user.paths[name]);
		// @endif
	  event.returnValue = this.user.paths[name];
	}.bind(this));
}

UserManager.prototype.getFactoryFile = function(fileName) {

	// Erase comments to validate JSON
	var raw = fs.readFileSync(__dirname + '/src/data/' + fileName, 'utf8');
	var re = /(^\/\/|^\t\/\/).*/gm; // Any line that starts with `//` or with a tab followed by `//`
	var stripped = raw.replace(re, '');
	c.log('Gettin ' + fileName + ' – ' + JSON.parse(stripped));
	return JSON.parse(stripped);

}

UserManager.prototype.getPreferenceByName = function(name) {
	/* 
	Checks default user for preference
	If not defined, falls back to factory setting.
	*/
	if(this.user.preferences[name] !== undefined) {
		return this.user.preferences[name];
	}
	else {
		return this.factory.preferences[name];
	}
}

UserManager.prototype.reset = function(niceName, fileName, factoryName) {

	fs.writeFile(this.user.paths.conf + '/' + fileName, fs.readFileSync(__dirname + '/src/data/' + factoryName, 'utf8'), function(err) {
		// @if NODE_ENV='development'
		if(err) c.log(err);
		// @endif
		Oryoki.focusedWindow.browser.webContents.send('log-status', {
			'body' : niceName + ' reset'
		});
	});

}

UserManager.prototype.resetUserPreferencesToFactory = function() {
	fs.writeFile(this.user.paths.conf + '/' + 'oryoki-preferences.json', fs.readFileSync(__dirname + '/src/data/factory.json', 'utf8'), function(err) {
		// @if NODE_ENV='development'
		if(err) c.log(err);
		// @endif
		Oryoki.focusedWindow.browser.webContents.send('log-status', {
			'body' : 'Preferences reset'
		});
	});
}

UserManager.prototype.openPreferencesFile = function() {
	shell.openItem(this.user.paths.conf + '/' + 'oryoki-preferences.json');
}<commit_msg>Clean logs<commit_after>function UserManager() {

	this.factory = {
		'preferences' : this.getFactoryFile('factory.json'),
		'searchDictionary' : this.getFactoryFile('search-dictionary.json')
	}
	
	// We'll only use one user for now.
	this.user = new User('Oryoki', this.factory);

	// Allow for renderer to use preferences
	ipcMain.on('get-preference', function(event, name) {
	  event.returnValue = this.getPreferenceByName(name);
	}.bind(this));

	// Allow for renderer to use user paths
	ipcMain.on('get-user-path', function(event, name) {
		// @if NODE_ENV='development'
		c.log('Returning path: '+this.user.paths[name]);
		// @endif
	  event.returnValue = this.user.paths[name];
	}.bind(this));
}

UserManager.prototype.getFactoryFile = function(fileName) {

	// Erase comments to validate JSON
	var raw = fs.readFileSync(__dirname + '/src/data/' + fileName, 'utf8');
	var re = /(^\/\/|^\t\/\/).*/gm; // Any line that starts with `//` or with a tab followed by `//`
	var stripped = raw.replace(re, '');

	// @if NODE_ENV='development'
	c.log('Getting ' + fileName + ' – ' + JSON.parse(stripped));
	// @endif
	
	return JSON.parse(stripped);

}

UserManager.prototype.getPreferenceByName = function(name) {
	/* 
	Checks default user for preference
	If not defined, falls back to factory setting.
	*/
	if(this.user.preferences[name] !== undefined) {
		return this.user.preferences[name];
	}
	else {
		return this.factory.preferences[name];
	}
}

UserManager.prototype.reset = function(niceName, fileName, factoryName) {

	fs.writeFile(this.user.paths.conf + '/' + fileName, fs.readFileSync(__dirname + '/src/data/' + factoryName, 'utf8'), function(err) {
		// @if NODE_ENV='development'
		if(err) c.log(err);
		// @endif
		Oryoki.focusedWindow.browser.webContents.send('log-status', {
			'body' : niceName + ' reset'
		});
	});

}

UserManager.prototype.resetUserPreferencesToFactory = function() {
	fs.writeFile(this.user.paths.conf + '/' + 'oryoki-preferences.json', fs.readFileSync(__dirname + '/src/data/factory.json', 'utf8'), function(err) {
		// @if NODE_ENV='development'
		if(err) c.log(err);
		// @endif
		Oryoki.focusedWindow.browser.webContents.send('log-status', {
			'body' : 'Preferences reset'
		});
	});
}

UserManager.prototype.openPreferencesFile = function() {
	shell.openItem(this.user.paths.conf + '/' + 'oryoki-preferences.json');
}
{'fraction_non_alphanumeric': 0.17483415364861973, 'fraction_numerical': 0.0012839717526214422, 'mean_word_length': 4.113785557986871, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4793164', 'n_tokens_mistral': 1670, 'n_tokens_neox': 1597, 'n_words': 300}