def main():
    args = parse_arguments()
    if args.locale:
        locale.setlocale(locale.LC_ALL, args.locale)
    else:
        locale.setlocale(locale.LC_ALL, 'en_GB')
    datastore_path = args.path
    nr_records = args.number
    if (not is_path_existent(('%s/%s' % (datastore_path, 'csv')))):
        sys.exit(1)
    if (not is_path_existent(('%s/%s' % (datastore_path, 'db')))):
        sys.exit(1)
    if args.customer:
        customers = load_customers_pages(args.key, args.customer)
        persist_customers_to_sqlite(customers, datastore_path)
    lookup = lookup_customers(datastore_path)
    orders = load_orders_pages(args.key, nr_records, lookup)
    print(('info: loaded %d order(s)...' % len(orders)))
    print(orders[0])
    print('info: all records between FIRST and LAST\n')
    print(orders[(- 1)])
    export_to_csv(orders, datastore_path)
    print(('info: CSV export successul %d order(s)' % len(orders)))
    if args.db:
        export_to_sqlite(orders, datastore_path)
def main():
    args = parse_arguments()
    if args.locale:
        locale.setlocale(locale.LC_ALL, args.locale)
    else:
        locale.setlocale(locale.LC_ALL, 'en_GB')
    datastore_path = args.path
    nr_records = args.number
    if (not is_path_existent(('%s/%s' % (datastore_path, 'csv')))):
        sys.exit(1)
    if (not is_path_existent(('%s/%s' % (datastore_path, 'db')))):
        sys.exit(1)
    if args.customer:
        customers = load_customers_pages(args.key, args.customer)
        persist_customers_to_sqlite(customers, datastore_path)
    lookup = lookup_customers(datastore_path)
    orders = load_orders_pages(args.key, nr_records, lookup)
    print(('info: loaded %d order(s)...' % len(orders)))
    print(orders[0])
    print('info: all records between FIRST and LAST\n')
    print(orders[(- 1)])
    export_to_csv(orders, datastore_path)
    print(('info: CSV export successul %d order(s)' % len(orders)))
    if args.db:
        export_to_sqlite(orders, datastore_path)