mirror of
https://github.com/esphome/esphome.git
synced 2025-09-10 15:22:24 +01:00
Cleanup dashboard JS (#491)
* Cleanup dashboard JS * Add vscode * Save start_mark/end_mark * Updates * Updates * Remove need for cv.nameable It's a bit hacky but removes so much bloat from integrations * Add enum helper * Document APIs, and Improvements * Fixes * Fixes * Update PULL_REQUEST_TEMPLATE.md * Updates * Updates * Updates
This commit is contained in:
@@ -13,19 +13,42 @@ from esphome.py_compat import IS_PY2
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class RegistryEntry(object):
|
||||
def __init__(self, name, fun, type_id, schema):
|
||||
self.name = name
|
||||
self.fun = fun
|
||||
self.type_id = type_id
|
||||
self.raw_schema = schema
|
||||
|
||||
@property
|
||||
def coroutine_fun(self):
|
||||
from esphome.core import coroutine
|
||||
return coroutine(self.fun)
|
||||
|
||||
@property
|
||||
def schema(self):
|
||||
from esphome.config_validation import Schema
|
||||
return Schema(self.raw_schema)
|
||||
|
||||
|
||||
class Registry(dict):
|
||||
def register(self, name):
|
||||
def __init__(self, base_schema=None, type_id_key=None):
|
||||
super(Registry, self).__init__()
|
||||
self.base_schema = base_schema or {}
|
||||
self.type_id_key = type_id_key
|
||||
|
||||
def register(self, name, type_id, schema):
|
||||
def decorator(fun):
|
||||
self[name] = fun
|
||||
self[name] = RegistryEntry(name, fun, type_id, schema)
|
||||
return fun
|
||||
|
||||
return decorator
|
||||
|
||||
|
||||
class ServiceRegistry(dict):
|
||||
def register(self, name, validator):
|
||||
class SimpleRegistry(dict):
|
||||
def register(self, name, data):
|
||||
def decorator(fun):
|
||||
self[name] = (validator, fun)
|
||||
self[name] = (fun, data)
|
||||
return fun
|
||||
|
||||
return decorator
|
||||
|
Reference in New Issue
Block a user