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

import json
import sys
import argparse
import usb.core

try:
    from termcolor import colored
except ImportError:
    def colored(text, color):
        return text


class DataPoint(object):
    def __init__(self, name, value_type, min_value=0, max_value=0, vocab=None):
        self.name = name
        self.type = value_type
        self.min_value = min_value
        self.max_value = max_value
        self.event = ''
        self.bad_data = False
        self.data_present = False
        self.current_data = 0.0

        # Vocab is a list of acceptable strings for CurrentValue
        self.vocab = vocab or []

    def NewVal(self, ParsedMess):
        self.data_present = True
        if self.bad_data==False:
            self.current_data = ParsedMess['value']
            if type(self.current_data) != self.type:
                self.bad_data = True
            else:
                if type(self.current_data) is unicode:
                    if self.current_data in self.vocab:
                        self.bad_data = False
                        if len(ParsedMess) > 2:
                            self.Event = ParsedMess['event']
                    else:
                        self.bad_data = True
                elif type(self.current_data) is bool:
                    self.bad_data = False
                else:
                    if self.current_data < self.min_value:
                        self.bad_data = True
                    if self.current_data > self.max_value:
                        self.bad_data = True

    def PrintVal(self):
        print self.name, '  ',
        if self.data_present == False:
            print colored('No Data', 'yellow')
        elif self.bad_data == True:
            print (colored('Bad Data:  ', 'red'), self.current_data, ' ',
                    self.Event)
        else:
            print (colored('Good Data:  ', 'green'), self.current_data, ' ',
                    self.Event)


class UsbDevice(object):
    DATA_ENDPOINT = 0x81
    VERSION_CONTROL_COMMAND = 0x80
    RESET_CONTROL_COMMAND = 0x81

    def __init__(self, vendorId=0x04d8, endpoint=0x81, verbose=False,
            dump=False, dashboard=False, elements=None):
        self.verbose = verbose
        self.dump = dump<commit_msg>Use simpler boolean checks, not explicit comparison to True/False.<commit_after>#!/usr/bin/env python

import json
import sys
import argparse
import usb.core

try:
    from termcolor import colored
except ImportError:
    def colored(text, color):
        return text


class DataPoint(object):
    def __init__(self, name, value_type, min_value=0, max_value=0, vocab=None):
        self.name = name
        self.type = value_type
        self.min_value = min_value
        self.max_value = max_value
        self.event = ''
        self.bad_data = False
        self.data_present = False
        self.current_data = 0.0

        # Vocab is a list of acceptable strings for CurrentValue
        self.vocab = vocab or []

    def NewVal(self, ParsedMess):
        self.data_present = True
        if not self.bad_data:
            self.current_data = ParsedMess['value']
            if type(self.current_data) != self.type:
                self.bad_data = True
            else:
                if type(self.current_data) is unicode:
                    if self.current_data in self.vocab:
                        self.bad_data = False
                        if len(ParsedMess) > 2:
                            self.Event = ParsedMess['event']
                    else:
                        self.bad_data = True
                elif type(self.current_data) is bool:
                    self.bad_data = False
                else:
                    if self.current_data < self.min_value:
                        self.bad_data = True
                    if self.current_data > self.max_value:
                        self.bad_data = True

    def PrintVal(self):
        print self.name, '  ',
        if not self.data_present:
            print colored('No Data', 'yellow')
        elif self.bad_data:
            print (colored('Bad Data:  ', 'red'), self.current_data, ' ',
                    self.Event)
        else:
            print (colored('Good Data:  ', 'green'), self.current_data, ' ',
                    self.Event)


class UsbDevice(object):
    DATA_ENDPOINT = 0x81
    VERSION_CONTROL_COMMAND = 0x80
    RESET_CONTROL_COMMAND = 0x81

    def __init__(self, vendorId=0x04d8, endpoint=0x81, verbose=False,
            dump=False, dashboard=False, elements=None):
        self.verbose = verbose
        self.dump = dump
{'fraction_non_alphanumeric': 0.08687217072644966, 'fraction_numerical': 0.009053675361069196, 'mean_word_length': 1.6408651109846328, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6452512', 'n_tokens_mistral': 1364, 'n_tokens_neox': 1279, 'n_words': 317}