<commit_before>#!/usr/bin/env python

# Retrieve the latest Bitcoin price and optionally convert a US dollar
# amount to a BTC amount.

import sys, argparse, logging
from btclib import logger, get_bitcoin_price


# parse arguments
parser = argparse.ArgumentParser(description='Fetch latest Bitcoin price')
parser.add_argument('-u', '--USD', help='convert a USD amount to BTC', nargs=1, type=float, required=False)
parser.add_argument('-v', '--verbose', help='show verbose output', action='store_true', required=False)
args = vars(parser.parse_args())

if (args['verbose']):
    logger.setLevel(logging.DEBUG)
else:
    logger.setLevel(logging.WARNING)


price = get_bitcoin_price()

if args['USD'] is None:
    sys.stdout.write('${:,.2f} = 1 BTC\n'.format(price))
else:
    usd = args['USD'][0]
    btc = usd / price
    sys.stdout.write('${:,.2f} = {:,.8f} BTC\n'.format(usd, btc))

<commit_msg>wrap execution in def main()<commit_after>#!/usr/bin/env python

# Retrieve the latest Bitcoin price and optionally convert a US dollar
# amount to a BTC amount.

import sys, argparse, logging
from btclib import logger, get_bitcoin_price


def main():

    # parse arguments
    parser = argparse.ArgumentParser(description='Fetch latest Bitcoin price')
    parser.add_argument('-u', '--USD', help='convert a USD dollar amount to BTC', nargs=1, type=float, required=False)
    parser.add_argument('-v', '--verbose', help='show verbose output', action='store_true', required=False)
    args = vars(parser.parse_args())

    if (args['verbose']):
        logger.setLevel(logging.DEBUG)
    else:
        logger.setLevel(logging.WARNING)


    price = get_bitcoin_price()

    if args['USD'] is None:
        sys.stdout.write('${:,.2f} = 1 BTC\n'.format(price))

    else:
        usd = args['USD'][0]
        btc = usd / price
        sys.stdout.write('${:,.2f} = {:,.8f} BTC\n'.format(usd, btc))


if __name__ == "__main__":
    main()

{'fraction_non_alphanumeric': 0.15535991714137753, 'fraction_numerical': 0.006214396685655101, 'mean_word_length': 3.979381443298969, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2379922', 'n_tokens_mistral': 658, 'n_tokens_neox': 626, 'n_words': 167}