Package wafadmin :: Package Tools :: Module kde4
[hide private]
[frames] | no frames]

Source Code for Module wafadmin.Tools.kde4

 1  #!/usr/bin/env python 
 2  # encoding: utf-8 
 3  # Thomas Nagy, 2006 (ita) 
 4   
 5  import os, sys, re, TaskGen, Task, Utils 
 6   
7 -class msgfmt_taskgen(TaskGen.task_gen):
8 - def __init__(self, appname='set_your_app_name'):
9 TaskGen.task_gen.__init__(self) 10 self.langs = '' # for example "foo/fr foo/br" 11 self.chmod = 0644 12 self.default_install_path = '${KDE4_LOCALE_INSTALL_DIR}' 13 self.appname = appname
14
15 - def apply(self):
16 17 for lang in self.to_list(self.langs): 18 node = self.path.find_resource(lang+'.po') 19 task = self.create_task('msgfmt') 20 task.set_inputs(node) 21 task.set_outputs(node.change_ext('.mo')) 22 23 if not Options.is_install: continue 24 langname = lang.split('/') 25 langname = langname[-1] 26 tsk.install_path = self.install_path + os.sep + langname + os.sep + 'LC_MESSAGES' 27 task.filename = self.appname+'.mo' 28 task.chmod = self.chmod
29
30 -def detect(conf):
31 kdeconfig = conf.find_program('kde4-config') 32 if not kdeconfig: 33 conf.fatal('we need kde4-config') 34 prefix = Utils.cmd_output('%s --prefix' % kdeconfig).strip() 35 file = '%s/share/apps/cmake/modules/KDELibsDependencies.cmake' % prefix 36 try: os.stat(file) 37 except OSError: 38 file = '%s/share/apps/cmake/modules/KDELibsDependencies.cmake' % prefix 39 try: os.stat(file) 40 except: conf.fatal('could not open %s' % file) 41 42 try: 43 f = open(file, 'r') 44 txt = f.read() 45 f.close() 46 except (OSError, IOError): 47 conf.fatal('could not read %s' % file) 48 49 txt = txt.replace('\\\n', '\n') 50 fu = re.compile('#(.*)\n') 51 txt = fu.sub('', txt) 52 53 setregexp = re.compile('([sS][eE][tT]\s*\()\s*([^\s]+)\s+\"([^"]+)\"\)') 54 found = setregexp.findall(txt) 55 56 for (_, key, val) in found: 57 #print key, val 58 conf.env[key] = val 59 60 # well well, i could just write an interpreter for cmake files 61 conf.env['LIB_KDECORE']='kdecore' 62 conf.env['LIB_KDEUI'] ='kdeui' 63 conf.env['LIB_KIO'] ='kio' 64 conf.env['LIB_KHTML'] ='khtml' 65 conf.env['LIB_KPARTS'] ='kparts' 66 67 conf.env['LIBPATH_KDECORE'] = conf.env['KDE4_LIB_INSTALL_DIR'] 68 conf.env['CPPPATH_KDECORE'] = conf.env['KDE4_INCLUDE_INSTALL_DIR'] 69 conf.env.append_value('CPPPATH_KDECORE', conf.env['KDE4_INCLUDE_INSTALL_DIR']+"/KDE") 70 71 conf.env['MSGFMT'] = conf.find_program('msgfmt')
72 73 Task.simple_task_type('msgfmt', '${MSGFMT} ${SRC} -o ${TGT}', color='BLUE') 74