• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python waflib.Utils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中waflib.Utils的典型用法代码示例。如果您正苦于以下问题:Python Utils类的具体用法?Python Utils怎么用?Python Utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Utils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

	def __init__(cls, name, bases, dict):
		super(store_task_type, cls).__init__(name, bases, dict)
		name = cls.__name__

		if name != 'evil' and name != 'Task':
			if getattr(cls, 'run_str', None):
				# if a string is provided, convert it to a method
				(f, dvars) = compile_fun(cls.run_str, cls.shell)
				cls.hcode = Utils.h_cmd(cls.run_str)
				cls.orig_run_str = cls.run_str
				# change the name of run_str or it is impossible to subclass with a function
				cls.run_str = None
				cls.run = f
				# process variables
				cls.vars = list(set(cls.vars + dvars))
				cls.vars.sort()
				if cls.vars:
					fun = compile_sig_vars(cls.vars)
					if fun:
						cls.sig_vars = fun
			elif getattr(cls, 'run', None) and not 'hcode' in cls.__dict__:
				# getattr(cls, 'hcode') would look in the upper classes
				cls.hcode = Utils.h_cmd(cls.run)

			# be creative
			getattr(cls, 'register', classes)[name] = cls
开发者ID:jackaudio,项目名称:jack2,代码行数:26,代码来源:Task.py


示例2: can_retrieve_cache

 def can_retrieve_cache(self):
     if not getattr(self, "outputs", None):
         return None
     sig = self.signature()
     ssig = Utils.to_hex(self.uid()) + Utils.to_hex(sig)
     dname = os.path.join(self.generator.bld.cache_global, ssig)
     try:
         t1 = os.stat(dname).st_mtime
     except OSError:
         return None
     for node in self.outputs:
         orig = os.path.join(dname, node.name)
         try:
             shutil.copy2(orig, node.abspath())
             os.utime(orig, None)
         except (OSError, IOError):
             Logs.debug("task: failed retrieving file")
             return None
     try:
         t2 = os.stat(dname).st_mtime
     except OSError:
         return None
     if t1 != t2:
         return None
     for node in self.outputs:
         node.sig = sig
         if self.generator.bld.progress_bar < 1:
             self.generator.bld.to_log("restoring from cache %r\n" % node.abspath())
     self.cached = True
     return True
开发者ID:jgoppert,项目名称:mavsim,代码行数:30,代码来源:Task.py


示例3: store

	def store(self):
		"""
		Store data for next runs, set the attributes listed in :py:const:`waflib.Build.SAVED_ATTRS`. Uses a temporary
		file to avoid problems on ctrl+c.
		"""
		data = {}
		for x in SAVED_ATTRS:
			data[x] = getattr(self, x)
		db = os.path.join(self.variant_dir, Context.DBFILE)

		try:
			Node.pickle_lock.acquire()
			Node.Nod3 = self.node_class
			x = cPickle.dumps(data, PROTOCOL)
		finally:
			Node.pickle_lock.release()

		Utils.writef(db + '.tmp', x, m='wb')

		try:
			st = os.stat(db)
			os.remove(db)
			if not Utils.is_win32: # win32 has no chown but we're paranoid
				os.chown(db + '.tmp', st.st_uid, st.st_gid)
		except (AttributeError, OSError):
			pass

		# do not use shutil.move (copy is not thread-safe)
		os.rename(db + '.tmp', db)
开发者ID:blablack,项目名称:ams-lv2,代码行数:29,代码来源:Build.py


示例4: set_qt4_libs_to_check

def set_qt4_libs_to_check(self):
	if not hasattr(self,'qt4_vars'):
		self.qt4_vars=QT4_LIBS
	self.qt4_vars=Utils.to_list(self.qt4_vars)
	if not hasattr(self,'qt4_vars_debug'):
		self.qt4_vars_debug=[a+'_debug'for a in self.qt4_vars]
	self.qt4_vars_debug=Utils.to_list(self.qt4_vars_debug)
开发者ID:AliZafar120,项目名称:ns3,代码行数:7,代码来源:qt4.py


示例5: rsync_and_ssh

def rsync_and_ssh(task):

	# remove a warning
	task.uid_ = id(task)

	bld = task.generator.bld

	task.env.user, _, _ = task.env.login.partition('@')
	task.env.hdir = Utils.to_hex(Utils.h_list((task.generator.path.abspath(), task.env.variant)))
	task.env.remote_dir = '~%s/wafremote/%s' % (task.env.user, task.env.hdir)
	task.env.local_dir = bld.srcnode.abspath() + '/'

	task.env.remote_dir_variant = '%s/%s/%s' % (task.env.remote_dir, Context.g_module.out, task.env.variant)
	task.env.build_dir = bld.bldnode.abspath()

	ret = task.exec_command(bld.make_mkdir_command(task))
	if ret:
		return ret
	ret = task.exec_command(bld.make_send_command(task))
	if ret:
		return ret
	ret = task.exec_command(bld.make_exec_command(task))
	if ret:
		return ret
	ret = task.exec_command(bld.make_save_command(task))
	if ret:
		return ret
开发者ID:JodyGoldberg,项目名称:waf,代码行数:27,代码来源:remote.py


示例6: set_qt5_libs_to_check

def set_qt5_libs_to_check(self):
    if not hasattr(self, "qt5_vars"):
        self.qt5_vars = QT5_LIBS
    self.qt5_vars = Utils.to_list(self.qt5_vars)
    if not hasattr(self, "qt5_vars_debug"):
        self.qt5_vars_debug = [a + "_debug" for a in self.qt5_vars]
    self.qt5_vars_debug = Utils.to_list(self.qt5_vars_debug)
开发者ID:markreyn,项目名称:ndnSIMx,代码行数:7,代码来源:qt5.py


示例7: declare_chain

def declare_chain(
    name="",
    rule=None,
    reentrant=True,
    color="BLUE",
    ext_in=[],
    ext_out=[],
    before=[],
    after=[],
    decider=None,
    scan=None,
):
    ext_in = Utils.to_list(ext_in)
    ext_out = Utils.to_list(ext_out)
    cls = Task.task_factory(
        name, rule, color=color, ext_in=ext_in, ext_out=ext_out, before=before, after=after, scan=scan
    )

    def x_file(self, node):
        ext = decider and decider(self, node) or cls.ext_out
        if ext_in:
            _ext_in = ext_in[0]
        out_source = [node.change_ext(x, ext_in=_ext_in) for x in ext]
        if reentrant:
            for i in range(reentrant):
                self.source.append(out_source[i])
        tsk = self.create_task(name, node, out_source)

    for x in cls.ext_in:
        task_gen.mappings[x] = x_file
    return x_file
开发者ID:spo11,项目名称:archlinux,代码行数:31,代码来源:TaskGen.py


示例8: load

	def load(self,input,tooldir=None,funs=None,download=True):
		tools=Utils.to_list(input)
		if tooldir:tooldir=Utils.to_list(tooldir)
		for tool in tools:
			mag=(tool,id(self.env),funs)
			if mag in self.tool_cache:
				self.to_log('(tool %s is already loaded, skipping)'%tool)
				continue
			self.tool_cache.append(mag)
			module=None
			try:
				module=Context.load_tool(tool,tooldir)
			except ImportError as e:
				if Options.options.download:
					module=download_tool(tool,ctx=self)
					if not module:
						self.fatal('Could not load the Waf tool %r or download a suitable replacement from the repository (sys.path %r)\n%s'%(tool,sys.path,e))
				else:
					self.fatal('Could not load the Waf tool %r from %r (try the --download option?):\n%s'%(tool,sys.path,e))
			except Exception as e:
				self.to_log('imp %r (%r & %r)'%(tool,tooldir,funs))
				self.to_log(Utils.ex_stack())
				raise
			if funs is not None:
				self.eval_rules(funs)
			else:
				func=getattr(module,'configure',None)
				if func:
					if type(func)is type(Utils.readf):func(self)
					else:self.eval_rules(func)
			self.tools.append({'tool':tool,'tooldir':tooldir,'funs':funs})
开发者ID:adrwtr,项目名称:BDJogosChip8,代码行数:31,代码来源:Configure.py


示例9: do_link

	def do_link(self, src, tgt):
		"""
		Create a symlink from tgt to src.

		This method is overridden in :py:meth:`waflib.Build.UninstallContext.do_link` to remove the symlink.

		:param src: file name as absolute path
		:type src: string
		:param tgt: file destination, as absolute path
		:type tgt: string
		"""
		d, _ = os.path.split(tgt)
		Utils.check_dir(d)

		link = False
		if not os.path.islink(tgt):
			link = True
		elif os.readlink(tgt) != src:
			link = True

		if link:
			try: os.remove(tgt)
			except OSError: pass
			if not self.progress_bar:
				Logs.info('+ symlink %s (to %s)' % (tgt, src))
			os.symlink(src, tgt)
		else:
			if not self.progress_bar:
				Logs.info('- symlink %s (to %s)' % (tgt, src))
开发者ID:Anastasia1302,项目名称:code-pile,代码行数:29,代码来源:Build.py


示例10: apply_haxe

def apply_haxe(self):
    Utils.def_attrs(self,
        target="", classpath="", flags="", libs="", swflib=None);

    classpath = Utils.to_list(self.classpath)
    flags = Utils.to_list(self.flags)
    target = self.target;

    inputs = []

    if target.endswith(".swf"):
        flags += ["-swf", target, "--flash-strict", "-D", "nativeTrace"]
        if (self.swflib is not None):
            swflib = self.path.get_bld().make_node(self.swflib)
            inputs += [swflib]
            flags += ["-swf-lib", str(swflib)]
    elif target.endswith(".js"):
        flags += ["-js", target]
    elif target.endswith(".n"):
        flags += ["-neko", target]
    else:
        raise "Unsupported target file type!"

    for lib in Utils.to_list(self.libs):
        flags += ["-lib", lib]

    task = self.create_task("haxe", inputs, self.path.get_bld().make_node(target))
    task.classpath = [self.path.find_node(cp) for cp in classpath]
    task.env.flags = flags
    self.haxe_task = task
开发者ID:flyingstar16,项目名称:flambe,代码行数:30,代码来源:haxe.py


示例11: process_py

def process_py(self,node):
	assert(node.get_bld_sig())
	assert(getattr(self,'install_path')),'add features="py"'
	if self.install_path:
		if self.install_from:
			self.bld.install_files(self.install_path,[node],cwd=self.install_from,relative_trick=True)
		else:
			self.bld.install_files(self.install_path,[node],relative_trick=True)
	lst=[]
	if self.env.PYC:
		lst.append('pyc')
	if self.env.PYO:
		lst.append('pyo')
	if self.install_path:
		if self.install_from:
			pyd=Utils.subst_vars("%s/%s"%(self.install_path,node.path_from(self.install_from)),self.env)
		else:
			pyd=Utils.subst_vars("%s/%s"%(self.install_path,node.path_from(self.path)),self.env)
	else:
		pyd=node.abspath()
	for ext in lst:
		if self.env.PYTAG:
			name=node.name[:-3]
			pyobj=node.parent.get_bld().make_node('__pycache__').make_node("%s.%s.%s"%(name,self.env.PYTAG,ext))
			pyobj.parent.mkdir()
		else:
			pyobj=node.change_ext(".%s"%ext)
		tsk=self.create_task(ext,node,pyobj)
		tsk.pyd=pyd
		if self.install_path:
			self.bld.install_files(os.path.dirname(pyd),pyobj,cwd=node.parent.get_bld(),relative_trick=True)
开发者ID:markreyn,项目名称:ndnSIMx,代码行数:31,代码来源:python.py


示例12: set_qt5_libs_to_check

def set_qt5_libs_to_check(self):
	self.qt5_vars = Utils.to_list(getattr(self, 'qt5_vars', []))
	if not self.qt5_vars:
		dirlst = Utils.listdir(self.env.QTLIBS)

		pat = self.env.cxxshlib_PATTERN
		if Utils.is_win32:
			pat = pat.replace('.dll', '.lib')
		if self.environ.get('QT5_FORCE_STATIC'):
			pat = self.env.cxxstlib_PATTERN
		if Utils.unversioned_sys_platform() == 'darwin':
			pat = "%s\.framework"
		re_qt = re.compile(pat%'Qt5?(?P<name>.*)'+'$')
		for x in dirlst:
			m = re_qt.match(x)
			if m:
				self.qt5_vars.append("Qt5%s" % m.group('name'))
		if not self.qt5_vars:
			self.fatal('cannot find any Qt5 library (%r)' % self.env.QTLIBS)

	qtextralibs = getattr(Options.options, 'qtextralibs', None)
	if qtextralibs:
		self.qt5_vars.extend(qtextralibs.split(','))

	if not hasattr(self, 'qt5_vars_debug'):
		self.qt5_vars_debug = [a + '_DEBUG' for a in self.qt5_vars]
	self.qt5_vars_debug = Utils.to_list(self.qt5_vars_debug)
开发者ID:JodyGoldberg,项目名称:waf,代码行数:27,代码来源:qt5.py


示例13: apply_java

def apply_java(self):
    Utils.def_attrs(
        self, jarname="", classpath="", sourcepath=".", srcdir=".", jar_mf_attributes={}, jar_mf_classpath=[]
    )
    nodes_lst = []
    if not self.classpath:
        if not self.env["CLASSPATH"]:
            self.env["CLASSPATH"] = ".." + os.pathsep + "."
    else:
        self.env["CLASSPATH"] = self.classpath
    if isinstance(self.srcdir, self.path.__class__):
        srcdir_node = self.srcdir
    else:
        srcdir_node = self.path.find_dir(self.srcdir)
    if not srcdir_node:
        raise Errors.WafError("could not find srcdir %r" % self.srcdir)
    self.env["OUTDIR"] = [srcdir_node.get_src().srcpath()]
    self.javac_task = tsk = self.create_task("javac")
    tsk.srcdir = srcdir_node
    if getattr(self, "compat", None):
        tsk.env.append_value("JAVACFLAGS", ["-source", self.compat])
    if hasattr(self, "sourcepath"):
        fold = [
            isinstance(x, self.path.__class__) and x or self.path.find_dir(x) for x in self.to_list(self.sourcepath)
        ]
        names = os.pathsep.join([x.srcpath() for x in fold])
    else:
        names = srcdir_node.srcpath()
    if names:
        tsk.env.append_value("JAVACFLAGS", ["-sourcepath", names])
开发者ID:RunarFreyr,项目名称:waz,代码行数:30,代码来源:javaw.py


示例14: apply_read_format_extensions

def apply_read_format_extensions(self):
    enabled_exts = Utils.to_list(getattr(self, 'enabled_exts', []))
    disabled_exts = Utils.to_list(getattr(self, 'disabled_exts', []))
    read_format = getattr(self, 'read_format', 'markdown')
    read_format += ''.join(('+' + e for e in enabled_exts))
    read_format += ''.join(('-' + e for e in disabled_exts))
    self.read_format = read_format
开发者ID:kirelagin,项目名称:thesis-template,代码行数:7,代码来源:pandoc.py


示例15: find_file

def find_file(self,filename,path_list=[]):
	for n in Utils.to_list(filename):
		for d in Utils.to_list(path_list):
			p=os.path.join(d,n)
			if os.path.exists(p):
				return p
	self.fatal('Could not find %r'%filename)
开发者ID:AkiraShirase,项目名称:audacity,代码行数:7,代码来源:Configure.py


示例16: __boost_get_libs_path

def __boost_get_libs_path(self, *k, **kw):
	''' return the lib path and all the files in it '''
	if 'files' in kw:
		return self.root.find_dir('.'), Utils.to_list(kw['files'])
	libs = k and k[0] or kw.get('libs', None)
	if libs:
		path = self.root.find_dir(libs)
		files = path.ant_glob('*boost_*')
	if not libs or not files:
		for d in Utils.to_list(self.environ.get('LIB', [])) + BOOST_LIBS:
			path = self.root.find_dir(d)
			if path:
				files = path.ant_glob('*boost_*')
				if files:
					break
			path = self.root.find_dir(d + '64')
			if path:
				files = path.ant_glob('*boost_*')
				if files:
					break
	if not path:
		if libs:
			self.end_msg('libs not found in %s' % libs)
			self.fatal('The configuration failed')
		else:
			self.end_msg('libs not found, please provide a --boost-libs argument (see help)')
			self.fatal('The configuration failed')

	self.to_log('Found the boost path in %r with the libraries:' % path)
	for x in files:
		self.to_log('    %r' % x)
	return path, files
开发者ID:hawkxiang,项目名称:Centaur,代码行数:32,代码来源:boost.py


示例17: post_check

def post_check(self,*k,**kw):
	is_success=0
	if kw['execute']:
		if kw['success']is not None:
			if kw.get('define_ret',False):
				is_success=kw['success']
			else:
				is_success=(kw['success']==0)
	else:
		is_success=(kw['success']==0)
	if'define_name'in kw:
		if'header_name'in kw or'function_name'in kw or'type_name'in kw or'fragment'in kw:
			if kw['execute']and kw.get('define_ret',None)and isinstance(is_success,str):
				self.define(kw['define_name'],is_success,quote=kw.get('quote',1))
			else:
				self.define_cond(kw['define_name'],is_success)
		else:
			self.define_cond(kw['define_name'],is_success)
	if'header_name'in kw:
		if kw.get('auto_add_header_name',False):
			self.env.append_value(INCKEYS,Utils.to_list(kw['header_name']))
	if is_success and'uselib_store'in kw:
		from waflib.Tools import ccroot
		_vars=set([])
		for x in kw['features']:
			if x in ccroot.USELIB_VARS:
				_vars|=ccroot.USELIB_VARS[x]
		for k in _vars:
			lk=k.lower()
			if lk in kw:
				val=kw[lk]
				if isinstance(val,str):
					val=val.rstrip(os.path.sep)
				self.env.append_unique(k+'_'+kw['uselib_store'],Utils.to_list(val))
	return is_success
开发者ID:WU-ARL,项目名称:ndn-ops,代码行数:35,代码来源:c_config.py


示例18: prepare_env

	def prepare_env(self,env):
		if not env.PREFIX:
			env.PREFIX=os.path.abspath(os.path.expanduser(Options.options.prefix))
		if not env.BINDIR:
			env.BINDIR=Utils.subst_vars('${PREFIX}/bin',env)
		if not env.LIBDIR:
			env.LIBDIR=Utils.subst_vars('${PREFIX}/lib',env)
开发者ID:AKASeon,项目名称:Whatever,代码行数:7,代码来源:Configure.py


示例19: store

	def store(self, filename):
		"""
		Write the :py:class:`ConfigSet` data into a file. See :py:meth:`ConfigSet.load` for reading such files.

		:param filename: file to use
		:type filename: string
		"""
		try:
			os.makedirs(os.path.split(filename)[0])
		except OSError:
			pass

		buf = []
		merged_table = self.get_merged_dict()
		keys = list(merged_table.keys())
		keys.sort()

		try:
			fun = ascii
		except NameError:
			fun = repr

		for k in keys:
			if k != 'undo_stack':
				buf.append('%s = %s\n' % (k, fun(merged_table[k])))
		Utils.writef(filename, ''.join(buf))
开发者ID:DigitalDan05,项目名称:waf,代码行数:26,代码来源:ConfigSet.py


示例20: xcheck_host_envar

def xcheck_host_envar(conf, name, wafname=None):
	wafname = wafname or name

	chost, chost_envar = get_chost_stuff(conf)

	specific = None
	if chost:
		specific = os.environ.get('%s_%s' % (chost_envar, name), None)

	if specific:
		value = Utils.to_list(specific)
		conf.env[wafname] += value
		conf.msg('Will use cross-compilation %s from %s_%s' \
		 % (name, chost_envar, name),
		 " ".join(quote(x) for x in value))
		return


	envar = os.environ.get('HOST_%s' % name, None)
	if envar is None:
		return

	value = Utils.to_list(envar) if envar != '' else [envar]

	conf.env[wafname] = value
	conf.msg('Will use cross-compilation %s from HOST_%s' \
	 % (name, name),
	 " ".join(quote(x) for x in value))
开发者ID:kenmasumitsu,项目名称:waf,代码行数:28,代码来源:cfg_cross_gnu.py



注:本文中的waflib.Utils类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python Configure.conf函数代码示例发布时间:2022-05-26
下一篇:
Python waflib.TaskGen类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap