<commit_before>#!/usr/bin/env python

import subprocess
from Tkinter import *
from tkFileDialog import *
import os

GPG = 'gpg2'
SERVER_KEY = ''  # replace with gpg key ID of server key

class GpgApp(object):
    def __init__(self, master):
        frame = Frame(master)
        frame.pack()
        self.text = Text()
        self.text.pack()
        menu = Menu(master)
        root.config(menu=menu)

        filemenu = Menu(menu, tearoff=0)
        menu.add_cascade(label="File", menu=filemenu)
        filemenu.add_command(label="Open", command=self.filename_open)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.do_exit)
    def filename_open(self):
        fin = askopenfilenames()
        if fin:
            self.text.insert(END,fin)
            return fin
    def encrypt_file(self, input_file, output_file, recipient):
        args = [GPG, '--output', output_file, '--recipient', recipient, '-sea', input_file]
        subprocess.call(args)
    def do_exit(self):
        root.destroy()


root = Tk()
root.title("a simple GnuPG interface")
app = GpgApp(root)
root.mainloop()

<commit_msg>Add batch encrypt/decrypt methods (untested)<commit_after>#!/usr/bin/env python

import subprocess
from Tkinter import *
from tkFileDialog import *
import os
import datetime

GPG = 'gpg2'
SERVER_KEY = ''  # replace with gpg key ID of server key
DECRYPTED_PREFIX = 'decrypted'

class GpgApp(object):
    def __init__(self, master):
        frame = Frame(master)
        frame.pack()
        self.text = Text()
        self.text.pack()
        menu = Menu(master)
        root.config(menu=menu)

        filemenu = Menu(menu, tearoff=0)
        menu.add_cascade(label="File", menu=filemenu)
        filemenu.add_command(label="Open", command=self.filename_open)
        filemenu.add_command(label="Decrypt files", command=self.batch_decrypt)
        filemenu.add_command(label="Encrypt files", command=self.batch_encrypt)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.do_exit)
    def filename_open(self):
        fin = askopenfilenames()
        if fin:
            self.text.insert(END,fin)
            return fin
    def batch_decrypt(self):
        timestring = datetime.datetime.now().strftime("%Y%m%d_%H%M")
        dirname = 'decrypted_'+timestring
        os.mkdir(dirname)
        fin = askopenfilenames()
        for f in fin:
            try:
                decrypt_file(f, dirname+'/'+f+'_decrypted')
            except:
                print "Error decrypting: "+f
        self.text.insert(END, 'Wrote decrypted files to '+dirname)
    def batch_encrypt(self, recipient='<EMAIL>'):
        timestring = datetime.datetime.now().strftime("%Y%m%d_%H%M")
        dirname = 'encrypted_'+timestring
        os.mkdir(dirname)
        fin = askopenfilenames()
        for f in fin:
            try:
                encrypt_file(f, dirname+'/'+f+'_encrypted', recipient)
            except:
                print "Error encrypting: "+f
        self.text.insert(END, 'Wrote encrypted files to '+dirname)
    def encrypt_file(self, input_file, output_file, recipient):
        args = [GPG, '--output', output_file, '--recipient', recipient, '-sea', input_file]
        subprocess.call(args)
    def decrypt_file(self, input_file, output_file):
        args = [GPG, '--output', output_file, '--decrypt', input_file]
        subprocess.call(args)
    def do_exit(self):
        root.destroy()


root = Tk()
root.title("a simple GnuPG interface")
app = GpgApp(root)
root.mainloop()
{'fraction_non_alphanumeric': 0.12408759124087591, 'fraction_numerical': 0.0011229646266142617, 'mean_word_length': 2.719206680584551, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '4845970', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1122, 'n_words': 245}