<commit_before>import os
import sys
import argparse
import PythonQt
from PythonQt import QtCore, QtGui

import ddapp
from ddapp import applogic
from ddapp import objectmodel as om
from ddapp import vtkAll as vtk
from ddapp import vtkNumpy as vnp
from ddapp import viewbehaviors
from ddapp import visualization as vis
from ddapp.timercallback import TimerCallback

import numpy as np


class ConsoleApp(object):

    def __init__(self):
        om.init()
        self.objectModelWidget = None

    @staticmethod
    def start():

        if ConsoleApp.getTestingEnabled() and not ConsoleApp.getTestingInteractiveEnabled():
            quitTimer = TimerCallback()
            quitTimer.callback = ConsoleApp.quit
            quitTimer.singleShot(0.1)

        ConsoleApp.applicationInstance().exec_()

    @staticmethod
    def quit():
        ConsoleApp.applicationInstance().quit()

    @staticmethod
    def applicationInstance():
        return QtCore.QCoreApplication.instance()

    def showObjectModel(self):

        if not self.objectModelWidget:
            w = QtGui.QWidget()
            l = QtGui.QVBoxLayout(w)
            model = om.getDefaultObjectModel()
            l.addWidget(model.getTreeWidget())
            l.addWidget(model.getPropertiesPanel())
            applogic.addShortcut(w, 'Ctrl+Q', self.quit)
            self.objectModelWidget = w
            self.objectModelWidget.resize(350, 700)

        self.objectModelWidget.show()
        self.objectModelWidget.raise_()
        self.objectModelWidget.activateWindow()

    def createView(self, useGrid=True):
        view = PythonQt.dd.ddQVTKWidgetView()
        view.resize(600, 400)

        applogic.setCameraTerrainModeEnabled(view, True)
        if useGrid:
            vis.showGrid(view, parent='scene')

        applogic.resetCamera(viewDirection=[-1,-1,-0.3], view=view)
        viewBehaviors = viewbehaviors.ViewBehaviors(view)
        applogic._defaultRenderView = view

        applogic.addShortcut(view, 'Ctrl+Q', self.quit)
        applogic.addShortcut(view, 'F8', self.showPythonConsole)
        applogic.addShortcut(view, 'F9', self.showObjectModel)

        view.setWindowIcon(om.Icons.getIcon(om.Icons.Robot))
        view.setWindowTitle('View')

        return view

    @staticmethod
    def showPythonConsole():
        applogic.showPythonConsole()

    def setupGlobals(self, globalsDict):

        quit = ConsoleApp.quit
        exit = quit

        globalsDict.update(locals())
        for arg in ['globalsDict', 'self']:
            del globalsDict[arg]

    @staticmethod
    def getTestingArgs(dataDirRequired=False, outputDirRequired=False):

      parser = argparse.ArgumentParser()
      parser.add_argument('--testing', action='store_true', help='enable testing mode')
      parser.add_argument('-d', '--data-dir', type=str, help='testing data directory', required=dataDirRequired)
      parser.add_argument('-o', '--output-dir', type=str, help='output directory for writing test output', required=outputDirRequired)
      parser.add_argument('-i', '--interactive', action='store_true', help='enable interactive testing mode')

      args, unknown = parser.parse_known_args()<commit_msg>change consoleapp shortcut<commit_after>import os
import sys
import argparse
import PythonQt
from PythonQt import QtCore, QtGui

import ddapp
from ddapp import applogic
from ddapp import objectmodel as om
from ddapp import vtkAll as vtk
from ddapp import vtkNumpy as vnp
from ddapp import viewbehaviors
from ddapp import visualization as vis
from ddapp.timercallback import TimerCallback

import numpy as np


class ConsoleApp(object):

    def __init__(self):
        om.init()
        self.objectModelWidget = None

    @staticmethod
    def start():

        if ConsoleApp.getTestingEnabled() and not ConsoleApp.getTestingInteractiveEnabled():
            quitTimer = TimerCallback()
            quitTimer.callback = ConsoleApp.quit
            quitTimer.singleShot(0.1)

        ConsoleApp.applicationInstance().exec_()

    @staticmethod
    def quit():
        ConsoleApp.applicationInstance().quit()

    @staticmethod
    def applicationInstance():
        return QtCore.QCoreApplication.instance()

    def showObjectModel(self):

        if not self.objectModelWidget:
            w = QtGui.QWidget()
            l = QtGui.QVBoxLayout(w)
            model = om.getDefaultObjectModel()
            l.addWidget(model.getTreeWidget())
            l.addWidget(model.getPropertiesPanel())
            applogic.addShortcut(w, 'Ctrl+Q', self.quit)
            self.objectModelWidget = w
            self.objectModelWidget.resize(350, 700)

        self.objectModelWidget.show()
        self.objectModelWidget.raise_()
        self.objectModelWidget.activateWindow()

    def createView(self, useGrid=True):
        view = PythonQt.dd.ddQVTKWidgetView()
        view.resize(600, 400)

        applogic.setCameraTerrainModeEnabled(view, True)
        if useGrid:
            vis.showGrid(view, parent='scene')

        applogic.resetCamera(viewDirection=[-1,-1,-0.3], view=view)
        viewBehaviors = viewbehaviors.ViewBehaviors(view)
        applogic._defaultRenderView = view

        applogic.addShortcut(view, 'Ctrl+Q', self.quit)
        applogic.addShortcut(view, 'F8', self.showPythonConsole)
        applogic.addShortcut(view, 'F1', self.showObjectModel)

        view.setWindowIcon(om.Icons.getIcon(om.Icons.Robot))
        view.setWindowTitle('View')

        return view

    @staticmethod
    def showPythonConsole():
        applogic.showPythonConsole()

    def setupGlobals(self, globalsDict):

        quit = ConsoleApp.quit
        exit = quit

        globalsDict.update(locals())
        for arg in ['globalsDict', 'self']:
            del globalsDict[arg]

    @staticmethod
    def getTestingArgs(dataDirRequired=False, outputDirRequired=False):

      parser = argparse.ArgumentParser()
      parser.add_argument('--testing', action='store_true', help='enable testing mode')
      parser.add_argument('-d', '--data-dir', type=str, help='testing data directory', required=dataDirRequired)
      parser.add_argument('-o', '--output-dir', type=str, help='output directory for writing test output', required=outputDirRequired)
      parser.add_argument('-i', '--interactive', action='store_true', help='enable interactive testing mode')

      args, unknown = parser.parse_known_args()
{'fraction_non_alphanumeric': 0.10064072511329895, 'fraction_numerical': 0.006250976715111736, 'mean_word_length': 3.053198226725776, 'pattern_counts': {'":': 0, '<': 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': '2881206', 'n_tokens_mistral': 1905, 'n_tokens_neox': 1785, 'n_words': 395}