+ 1#============================================================================
+ 2#Name : ant.py
+ 3#Part of : Helium
+ 4
+ 5#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ 6#All rights reserved.
+ 7#This component and the accompanying materials are made available
+ 8#under the terms of the License "Eclipse Public License v1.0"
+ 9#which accompanies this distribution, and is available
+10#at the URL "http://www.eclipse.org/legal/epl-v10.html".
+11#
+12#Initial Contributors:
+13#Nokia Corporation - initial contribution.
+14#
+15#Contributors:
+16#
+17#Description:
+18#===============================================================================
+19
+20""" This module defines helper functions to be used in python Ant tasks. """
+21
+22
+23importlogging
+24importre
+25importos.path
+26
+27
+
29""" This function return None if a property has not been replaced by Ant. """
+30iflen(property_name)>0andproperty_name.startswith('${'):
+31returnNone
+32returnproperty_name
+
56""" Determines the next build number if possible. """
+57match=re.match(r'(?P<bn_txt>\w[a-zA-Z0-9_.]*\.)?(?P<bn_num>\d+)',build_number)
+58ifmatch!=None:
+59bn_txt=match.group('bn_txt')
+60bn_num=match.group('bn_num')
+61try:
+62bn_num_int=int(bn_num)
+63previous_bn_num_int=bn_num_int+1
+64previous_bn_num=str(previous_bn_num_int).rjust(len(bn_num),'0')
+65previous_bn=previous_bn_num
+66ifbn_txt!=None:
+67previous_bn='%s%s'%(bn_txt,previous_bn_num)
+68returnprevious_bn
+69exceptValueError:
+70logging.warning('Parsing of Ant build number failed.')
+71return''
+
74""" Extract all files selected by the filesets in a script's elements. """
+75foreidinrange(elements.get("fileset").size()):
+76dirscanner=elements.get("fileset").get(int(eid)).getDirectoryScanner(project)
+77dirscanner.scan()
+78forjfilenameindirscanner.getIncludedFiles():
+79filename=str(jfilename)
+80task.log("Parsing %s"%filename)
+81filename=os.path.join(str(dirscanner.getBasedir()),filename)
+
85""" Implement a logger hanlder that prints error message using an Ant object.
+86 See Python documentation on how to use it.
+87 e.g:
+88 logging.getLogger("").addHandler(AntHandler(anttask))
+89 This line will redirect messages to Ant logging system.
+90 """
+