本文整理汇总了Python中ontology.Ontology.clone方法的典型用法代码示例。如果您正苦于以下问题:Python Ontology.clone方法的具体用法?Python Ontology.clone怎么用?Python Ontology.clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ontology.Ontology
的用法示例。
在下文中一共展示了Ontology.clone方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: transform
# 需要导入模块: from ontology import Ontology [as 别名]
# 或者: from ontology.Ontology import clone [as 别名]
def transform(self, template):
# apply overrides on the pivot location from the template
if 'override' in template:
for k,v in template['override'].iteritems():
self.location[k] = v
# apply track rules from the template
if 'track' in template:
for rule in template['track']:
for branch in rule['branch']:
taken = False
for stream in self.resource.stream:
if stream.match(branch):
taken = True
s = Ontology.clone(stream)
s['resource path digest'] = self.resource.location['path digest']
if 'override' in rule:
for k,v in rule['override'].iteritems(): s[k] = v
self.stream.append(s)
if rule['mode'] == 'choose':
break
if taken and rule['mode'] == 'choose':
break
return self.taken
示例2: _transcode_ac3
# 需要导入模块: from ontology import Ontology [as 别名]
# 或者: from ontology.Ontology import clone [as 别名]
def _transcode_ac3(self, task):
product = task.produce(task.ontology)
if product:
taken = False
for pivot in task.transform.pivot.values():
for stream in pivot.stream:
if not taken and stream['stream kind'] == 'audio':
taken = True
# Clone the hint ontology
product.hint = Ontology.clone(self.hint)
command = self.env.initialize_command('ffmpeg', self.log)
if command:
# make ffmpeg not check for overwrite, we already do this check
command.append(u'-y')
# set the number of processing threads
command.append(u'-threads')
command.append(unicode(self.env.system['threads']))
# set the input file
command.append(u'-i')
command.append(self.path)
for k,v in stream['ffmpeg parameters'].iteritems():
command.append(k)
if v is not None: command.append(unicode(v))
if taken: break
if taken and self.env.check_path_available(product.path, task.ontology['overwrite']):
command.append(product.path)
message = u'Transcode {} --> {}'.format(self.path, product.path)
self.env.execute(command, message, task.ontology['debug'], pipeout=True, pipeerr=False, log=self.log)
示例3: produce
# 需要导入模块: from ontology import Ontology [as 别名]
# 或者: from ontology.Ontology import clone [as 别名]
def produce(self, override=None):
# copy the location ontology
p = Ontology.clone(self.location)
# allow the location to recalculate those concepts
del p['volume path']
del p['file name']
del p['directory']
# explicitly set the volume and host from the task
p['host'] = self.env.host
p['volume'] = self.ontology['volume']
# for copy and move we try to set a profile from the source
if self.ontology['action'] in set(('copy', 'move', 'pack')):
if self.resource.meta['profile']:
p['profile'] = self.resource.meta['profile']
# for transcode we try to set the profile from the transform
elif self.ontology['action'] == 'transcode':
for pivot in self.transform.pivot.values():
if 'profile' in pivot.location:
p['profile'] = pivot.location['profile']
# whatever happened, if a profile has been explicitly provided by the task
# it will override anything we set implicitly
if self.ontology['profile']:
p['profile'] = self.ontology['profile']
# if an override was given set some concepts from it
if override:
for i in set((
'kind',
'language',
'stream order',
'resource path digest',
'routing type'
)):
if i in override: p[i] = override[i]
# try to produce a product
product = self.resource.asset.locate_resource(p)
if product:
self.product.append(product)
else:
self.log.error(u'Could not determine destination path from:\n%s', self.env.encode_json(p))
return product
示例4: __init__
# 需要导入模块: from ontology import Ontology [as 别名]
# 或者: from ontology.Ontology import clone [as 别名]
def __init__(self, resource):
self.resource = resource
self.location = Ontology.clone(resource.location)
self.stream = []