File: kde4.py

package info (click to toggle)
lysdr 1.0~git20141206+dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 832 kB
  • ctags: 1,685
  • sloc: python: 11,659; ansic: 1,335; makefile: 24
file content (49 lines) | stat: -rw-r--r-- 1,916 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#! /usr/bin/env python
# encoding: utf-8
# WARNING! All changes made to this file will be lost!

import os,sys,re
from waflib import Options,TaskGen,Task,Utils
from waflib.TaskGen import feature,after_method
def apply_msgfmt(self):
	for lang in self.to_list(self.langs):
		node=self.path.find_resource(lang+'.po')
		task=self.create_task('msgfmt',node,node.change_ext('.mo'))
		langname=lang.split('/')
		langname=langname[-1]
		inst=getattr(self,'install_path','${KDE4_LOCALE_INSTALL_DIR}')
		self.bld.install_as(inst+os.sep+langname+os.sep+'LC_MESSAGES'+os.sep+getattr(self,'appname','set_your_appname')+'.mo',task.outputs[0],chmod=getattr(self,'chmod',Utils.O644))
class msgfmt(Task.Task):
	color='BLUE'
	run_str='${MSGFMT} ${SRC} -o ${TGT}'
def configure(self):
	kdeconfig=self.find_program('kde4-config')
	prefix=self.cmd_and_log('%s --prefix'%kdeconfig).strip()
	fname='%s/share/apps/cmake/modules/KDELibsDependencies.cmake'%prefix
	try:os.stat(fname)
	except OSError:
		fname='%s/share/kde4/apps/cmake/modules/KDELibsDependencies.cmake'%prefix
		try:os.stat(fname)
		except OSError:self.fatal('could not open %s'%fname)
	try:
		txt=Utils.readf(fname)
	except(OSError,IOError):
		self.fatal('could not read %s'%fname)
	txt=txt.replace('\\\n','\n')
	fu=re.compile('#(.*)\n')
	txt=fu.sub('',txt)
	setregexp=re.compile('([sS][eE][tT]\s*\()\s*([^\s]+)\s+\"([^"]+)\"\)')
	found=setregexp.findall(txt)
	for(_,key,val)in found:
		self.env[key]=val
	self.env['LIB_KDECORE']=['kdecore']
	self.env['LIB_KDEUI']=['kdeui']
	self.env['LIB_KIO']=['kio']
	self.env['LIB_KHTML']=['khtml']
	self.env['LIB_KPARTS']=['kparts']
	self.env['LIBPATH_KDECORE']=[self.env['KDE4_LIB_INSTALL_DIR']]
	self.env['INCLUDES_KDECORE']=[self.env['KDE4_INCLUDE_INSTALL_DIR']]
	self.env.append_value('INCLUDES_KDECORE',[self.env['KDE4_INCLUDE_INSTALL_DIR']+os.sep+'KDE'])
	self.find_program('msgfmt',var='MSGFMT')

feature('msgfmt')(apply_msgfmt)