<commit_before>import wx

from src.wizard.view.clsSeriesSelectPanel \
    import SeriesSelectPanelView
from src.wizard.view.clsCustomDialog \
    import CustomDialog
from src.wizard.controller.frmSeriesWizard \
    import SeriesWizardController

from src.wizard.controller.WizardDialog \
    import WizardDialog
from src.wizard.controller.frmSampFeatSelectPanel \
    import SampFeatSelectPanel
from src.wizard.controller.frmVariableSelectPanel \
    import VariableSelectPanel
from src.wizard.controller.frmUnitSelectPanel \
    import UnitSelectPanel
from src.wizard.controller.frmProcLevelSelectPanel \
    import ProcLevelSelectPanel
from src.wizard.controller.frmActionsSelectPanel \
    import ActionsSelectPanel
from src.wizard.controller.frmResultSummaryPanel \
    import ResultSummaryPanel

from odm2api.ODM2.services.readService \
    import DetailedResult

from src.wizard.models.ResultMapping import ResultMapping

class SeriesSelectDialog(CustomDialog):
    def __init__(self, parent, variable, database):
        super(SeriesSelectDialog, self).__init__(\
            parent=parent,
            title="Select Result for %s" % variable,
            size=wx.Size(700, 500))
        self.database = database

        read = database.getReadSession()
        #read.getDetailedResultInfo("Time series coverage")
        self.seriesSelectPanel = SeriesSelectPanelView(self)
        self.addPanel(self.seriesSelectPanel)

        self.seriesSelectPanel.newBtn.Bind(wx.EVT_BUTTON, self.onNew)
        self.seriesSelectPanel.editBtn.Bind(wx.EVT_BUTTON, self.onEdit)
        self.seriesSelectPanel.okBtn.Bind(wx.EVT_BUTTON, self.onOK)

        self.seriesSelectPanel.listCtrl.SetObjects(read.getDetailedResultInfo("Time series coverage"))

        self.seriesSelectPanel.listCtrl.Bind(wx.EVT_LIST_ITEM_SELECTED, self.enable)
    # ================== #
    # > Event Handlers < #
    # ================== #

    def onNew(self, event):
        wiz = WizardDialog(self,
            database=self.database,
            title="New Result Wizard")
        
        wiz.addPage(SampFeatSelectPanel) 
        wiz.addPage(VariableSelectPanel) 
        wiz.addPage(UnitSelectPanel) 
        wiz.addPage(ProcLevelSelectPanel) 
        wiz.addPage(ActionsSelectPanel) 
        #wiz.addPage(ResultPageView)
        wiz.addPage(ResultSummaryPanel)

        wiz.CenterOnParent()
        if wiz.ShowModal() == wx.ID_OK:
            wiz.Center()
            read = self.database.getReadSession()
            r = read.getDetailedResultInfo("Time series coverage", 
                                            wiz.result.ResultID)
            r_id = r[0].resultID
            detailedResults = read.getDetailedResultInfo("Time series coverage")
            self.seriesSelectPanel.listCtrl.SetObjects(detailedResults)

            for i in detailedResults:
                if i.resultID == r_id:
                    self.seriesSelectPanel.listCtrl.SelectObject(\
                        i, deselectOthers=True,
                        ensureVisible=True)
        else:
            pass
            #wx.MessageBox('An error occurred while creating a new result', 'Error')
        
        event.Skip()

    def enable(self, event):
        self.seriesSelectPanel.editBtn.Enable(True)

    def onEdit(self, event):
        print "Edit"
        wiz = WizardDialog(self, database=self.database, title="Edit Result Wizard")
        wiz.centerSelf()
        wiz.addPage(SampFeatSelectPanel)
        wiz.addPage(VariableSelectPanel)
        wiz.addPage(UnitSelectPanel)
        wiz.addPage(ProcLevelSelectPanel)
        wiz.addPage(ActionsSelectPanel)
        wiz.addPage(ResultSummaryPanel)
        wiz.CenterOnParent()
        wiz.ShowModal()<commit_msg>edit btn functionality in progress<commit_after>import wx

from src.wizard.view.clsSeriesSelectPanel \
    import SeriesSelectPanelView
from src.wizard.view.clsCustomDialog \
    import CustomDialog
from src.wizard.controller.frmSeriesWizard \
    import SeriesWizardController

from src.wizard.controller.WizardDialog \
    import WizardDialog
from src.wizard.controller.frmSampFeatSelectPanel \
    import SampFeatSelectPanel
from src.wizard.controller.frmVariableSelectPanel \
    import VariableSelectPanel
from src.wizard.controller.frmUnitSelectPanel \
    import UnitSelectPanel
from src.wizard.controller.frmProcLevelSelectPanel \
    import ProcLevelSelectPanel
from src.wizard.controller.frmActionsSelectPanel \
    import ActionsSelectPanel
from src.wizard.controller.frmResultSummaryPanel \
    import ResultSummaryPanel

from odm2api.ODM2.services.readService \
    import DetailedResult

from src.wizard.models.ResultMapping import ResultMapping

class SeriesSelectDialog(CustomDialog):
    def __init__(self, parent, variable, database):
        super(SeriesSelectDialog, self).__init__(\
            parent=parent,
            title="Select Result for %s" % variable,
            size=wx.Size(700, 500))
        self.database = database

        read = database.getReadSession()
        #read.getDetailedResultInfo("Time series coverage")
        self.seriesSelectPanel = SeriesSelectPanelView(self)
        self.addPanel(self.seriesSelectPanel)

        self.seriesSelectPanel.newBtn.Bind(wx.EVT_BUTTON, self.onNew)
        self.seriesSelectPanel.editBtn.Bind(wx.EVT_BUTTON, self.onEdit)
        self.seriesSelectPanel.okBtn.Bind(wx.EVT_BUTTON, self.onOK)

        self.seriesSelectPanel.listCtrl.SetObjects(read.getDetailedResultInfo("Time series coverage"))

        self.seriesSelectPanel.listCtrl.Bind(wx.EVT_LIST_ITEM_SELECTED, self.enable)
    # ================== #
    # > Event Handlers < #
    # ================== #

    def onNew(self, event):
        wiz = WizardDialog(self,
            database=self.database,
            title="New Result Wizard")
        
        wiz.addPage(SampFeatSelectPanel) 
        wiz.addPage(VariableSelectPanel) 
        wiz.addPage(UnitSelectPanel) 
        wiz.addPage(ProcLevelSelectPanel) 
        wiz.addPage(ActionsSelectPanel) 
        #wiz.addPage(ResultPageView)
        wiz.addPage(ResultSummaryPanel)

        wiz.CenterOnParent()
        if wiz.ShowModal() == wx.ID_OK:
            wiz.Center()
            read = self.database.getReadSession()
            r = read.getDetailedResultInfo("Time series coverage", 
                                            wiz.result.ResultID)
            r_id = r[0].resultID
            detailedResults = read.getDetailedResultInfo("Time series coverage")
            self.seriesSelectPanel.listCtrl.SetObjects(detailedResults)

            for i in detailedResults:
                if i.resultID == r_id:
                    self.seriesSelectPanel.listCtrl.SelectObject(\
                        i, deselectOthers=True,
                        ensureVisible=True)
        else:
            pass
            #wx.MessageBox('An error occurred while creating a new result', 'Error')
        
        event.Skip()

    def enable(self, event):
        self.seriesSelectPanel.editBtn.Enable(True)
        existingResult = self.seriesSelectPanel.listCtrl.GetSelectedObject()


    def onEdit(self, event):
        print "Edit"
        wiz = WizardDialog(self, database=self.database, title="Edit Result Wizard")
        wiz.centerSelf()
        wiz.addPage(SampFeatSelectPanel)
        wiz.addPage(VariableSelectPanel)
        wiz.addPage(UnitSelectPanel)
        wiz.addPage(ProcLevelSelectPanel)
        wiz.addPage(ActionsSelectPanel)
        wiz.addPage(ResultSummaryPanel)
        wiz.CenterOnParent()
        wiz.ShowModal()
{'fraction_non_alphanumeric': 0.09142555159202008, 'fraction_numerical': 0.0023781212841854932, 'mean_word_length': 2.703522504892368, 'pattern_counts': {'":': 0, '<': 5, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2126514', 'n_tokens_mistral': 2164, 'n_tokens_neox': 2098, 'n_words': 349}