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


Python Utils.pprint方法代码示例

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


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

示例1: apply_intltool_po

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import pprint [as 别名]
def apply_intltool_po(self):
    try:
        self.meths.remove("process_source")
    except ValueError:
        pass
    self.default_install_path = "${LOCALEDIR}"
    appname = getattr(self, "appname", "set_your_app_name")
    podir = getattr(self, "podir", "")

    def install_translation(task):
        out = task.outputs[0]
        filename = out.name
        (langname, ext) = os.path.splitext(filename)
        inst_file = langname + os.sep + "LC_MESSAGES" + os.sep + appname + ".mo"
        self.bld.install_as(os.path.join(self.install_path, inst_file), out, self.env, self.chmod)

    linguas = self.path.find_resource(os.path.join(podir, "LINGUAS"))
    if linguas:
        file = open(linguas.abspath())
        langs = []
        for line in file.readlines():
            if not line.startswith("#"):
                langs += line.split()
        file.close()
        re_linguas = re.compile("[[email protected]]+")
        for lang in langs:
            if re_linguas.match(lang):
                node = self.path.find_resource(os.path.join(podir, re_linguas.match(lang).group() + ".po"))
                task = self.create_task("po")
                task.set_inputs(node)
                task.set_outputs(node.change_ext(".mo"))
                if self.bld.is_install:
                    task.install = install_translation
    else:
        Utils.pprint("RED", "Error no LINGUAS file found in po directory")
开发者ID:RunarFreyr,项目名称:waz,代码行数:37,代码来源:intltool.py

示例2: daemon

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import pprint [as 别名]
def daemon(ctx):
	"""waf command: rebuild as soon as something changes"""
	bld = None
	while True:
		bld = Context.create_context('build')
		try:
			bld.options = Options.options
			bld.cmd = 'build'
			bld.execute()
		except ctx.errors.WafError as e:
			print(e)
		except KeyboardInterrupt:
			Utils.pprint('RED', 'interrupted')
			break

		try:
			x = ctx.state
		except AttributeError:
			setattr(ctx, 'state', DirWatch())
			x = ctx.state

		x.wait(bld)
开发者ID:kaihuangecnu,项目名称:freqt,代码行数:24,代码来源:daemon.py

示例3: summary

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import pprint [as 别名]
def summary(bld):
	lst = getattr(bld, 'utest_results', [])
	if lst:
		Utils.pprint('CYAN', 'execution summary')
		for (f, fail, ret) in lst:
			col = fail and 'RED' or 'GREEN'
			Utils.pprint(col, (fail and 'FAIL' or 'ok') + " " + f)
			if fail: Utils.pprint('NORMAL', ret.replace('\\n', '\n'))
开发者ID:zsx,项目名称:waf,代码行数:10,代码来源:waf_unit_test.py

示例4: apply_intltool_po

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import pprint [as 别名]
def apply_intltool_po(self):
	try: self.meths.remove('process_source')
	except ValueError: pass

	self.default_install_path = '${LOCALEDIR}'
	appname = getattr(self, 'appname', 'set_your_app_name')
	podir = getattr(self, 'podir', '')

	def install_translation(task):
		out = task.outputs[0]
		filename = out.name
		(langname, ext) = os.path.splitext(filename)
		inst_file = langname + os.sep + 'LC_MESSAGES' + os.sep + appname + '.mo'
		self.bld.install_as(os.path.join(self.install_path, inst_file), out, self.env, self.chmod)

	linguas = self.path.find_resource(os.path.join(podir, 'LINGUAS'))
	if linguas:
		# scan LINGUAS file for locales to process
		file = open(linguas.abspath())
		langs = []
		for line in file.readlines():
			# ignore lines containing comments
			if not line.startswith('#'):
				langs += line.split()
		file.close()
		re_linguas = re.compile('[[email protected]]+')
		for lang in langs:
			# Make sure that we only process lines which contain locales
			if re_linguas.match(lang):
				node = self.path.find_resource(os.path.join(podir, re_linguas.match(lang).group() + '.po'))
				task = self.create_task('po')
				task.set_inputs(node)
				task.set_outputs(node.change_ext('.mo'))
				if self.bld.is_install: task.install = install_translation
	else:
		Utils.pprint('RED', "Error no LINGUAS file found in po directory")
开发者ID:zsx,项目名称:waf,代码行数:38,代码来源:intltool.py


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