<commit_before>import gtk

import logging
from optparse import OptionParser
import os
import stdout_capture
import sys

from global_settings import global_settings
from worksheet_window import WorksheetWindow

stdout_capture.init()

usage = "usage: %prog [options]"
op = OptionParser(usage=usage)
op.add_option("-u", "--ui", type="choice", choices=("standard", "hildon"),
              default="standard",  help=("which user interface to use (standard or "
					 "hildon), default=%default"))
op.add_option("-d", "--debug", action="store_true",
              help=("enable internal debug messages"))

options, args = op.parse_args()

if options.debug:
    logging.basicConfig(level=logging.DEBUG)

if options.ui == "hildon":
    try:
        import hildon
        global_settings.use_hildon = True
    except ImportError, e:
        print >>sys.stderr, "Error importing hildon. Falling back to standard ui."

w = WorksheetWindow()

if len(args) > 0:
    w.load(args[0])
else:
    # If you run reinteract from the command line, you'd expect to be able to
    # create a worksheet, test it, then save it in the current directory, and
    # have that act the same as loading the worksheet to start with. This is
    # less obviously right when run from a menu item.
    w.notebook.set_path([os.getcwd()])

w.show()

gtk.main()
<commit_msg>Add ~/.reinteract/modules to sys.path, if it exists.<commit_after>import gtk

import logging
from optparse import OptionParser
import os
import stdout_capture
import sys

from global_settings import global_settings
from worksheet_window import WorksheetWindow

stdout_capture.init()

usage = "usage: %prog [options]"
op = OptionParser(usage=usage)
op.add_option("-u", "--ui", type="choice", choices=("standard", "hildon"),
              default="standard",  help=("which user interface to use (standard or "
					 "hildon), default=%default"))
op.add_option("-d", "--debug", action="store_true",
              help=("enable internal debug messages"))

options, args = op.parse_args()

if options.debug:
    logging.basicConfig(level=logging.DEBUG)

if options.ui == "hildon":
    try:
        import hildon
        global_settings.use_hildon = True
    except ImportError, e:
        print >>sys.stderr, "Error importing hildon. Falling back to standard ui."

user_ext_path = os.path.expanduser(os.path.join('~', '.reinteract', 'modules'))
if os.path.exists(user_ext_path):
    sys.path[0:0] = [user_ext_path]

w = WorksheetWindow()

if len(args) > 0:
    w.load(args[0])
else:
    # If you run reinteract from the command line, you'd expect to be able to
    # create a worksheet, test it, then save it in the current directory, and
    # have that act the same as loading the worksheet to start with. This is
    # less obviously right when run from a menu item.
    w.notebook.set_path([os.getcwd()])

w.show()

gtk.main()

{'fraction_non_alphanumeric': 0.11740041928721175, 'fraction_numerical': 0.0020964360587002098, 'mean_word_length': 3.7796327212020033, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 9, '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': '1741800', 'n_tokens_mistral': 899, 'n_tokens_neox': 880, 'n_words': 290}