-
Notifications
You must be signed in to change notification settings - Fork 0
Python guidelines
Thomas Milox edited this page Apr 28, 2017
·
24 revisions
Alright, here we are :) If you are reading these lines that means you choose to develop your plugin for AVA in Python
...
Great choice!
You'll see there are only 4 rules to create your plugin... "What only 4? this guy has to be kidding me"
- Python version:
We are using Python3
, only!
- Plugin conception:
You plugin must be conceived as a Python
class and named in the same way as the plugin as well as the folder in which it's located!
This class must have as attribute a dictionnary binding the commands to catch and the methods of your class to execute, and the get_commands
method which returns this dictionnary.
- The dictionnary
Ok take again our git
plugin as example:
import subprocess
class git(object):
"""Git plugin"""
def __init__(self):
self.commands = {
'log': self.log,
'version': self.version,
}
def log(self):
subprocess.call(["git", "log"])
def version(self):
subprocess.call(["git", "version"])
def get_commands(self):
return self.commands
As you can see, in the __init__
method, I am binding the commands that I am expecting to the methods of my class to execute.