src/dirbs/listgen/generator.py
def _write_full_csv_notifications_list(self, operator_id):
        """Write full CSV, per-MNO notifications list for a given MNO from the intermediate tables."""
        tblname = self._notifications_lists_new_part_tblname(operator_id)
        filename = os.path.join(self._output_dir, '{0}_notifications_{1}.csv'.format(self._date_str, operator_id))
        cursor_name = 'listgen_write_full_csv_notifications_list_{0}'.format(operator_id)
        notification_list_columns, include_amnesty_column = self._notification_list_columns
        with create_db_connection(self._config.db_config) as conn, \
                conn.cursor(name=cursor_name) as cursor, open(filename, 'w') as csvfile, CodeProfiler() as cp:
            csv_writer = csv.DictWriter(csvfile,
                                        fieldnames=notification_list_columns,
                                        extrasaction='ignore')
            csv_writer.writeheader()
            cursor.execute(sql.SQL("""SELECT {imei_col} AS imei,
                                             imsi,
                                             msisdn,
                                             TO_CHAR(block_date, 'YYYYMMDD') AS block_date,
                                             array_to_string(reasons, '|') AS reasons
                                             {include_amnesty_column}
                                        FROM {tblname}
                                       WHERE {valid_filter}
                                   """).format(imei_col=self._output_imei_column,
                                               tblname=sql.Identifier(tblname),
                                               valid_filter=self._valid_filter_query,
                                               include_amnesty_column=include_amnesty_column))
            num_written_records = 0
            for row_data in cursor:
                csv_writer.writerow(row_data._asdict())
                num_written_records += 1
            num_records = self._get_total_record_count(conn, tblname)

        return self._gen_metadata_for_list(filename,
                                           num_records=num_records,
                                           num_written_records=num_written_records), 'notification_lists', cp.duration
Write full CSV, per-MNO notifications list for a given MNO from the intermediate tables.
Write full CSV, per-MNO notifications list for a given MNO from the intermediate tables.
Write full CSV per - MNO notifications list for a given MNO from the intermediate tables .
def _write_full_csv_notifications_list(self, operator_id):
        tblname = self._notifications_lists_new_part_tblname(operator_id)
        filename = os.path.join(self._output_dir, '{0}_notifications_{1}.csv'.format(self._date_str, operator_id))
        cursor_name = 'listgen_write_full_csv_notifications_list_{0}'.format(operator_id)
        notification_list_columns, include_amnesty_column = self._notification_list_columns
        with create_db_connection(self._config.db_config) as conn, \
                conn.cursor(name=cursor_name) as cursor, open(filename, 'w') as csvfile, CodeProfiler() as cp:
            csv_writer = csv.DictWriter(csvfile,
                                        fieldnames=notification_list_columns,
                                        extrasaction='ignore')
            csv_writer.writeheader()
            cursor.execute(sql.SQL("""SELECT {imei_col} AS imei,
                                             imsi,
                                             msisdn,
                                             TO_CHAR(block_date, 'YYYYMMDD') AS block_date,
                                             array_to_string(reasons, '|') AS reasons
                                             {include_amnesty_column}
                                        FROM {tblname}
                                       WHERE {valid_filter}
                                   """).format(imei_col=self._output_imei_column,
                                               tblname=sql.Identifier(tblname),
                                               valid_filter=self._valid_filter_query,
                                               include_amnesty_column=include_amnesty_column))
            num_written_records = 0
            for row_data in cursor:
                csv_writer.writerow(row_data._asdict())
                num_written_records += 1
            num_records = self._get_total_record_count(conn, tblname)
        return self._gen_metadata_for_list(filename,
                                           num_records=num_records,
                                           num_written_records=num_written_records), 'notification_lists', cp.duration
def _write_full_csv_notifications_list ( self , operator_id ) : tblname = self . _notifications_lists_new_part_tblname ( operator_id ) filename = os . path . join ( self . _output_dir , '{0}_notifications_{1}.csv' . format ( self . _date_str , operator_id ) ) cursor_name = 'listgen_write_full_csv_notifications_list_{0}' . format ( operator_id ) notification_list_columns , include_amnesty_column = self . _notification_list_columns with create_db_connection ( self . _config . db_config ) as conn , conn . cursor ( name = cursor_name ) as cursor , open ( filename , 'w' ) as csvfile , CodeProfiler ( ) as cp : csv_writer = csv . DictWriter ( csvfile , fieldnames = notification_list_columns , extrasaction = 'ignore' ) csv_writer . writeheader ( ) cursor . execute ( sql . SQL ( """SELECT {imei_col} AS imei,
                                             imsi,
                                             msisdn,
                                             TO_CHAR(block_date, 'YYYYMMDD') AS block_date,
                                             array_to_string(reasons, '|') AS reasons
                                             {include_amnesty_column}
                                        FROM {tblname}
                                       WHERE {valid_filter}
                                   """ ) . format ( imei_col = self . _output_imei_column , tblname = sql . Identifier ( tblname ) , valid_filter = self . _valid_filter_query , include_amnesty_column = include_amnesty_column ) ) num_written_records = 0 for row_data in cursor : csv_writer . writerow ( row_data . _asdict ( ) ) num_written_records += 1 num_records = self . _get_total_record_count ( conn , tblname ) return self . _gen_metadata_for_list ( filename , num_records = num_records , num_written_records = num_written_records ) , 'notification_lists' , cp . duration
Write full CSV, per-MNO notifications list for a given MNO from the intermediate tables.
Write full CSV per - MNO notifications list for a given MNO from the intermediate tables .
"""Write full CSV, per-MNO notifications list for a given MNO from the intermediate tables."""
self
operator_id