本文整理汇总了Python中waflib.Utils.listdir方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.listdir方法的具体用法?Python Utils.listdir怎么用?Python Utils.listdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waflib.Utils
的用法示例。
在下文中一共展示了Utils.listdir方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import listdir [as 别名]
def update(ctx):
lst=Options.options.files
if lst:
lst=lst.split(',')
else:
path=os.path.join(Context.waf_dir,'waflib','extras')
lst=[x for x in Utils.listdir(path)if x.endswith('.py')]
for x in lst:
tool=x.replace('.py','')
if not tool:
continue
try:
dl=Configure.download_tool
except AttributeError:
ctx.fatal('The command "update" is dangerous; include the tool "use_config" in your project!')
try:
dl(tool,force=True,ctx=ctx)
except Errors.WafError:
Logs.error('Could not find the tool %r in the remote repository'%x)
else:
Logs.warn('Updated %r'%tool)
示例2: distclean
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import listdir [as 别名]
def distclean(ctx):
'''removes the build directory'''
lst=os.listdir('.')
for f in lst:
if f==Options.lockfile:
try:
proj=ConfigSet.ConfigSet(f)
except IOError:
Logs.warn('Could not read %r'%f)
continue
if proj['out_dir']!=proj['top_dir']:
try:
shutil.rmtree(proj['out_dir'])
except IOError:
pass
except OSError ,e:
if e.errno!=errno.ENOENT:
Logs.warn('Could not remove %r'%proj['out_dir'])
else:
distclean_dir(proj['out_dir'])
for k in(proj['out_dir'],proj['top_dir'],proj['run_dir']):
p=os.path.join(k,Options.lockfile)
try:
os.remove(p)
except OSError ,e:
if e.errno!=errno.ENOENT:
Logs.warn('Could not remove %r'%p)
示例3: update
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import listdir [as 别名]
def update(ctx):
lst=Options.options.files.split(',')
if not lst:
lst=[x for x in Utils.listdir(Context.waf_dir+'/waflib/extras')if x.endswith('.py')]
for x in lst:
tool=x.replace('.py','')
try:
Configure.download_tool(tool,force=True,ctx=ctx)
except Errors.WafError:
Logs.error('Could not find the tool %s in the remote repository'%x)
示例4: listdir
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import listdir [as 别名]
def listdir(self):
lst=Utils.listdir(self.abspath())
lst.sort()
return lst
示例5: ant_iter
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import listdir [as 别名]
def ant_iter(self,accept=None,maxdepth=25,pats=[],dir=False,src=True,remove=True):
dircont=self.listdir()
dircont.sort()
try:
lst=set(self.children.keys())
except AttributeError:
self.children=self.dict_class()
else:
if remove:
for x in lst-set(dircont):
self.children[x].evict()
for name in dircont:
npats=accept(name,pats)
if npats and npats[0]:
accepted=[]in npats[0]
node=self.make_node([name])
isdir=os.path.isdir(node.abspath())
if accepted:
if isdir:
if dir:
yield node
else:
if src:
yield node
if getattr(node,'cache_isdir',None)or isdir:
node.cache_isdir=True
if maxdepth:
for k in node.ant_iter(accept=accept,maxdepth=maxdepth-1,pats=npats,dir=dir,src=src,remove=remove):
yield k
raise StopIteration