Esempio n. 1
0
 def __get_db_paths(self):
     output_dir = get_output_dir(client_file=False)
     self.db_path = os.path.join(output_dir, DATABASE_PATH)
     self.db_backup_b4_path = os.path.join(output_dir,
                                           BACKUP_DB_BEFORE_NAME)
     self.db_backup_after_path = os.path.join(output_dir,
                                              BACKUP_DB_AFTER_NAME)
Esempio n. 2
0
 def backup_wb(inventory_file: str):
     '''Creates a backup of workbook before new edits'''
     backup_dir = get_output_dir(client_file=False)
     backup_path = os.path.join(backup_dir,
                                'Inventory Reduction b4lastrun.xlsx')
     copy(inventory_file, backup_path)
     logging.info(
         f'Backup created at: {backup_path}, before touching {inventory_file}'
     )
Esempio n. 3
0
 def _prepare_filepaths(self):
     '''creates cls variables of files abs paths to be created one dir above this script dir'''
     output_dir = get_output_dir()
     date_stamp = datetime.today().strftime("%Y.%m.%d %H.%M")
     self.same_buyers_filename = os.path.join(
         output_dir, f'Same Buyer Orders {date_stamp}.txt')
     self.etonas_filename = os.path.join(
         output_dir, f'Etonas-Amazon {date_stamp}.xlsx')
     self.dpost_filename = os.path.join(output_dir,
                                        f'DPost-Amazon {date_stamp}.csv')
     self.ups_filename = os.path.join(output_dir,
                                      f'UPS-Amazon {date_stamp}.csv')
Esempio n. 4
0
 def _prepare_filepath(self):
     '''constructs cls variable of output abs file path'''
     output_dir = get_output_dir()
     self.inventory_file = os.path.join(output_dir, EXPORT_FILE)
# GLOBAL VARIABLES
TESTING = False
EXPECTED_SYS_ARGS = 2
VBA_ERROR_ALERT = 'ERROR_CALL_DADDY'
VBA_KEYERROR_ALERT = 'ERROR_IN_SOURCE_HEADERS'
VBA_OK = 'EXPORTED_SUCCESSFULLY'
TEST_AMZN_EXPORT_TXT = r'C:\Coding\Amazon Orders Parser\Amazon exports\sample_amzn_export.txt'

if is_windows_machine():
    TEST_AMZN_EXPORT_TXT = r'C:\Coding\Ebay\Working\Backups\Amazon exports\amzn2.txt'
else:
    TEST_AMZN_EXPORT_TXT = r'/home/devyo/Coding/Git/Amazon Orders Parser/Amazon exports/Collected exports/run4.txt'

# Logging config:
log_path = os.path.join(get_output_dir(client_file=False),
                        'loading_amazon_orders.log')
logging.basicConfig(handlers=[logging.FileHandler(log_path, 'a', 'utf-8')],
                    level=logging.INFO)


def get_cleaned_orders(source_file: str) -> list:
    '''returns cleaned orders (as cleaned in clean_orders func) from source_file arg path'''
    raw_orders = get_raw_orders(source_file)
    cleaned_orders = clean_orders(raw_orders)
    return cleaned_orders


def get_raw_orders(source_file: str) -> list:
    '''returns raw orders as list of dicts for each order in txt source_file'''
    with open(source_file, 'r', encoding='utf-8') as f: