Best Python code snippet using green
customize.py
Source:customize.py
1"""Provide configuration end points for Customize."""2import asyncio3from homeassistant.components.config import EditKeyBasedConfigView4from homeassistant.components import async_reload_core_config5from homeassistant.config import DATA_CUSTOMIZE6import homeassistant.helpers.config_validation as cv7CONFIG_PATH = 'customize.yaml'8@asyncio.coroutine9def async_setup(hass):10 """Set up the Customize config API."""11 hass.http.register_view(CustomizeConfigView(12 'customize', 'config', CONFIG_PATH, cv.entity_id, dict,13 post_write_hook=async_reload_core_config14 ))15 return True16class CustomizeConfigView(EditKeyBasedConfigView):17 """Configure a list of entries."""18 def _get_value(self, hass, data, config_key):19 """Get value."""20 customize = hass.data.get(DATA_CUSTOMIZE, {}).get(config_key) or {}21 return {'global': customize, 'local': data.get(config_key, {})}22 def _write_value(self, hass, data, config_key, new_value):23 """Set value."""24 data[config_key] = new_value25 state = hass.states.get(config_key)26 state_attributes = dict(state.attributes)27 state_attributes.update(new_value)...
controllers.py
Source:controllers.py
1# -*- coding: utf-8 -*-2# from odoo import http3# class SchoolCustomize(http.Controller):4# @http.route('/school_customize/school_customize', auth='public')5# def index(self, **kw):6# return "Hello, world"7# @http.route('/school_customize/school_customize/objects', auth='public')8# def list(self, **kw):9# return http.request.render('school_customize.listing', {10# 'root': '/school_customize/school_customize',11# 'objects': http.request.env['school_customize.school_customize'].search([]),12# })13# @http.route('/school_customize/school_customize/objects/<model("school_customize.school_customize"):obj>', auth='public')14# def object(self, obj, **kw):15# return http.request.render('school_customize.object', {16# 'object': obj...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!