<commit_before>import inspect

from virtualbox import library

import vboxapi
manager = vboxapi.VirtualBoxManager(None, None)

"""
 This module is responsible for bootstrapping the COM interfaces into the 
 VirthalBox and Session class interfaces.

 It is also the place to import extension classes that fix up or improve on
 the default COM API behaviour and auto generated Python library file when
 interacting through an Interface to the Main library API.
"""

# Import extension modules
from virtualbox._library_ext.keyboard import IKeyboard
from virtualbox._library_ext.guest_session import IGuestSession
from virtualbox._library_ext.guest import IGuest
from virtualbox._library_ext.machine import IMachine


# Configure ISession bootstrap to build from vboxapi getSessionObject
class ISession(library.ISession):
    __doc__ = library.ISession.__doc__
    def __init__(self, interface=None):
        if interface is None:
            self._i = manager.platform.getSessionObject(None)
        else:
            self._i = interface
    
    def __enter__(self):
        return self

    def __exit__(self, exception_type, exception_val, trace):
        self.unlock_machine()


# Configure IVirtualBox bootstrap to build from vboxapi getVirtualBox
class IVirtualBox(library.IVirtualBox):
    __doc__ = library.IVirtualBox.__doc__
    def __init__(self, interface=None):
        if interface is None:
            self._i = manager.getVirtualBox()
        else:
            self._i = interface


# Replace original with extension
for k, v in locals().items():<commit_msg>IVirtualBox and ISession now using virtualbox.Manager<commit_after>import inspect

import virtualbox
from virtualbox import library

"""
 This module is responsible for shimming out the auto generated libraries found
 under librar.py.  The intension for the extension classes is to fix up or
 improve on the default COM API behaviour and auto generated Python library
 file when interacting through an Interface to the Main library API.
"""

# Import extension modules
from virtualbox._library_ext.keyboard import IKeyboard
from virtualbox._library_ext.guest_session import IGuestSession
from virtualbox._library_ext.guest import IGuest
from virtualbox._library_ext.machine import IMachine


# Configure IVirtualBox bootstrap to build from vboxapi getVirtualBox
class IVirtualBox(library.IVirtualBox):
    __doc__ = library.IVirtualBox.__doc__
    def __init__(self, interface=None, manager=None):
        if interface is not None:
            self._i = interface
        elif manager is not None:
            self._i = manager.get_virtualbox()
        else:
            manager = virtualbox.Manager()
            self._i = manager.get_virtualbox()


# Configure ISession bootstrap to build from vboxapi getSessionObject
class ISession(library.ISession):
    __doc__ = library.ISession.__doc__
    def __init__(self, interface=None, manager=None):
        if interface is not None:
            self._i = interface
        elif manager is not None:
            self._i = manager.get_session()
        else:
            manager = virtualbox.Manager()
            self._i = manager.get_session()
    
    def __enter__(self):
        return self

    def __exit__(self, exception_type, exception_val, trace):
        self.unlock_machine()


# Replace original with extension
for k, v in locals().items():
{'fraction_non_alphanumeric': 0.05931198102016608, 'fraction_numerical': 0.0, 'mean_word_length': 3.491344873501997, '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': '3729122', 'n_tokens_mistral': 885, 'n_tokens_neox': 857, 'n_words': 317}