<commit_before>package key

import (
	"fmt"
	"github.com/globocom/config"
	"github.com/globocom/tsuru/fs"
	"io/ioutil"
	"os"
	"path"
	"strings"
)

// file to write user's keys
var authKey string = path.Join(os.Getenv("HOME"), "authorized_keys")
var fsystem fs.Fs

// Add writes a key in authKey file
func Add(key string, fsystem fs.Fs) error {
	file, err := fsystem.OpenFile(authKey, os.O_RDWR, 0755)
	defer file.Close()
	if err != nil {
		return err
	}
	keys, err := ioutil.ReadAll(file)
	if err != nil {
		return err
	}
	content := formatKey(key)
	if len(keys) != 0 {
		content = fmt.Sprintf("%s\n%s", keys, formatKey(key))
	}
	if _, err := file.Seek(0, 0); err != nil {
		return err
	}
	if _, err := file.WriteString(content); err != nil {
		return err
	}
	return nil
}

// Remove a key from auhtKey file
func Remove(key string, fsystem fs.Fs) error {
	file, err := fsystem.OpenFile(authKey, os.O_RDWR, 0755)
	defer file.Close()
	if err != nil {
		return err
	}
	keys, err := ioutil.ReadAll(file)<commit_msg>key: Improving commend on Add function<commit_after>package key

import (
	"fmt"
	"github.com/globocom/config"
	"github.com/globocom/tsuru/fs"
	"io/ioutil"
	"os"
	"path"
	"strings"
)

// file to write user's keys
var authKey string = path.Join(os.Getenv("HOME"), "authorized_keys")
var fsystem fs.Fs

// Writes `key` in authorized_keys file (from current user)
// It does not writes in the database, there is no need for that since the key
// object is embedded on the user's document
func Add(key string, fsystem fs.Fs) error {
	file, err := fsystem.OpenFile(authKey, os.O_RDWR, 0755)
	defer file.Close()
	if err != nil {
		return err
	}
	keys, err := ioutil.ReadAll(file)
	if err != nil {
		return err
	}
	content := formatKey(key)
	if len(keys) != 0 {
		content = fmt.Sprintf("%s\n%s", keys, formatKey(key))
	}
	if _, err := file.Seek(0, 0); err != nil {
		return err
	}
	if _, err := file.WriteString(content); err != nil {
		return err
	}
	return nil
}

// Remove a key from auhtKey file
func Remove(key string, fsystem fs.Fs) error {
	file, err := fsystem.OpenFile(authKey, os.O_RDWR, 0755)
	defer file.Close()
	if err != nil {
		return err
	}
	keys, err := ioutil.ReadAll(file)
{'fraction_non_alphanumeric': 0.14350797266514806, 'fraction_numerical': 0.010022779043280182, 'mean_word_length': 3.632911392405063, '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': '1713253', 'n_tokens_mistral': 876, 'n_tokens_neox': 836, 'n_words': 246}