本文整理汇总了Python中waflib.Utils.defaultdict方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.defaultdict方法的具体用法?Python Utils.defaultdict怎么用?Python Utils.defaultdict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waflib.Utils
的用法示例。
在下文中一共展示了Utils.defaultdict方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_file_constraints
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import defaultdict [as 别名]
def set_file_constraints(tasks):
ins = Utils.defaultdict(set)
outs = Utils.defaultdict(set)
for x in tasks:
for a in getattr(x, "inputs", []) + getattr(x, "dep_nodes", []):
ins[id(a)].add(x)
for a in getattr(x, "outputs", []):
outs[id(a)].add(x)
links = set(ins.keys()).intersection(outs.keys())
for k in links:
for a in ins[k]:
a.run_after.update(outs[k])
示例2: set_file_constraints
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import defaultdict [as 别名]
def set_file_constraints(tasks):
"adds tasks to the task 'run_after' attribute based on the task inputs and outputs"
ins = Utils.defaultdict(set)
outs = Utils.defaultdict(set)
for x in tasks:
for a in getattr(x, 'inputs', []) + getattr(x, 'dep_nodes', []):
ins[id(a)].add(x)
for a in getattr(x, 'outputs', []):
outs[id(a)].add(x)
links = set(ins.keys()).intersection(outs.keys())
for k in links:
for a in ins[k]:
a.run_after.update(outs[k])
示例3: runnable_status
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import defaultdict [as 别名]
def runnable_status(self):
if getattr(self,'mod_fortran_done',None):
return super(fc,self).runnable_status()
bld=self.generator.bld
lst=get_fortran_tasks(self)
for tsk in lst:
tsk.mod_fortran_done=True
for tsk in lst:
ret=tsk.runnable_status()
if ret==Task.ASK_LATER:
for x in lst:
x.mod_fortran_done=None
return Task.ASK_LATER
ins=Utils.defaultdict(set)
outs=Utils.defaultdict(set)
for tsk in lst:
key=tsk.uid()
for x in bld.raw_deps[key]:
if x.startswith('[email protected]'):
name=bld.modfile(x.replace('[email protected]',''))
node=bld.srcnode.find_or_declare(name)
tsk.set_outputs(node)
outs[id(node)].add(tsk)
for tsk in lst:
key=tsk.uid()
for x in bld.raw_deps[key]:
if x.startswith('[email protected]'):
name=bld.modfile(x.replace('[email protected]',''))
node=bld.srcnode.find_resource(name)
if node and node not in tsk.outputs:
if not node in bld.node_deps[key]:
bld.node_deps[key].append(node)
ins[id(node)].add(tsk)
for k in ins.keys():
for a in ins[k]:
a.run_after.update(outs[k])
tmp=[]
for t in outs[k]:
tmp.extend(t.outputs)
a.dep_nodes.extend(tmp)
try:
a.dep_nodes.sort(key=lambda x:x.abspath())
except:
a.dep_nodes.sort(lambda x,y:cmp(x.abspath(),y.abspath()))
for tsk in lst:
try:
delattr(tsk,'cache_sig')
except AttributeError:
pass
return super(fc,self).runnable_status()
示例4: __init__
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import defaultdict [as 别名]
def __init__(self,**kw):
super(BuildContext,self).__init__(**kw)
self.is_install=0
self.top_dir=kw.get('top_dir',Context.top_dir)
self.out_dir=kw.get('out_dir',Context.out_dir)
self.run_dir=kw.get('run_dir',Context.run_dir)
self.launch_dir=Context.launch_dir
self.post_mode=POST_LAZY
self.cache_dir=kw.get('cache_dir')
if not self.cache_dir:
self.cache_dir=os.path.join(self.out_dir,CACHE_DIR)
self.all_envs={}
self.node_sigs={}
self.task_sigs={}
self.imp_sigs={}
self.node_deps={}
self.raw_deps={}
self.task_gen_cache_names={}
self.jobs=Options.options.jobs
self.targets=Options.options.targets
self.keep=Options.options.keep
self.progress_bar=Options.options.progress_bar
self.deps_man=Utils.defaultdict(list)
self.current_group=0
self.groups=[]
self.group_names={}
for v in SAVED_ATTRS:
if not hasattr(self,v):
setattr(self,v,{})
示例5: __init__
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import defaultdict [as 别名]
def __init__(self, **kw):
super(BuildContext, self).__init__(**kw)
self.is_install = 0
self.top_dir = kw.get("top_dir", Context.top_dir)
self.run_dir = kw.get("run_dir", Context.run_dir)
self.post_mode = POST_AT_ONCE
self.out_dir = kw.get("out_dir", Context.out_dir)
self.cache_dir = kw.get("cache_dir", None)
if not self.cache_dir:
self.cache_dir = self.out_dir + os.sep + CACHE_DIR
self.all_envs = {}
self.task_sigs = {}
self.node_deps = {}
self.raw_deps = {}
self.cache_dir_contents = {}
self.task_gen_cache_names = {}
self.launch_dir = Context.launch_dir
self.jobs = Options.options.jobs
self.targets = Options.options.targets
self.keep = Options.options.keep
self.cache_global = Options.cache_global
self.nocache = Options.options.nocache
self.progress_bar = Options.options.progress_bar
self.deps_man = Utils.defaultdict(list)
self.current_group = 0
self.groups = []
self.group_names = {}
示例6: check_same_targets
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import defaultdict [as 别名]
def check_same_targets(self):
mp=Utils.defaultdict(list)
uids={}
def check_task(tsk):
if not isinstance(tsk,Task.Task):
return
for node in tsk.outputs:
mp[node].append(tsk)
try:
uids[tsk.uid()].append(tsk)
except:
uids[tsk.uid()]=[tsk]
for g in self.groups:
for tg in g:
try:
for tsk in tg.tasks:
check_task(tsk)
except AttributeError:
check_task(tg)
dupe=False
for(k,v)in mp.items():
if len(v)>1:
dupe=True
Logs.error('* Node %r is created by more than one task. The task generators are:'%k)
for x in v:
Logs.error(' %d. %r'%(1+v.index(x),x.generator))
if not dupe:
for(k,v)in uids.items():
if len(v)>1:
Logs.error('* Several tasks use the same identifier. Please check the information on\n http://waf.googlecode.com/svn/docs/apidocs/Task.html#waflib.Task.Task.uid')
for tsk in v:
Logs.error(' - object %r (%r) defined in %r'%(tsk.__class__.__name__,tsk,tsk.generator))
示例7: set_precedence_constraints
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import defaultdict [as 别名]
def set_precedence_constraints(tasks):
cstr_groups = Utils.defaultdict(list)
for x in tasks:
x.run_after = SetOfTasks(x)
x.run_after_groups = []
x.waiting_sets = []
h = x.hash_constraints()
cstr_groups[h].append(x)
# create sets which can be reused for all tasks
for k in cstr_groups.keys():
cstr_groups[k] = set(cstr_groups[k])
# this list should be short
for key1, key2 in itertools.combinations(cstr_groups.keys(), 2):
group1 = cstr_groups[key1]
group2 = cstr_groups[key2]
# get the first entry of the set
t1 = next(iter(group1))
t2 = next(iter(group2))
# add the constraints based on the comparisons
if Task.is_before(t1, t2):
for x in group2:
x.run_after_groups.append(group1)
for k in group1:
k.waiting_sets.append(group1)
elif Task.is_before(t2, t1):
for x in group1:
x.run_after_groups.append(group2)
for k in group2:
k.waiting_sets.append(group2)
示例8: set_precedence_constraints
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import defaultdict [as 别名]
def set_precedence_constraints(tasks):
"""
Updates the ``run_after`` attribute of all tasks based on the after/before/ext_out/ext_in attributes
:param tasks: tasks
:type tasks: list of :py:class:`waflib.Task.TaskBase`
"""
cstr_groups = Utils.defaultdict(list)
for x in tasks:
h = x.hash_constraints()
cstr_groups[h].append(x)
keys = list(cstr_groups.keys())
maxi = len(keys)
# this list should be short
for i in range(maxi):
t1 = cstr_groups[keys[i]][0]
for j in range(i + 1, maxi):
t2 = cstr_groups[keys[j]][0]
# add the constraints based on the comparisons
if is_before(t1, t2):
a = i
b = j
elif is_before(t2, t1):
a = j
b = i
else:
continue
aval = set(cstr_groups[keys[a]])
for x in cstr_groups[keys[b]]:
x.run_after.update(aval)
示例9: set_precedence_constraints
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import defaultdict [as 别名]
def set_precedence_constraints(tasks):
"adds tasks to the task 'run_after' attribute based on the after/before/ext_out/ext_in attributes"
cstr_groups = Utils.defaultdict(list)
for x in tasks:
h = x.hash_constraints()
cstr_groups[h].append(x)
keys = list(cstr_groups.keys())
maxi = len(keys)
# this list should be short
for i in range(maxi):
t1 = cstr_groups[keys[i]][0]
for j in range(i + 1, maxi):
t2 = cstr_groups[keys[j]][0]
# add the constraints based on the comparisons
if is_before(t1, t2):
a = i
b = j
elif is_before(t2, t1):
a = j
b = i
else:
continue
for x in cstr_groups[keys[b]]:
x.run_after.update(cstr_groups[keys[a]])
示例10: __init__
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import defaultdict [as 别名]
def __init__(self, bld, j=2):
"""
The initialization requires a build context reference
for computing the total number of jobs.
"""
self.numjobs = j
"""
Amount of parallel consumers to use
"""
self.bld = bld
"""
Instance of :py:class:`waflib.Build.BuildContext`
"""
self.outstanding = PriorityTasks()
"""Heap of :py:class:`waflib.Task.Task` that may be ready to be executed"""
self.postponed = PriorityTasks()
"""Heap of :py:class:`waflib.Task.Task` which are not ready to run for non-DAG reasons"""
self.incomplete = set()
"""List of :py:class:`waflib.Task.Task` waiting for dependent tasks to complete (DAG)"""
self.ready = PriorityQueue(0)
"""List of :py:class:`waflib.Task.Task` ready to be executed by consumers"""
self.out = Queue(0)
"""List of :py:class:`waflib.Task.Task` returned by the task consumers"""
self.count = 0
"""Amount of tasks that may be processed by :py:class:`waflib.Runner.TaskConsumer`"""
self.processed = 0
"""Amount of tasks processed"""
self.stop = False
"""Error flag to stop the build"""
self.error = []
"""Tasks that could not be executed"""
self.biter = None
"""Task iterator which must give groups of parallelizable tasks when calling ``next()``"""
self.dirty = False
"""
Flag that indicates that the build cache must be saved when a task was executed
(calls :py:meth:`waflib.Build.BuildContext.store`)"""
self.revdeps = Utils.defaultdict(set)
"""
The reverse dependency graph of dependencies obtained from Task.run_after
"""
self.spawner = Spawner(self)
"""
示例11: set_file_constraints
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import defaultdict [as 别名]
def set_file_constraints(tasks):
"""
Updates the ``run_after`` attribute of all tasks based on the task inputs and outputs
:param tasks: tasks
:type tasks: list of :py:class:`waflib.Task.TaskBase`
"""
ins = Utils.defaultdict(set)
outs = Utils.defaultdict(set)
for x in tasks:
for a in getattr(x, 'inputs', []) + getattr(x, 'dep_nodes', []):
ins[id(a)].add(x)
for a in getattr(x, 'outputs', []):
outs[id(a)].add(x)
links = set(ins.keys()).intersection(outs.keys())
for k in links:
for a in ins[k]:
a.run_after.update(outs[k])
示例12: __init__
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import defaultdict [as 别名]
def __init__(self, *k, **kw):
"""
The task generator objects predefine various attributes (source, target) for possible
processing by process_rule (make-like rules) or process_source (extensions, misc methods)
The tasks are stored on the attribute 'tasks'. They are created by calling methods
listed in self.meths *or* referenced in the attribute features
A topological sort is performed to ease the method re-use.
The extra key/value elements passed in kw are set as attributes
"""
# so we will have to play with directed acyclic graphs
# detect cycles, etc
self.source = ''
self.target = ''
self.meths = []
"""
List of method names to execute (it is usually a good idea to avoid touching this)
"""
self.prec = Utils.defaultdict(list)
"""
Precedence table for sorting the methods in self.meths
"""
self.mappings = {}
"""
List of mappings {extension -> function} for processing files by extension
"""
self.features = []
"""
List of feature names for bringing new methods in
"""
self.tasks = []
"""
List of tasks created.
"""
if not 'bld' in kw:
# task generators without a build context :-/
self.env = ConfigSet.ConfigSet()
self.idx = 0
self.path = None
else:
self.bld = kw['bld']
self.env = self.bld.env.derive()
self.path = self.bld.path # emulate chdir when reading scripts
for key, val in kw.items():
setattr(self, key, val)
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:56,代码来源:TaskGen.py
示例13: check_same_targets
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import defaultdict [as 别名]
def check_same_targets(self):
mp = Utils.defaultdict(list)
uids = {}
def check_task(tsk):
if not isinstance(tsk, Task.Task):
return
for node in tsk.outputs:
mp[node].append(tsk)
try:
uids[tsk.uid()].append(tsk)
except:
uids[tsk.uid()] = [tsk]
for g in self.groups:
for tg in g:
try:
for tsk in tg.tasks:
check_task(tsk)
except AttributeError:
# raised if not a task generator, which should be uncommon
check_task(tg)
dupe = False
for (k, v) in mp.items():
if len(v) > 1:
dupe = True
msg = "* Node %r is created by more than once%s. The task generators are:" % (
k,
Logs.verbose == 1 and " (full message on 'waf -v -v')" or "",
)
Logs.error(msg)
for x in v:
if Logs.verbose > 1:
Logs.error(" %d. %r" % (1 + v.index(x), x.generator))
else:
Logs.error(
" %d. %r in %r" % (1 + v.index(x), x.generator.name, getattr(x.generator, "path", None))
)
if not dupe:
for (k, v) in uids.items():
if len(v) > 1:
Logs.error(
"* Several tasks use the same identifier. Please check the information on\n http://waf.googlecode.com/svn/docs/apidocs/Task.html#waflib.Task.Task.uid"
)
for tsk in v:
Logs.error(" - object %r (%r) defined in %r" % (tsk.__class__.__name__, tsk, tsk.generator))
示例14: check_same_targets
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import defaultdict [as 别名]
def check_same_targets(self):
mp=Utils.defaultdict(list)
for g in self.groups:
for tg in g:
try:
for tsk in tg.tasks:
for node in tsk.outputs:
mp[node].append(tsk)
except AttributeError:
pass
for(k,v)in mp.items():
if len(v)>1:
Logs.error('* Node %r is created by more than one task. The task generators are:'%k)
for x in v:
Logs.error(' %d. %r'%(1+v.index(x),x.generator))
示例15: check_same_targets
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import defaultdict [as 别名]
def check_same_targets(self):
mp = Utils.defaultdict(list)
uids = {}
def check_task(tsk):
if not isinstance(tsk, Task.Task):
return
if hasattr(tsk, 'no_errcheck_out'):
return
for node in tsk.outputs:
mp[node].append(tsk)
try:
uids[tsk.uid()].append(tsk)
except KeyError:
uids[tsk.uid()] = [tsk]
for g in self.groups:
for tg in g:
try:
for tsk in tg.tasks:
check_task(tsk)
except AttributeError:
# raised if not a task generator, which should be uncommon
check_task(tg)
dupe = False
for (k, v) in mp.items():
if len(v) > 1:
dupe = True
msg = '* Node %r is created more than once%s. The task generators are:' % (k, Logs.verbose == 1 and " (full message on 'waf -v -v')" or "")
Logs.error(msg)
for x in v:
if Logs.verbose > 1:
Logs.error(' %d. %r', 1 + v.index(x), x.generator)
else:
Logs.error(' %d. %r in %r', 1 + v.index(x), x.generator.name, getattr(x.generator, 'path', None))
Logs.error('If you think that this is an error, set no_errcheck_out on the task instance')
if not dupe:
for (k, v) in uids.items():
if len(v) > 1:
Logs.error('* Several tasks use the same identifier. Please check the information on\n https://waf.io/apidocs/Task.html?highlight=uid#waflib.Task.Task.uid')
tg_details = tsk.generator.name
if Logs.verbose > 2:
tg_details = tsk.generator
for tsk in v:
Logs.error(' - object %r (%r) defined in %r', tsk.__class__.__name__, tsk, tg_details)