import sys class ServiceBase : _config = {} error = [] warn = [] _status = "Ready" def __init__(self,hints={},config={}): self._config = config self._error = [] self._warn = [] self.hints = hints pass def _set_config(self,config) : """Allows for post-initialization configuration""" self._config = config def _set_hints(self,hints) : """Allows for post-initialization configuration of hint data""" self.hints = hints def _cache_invalid(self) : """Returns a boolean representing whether or not a cached value from the last lookup should be invalidated.""" return False def debug(self,message,verbosity_level) : """Prints the submitted message if the environment's verbosity level matches or is surpassed by the submitted level.""" if self._config['_namespace']['debug'] and self._config['_namespace']['debug'] >= verbosity_level : print(message,file=sys.stderr) @classmethod def get_arguments(cls) : """Returns an array of information used to construct an argumentparser argument.""" # [ ,,, ] # Example return: [ '-n', '--net', 'store_true', 'Output network information about the subject' ] return None def startup(self) : """Perform any setup that is needed to perform lookups, such as logging in or obtaining auth sessions.""" pass def lookup(self,subject) : """Returns a dictionary with lookup information about the given subject.""" # Note: You should only return arrays and dictionaries with strings as keys so the information # serializes correctly. return None def shutdown(self) : """Perform any cleanup that is needed, such as logging out of auth sessions.""" pass def reset(self) : """Reinitialize the plugin, performing any involved operations.""" self.shutdown() self.startup()