<commit_before>import os
import re
import platform
try:
    import cPickle as pickle
except:
    import pickle

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.popup import Popup
from kivy.uix.button import Button
from kivy.uix.filechooser import FileChooserIconView
from kivy.uix.textinput import TextInput
import kivy
kivy.require('1.9.1')

class TestFile(object):
    def __init__(self):
        self.name = "Test"
        self.version = 420
        self.is_dank = True

    def test_print(self, string):
        print string


class FileHandler(BoxLayout):
    def show_load_popup(self, *args):
        load_btn = Button(text='Load', size_hint=(.08, .05))
        file_chooser = FileChooserIconView(path="../saves")

        content = FloatLayout()
        content.clear_widgets()
        content.add_widget(file_chooser)
        content.add_widget(load_btn)

        popup = Popup(title="Load a file", content=content)
        load_callback = lambda load: self.load(
            file_chooser.path,
            file_chooser.selection, popup)
        load_btn.bind(on_release=load_callback)
        popup.open()

    def show_save_popup(self, save_unit, *args):
        text_input = TextInput(
            size_hint=(.20, .05),
            pos_hint={'center_x': .5, 'bottom_y': .05},
            multiline=False)
        save_btn = Button(text='Save', size_hint=(.08, .05))
        file_chooser = FileChooserIconView(path="../saves")

        content = FloatLayout()
        content.clear_widgets()
        content.add_widget(file_chooser)
        content.add_widget(save_btn)
        content.add_widget(text_input)

        popup = Popup(title="Save a file", content=content)

        serialize_callback = lambda save: self.save(<commit_msg>Filepath pseudo fix. Finds 'saves/' as long as main.py is launched from within ddh/<commit_after>import os
import re
import platform
try:
    import cPickle as pickle
except:
    import pickle

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.popup import Popup
from kivy.uix.button import Button
from kivy.uix.filechooser import FileChooserIconView
from kivy.uix.textinput import TextInput
import kivy
kivy.require('1.9.1')

class TestFile(object):
    def __init__(self):
        self.name = "Test"
        self.version = 420
        self.is_dank = True

    def test_print(self, string):
        print string


class FileHandler(BoxLayout):
    def show_load_popup(self, *args):
        if os.path.exists(os.path.abspath('saves/')):
            file_chooser = FileChooserIconView(path="saves")
        elif os.path.exists(os.path.abspath('../saves')):
            file_chooser = FileChooserIconView(path="../saves")
        else:
            file_chooser = FileChooserIconView(path=".")
        load_btn = Button(text='Load', size_hint=(.08, .05))

        content = FloatLayout()
        content.clear_widgets()
        content.add_widget(file_chooser)
        content.add_widget(load_btn)

        popup = Popup(title="Load a file", content=content)
        load_callback = lambda load: self.load(
            file_chooser.path,
            file_chooser.selection, popup)
        load_btn.bind(on_release=load_callback)
        popup.open()

    def show_save_popup(self, save_unit, *args):
        if os.path.exists(os.path.abspath('saves/')):
            file_chooser = FileChooserIconView(path="saves")
        elif os.path.exists(os.path.abspath('../saves')):
            file_chooser = FileChooserIconView(path="../saves")
        else:
            file_chooser = FileChooserIconView(path=".")
        text_input = TextInput(
            size_hint=(.20, .05),
            pos_hint={'center_x': .5, 'bottom_y': .05},
            multiline=False)
        save_btn = Button(text='Save', size_hint=(.08, .05))

        content = FloatLayout()
        content.clear_widgets()
        content.add_widget(file_chooser)
        content.add_widget(save_btn)
        content.add_widget(text_input)

        popup = Popup(title="Save a file", content=content)

        serialize_callback = lambda save: self.save(
{'fraction_non_alphanumeric': 0.10973871733966746, 'fraction_numerical': 0.009976247030878859, 'mean_word_length': 2.793693693693694, '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': '4085729', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1328, 'n_words': 278}