<commit_before>import struct
import glob
from warnings import warn

from pcapdump import *
from daintree import *
from pcapdlt import *

from kbutils import *      #provides serial, usb, USBVER
from zigbeedecode import * #would like to import only within killerbee class
from dot154decode import * #would like to import only within killerbee class
from config import *       #to get DEV_ENABLE_* variables

# Utility Functions
def getKillerBee(channel):
    '''
    Returns an instance of a KillerBee device, setup on the given channel.
    Error handling for KillerBee creation and setting of the channel is wrapped
    and will raise an Exception().
    @return: A KillerBee instance initialized to the given channel.
    '''
    kb = KillerBee()
    if kb is None:
        raise Exception("Failed to create a KillerBee instance.")
    try:
        kb.set_channel(channel)
    except Exception, e:
        raise Exception('Error: Failed to set channel to %d' % channel, e)
    return kb

def kb_dev_list(vendor=None, product=None):
    '''Deprecated. Use show_dev or call kbutils.devlist.'''
    return kbutils.devlist(vendor=None, product=None)

def show_dev(vendor=None, product=None, gps=None, include=None):
    '''
    A basic function to output the device listing.
    Placed here for reuse, as many tool scripts were implementing it.
    @param gps: Provide device names in this argument (previously known as
        'gps') which you wish to not be enumerated. Aka, exclude these items.
    @param include: Provide device names in this argument if you would like only
        these to be enumerated. Aka, include only these items.
    '''
    print("{: >14} {: <20} {: >10}".format("Dev", "Product String", "Serial Number"))
    for dev in kbutils.devlist(vendor=vendor, product=product, gps=gps, include=include):
        print("{0: >14} {1: <20} {2: >10}".format(dev[0], dev[1], dev[2]))

# KillerBee Class
class KillerBee:
    def __init__(self, device=None, datasource=None, gps=None):
        '''
        Instantiates the KillerBee class.<commit_msg>use common formatting string in killerbee.show_dev()<commit_after>import struct
import glob
from warnings import warn

from pcapdump import *
from daintree import *
from pcapdlt import *

from kbutils import *      #provides serial, usb, USBVER
from zigbeedecode import * #would like to import only within killerbee class
from dot154decode import * #would like to import only within killerbee class
from config import *       #to get DEV_ENABLE_* variables

# Utility Functions
def getKillerBee(channel):
    '''
    Returns an instance of a KillerBee device, setup on the given channel.
    Error handling for KillerBee creation and setting of the channel is wrapped
    and will raise an Exception().
    @return: A KillerBee instance initialized to the given channel.
    '''
    kb = KillerBee()
    if kb is None:
        raise Exception("Failed to create a KillerBee instance.")
    try:
        kb.set_channel(channel)
    except Exception, e:
        raise Exception('Error: Failed to set channel to %d' % channel, e)
    return kb

def kb_dev_list(vendor=None, product=None):
    '''Deprecated. Use show_dev or call kbutils.devlist.'''
    return kbutils.devlist(vendor=None, product=None)

def show_dev(vendor=None, product=None, gps=None, include=None):
    '''
    A basic function to output the device listing.
    Placed here for reuse, as many tool scripts were implementing it.
    @param gps: Provide device names in this argument (previously known as
        'gps') which you wish to not be enumerated. Aka, exclude these items.
    @param include: Provide device names in this argument if you would like only
        these to be enumerated. Aka, include only these items.
    '''
    fmt = "{: >14} {: <20} {: >10}"
    print(fmt.format("Dev", "Product String", "Serial Number"))
    for dev in kbutils.devlist(vendor=vendor, product=product, gps=gps, include=include):
        print(fmt.format(dev[0], dev[1], dev[2]))

# KillerBee Class
class KillerBee:
    def __init__(self, device=None, datasource=None, gps=None):
        '''
        Instantiates the KillerBee class.
{'fraction_non_alphanumeric': 0.08999037536092397, 'fraction_numerical': 0.007940327237728586, 'mean_word_length': 3.603543743078627, 'pattern_counts': {'":': 0, '<': 6, '<?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': '7281080', 'n_tokens_mistral': 1251, 'n_tokens_neox': 1200, 'n_words': 484}