sethmlarson / virtualbox-python

Complete implementation of VirtualBox's COM API with a Pythonic interface.
https://pypi.org/project/virtualbox
Apache License 2.0
354 stars 75 forks source link

Modify Autogen script to inherit extensions automatically #109

Closed sethmlarson closed 5 years ago

sethmlarson commented 6 years ago

Define extension code within the _ext directory with the name of the object as a non-class Pythonic name + .py.

# _ext/machine.py
class Machine(object):
    def execute(self, command, ...):
        pass

When a class is parsed that has a corresponding extension module copy the contents of the file into the _base.py after the auto-generated class has been added and make the extension code inherit from the auto-generated class. This makes it so that all auto-generated classes automatically have extensions added.

# _base.py
class _Machine(object):
    # Autogenerated code here...
    @property
    def name(self):
        pass

class Machine(_Machine):
    # Extension code here...
    def execute(self, command, ...):
        pass

Also will need to add a test that runs the autogen script on Travis to ensure that the script is run each time extensions are changed.