def get_nuimo_component_view(request):
component_id = request.matchdict['component_id']
mac_address = request.matchdict['mac_address'].replace('-', ':')
with open(request.registry.settings['nuimo_app_config_path'], 'r') as f:
config = yaml.load(f)
try:
nuimo = config['nuimos'][mac_address]
except (KeyError, TypeError):
return HTTPNotFound("No Nuimo with such ID")
components = nuimo['components']
try:
return next(c for c in components if c['id'] == component_id)
except StopIteration:
raise HTTPNotFound
评论列表
文章目录