当前位置: 首页>>代码示例>>Python>>正文


Python Context.load_tool方法代码示例

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


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

示例1: load

# 需要导入模块: from waflib import Context [as 别名]
# 或者: from waflib.Context import load_tool [as 别名]
 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, 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, e:
             self.to_log("imp %r (%r & %r)" % (tool, tooldir, funs))
             self.to_log(Utils.ex_stack())
             raise
开发者ID:RONNCC,项目名称:pysoy,代码行数:31,代码来源:Configure.py

示例2: download_tool

# 需要导入模块: from waflib import Context [as 别名]
# 或者: from waflib.Context import load_tool [as 别名]
def download_tool(tool,force=False,ctx=None):
	for x in Utils.to_list(Context.remote_repo):
		for sub in Utils.to_list(Context.remote_locs):
			url='/'.join((x,sub,tool+'.py'))
			try:
				web=urlopen(url)
				try:
					if web.getcode()!=200:
						continue
				except AttributeError:
					pass
			except Exception:
				continue
			else:
				tmp=ctx.root.make_node(os.sep.join((Context.waf_dir,'waflib','extras',tool+'.py')))
				tmp.write(web.read(),'wb')
				Logs.warn('Downloaded %s from %s'%(tool,url))
				download_check(tmp)
				try:
					module=Context.load_tool(tool)
				except Exception:
					Logs.warn('The tool %s from %s is unusable'%(tool,url))
					try:
						tmp.delete()
					except Exception:
						pass
					continue
				return module
	raise Errors.WafError('Could not load the Waf tool')
开发者ID:AkiraShirase,项目名称:audacity,代码行数:31,代码来源:Configure.py

示例3: load

# 需要导入模块: from waflib import Context [as 别名]
# 或者: from waflib.Context import load_tool [as 别名]
	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,代码行数:33,代码来源:Configure.py

示例4: download_tool

# 需要导入模块: from waflib import Context [as 别名]
# 或者: from waflib.Context import load_tool [as 别名]
def download_tool(tool, force=False):
	"""downloads a tool from the waf repository"""
	for x in Utils.to_list(Context.remote_repo):
		for sub in Utils.to_list(Context.remote_locs):
			url = '/'.join((x, sub, tool + '.py'))
			try:
				web = urlopen(url)
				if web.getcode() != 200:
					continue
			except Exception as e:
				# on python3 urlopen throws an exception
				continue
			else:
				tmp = self.root.make_node(os.sep.join((Context.waf_dir, 'waflib', 'extras', tool + '.py')))
				tmp.write(web.read())
				Logs.warn('downloaded %s from %s' % (tool, url))
				download_check(tmp)
				try:
					module = Context.load_tool(tool)
				except:
					Logs.warn('module %s from %s is unusable' % (tool, url))
					try:
						tmp.delete()
					except:
						pass
					continue
				return module
		else:
				break
		raise Errors.WafError('Could not load the Waf tool')
开发者ID:RunarFreyr,项目名称:waz,代码行数:32,代码来源:Configure.py

示例5: load

# 需要导入模块: from waflib import Context [as 别名]
# 或者: from waflib.Context import load_tool [as 别名]
	def load(self,input,tooldir=None,funs=None,with_sys_path=True,cache=False):
		tools=Utils.to_list(input)
		if tooldir:tooldir=Utils.to_list(tooldir)
		for tool in tools:
			if cache:
				mag=(tool,id(self.env),tooldir,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,ctx=self,with_sys_path=with_sys_path)
			except ImportError as e:
				self.fatal('Could not load the Waf tool %r from %r\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:Gnurou,项目名称:glmark2,代码行数:29,代码来源:Configure.py

示例6: download_tool

# 需要导入模块: from waflib import Context [as 别名]
# 或者: from waflib.Context import load_tool [as 别名]
def download_tool(tool, force=False, ctx=None):
	"""
	Download a Waf tool from the remote repository defined in :py:const:`waflib.Context.remote_repo`::

		$ waf configure --download
	"""
	for x in Utils.to_list(Context.remote_repo):
		for sub in Utils.to_list(Context.remote_locs):
			url = '/'.join((x, sub, tool + '.py'))
			try:
				web = urlopen(url)
				if web.getcode() != 200:
					continue
			except Exception as e:
				# on python3 urlopen throws an exception
				continue
			else:
				tmp = ctx.root.make_node(os.sep.join((Context.waf_dir, 'waflib', 'extras', tool + '.py')))
				tmp.write(web.read())
				Logs.warn('Downloaded %s from %s' % (tool, url))
				download_check(tmp)
				try:
					module = Context.load_tool(tool)
				except:
					Logs.warn('The tool %s from %s is unusable' % (tool, url))
					try:
						tmp.delete()
					except:
						pass
					continue
				return module
	raise Errors.WafError('Could not load the Waf tool')
开发者ID:ita1024,项目名称:node,代码行数:34,代码来源:Configure.py

示例7: setup

# 需要导入模块: from waflib import Context [as 别名]
# 或者: from waflib.Context import load_tool [as 别名]
 def setup(self, tool, tooldir=None, funs=None):
     if isinstance(tool, list):
         for i in tool:
             self.setup(i, tooldir)
         return
     module = Context.load_tool(tool, tooldir)
     if hasattr(module, "setup"):
         module.setup(self)
开发者ID:asivakum,项目名称:EE563Project,代码行数:10,代码来源:Build.py

示例8: setup

# 需要导入模块: from waflib import Context [as 别名]
# 或者: from waflib.Context import load_tool [as 别名]
	def setup(self, tool, tooldir=None, funs=None):
		"""Loads the waf tools declared in the configuration section"""
		if isinstance(tool, list):
			for i in tool: self.setup(i, tooldir)
			return

		module = Context.load_tool(tool, tooldir)
		if hasattr(module, "setup"): module.setup(self)
开发者ID:zsx,项目名称:waf,代码行数:10,代码来源:Build.py

示例9: load

# 需要导入模块: from waflib import Context [as 别名]
# 或者: from waflib.Context import load_tool [as 别名]
    def load(self, input, tooldir=None, funs=None, download=True):
        """
        Load Waf tools, which will be imported whenever a build is started.

        :param input: waf tools to import
        :type input: list of string
        :param tooldir: paths for the imports
        :type tooldir: list of string
        :param funs: functions to execute from the waf tools
        :type funs: list of string
        :param download: whether to download the tool from the waf repository
        :type download: bool
        """

        tools = Utils.to_list(input)
        if tooldir:
            tooldir = Utils.to_list(tooldir)
        for tool in tools:
            # avoid loading the same tool more than once with the same functions
            # used by composite projects

            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:pbx,项目名称:kupfer,代码行数:55,代码来源:Configure.py

示例10: load

# 需要导入模块: from waflib import Context [as 别名]
# 或者: from waflib.Context import load_tool [as 别名]
	def load(self, input, tooldir=None, funs=None, with_sys_path=True, cache=False):
		"""
		Load Waf tools, which will be imported whenever a build is started.

		:param input: waf tools to import
		:type input: list of string
		:param tooldir: paths for the imports
		:type tooldir: list of string
		:param funs: functions to execute from the waf tools
		:type funs: list of string
		:param cache: whether to prevent the tool from running twice
		:type cache: bool
		"""

		tools = Utils.to_list(input)
		if tooldir:
			tooldir = Utils.to_list(tooldir)
		for tool in tools:
			# avoid loading the same tool more than once with the same functions
			# used by composite projects

			if cache:
				mag = (tool, id(self.env), tooldir, 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, ctx=self, with_sys_path=with_sys_path)
			except ImportError as e:
				self.fatal('Could not load the Waf tool %r from %r\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:JodyGoldberg,项目名称:waf,代码行数:51,代码来源:Configure.py

示例11: tool_options

# 需要导入模块: from waflib import Context [as 别名]
# 或者: from waflib.Context import load_tool [as 别名]
	def tool_options(self, tool_list, *k, **kw):
		#if not k[0]:
		#	raise Utils.WafError('invalid tool_options call %r %r' % (k, kw))
		tools = Utils.to_list(tool_list)

		path = Utils.to_list(kw.get('tooldir', ''))

		for tool in tools:
			module = Context.load_tool(tool, path)
			try:
				fun = module.options
			except AttributeError:
				pass
			else:
				fun(kw.get('option_group', self))
开发者ID:zsx,项目名称:waf,代码行数:17,代码来源:Options.py

示例12: load

# 需要导入模块: from waflib import Context [as 别名]
# 或者: from waflib.Context import load_tool [as 别名]
    def load(self, input, tooldir=None, funs=None):
        """
		Load Waf tools, which will be imported whenever a build is started.

		:param input: waf tools to import
		:type input: list of string
		:param tooldir: paths for the imports
		:type tooldir: list of string
		:param funs: functions to execute from the waf tools
		:type funs: list of string
		"""

        tools = Utils.to_list(input)
        if tooldir:
            tooldir = Utils.to_list(tooldir)
        for tool in tools:
            # avoid loading the same tool more than once with the same functions
            # used by composite projects

            mag = (tool, id(self.env), tooldir, 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, ctx=self)
            except ImportError as e:
                self.fatal("Could not load the Waf tool %r from %r\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:yotann,项目名称:waf,代码行数:48,代码来源:Configure.py

示例13: load

# 需要导入模块: from waflib import Context [as 别名]
# 或者: from waflib.Context import load_tool [as 别名]
	def load(self,input,tooldir=None,funs=None):
		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,ctx=self)
			except ImportError ,e:
				self.fatal('Could not load the Waf tool %r from %r\n%s'%(tool,sys.path,e))
			except Exception ,e:
				self.to_log('imp %r (%r & %r)'%(tool,tooldir,funs))
				self.to_log(Utils.ex_stack())
				raise
开发者ID:raystubbs,项目名称:NMSU-BigData-REU-NDN-Access-Control-Simulation,代码行数:20,代码来源:Configure.py

示例14: setup

# 需要导入模块: from waflib import Context [as 别名]
# 或者: from waflib.Context import load_tool [as 别名]
	def setup(self, tool, tooldir=None, funs=None):
		"""
		Import waf tools, used to import those accessed during the configuration::

			def configure(conf):
				conf.load('glib2')

			def build(bld):
				pass # glib2 is imported implicitly

		:param tool: tool list
		:type tool: list
		:param tooldir: optional tool directory (sys.path)
		:type tooldir: list of string
		:param funs: unused variable
		"""
		if isinstance(tool, list):
			for i in tool: self.setup(i, tooldir)
			return

		module = Context.load_tool(tool, tooldir)
		if hasattr(module, "setup"): module.setup(self)
开发者ID:Anastasia1302,项目名称:code-pile,代码行数:24,代码来源:Build.py

示例15: download_tool

# 需要导入模块: from waflib import Context [as 别名]
# 或者: from waflib.Context import load_tool [as 别名]
def download_tool(tool, force=False, ctx=None):
    """
	Download a Waf tool from the remote repository defined in :py:const:`waflib.Context.remote_repo`::

		$ waf configure --download
	"""
    for x in Utils.to_list(Context.remote_repo):
        for sub in Utils.to_list(Context.remote_locs):
            url = "/".join((x, sub, tool + ".py"))
            try:
                web = urlopen(url)
                try:
                    if web.getcode() != 200:
                        continue
                except AttributeError:
                    pass
            except Exception:
                # on python3 urlopen throws an exception
                # python 2.3 does not have getcode and throws an exception to fail
                continue
            else:
                tmp = ctx.root.make_node(os.sep.join((Context.waf_dir, "waflib", "extras", tool + ".py")))
                tmp.write(web.read(), "wb")
                Logs.warn("Downloaded %s from %s" % (tool, url))
                download_check(tmp)
                try:
                    module = Context.load_tool(tool)
                except Exception:
                    Logs.warn("The tool %s from %s is unusable" % (tool, url))
                    try:
                        tmp.delete()
                    except Exception:
                        pass
                    continue
                return module
    raise Errors.WafError("Could not load the Waf tool")
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:38,代码来源:Configure.py


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