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


Python Utils.sane_path方法代码示例

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


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

示例1: prepare_env

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import sane_path [as 别名]
	def prepare_env(self,env):
		if not env.PREFIX:
			if Options.options.prefix or Utils.is_win32:
				env.PREFIX=Utils.sane_path(Options.options.prefix)
			else:
				env.PREFIX=''
		if not env.BINDIR:
			if Options.options.bindir:
				env.BINDIR=Utils.sane_path(Options.options.bindir)
			else:
				env.BINDIR=Utils.subst_vars('${PREFIX}/bin',env)
		if not env.LIBDIR:
			if Options.options.libdir:
				env.LIBDIR=Utils.sane_path(Options.options.libdir)
			else:
				env.LIBDIR=Utils.subst_vars('${PREFIX}/lib%s'%Utils.lib64(),env)
开发者ID:allencubie,项目名称:lib,代码行数:18,代码来源:Configure.py

示例2: prepare_env

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import sane_path [as 别名]
	def prepare_env(self, env):
		"""
		Insert *PREFIX*, *BINDIR* and *LIBDIR* values into ``env``

		:type env: :py:class:`waflib.ConfigSet.ConfigSet`
		:param env: a ConfigSet, usually ``conf.env``
		"""
		if not env.PREFIX:
			if Options.options.prefix or Utils.is_win32:
				env.PREFIX = Utils.sane_path(Options.options.prefix)
			else:
				env.PREFIX = ''
		if not env.BINDIR:
			if Options.options.bindir:
				env.BINDIR = Utils.sane_path(Options.options.bindir)
			else:
				env.BINDIR = Utils.subst_vars('${PREFIX}/bin', env)
		if not env.LIBDIR:
			if Options.options.libdir:
				env.LIBDIR = Utils.sane_path(Options.options.libdir)
			else:
				env.LIBDIR = Utils.subst_vars('${PREFIX}/lib%s' % Utils.lib64(), env)
开发者ID:BigPigg,项目名称:waf,代码行数:24,代码来源:Configure.py

示例3: parse_args

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import sane_path [as 别名]
	def parse_args(self,_args=None):
		global options,commands,envvars
		(options,leftover_args)=self.parser.parse_args(args=_args)
		for arg in leftover_args:
			if'='in arg:
				envvars.append(arg)
			else:
				commands.append(arg)
		if options.destdir:
			options.destdir=Utils.sane_path(options.destdir)
		if options.verbose>=1:
			self.load('errcheck')
		colors={'yes':2,'auto':1,'no':0}[options.colors]
		Logs.enable_colors(colors)
开发者ID:Gnurou,项目名称:glmark2,代码行数:16,代码来源:Options.py

示例4: parse_args

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import sane_path [as 别名]
 def parse_args(self, _args=None):
     global options, commands, envvars
     (options, leftover_args) = self.parser.parse_args(args=_args)
     for arg in leftover_args:
         if "=" in arg:
             envvars.append(arg)
         else:
             commands.append(arg)
     if options.destdir:
         options.destdir = Utils.sane_path(options.destdir)
     if options.verbose >= 1:
         self.load("errcheck")
     colors = {"yes": 2, "auto": 1, "no": 0}[options.colors]
     Logs.enable_colors(colors)
开发者ID:raahilshah,项目名称:MSMPTCP,代码行数:16,代码来源:Options.py

示例5: parse_args

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import sane_path [as 别名]
	def parse_args(self, _args=None):
		"""
		Parse arguments from a list (not bound to the command-line).

		:param _args: arguments
		:type _args: list of strings
		"""
		global options, commands, envvars
		(options, leftover_args) = self.parser.parse_args(args=_args)

		for arg in leftover_args:
			if '=' in arg:
				envvars.append(arg)
			else:
				commands.append(arg)

		if options.destdir:
			options.destdir = Utils.sane_path(options.destdir)

		if options.verbose >= 1:
			self.load('errcheck')

		colors = {'yes' : 2, 'auto' : 1, 'no' : 0}[options.colors]
		Logs.enable_colors(colors)
开发者ID:DigitalDan05,项目名称:waf,代码行数:26,代码来源:Options.py

示例6: parse_args

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import sane_path [as 别名]
    def parse_args(self, _args=None):
        """
		Parses arguments from a list which is not necesarily the command-line.

		:param _args: arguments
		:type _args: list of strings
		"""
        global options, commands, envvars
        (options, leftover_args) = self.parser.parse_args(args=_args)

        for arg in leftover_args:
            if "=" in arg:
                envvars.append(arg)
            else:
                commands.append(arg)

        if options.destdir:
            options.destdir = Utils.sane_path(options.destdir)

        if options.verbose >= 1:
            self.load("errcheck")

        colors = {"yes": 2, "auto": 1, "no": 0}[options.colors]
        Logs.enable_colors(colors)
开发者ID:yukimori,项目名称:waf,代码行数:26,代码来源:Options.py

示例7: waf_entry_point

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import sane_path [as 别名]
def waf_entry_point(current_directory, version, wafdir):
	"""
	This is the main entry point, all Waf execution starts here.

	:param current_directory: absolute path representing the current directory
	:type current_directory: string
	:param version: version number
	:type version: string
	:param wafdir: absolute path representing the directory of the waf library
	:type wafdir: string
	"""

	Logs.init_log()

	if Context.WAFVERSION != version:
		Logs.error('Waf script %r and library %r do not match (directory %r)' % (version, Context.WAFVERSION, wafdir))
		sys.exit(1)

	if '--version' in sys.argv:
		Context.run_dir = current_directory
		ctx = Context.create_context('options')
		ctx.curdir = current_directory
		ctx.parse_args()
		sys.exit(0)

	if len(sys.argv) > 1:
		# os.path.join handles absolute paths in sys.argv[1] accordingly (it discards the previous ones)
		# if sys.argv[1] is not an absolute path, then it is relative to the current working directory
		potential_wscript = os.path.join(current_directory, sys.argv[1])
		# maybe check if the file is executable
		# perhaps extract 'wscript' as a constant
		if os.path.basename(potential_wscript) == 'wscript' and os.path.isfile(potential_wscript):
			# need to explicitly normalize the path, as it may contain extra '/.'
			# TODO abspath?
			current_directory = os.path.normpath(os.path.dirname(potential_wscript))
			sys.argv.pop(1)

	Context.waf_dir = wafdir
	Context.launch_dir = current_directory

	# if 'configure' is in the commands, do not search any further
	no_climb = os.environ.get('NOCLIMB', None)
	if not no_climb:
		for k in no_climb_commands:
			for y in sys.argv:
				if y.startswith(k):
					no_climb = True
					break

	# if --top is provided assume the build started in the top directory
	for i, x in enumerate(sys.argv):
		# WARNING: this modifies sys.argv
		if x.startswith('--top='):
			Context.run_dir = Context.top_dir = Utils.sane_path(x[6:])
			sys.argv[i] = '--top=' + Context.run_dir
		if x.startswith('--out='):
			Context.out_dir = Utils.sane_path(x[6:])
			sys.argv[i] = '--out=' + Context.out_dir

	# try to find a lock file (if the project was configured)
	# at the same time, store the first wscript file seen
	cur = current_directory
	while cur and not Context.top_dir:
		lst = os.listdir(cur)
		if Options.lockfile in lst:
			env = ConfigSet.ConfigSet()
			try:
				env.load(os.path.join(cur, Options.lockfile))
				ino = os.stat(cur)[stat.ST_INO]
			except Exception:
				pass
			else:
				# check if the folder was not moved
				for x in (env.run_dir, env.top_dir, env.out_dir):
					if Utils.is_win32:
						if cur == x:
							load = True
							break
					else:
						# if the filesystem features symlinks, compare the inode numbers
						try:
							ino2 = os.stat(x)[stat.ST_INO]
						except OSError:
							pass
						else:
							if ino == ino2:
								load = True
								break
				else:
					Logs.warn('invalid lock file in %s' % cur)
					load = False

				if load:
					Context.run_dir = env.run_dir
					Context.top_dir = env.top_dir
					Context.out_dir = env.out_dir
					break

		if not Context.run_dir:
			if Context.WSCRIPT_FILE in lst:
#.........这里部分代码省略.........
开发者ID:XNerv,项目名称:waf,代码行数:103,代码来源:Scripting.py

示例8: waf_entry_point

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import sane_path [as 别名]
def waf_entry_point(current_directory,version,wafdir):
	Logs.init_log()
	if Context.WAFVERSION!=version:
		Logs.error('Waf script %r and library %r do not match (directory %r)',version,Context.WAFVERSION,wafdir)
		sys.exit(1)
	if'--version'in sys.argv:
		Context.run_dir=current_directory
		ctx=Context.create_context('options')
		ctx.curdir=current_directory
		ctx.parse_args()
		sys.exit(0)
	if len(sys.argv)>1:
		potential_wscript=os.path.join(current_directory,sys.argv[1])
		if os.path.basename(potential_wscript)=='wscript'and os.path.isfile(potential_wscript):
			current_directory=os.path.normpath(os.path.dirname(potential_wscript))
			sys.argv.pop(1)
	Context.waf_dir=wafdir
	Context.launch_dir=current_directory
	no_climb=os.environ.get('NOCLIMB')
	if not no_climb:
		for k in no_climb_commands:
			for y in sys.argv:
				if y.startswith(k):
					no_climb=True
					break
	for i,x in enumerate(sys.argv):
		if x.startswith('--top='):
			Context.run_dir=Context.top_dir=Utils.sane_path(x[6:])
			sys.argv[i]='--top='+Context.run_dir
		if x.startswith('--out='):
			Context.out_dir=Utils.sane_path(x[6:])
			sys.argv[i]='--out='+Context.out_dir
	cur=current_directory
	while cur and not Context.top_dir:
		try:
			lst=os.listdir(cur)
		except OSError:
			lst=[]
			Logs.error('Directory %r is unreadable!',cur)
		if Options.lockfile in lst:
			env=ConfigSet.ConfigSet()
			try:
				env.load(os.path.join(cur,Options.lockfile))
				ino=os.stat(cur)[stat.ST_INO]
			except EnvironmentError:
				pass
			else:
				for x in(env.run_dir,env.top_dir,env.out_dir):
					if Utils.is_win32:
						if cur==x:
							load=True
							break
					else:
						try:
							ino2=os.stat(x)[stat.ST_INO]
						except OSError:
							pass
						else:
							if ino==ino2:
								load=True
								break
				else:
					Logs.warn('invalid lock file in %s',cur)
					load=False
				if load:
					Context.run_dir=env.run_dir
					Context.top_dir=env.top_dir
					Context.out_dir=env.out_dir
					break
		if not Context.run_dir:
			if Context.WSCRIPT_FILE in lst:
				Context.run_dir=cur
		next=os.path.dirname(cur)
		if next==cur:
			break
		cur=next
		if no_climb:
			break
	if not Context.run_dir:
		if'-h'in sys.argv or'--help'in sys.argv:
			Logs.warn('No wscript file found: the help message may be incomplete')
			Context.run_dir=current_directory
			ctx=Context.create_context('options')
			ctx.curdir=current_directory
			ctx.parse_args()
			sys.exit(0)
		Logs.error('Waf: Run from a directory containing a file named %r',Context.WSCRIPT_FILE)
		sys.exit(1)
	try:
		os.chdir(Context.run_dir)
	except OSError:
		Logs.error('Waf: The folder %r is unreadable',Context.run_dir)
		sys.exit(1)
	try:
		set_main_module(os.path.normpath(os.path.join(Context.run_dir,Context.WSCRIPT_FILE)))
	except Errors.WafError as e:
		Logs.pprint('RED',e.verbose_msg)
		Logs.error(str(e))
		sys.exit(1)
	except Exception as e:
#.........这里部分代码省略.........
开发者ID:Gnurou,项目名称:glmark2,代码行数:103,代码来源:Scripting.py

示例9: waf_entry_point

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import sane_path [as 别名]
def waf_entry_point(current_directory,version,wafdir):
	Logs.init_log()
	if Context.WAFVERSION!=version:
		Logs.error('Waf script %r and library %r do not match (directory %r)'%(version,Context.WAFVERSION,wafdir))
		sys.exit(1)
	if'--version'in sys.argv:
		Context.run_dir=current_directory
		ctx=Context.create_context('options')
		ctx.curdir=current_directory
		ctx.parse_args()
		sys.exit(0)
	if len(sys.argv)>1:
		potential_wscript=os.path.join(current_directory,sys.argv[1])
		if os.path.basename(potential_wscript)=='wscript'and os.path.isfile(potential_wscript):
			current_directory=os.path.normpath(os.path.dirname(potential_wscript))
			sys.argv.pop(1)
	Context.waf_dir=wafdir
	Context.launch_dir=current_directory
	no_climb=os.environ.get('NOCLIMB',None)
	if not no_climb:
		for k in no_climb_commands:
			for y in sys.argv:
				if y.startswith(k):
					no_climb=True
					break
	for i,x in enumerate(sys.argv):
		if x.startswith('--top='):
			Context.run_dir=Context.top_dir=Utils.sane_path(x[6:])
			sys.argv[i]='--top='+Context.run_dir
		if x.startswith('--out='):
			Context.out_dir=Utils.sane_path(x[6:])
			sys.argv[i]='--out='+Context.out_dir
	cur=current_directory
	while cur and not Context.top_dir:
		lst=os.listdir(cur)
		if Options.lockfile in lst:
			env=ConfigSet.ConfigSet()
			try:
				env.load(os.path.join(cur,Options.lockfile))
				ino=os.stat(cur)[stat.ST_INO]
			except Exception:
				pass
			else:
				for x in(env.run_dir,env.top_dir,env.out_dir):
					if Utils.is_win32:
						if cur==x:
							load=True
							break
					else:
						try:
							ino2=os.stat(x)[stat.ST_INO]
						except OSError:
							pass
						else:
							if ino==ino2:
								load=True
								break
				else:
					Logs.warn('invalid lock file in %s'%cur)
					load=False
				if load:
					Context.run_dir=env.run_dir
					Context.top_dir=env.top_dir
					Context.out_dir=env.out_dir
					break
		if not Context.run_dir:
			if Context.WSCRIPT_FILE in lst:
				Context.run_dir=cur
		next=os.path.dirname(cur)
		if next==cur:
			break
		cur=next
		if no_climb:
			break
	if not Context.run_dir:
		if'-h'in sys.argv or'--help'in sys.argv:
			Logs.warn('No wscript file found: the help message may be incomplete')
			Context.run_dir=current_directory
			ctx=Context.create_context('options')
			ctx.curdir=current_directory
			ctx.parse_args()
			sys.exit(0)
		Logs.error('Waf: Run from a directory containing a file named %r'%Context.WSCRIPT_FILE)
		sys.exit(1)
	try:
		os.chdir(Context.run_dir)
	except OSError:
		Logs.error('Waf: The folder %r is unreadable'%Context.run_dir)
		sys.exit(1)
	try:
		set_main_module(os.path.normpath(os.path.join(Context.run_dir,Context.WSCRIPT_FILE)))
	except Errors.WafError ,e:
		Logs.pprint('RED',e.verbose_msg)
		Logs.error(str(e))
		sys.exit(1)
开发者ID:AliZafar120,项目名称:ns3,代码行数:97,代码来源:Scripting.py


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