<commit_before>/*
*   Save datas for one user in ~/.config/***rc
*/

const fs = require('fs')
//const homedir = require('os')
const homedir =require('os').homedir
const consts = require('./consts.js')

module.exports= class UserConfig {
    constructor() {
        this.path = `${homedir()}/.config/${consts.name}rc`
        this.data = {
            w : consts.ui.windowDefaultWidth,
            h : consts.ui.windowDefaultHeight,
            theme : 'flatly'
        }
    }

    setItem(key,value) {
        this.data[key] = value
    }

    getItem(key) {
        return (this.data[key]) ? this.data[key] : ''
    }    

    load () {
        try {
            let data= fs.readFileSync(this.path, 'utf8')
            this.data =JSON.parse(data)
            console.log('user loaded',data)
            return true
        } catch (e) {
            console.log('UserConfig error:', e)
            this.save()
        }
        return false
    }

    save () {
        try {
            fs.writeFile(this.path, JSON.stringify(this.data), (err) => {
                console.log('user saved',JSON.stringify(this.data))
                return true
            })
        } catch (e) {
            console.log('UserConfig error:', e)
        }
        return false
    }
}   
<commit_msg>maximum logs now is in userconfig<commit_after>/*
*   Save datas for one user in ~/.config/***rc
*/

const fs = require('fs')
//const homedir = require('os')
const homedir =require('os').homedir
const consts = require('./consts.js')

module.exports= class UserConfig {
    constructor() {
        this.path = `${homedir()}/.config/${consts.name}rc`
        this.data = {
            w : consts.ui.windowDefaultWidth,
            h : consts.ui.windowDefaultHeight,
            theme : 'flatly',
            maxlogs : 1400
        }
    }

    setItem(key,value) {
        this.data[key] = value
    }

    getItem(key) {
        return (this.data[key]) ? this.data[key] : ''
    }    

    load () {
        try {
            let data= fs.readFileSync(this.path, 'utf8')
            this.data =JSON.parse(data)
            if (!this.data.maxlogs) this.data.maxlogs=1400
            consts.packageInfos.maxitems = this.data.maxlogs
            console.log('user loaded',data)
            return true
        } catch (e) {
            console.log('UserConfig error:', e)
            this.save()
        }
        return false
    }

    save () {
        try {
            fs.writeFile(this.path, JSON.stringify(this.data), (err) => {
                console.log('user saved',JSON.stringify(this.data))
                return true
            })
        } catch (e) {
            console.log('UserConfig error:', e)
        }
        return false
    }
}   

{'fraction_non_alphanumeric': 0.14186725018234866, 'fraction_numerical': 0.0036469730123997084, 'mean_word_length': 1.6299137104506232, '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': '1020825', 'n_tokens_mistral': 858, 'n_tokens_neox': 840, 'n_words': 164}