View | Details | Raw Unified | Return to bug 32814
Collapse All | Expand All

(-)a/branches/ucs-3.2/ucs-3.2-0/management/univention-management-console/dev/dh-umc-module-build (-19 / +27 lines)
 Lines 2-8    Link Here 
2
# -*- coding: utf-8 -*-
2
# -*- coding: utf-8 -*-
3
#
3
#
4
# Univention Configuration Registry
4
# Univention Configuration Registry
5
#  build UMC module
5
"""Helps installing UMC modules. It parses a RFC 822 file called
6
$(package).umc-modules and installs the specified components of a module
7
into the correct directories."""
6
#
8
#
7
# Copyright 2011-2013 Univention GmbH
9
# Copyright 2011-2013 Univention GmbH
8
#
10
#
 Lines 36-61   import sys Link Here 
36
from optparse import OptionParser
38
from optparse import OptionParser
37
39
38
import univention.debhelper as dh_ucs
40
import univention.debhelper as dh_ucs
41
import univention.dh_umc as dh_umc
39
42
40
try:
41
	sys.path.insert( 0, './dev' )
42
	import dh_umc
43
except BaseException, e:
44
	print 'warning:', str( e )
45
	import univention.dh_umc as dh_umc
46
47
"""Helps installing UMC modules. It parses a RFC 822 file called
48
$(package).umc-modules and installs the specified components of a module
49
into the correct directories."""
50
43
51
def do_package( package, core ):
44
def do_package(package, core):
52
	try:
45
	try:
53
		modules = dh_umc.read_modules( package, core )
46
		modules = dh_umc.read_modules( package, core )
54
	except AttributeError, e:
47
	except AttributeError, e:
55
		print >>sys.stderr, str( e )
48
		print >>sys.stderr, str( e )
56
		sys.exit( 1 )
49
		sys.exit( 1 )
57
50
58
	if not options.core:
51
	if not core:
59
		# build python PO files
52
		# build python PO files
60
		for module in modules:
53
		for module in modules:
61
			for po_file in module.python_po_files:
54
			for po_file in module.python_po_files:
 Lines 76-86   def do_package( package, core ): Link Here 
76
			dh_umc.create_mo_file( po_file )
69
			dh_umc.create_mo_file( po_file )
77
70
78
71
79
if __name__ == '__main__':
72
def main():
80
	# parse all options
73
	# parse all options
81
	parser = OptionParser( usage = 'usage: %prog [--core]' )
74
	parser = OptionParser(
82
	parser.add_option( '-c', '--core', action = 'store_true', dest = 'core', help = 'If specified modules without javascript and python code are excepted' )
75
		usage='usage: %prog [--core]',
76
		description=sys.modules[__name__].__doc__.strip(),
77
	)
78
	parser.add_option(
79
		'-c', '--core',
80
		action='store_true', dest='core',
81
		help='If specified modules without javascript and python code are excepted')
82
83
	(options, args) = parser.parse_args()
84
85
	try:
86
		for package in dh_ucs.binary_packages():
87
			do_package(package, options.core)
88
	except dh_umc.UMC_Build_Error, ex:
89
		print >> sys.stderr, ex
90
		sys.exit(1)
91
83
92
84
	( options, args ) = parser.parse_args()
93
if __name__ == '__main__':
85
	for package in dh_ucs.binary_packages():
94
	main()
86
		do_package( package, options.core )
(-)a/branches/ucs-3.2/ucs-3.2-0/management/univention-management-console/dev/dh_umc.py (-7 / +17 lines)
 Lines 86-91   Example: Link Here 
86
 Icons: umc/icons
86
 Icons: umc/icons
87
"""
87
"""
88
88
89
90
class UMC_Build_Error(Exception):
91
	pass
92
93
89
class UMC_Module( dict ):
94
class UMC_Module( dict ):
90
	def __init__( self, *args ):
95
	def __init__( self, *args ):
91
		dict.__init__( self, *args )
96
		dict.__init__( self, *args )
 Lines 244-254   def module_xml2po( module, po_file, language ): Link Here 
244
249
245
	po.save( message_po )
250
	po.save( message_po )
246
	if os.path.isfile( po_file ):
251
	if os.path.isfile( po_file ):
247
		dh_ucs.doIt( 'msgmerge', '--update', '--sort-output', po_file, message_po )
252
		if dh_ucs.doIt('msgmerge', '--update', '--sort-output', po_file, message_po):
253
			raise UMC_Build_Error("Error updating translation '%s'" % (po_file,))
248
		if os.path.isfile( message_po ):
254
		if os.path.isfile( message_po ):
249
			os.unlink( message_po )
255
			os.unlink( message_po )
250
	else:
256
	else:
251
		dh_ucs.doIt( 'mv', message_po, po_file )
257
		if dh_ucs.doIt('mv', message_po, po_file):
258
			raise UMC_Build_Error("Error moving translation '%s'" % (po_file,))
252
259
253
def create_po_file( po_file, package, files, language = 'python' ):
260
def create_po_file( po_file, package, files, language = 'python' ):
254
	"""Create a PO file for a defined set of files"""
261
	"""Create a PO file for a defined set of files"""
 Lines 258-277   def create_po_file( po_file, package, files, language = 'python' ): Link Here 
258
		os.unlink( message_po )
265
		os.unlink( message_po )
259
	if isinstance( files, basestring ):
266
	if isinstance( files, basestring ):
260
		files = [ files ]
267
		files = [ files ]
261
	dh_ucs.doIt( 'xgettext', '--force-po', '--from-code=UTF-8', '--sort-output', '--package-name=%s' % package, '--msgid-bugs-address=packages@univention.de', '--copyright-holder=Univention GmbH', '--language', language, '-o', message_po, *files )
268
	if dh_ucs.doIt('xgettext', '--force-po', '--from-code=UTF-8', '--sort-output', '--package-name=%s' % package, '--msgid-bugs-address=packages@univention.de', '--copyright-holder=Univention GmbH', '--language', language, '-o', message_po, *files):
269
		raise UMC_Build_Error("Error extracting translations '%s'" % (message_po,))
262
	po = polib.pofile( message_po )
270
	po = polib.pofile( message_po )
263
	po.header = PO_HEADER
271
	po.header = PO_HEADER
264
	po.metadata[ 'Content-Type' ] = 'text/plain; charset=UTF-8'
272
	po.metadata[ 'Content-Type' ] = 'text/plain; charset=UTF-8'
265
	po.save()
273
	po.save()
266
	if os.path.isfile( po_file ):
274
	if os.path.isfile( po_file ):
267
		dh_ucs.doIt( 'msgmerge', '--update', '--sort-output', po_file, message_po )
275
		if dh_ucs.doIt('msgmerge', '--update', '--sort-output', po_file, message_po):
276
			raise UMC_Build_Error("Error updating translation '%s'" % (po_file,))
268
		if os.path.isfile( message_po ):
277
		if os.path.isfile( message_po ):
269
			os.unlink( message_po )
278
			os.unlink( message_po )
270
	else:
279
	else:
271
		dh_ucs.doIt( 'mv', message_po, po_file )
280
		if dh_ucs.doIt('mv', message_po, po_file):
281
			raise UMC_Build_Error("Error moving translation '%s'" % (po_file,))
272
282
273
def create_mo_file( po_file ):
283
def create_mo_file( po_file ):
274
	dh_ucs.doIt( 'msgfmt', '--check', '--output-file', po_file.replace( '.po', '.mo' ), po_file )
284
	if dh_ucs.doIt('msgfmt', '--check', '--output-file', po_file.replace('.po', '.mo'), po_file):
285
		raise UMC_Build_Error("Error compiling translations '%s'" % (po_file,))
275
286
276
def create_json_file( po_file ):
287
def create_json_file( po_file ):
277
	json_file = po_file.replace( '.po', '.json' )
288
	json_file = po_file.replace( '.po', '.json' )
 Lines 283-286   def create_json_file( po_file ): Link Here 
283
294
284
	json_fd.write( json.dumps( data ) )
295
	json_fd.write( json.dumps( data ) )
285
	json_fd.close()
296
	json_fd.close()
286

Return to bug 32814