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

Source Code for Module vbaconf.new_delivery

+
+  1  #============================================================================  
+  2  #Name        : new_delivery.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  """ Helper to convert delivery.xml and prep.xml to VirtualBuildArea 
+ 21      configuration file. 
+ 22  """ 
+ 23  from  xml.dom.minidom import getDOMImplementation 
+ 24  import amara 
+ 25  import ccm 
+ 26  import re 
+ 27  import os.path 
+ 28  import sys 
+ 29  import configuration 
+ 30   
+
31 -def cleanup_path(path): +
32 """ Returns path without any sequence of '/' and replacing '\' by '/' """ + 33 return re.sub(r'/+', '/', re.sub(r'\\', '/', path)) +
34 +
35 -class config_wrapper: +
36 """ wrapper object to access directly conf property. """ +
37 - def __init__(self, config): +
38 self.project = config.name + 39 self.dir = config['dir'] +
40 +
41 -def generate_config(deliveryinput, prepinput): +
42 """ deliveryinput: path to delivery conf file (old format). + 43 prepinput: path to the prep conf file. + 44 Return XML Document object. + 45 """ + 46 impl = getDOMImplementation() + 47 doc = getDOMImplementation().createDocument(None, "virtualBuildArea", None) + 48 vba = doc.getElementsByTagName("virtualBuildArea")[0] + 49 + 50 # Loading delivery content + 51 configBuilder = configuration.NestedConfigurationBuilder(open(deliveryinput, 'r')) + 52 deliveryConfigs = configBuilder.getConfiguration().getConfigurations() + 53 + 54 # loading prep file + 55 prep = amara.parse(open(prepinput, 'r')) + 56 # analysing preparation creation + 57 for source in prep.xml_xpath('/prepSpec/source'): + 58 basedir = cleanup_path(source.basedir) + 59 for copy in source.xml_xpath('./copy'): + 60 src = cleanup_path(copy.name) + 61 for config in deliveryConfigs: + 62 p = config_wrapper(config) + 63 ccmp = ccm.FourPartName(p.project) + 64 p_dir = cleanup_path(p.dir) + 65 #print "ccmp: %s" % ccmp + 66 #print "pdir: %s" % p_dir + 67 # looking for project_name/project_name pattern, and if dest doesn't exist + 68 if (re.match(r"%s/%s" % (ccmp.name, ccmp.name), src, re.I) is not None) and not hasattr(copy, 'dest'): + 69 print "All object from root." + 70 add = doc.createElementNS("", "add") + 71 add.setAttributeNS("", "project", str(ccmp)) + 72 vba.appendChild(add) + 73 objs = doc.createElementNS("", "objects") + 74 objs.setAttributeNS("", "from", ccmp.name) + 75 add.appendChild(objs) + 76 # looking for project_name/project_name pattern, and if dest exists + 77 elif (re.match(r"%s/%s" % (ccmp.name, ccmp.name), src, re.I) is not None) and hasattr(copy, 'dest'): + 78 if os.path.basename(copy.dest).lower() == ccmp.name.lower(): + 79 add = doc.createElementNS("", "add") + 80 add.setAttributeNS("", "project", str(ccmp)) + 81 add.setAttributeNS("", "to", cleanup_path('/' + os.path.dirname(copy.dest))) + 82 vba.appendChild(add) + 83 else: + 84 add = doc.createElementNS("", "add") + 85 add.setAttributeNS("", "project", str(ccmp)) + 86 add.setAttributeNS("", "to", cleanup_path('/' + copy.dest)) + 87 vba.appendChild(add) + 88 # for directory copy + 89 elif cleanup_path(basedir + "/" + src) == p_dir: + 90 print "Adding to subdirectory" + 91 print ccmp.name, basedir + "/" + src, p_dir + 92 add = doc.createElementNS("", "add") + 93 add.setAttributeNS("", "project", str(ccmp)) + 94 if hasattr(copy, 'dest'): + 95 add.setAttributeNS("", "to", cleanup_path('/' + copy.dest + '/' + ccmp.name)) + 96 else: + 97 add.setAttributeNS("", "to", cleanup_path('/'+ ccmp.name)) + 98 vba.appendChild(add) + 99 elif p_dir.startswith(cleanup_path(basedir + "/" + src + '/')): +100 print "Adding to subdirectory" +101 delta = p_dir[len(cleanup_path(basedir)):] +102 add = doc.createElementNS("", "add") +103 add.setAttributeNS("", "project", str(ccmp)) +104 if hasattr(copy, 'dest'): +105 add.setAttributeNS("", "to", cleanup_path('/' + os.path.dirname(copy.dest) + '/' + delta + '/' + ccmp.name)) +106 else: +107 add.setAttributeNS("", "to", cleanup_path(delta + '/' + ccmp.name)) +108 vba.appendChild(add) +109 return doc +
110 +
+
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + +