Beispiel #1
0
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("[-a-zA-Z_@.]+")
        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")
Beispiel #2
0
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)
Beispiel #3
0
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)
Beispiel #4
0
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'))
Beispiel #5
0
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('[-a-zA-Z_@.]+')
		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")
Beispiel #6
0
def apply_intltool_po(self):
    try:
        self.meths.remove('process_source')
    except ValueError:
        pass
    if not self.env.LOCALEDIR:
        self.env.LOCALEDIR = self.env.PREFIX + '/share/locale'
    appname = getattr(self, 'appname', 'set_your_app_name')
    podir = getattr(self, 'podir', '')
    inst = getattr(self, 'install_path', '${LOCALEDIR}')
    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('[-a-zA-Z_@.]+')
        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', node, node.change_ext('.mo'))
                if inst:
                    filename = task.outputs[0].name
                    (langname, ext) = os.path.splitext(filename)
                    inst_file = inst + os.sep + langname + os.sep + 'LC_MESSAGES' + os.sep + appname + '.mo'
                    self.bld.install_as(inst_file,
                                        task.outputs[0],
                                        chmod=getattr(self, 'chmod',
                                                      Utils.O644),
                                        env=task.env)
    else:
        Utils.pprint('RED', "Error no LINGUAS file found in po directory")