Ejemplo n.º 1
0
    def _parse(self, address_column):
        loading_circle = progress.LoadingCircle(self.gui, text='Parsing')
        loading_circle.start()

        self.address_parser.set_address_column(address_column)

        self.address_parser.parse_addresses(self.file_df)

        self._write_output_file()

        loading_circle.end()

        self.gui.destroy()
Ejemplo n.º 2
0
 def _update(self, new):
     loading_circle = progress.LoadingCircle(self.gui, text='Updating')
     loading_circle.start()
     
     column = self._period_column()
     
     sql_code = f'''
         UPDATE {self.table_name} 
         SET {column}=?
         WHERE {constants.ID_COLUMN_NAME} LIKE "{self.permit}-{self.sub}%"
         '''
     
     updated = utilities.execute_sql(
         sql_code=sql_code, args=(new, ), db_name=self.db_name, dml=True
         )
     
     if updated:
         message = f'{self.permit}-{self.sub} updated.'
         
         self._set_messge_label(message)
     
     loading_circle.end()
Ejemplo n.º 3
0
 def _fetch(self):
     loading_circle = progress.LoadingCircle(self.gui, text='Fetching')
     loading_circle.start()
     
     column = self._period_column()
     
     query = f'''
         SELECT {column}
         FROM {self.table_name}
         WHERE {constants.ID_COLUMN_NAME} LIKE "{self.permit}-{self.sub}%"
         '''
     
     results = utilities.execute_sql(sql_code=query, db_name=self.db_name)
     
     if results:
         value = '{:,}'.format(results[0])
         
     else:
         value = ''
         
     self.gui.current.set(value)
         
     loading_circle.end()
Ejemplo n.º 4
0
    def _compare(self, key_columns_one, key_columns_two, output_path):
        loading_circle = progress.LoadingCircle(self.gui, text='Comparing')
        loading_circle.start()

        open_output_state = self.gui.open_output_state.get()

        include_options = self._get_inlclude_options()

        self.Model = Model(self.path_one, self.path_two, key_columns_one,
                           key_columns_two, output_path, open_output_state,
                           include_options, self.gui.window_title)

        try:
            self.Model.run()

        except Exception:
            msg.showerror(
                self.gui.window_title,
                f'Unhandled exception occurred:\n\n{traceback.format_exc()}',
                parent=self.gui)

        finally:
            loading_circle.end()
Ejemplo n.º 5
0
    def load_csv_file(self, path):
        loading_circle = progress.LoadingCircle(parent=self.gui,
                                                text='Reading',
                                                bg_color='white')
        loading_circle.start()

        try:
            df = self.clearview_detail.get_dataframe(path)

        except Exception:
            msg.showerror(
                self.title,
                f'Unhandled exception occurred:\n\n{traceback.format_exc()}')

        finally:
            loading_circle.end()

        if not df is None:
            file_count = self._get_file_count()
            # if a jurisdiction has already been loaded but all the files
            # were removed then the flag to load the jurisdiction will be reset
            if self.jurisdiction_loaded and not file_count:
                self.jurisdiction_loaded = False

            check_new_file = True
            if not self.jurisdiction_loaded:
                self.tac = self.get_tac(df)

                data_type = self.get_data_type(path)
                self.data_type = data_type

                self.jurisdiction = self.get_jurisdiction(self.tac)

                if self.jurisdiction:
                    self._set_file_name()

                    self.jurisdiction_loaded = True
                    check_new_file = False
            else:
                tac = self.get_tac(df)
                data_type = self.get_data_type(path)

            if data_type in self.supported_files:
                same_juri = True
                same_data_type = True
                if check_new_file:
                    if self.tac and tac != self.tac:
                        same_juri = False

                        msg.showerror(
                            self.title,
                            'Can only join one jurisdiction at a time. '
                            f'Data for ({self.tac}) has already been '
                            f'loaded. To join files for ({tac}) either '
                            'open another window or clear all the files.',
                            parent=self.gui)

                    if same_juri and self.data_type and data_type != self.data_type:
                        same_data_type = False

                        msg.showerror(
                            self.title,
                            'Can only join one data type at a time. '
                            f'Data for ({self.data_type}) has already been '
                            f'loaded. To join files for ({data_type}) either '
                            'open another window or clear all the files.',
                            parent=self.gui)

                if same_juri and same_data_type:
                    quarter_range = self._get_quarter_range(df)

                    display_name = (
                        f'{self.jurisdiction.id} {data_type}: {quarter_range}')

                    if not display_name in self.files:
                        self.gui.file_list.insert('end', display_name)

                        self.files[display_name] = (self.jurisdiction, df)

                        period_count = self._get_period_count(df)

                        self.period_count += period_count

                        self._set_period_count_label()

                        if not self.load_enabled and len(self.files) >= 2:
                            self.gui.enable_left_button()

                            self.load_enabled = True
            else:
                msg.showerror(
                    self.title,
                    'Data type not supported. Supported data types are:'
                    f'\n\n({self.supported_files}) \n\nIf this is '
                    'one of those files, make sure that it is reflected '
                    'in the name of the file.',
                    parent=self.gui)