Esempio n. 1
0
 def __init__(self, window, period):
     super().__init__()
     
     self.loading_circle = LoadingCircle(window, 'Exporting')
     self.loading_circle.start()
     
     self.period = period
     
     self.con = None
     self.df = None
     self.output_saved = False
     
     self.output_path = constants.TEMP_FILE_PATH.joinpath(
         f'{self.period} Econ Totals.xlsx'
         )
     
     self.period_cols = utilities.get_period_headers(
         count=PERIOD_COUNT, 
         period=self.period,
         prefix=constants.QUARTER_COLUMN_PREFIX,
         descending=True
         )
     
     self.current_period = self.period_cols[0]
     self.prior_period = self.period_cols[4]
     
     self.bmy_col_one = (
         constants.YEAR_COLUMN_PREFIX + self.current_period[-6:]
         )
     
     self.bmy_col_two = (
         constants.YEAR_COLUMN_PREFIX + self.period_cols[4][-6:]
         )
     
     self._set_query()
Esempio n. 2
0
    def _set_period_cols(self):
        period_count = (self.col_indexes['Current Period'] -
                        self.col_indexes['Oldest Period'] + 1)

        self.period_cols = utilities.get_period_headers(
            count=period_count,
            period=self.period,
            prefix=constants.QUARTER_COLUMN_PREFIX)
Esempio n. 3
0
 def _set_column_names(self):
     period_count = len(list(self.df)) - constants.FIRST_QUARTER_COLUMN
     
     period_names = utilities.get_period_headers(
         period_count, self.selections, descending=True
         )
    
     self.column_names = self.default_column_names + period_names
Esempio n. 4
0
    def _set_year_periods(self):
        period_count = (self.selections.years * 4)

        period_headers = utilities.get_period_headers(
            count=period_count,
            selections=self.selections,
            prefix=constants.QUARTER_COLUMN_PREFIX)

        # tuple with list of periods making up oldest and newest years
        self.year_periods = (period_headers[:4], period_headers[-4:])
Esempio n. 5
0
    def __init__(self, controller):
        self.controller = controller
        self.selections = self.controller.selections

        self.output_saved = False

        self.quarter_changes = {}

        self.blank_business_names = []
        self.juri_pool_amounts = []
        self.county_pool_amounts = []
        self.top_businesses = []
        self.top_business_amounts = []

        self.period_headers = utilities.get_period_headers(
            self.QUARTER_COUNT, self.selections)
Esempio n. 6
0
    def _set_period_headers(self):
        '''
            Populates a list of string period headers for each of the 
            periods that will be fetched.
        '''
        if self.selections.period_count == 'All':
            if self.is_cash:
                table_name = utilities.get_jurisdiction_table_name(
                    self.jurisdiction.id)

                db_name = constants.QUARTERLY_CASH_DB

                # number of other columns in the table other than the
                # period columns
                other_column_count = 1

            else:
                table_name = self.econ_table_name
                db_name = constants.STATEWIDE_DATASETS_DB
                other_column_count = 3

            column_names = utilities.get_column_names(db_name, table_name)

            # the table has an id column and the available periods
            count = len(column_names) - other_column_count

        else:
            count = int(self.selections.period_count)

            if (self.selections.interval == 'Year'
                    and count + 3 <= constants.MAX_PERIOD_COUNT):

                count += 3

        self.period_headers = utilities.get_period_headers(
            count, self.selections)
Esempio n. 7
0
 def _set_interval_periods(self):
     self.interval_periods = utilities.get_period_headers(
         count=self.period_count, selections=self.selections, step=4)
Esempio n. 8
0
 def _set_periods(self):
     self.periods = utilities.get_period_headers(
         count=self.period_count,
         selections=self.selections,
         prefix=constants.QUARTER_COLUMN_PREFIX)