diff -r 7685cec9fd3c -r f2ddfa555b0f doc/api/python/version-pysrc.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/api/python/version-pysrc.html Fri Sep 11 11:54:49 2009 +0100 @@ -0,0 +1,253 @@ + + + + + version + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Module version + + + + + + +
[hide private]
[frames] | no frames]
+
+

Source Code for Module version

+
+ 1  #============================================================================  
+ 2  #Name        : version.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  """ S60 Version Management module. 
+21   
+22  :: 
+23   
+24      config = {'model.name': 'NXX', 
+25                'variant.id': '01', 
+26                'variant.revision' : '0', 
+27                'model.template': '${model.name} (${variant.id}.${variant.revision})'} 
+28      v = Version('model',config) 
+29      print v.version_string() 
+30   
+31  """ 
+32   
+33  from datetime import date 
+34  import codecs 
+35  import os 
+36  import re 
+37   
+
38 -class Version: +
39 """ Version template. +40 """ +
41 - def __init__(self, vtype, config): +
42 """ Initialise the Version object. +43 """ +44 self.vtype = vtype +45 self.config = config +46 today = date.today().strftime( "%d-%m-%y" ) +47 self.config['today'] = today +
48 +
49 - def version_string( self ): +
50 """ Returns the formatted version string. +51 """ +52 # Insert the attributes of this object into the format string +53 # Make all Ant-like substitution match the Python format for string substitution +54 return self.__unescape(self.config["%s.template" % self.vtype]) +
55 +
56 - def write(self): +
57 """ Write the version string to the vtype.txt.path file. +58 """ +59 self.__write(self.__unescape(self.config["%s.txt.path" % self.vtype]), self.version_string()) +
60 +
61 - def __write( self, path, content ): +
62 print 'Writing version file: ' + path +63 #print 'Content: ' + content +64 if os.path.exists( path ): +65 os.remove( path ) +66 newfile = open( path, 'w+' ) +67 newfile.write( codecs.BOM_UTF16_LE ) +68 newfile.close() +69 vout = codecs.open( path, 'a', 'utf-16-le' ) +70 vout.write( unicode( content ) ) +71 vout.close() +
72 +73 +
74 - def __unescape(self, text): +
75 previous = u'' +76 while previous != text: +77 previous = text +78 text = re.sub(r'\${(?P<name>[._a-zA-Z0-9]+)}', r'%(\g<name>)s', text) +79 text = text % self.config +80 return text +
81 +82 +
83 - def __str__(self): +
84 """ The string representation of the version object is the full version string. +85 """ +86 return self.version_string() +
87 +
+
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + +