<commit_before>var LocalStorage = require('./LocalStorage');
var fdialogs = require('node-webkit-fdialogs'); //https://www.npmjs.com/package/node-webkit-fdialogs
var Logger = require('../util/Logger');
var Commands = require('../models/Commands');
var gains_config = require('../../config/gains-config');

var GainsImporter = {
    export: function () {
        var keys = Object.keys(gains_config.default_settings);
        var str;
        var buf;
        var exported_settings = gains_config.default_settings;
        for (var i = 0; i < keys.length; i++)
        {
            exported_settings[keys[i]] = gains_config.get(keys[i]);
        }
        str = JSON.stringify(exported_settings, null, 2);
        buf = new Buffer(str);
        fdialogs.saveFile(buf, function (err, path) {
            Logger.debug("File saved succesfully to " + path);
        });
    },
    import: function () {
        var Dialog = new fdialogs.FDialog({
            type: 'open',
            accept: ['.txt'],
            path: '~/Documents'
        });
        fdialogs.readFile(function (err, content, path) {
            var keys = Object.keys(gains_config.default_settings);
            try {
                var object = JSON.parse(content, 2);
                for (var i = 0; i < keys.length; i++)
            {
                if (keys[i] in object)
                {
                    gains_config.set(keys[i], object[keys[i]]);
                }
            }
            } catch (e)
            {
                Logger.info("Could not save, bad file format" + e);
            }
        });
    }
};
module.exports = GainsImporter;<commit_msg>Fixed gain importer stuff<commit_after>var LocalStorage = require('./LocalStorage');
var fdialogs = require('node-webkit-fdialogs'); //https://www.npmjs.com/package/node-webkit-fdialogs
var Logger = require('../util/Logger');
var Commands = require('../models/Commands');
var gains_config = require('../../config/gains-config');

var GainsImporter = {
    export: function () {
        var keys = Object.keys(gains_config.default_settings);
        var str;
        var buf;
        var exported_settings = gains_config.default_settings;
        for (var i = 0; i < keys.length; i++)
        {
            exported_settings[keys[i]] = gains_config.get(keys[i]);
        }
        str = JSON.stringify(exported_settings, null, 2);
        buf = new Buffer(str);
        fdialogs.saveFile(buf, function (err, path) {
            if(err){
                Logger.error('There was an error saving the file to : '+path+' Error: '+err);
            }
            else{
                Logger.debug("File saved succesfully to " + path);
            }
        });
    },
    import: function () {
        var dialog = new fdialogs.FDialog({
            type: 'open',
            accept: ['.txt'],
            path: '~/Documents'
        });
        dialog.readFile(function (err, content, path) {
            var keys = Object.keys(gains_config.default_settings);
            try {
                var object = JSON.parse(content, 2);
                for (var i = 0; i < keys.length; i++)
            {
                if (keys[i] in object)
                {
                    gains_config.set(keys[i], object[keys[i]]);
                }
            }
            } catch (e)
            {
                Logger.info("Could not save, bad file format" + e);
            }
        });
    }
};
module.exports = GainsImporter;
{'fraction_non_alphanumeric': 0.13831937626335547, 'fraction_numerical': 0.002310135720473578, 'mean_word_length': 1.7168627450980392, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '5143037', 'n_tokens_mistral': 1014, 'n_tokens_neox': 977, 'n_words': 221}