Example #1
0
    def parse(self):
        db = BLLDatabase()

        self.parse_dict = {}

        lines = list(self.reader)

        if lines:
            #Note: the "Elapsed_Time" column does not reset here because we are using 5 minute blocks
            start = float(lines[0]['Elapsed_Time'])

            acts_dict = {}
            for row in lines:
                env = row['environment'].strip()
                act = row['Activity'].strip()

                if not env in self.parse_dict:
                    self.parse_dict[env] = {}

                if not act in self.parse_dict[env]:
                    self.parse_dict[env][act] = {
                        'used': [],
                        'unused': [],
                    }

                spreadsheet_timestamp = Reliability2Parser.get_row_timestamp(
                    row, start)
                child_code = Reliability2Parser.get_child_code(row)
                #note: no need to check wav_file here, since that is derived from child_code
                result_set = db.select(
                    'tests2', ['count(id)'],
                    'spreadsheet_timestamp=? AND child_code=?',
                    [spreadsheet_timestamp, child_code])
                if int(result_set[0][0]) > 0:
                    self.parse_dict[env][act]['used'].append(row)
                else:
                    self.parse_dict[env][act]['unused'].append(row)

                if not act in acts_dict:
                    acts_dict[act] = True

            self.acts = acts_dict.keys()
            self.envs = self.parse_dict.keys()

        db.close()
Example #2
0
    def _fill_entry(combo, entry):
        opt_id = combo.get_model()[combo.get_active()][1]
        db = BLLDatabase()
        # Ideally, the regex info should come out of an enum in the DBConstants class (such as DBConstants.COMMON_REGEXS).
        # However, we only have the combobox option id of the selected option, and this isn't enough to figure out which enum value we need.
        # To solve this problem, I've reverted to a database query here, but this should really be fixed in the future...we need something other
        # than the option id to identify the selected combo option.
        rows = db.select('common_regexs', 'regex'.split(), 'combo_option_id=?',
                         [opt_id])
        if rows and rows[0]:
            regex = rows[0][0]
            highlight_start = regex.find('\<')
            highlight_end = regex.find('\>')

            entry.set_text(regex.replace('\<', '<').replace('\>', '>'))

            entry.grab_focus()
            if highlight_start > -1 and highlight_end > -1:
                entry.select_region(highlight_start, highlight_end)

            db.close()