本文整理汇总了Python中solar.dblayer.solar_models.Resource.get方法的典型用法代码示例。如果您正苦于以下问题:Python Resource.get方法的具体用法?Python Resource.get怎么用?Python Resource.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类solar.dblayer.solar_models.Resource
的用法示例。
在下文中一共展示了Resource.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
# 需要导入模块: from solar.dblayer.solar_models import Resource [as 别名]
# 或者: from solar.dblayer.solar_models.Resource import get [as 别名]
def load(name):
r = DBResource.get(name)
if not r:
raise Exception('Resource {} does not exist in DB'.format(name))
return Resource(r)
示例2: add_events
# 需要导入模块: from solar.dblayer.solar_models import Resource [as 别名]
# 或者: from solar.dblayer.solar_models.Resource import get [as 别名]
def add_events(resource, lst):
resource = Resource.get(resource)
events = resource.events
# TODO: currently we don't track mutable objects
events.extend([ev.to_dict() for ev in lst])
resource.events = events
# import pdb; pdb.settrace()
resource.save_lazy()
示例3: remove_event
# 需要导入模块: from solar.dblayer.solar_models import Resource [as 别名]
# 或者: from solar.dblayer.solar_models.Resource import get [as 别名]
def remove_event(ev):
to_remove = ev.to_dict()
resource = ev.parent
resource = Resource.get(resource)
# TODO: currently we don't track mutable objects
events = resource.events
events.remove(to_remove)
resource.events = events
resource.save_lazy()
示例4: insert
# 需要导入模块: from solar.dblayer.solar_models import Resource [as 别名]
# 或者: from solar.dblayer.solar_models.Resource import get [as 别名]
def insert(self, changed_resources, changes_graph):
changed_resources.append(self.parent_node)
try:
location_id = Resource.get(self.parent).inputs['location_id']
except (DBLayerNotFound, DBLayerSolarException):
location_id = None
changes_graph.add_node(
self.parent_node, status='PENDING',
target=location_id,
errmsg='', type='solar_resource',
args=[self.parent, self.parent_action])
示例5: insert
# 需要导入模块: from solar.dblayer.solar_models import Resource [as 别名]
# 或者: from solar.dblayer.solar_models.Resource import get [as 别名]
def insert(self, changed_resources, changes_graph):
if self.parent_node in changes_graph:
if self.child_node not in changes_graph:
try:
location_id = Resource.get(self.child).inputs[
'location_id']
except DBLayerNotFound:
location_id = None
changes_graph.add_node(
self.child_node, status='PENDING',
target=location_id,
errmsg='', type='solar_resource',
args=[self.child, self.child_action])
changes_graph.add_edge(
self.parent_node, self.child_node, state=self.state)
changed_resources.append(self.child_node)
示例6: all_events
# 需要导入模块: from solar.dblayer.solar_models import Resource [as 别名]
# 或者: from solar.dblayer.solar_models.Resource import get [as 别名]
def all_events(resource):
return [create_event(e) for e in Resource.get(resource).events]