本文整理匯總了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