You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
893 B

from couchpotato.api import addApiView
14 years ago
from couchpotato.environment import Env
from flask.helpers import send_from_directory
import os.path
14 years ago
class Plugin():
14 years ago
def conf(self, attr):
return Env.setting(attr, self.getName().lower())
def getName(self):
return self.__class__.__name__
def registerStatic(self, file_path):
class_name = self.__class__.__name__.lower()
self.plugin_file = file_path
path = class_name + '.static/'
addApiView(path + '<path:file>', self.showStatic, static = True)
return path
def showStatic(self, file = ''):
plugin_dir = os.path.dirname(self.plugin_file)
dir = os.path.join(plugin_dir, 'static')
return send_from_directory(dir, file)
def isDisabled(self):
return not self.isEnabled()
def isEnabled(self):
return self.conf('enabled', True)