<commit_before>#!/usr/bin/env python
#
# This file is part of GreatFET

from __future__ import print_function

import inspect
import errno
import sys

from greatfet import GreatFET

from greatfet.utils import GreatFETArgumentParser
from pygreat.errors import DeviceNotFoundError

import IPython

def main():

    # Set up a simple argument parser.
    parser = GreatFETArgumentParser(
        description="Convenience shell for working with GreatFET devices.")
    gf = parser.find_specified_device()

    # Break into IPython for the shell.
    print("Spwaning an IPython shell for easy access to your GreatFET.")
    print("Like normal python, you can use help(object) to get help for that object.")
    print("Try help(gf.apis.example) to see the documentation for the example API.\n")
    
    print("A GreatFET object has been created for you as 'gf'. Have fun!\n")
    IPython.start_ipython(user_ns={"gf": gf}, display_banner=False)


if __name__ == '__main__':
    main()<commit_msg>gf shell: add new --exec option for rapid debugging<commit_after>#!/usr/bin/env python
#
# This file is part of GreatFET

from __future__ import print_function

import inspect
import errno
import sys

from greatfet import GreatFET

from greatfet.utils import GreatFETArgumentParser
from pygreat.errors import DeviceNotFoundError

import IPython

def main():


    # Set up a simple argument parser.
    parser = GreatFETArgumentParser(
        description="Convenience shell for working with GreatFET devices.")
    parser.add_argument('-e', '--exec', metavar="code", type=str, help="Executes the provided code as though it were passed" +
            "to a greatfet shell, and then terminates.", dest="code")

    args = parser.parse_args()
    gf = parser.find_specified_device()

    if args.code:
        print(repr(eval(args.code)))
        sys.exit(0)


    # Break into IPython for the shell.
    print("Spwaning an IPython shell for easy access to your GreatFET.")
    print("Like normal python, you can use help(object) to get help for that object.")
    print("Try help(gf.apis.example) to see the documentation for the example API.\n")

    print("A GreatFET object has been created for you as 'gf'. Have fun!\n")
    IPython.start_ipython(user_ns={"gf": gf}, display_banner=False, argv=[])


if __name__ == '__main__':
    main()
{'fraction_non_alphanumeric': 0.09141630901287554, 'fraction_numerical': 0.00042918454935622315, 'mean_word_length': 3.836099585062241, 'pattern_counts': {'":': 2, '<': 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': '963021', 'n_tokens_mistral': 717, 'n_tokens_neox': 668, 'n_words': 253}