diff -r 7685cec9fd3c -r f2ddfa555b0f doc/api/python/vbaconf-pysrc.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/api/python/vbaconf-pysrc.html Fri Sep 11 11:54:49 2009 +0100
@@ -0,0 +1,1026 @@
+
+
+
+
+ vbaconf
+
+
+
+
+
+
+
+
+
+
+
+ Package vbaconf
+
+ |
+
+
+ |
+
+
+
+
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 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
+ 32 """ Returns path without any sequence of '/' and replacing '\' by '/' """
+
33 return re.sub(r'/+', '/', re.sub(r'\\', '/', path))
+
34
+ 36 """ deliveryinput: path to delivery conf file (old format).
+
37 prepinput: path to the prep conf file.
+
38 Return XML Document object.
+
39 """
+
40 impl = getDOMImplementation()
+
41 doc = getDOMImplementation().createDocument(None, "virtualBuildArea", None)
+
42 vba = doc.getElementsByTagName("virtualBuildArea")[0]
+
43
+
44
+
45 delivery = amara.parse(open(deliveryinput, 'r'))
+
46
+
47 prep = amara.parse(open(prepinput, 'r'))
+
48
+
49 for source in prep.xml_xpath('/prepSpec/source'):
+
50 basedir = cleanup_path(source.basedir)
+
51 for copy in source.xml_xpath('./copy'):
+
52 src = cleanup_path(copy.name)
+
53 for p in delivery.xml_xpath('/deliveryConfiguration/*'):
+
54 ccmp = ccm.FourPartName(p.project)
+
55 p_dir = cleanup_path(p.dir)
+
56
+
57
+
58
+
59 if (re.match(r"%s/%s" % (ccmp.name, ccmp.name), src, re.I) is not None) and not hasattr(copy, 'dest'):
+
60 print "All object from root."
+
61 add = doc.createElementNS("", "add")
+
62 add.setAttributeNS("", "project", str(ccmp))
+
63 vba.appendChild(add)
+
64 objs = doc.createElementNS("", "objects")
+
65 objs.setAttributeNS("", "from", ccmp.name)
+
66 add.appendChild(objs)
+
67
+
68 elif (re.match(r"%s/%s" % (ccmp.name, ccmp.name), src, re.I) is not None) and hasattr(copy, 'dest'):
+
69 if os.path.basename(copy.dest).lower() == ccmp.name.lower():
+
70 add = doc.createElementNS("", "add")
+
71 add.setAttributeNS("", "project", str(ccmp))
+
72 add.setAttributeNS("", "to", cleanup_path('/' + os.path.dirname(copy.dest)))
+
73 vba.appendChild(add)
+
74 else:
+
75 add = doc.createElementNS("", "add")
+
76 add.setAttributeNS("", "project", str(ccmp))
+
77 add.setAttributeNS("", "to", cleanup_path('/' + copy.dest))
+
78 vba.appendChild(add)
+
79
+
80 elif cleanup_path(basedir + "/" + src) == p_dir:
+
81 print "Adding to subdirectory"
+
82 print ccmp.name, basedir + "/" + src, p_dir
+
83 add = doc.createElementNS("", "add")
+
84 add.setAttributeNS("", "project", str(ccmp))
+
85 if hasattr(copy, 'dest'):
+
86 add.setAttributeNS("", "to", cleanup_path('/' + copy.dest + '/' + ccmp.name))
+
87 else:
+
88 add.setAttributeNS("", "to", cleanup_path('/'+ ccmp.name))
+
89 vba.appendChild(add)
+
90 elif p_dir.startswith(cleanup_path(basedir + "/" + src + '/')):
+
91 print "Adding to subdirectory"
+
92 delta = p_dir[len(cleanup_path(basedir)):]
+
93 add = doc.createElementNS("", "add")
+
94 add.setAttributeNS("", "project", str(ccmp))
+
95 if hasattr(copy, 'dest'):
+
96 add.setAttributeNS("", "to", cleanup_path('/' + os.path.dirname(copy.dest) + '/' + delta + '/' + ccmp.name))
+
97 else:
+
98 add.setAttributeNS("", "to", cleanup_path(delta + '/' + ccmp.name))
+
99 vba.appendChild(add)
+
100 return doc
+
101
+102
+103
+105
+
108
+
110 raise Exception("Todo: not implemented.")
+
111
+
113 raise Exception("Todo: not implemented.")
+
114
+
116 """ deliveryinput: path to delivery conf file (old format).
+
117 prepinput: path to the prep conf file.
+
118 Return XML Document object.
+
119 """
+
120 impl = getDOMImplementation()
+
121 doc = getDOMImplementation().createDocument(None, "virtualBuildArea", None)
+
122 vba = doc.getElementsByTagName("virtualBuildArea")[0]
+
123
+
124
+
125 for copy in self._get_prep_configs():
+
126 basedir = cleanup_path(copy.basedir)
+
127 src = cleanup_path(copy.name)
+
128 for p in self._get_projects_configs():
+
129 ccmp = ccm.FourPartName(p.project)
+
130 p_dir = cleanup_path(p.dir)
+
131
+
132
+
133
+
134 if (re.match(r"%s/%s" % (ccmp.name, ccmp.name), src, re.I) is not None) and not hasattr(copy, 'dest'):
+
135 print "All object from root."
+
136 add = doc.createElementNS("", "add")
+
137 add.setAttributeNS("", "project", str(ccmp))
+
138 vba.appendChild(add)
+
139 objs = doc.createElementNS("", "objects")
+
140 objs.setAttributeNS("", "from", ccmp.name)
+
141 add.appendChild(objs)
+
142
+
143 elif (re.match(r"%s/%s" % (ccmp.name, ccmp.name), src, re.I) is not None) and hasattr(copy, 'dest'):
+
144 if os.path.basename(copy.dest).lower() == ccmp.name.lower():
+
145 add = doc.createElementNS("", "add")
+
146 add.setAttributeNS("", "project", str(ccmp))
+
147 add.setAttributeNS("", "to", cleanup_path('/' + os.path.dirname(copy.dest)))
+
148 vba.appendChild(add)
+
149 else:
+
150 add = doc.createElementNS("", "add")
+
151 add.setAttributeNS("", "project", str(ccmp))
+
152 add.setAttributeNS("", "to", cleanup_path('/' + copy.dest))
+
153 vba.appendChild(add)
+
154
+
155 elif cleanup_path(basedir + "/" + src) == p_dir:
+
156 print "Adding to subdirectory"
+
157 print ccmp.name, basedir + "/" + src, p_dir
+
158 add = doc.createElementNS("", "add")
+
159 add.setAttributeNS("", "project", str(ccmp))
+
160 if hasattr(copy, 'dest'):
+
161 add.setAttributeNS("", "to", cleanup_path('/' + copy.dest + '/' + ccmp.name))
+
162 else:
+
163 add.setAttributeNS("", "to", cleanup_path('/'+ ccmp.name))
+
164 vba.appendChild(add)
+
165 elif p_dir.startswith(cleanup_path(basedir + "/" + src + '/')):
+
166 print "Adding to subdirectory"
+
167 delta = p_dir[len(cleanup_path(basedir)):]
+
168 add = doc.createElementNS("", "add")
+
169 add.setAttributeNS("", "project", str(ccmp))
+
170 if hasattr(copy, 'dest'):
+
171 add.setAttributeNS("", "to", cleanup_path('/' + os.path.dirname(copy.dest) + '/' + delta + '/' + ccmp.name))
+
172 else:
+
173 add.setAttributeNS("", "to", cleanup_path(delta + '/' + ccmp.name))
+
174 vba.appendChild(add)
+
175 return doc
+
176
+177
+179 - def __init__(self, deliveryinput, prepinput):
+
183
+
185
+
186 delivery = amara.parse(open(self._deliveryinput, 'r'))
+
187 return delivery.xml_xpath('/deliveryConfiguration/*')
+
188
+
190
+
191 prep = amara.parse(open(self._prepinput, 'r'))
+
192 class __ConfigWrapper:
+
193 """ wrapper object to access directly conf property. """
+
194 def __init__(self, source, config):
+
195 self.basedir = source.basedir
+
196 self.name = config.name
+
197 if hasattr(copy, 'dest'):
+
198 self.dest = copy.dest
+
199
+200 result = []
+201 for source in prep.xml_xpath('/prepSpec/source'):
+202 for copy in source.xml_xpath('./copy'):
+203 result.append(__ConfigWrapper(source, copy))
+204 return result
+205
+206
+208 - def __init__(self, deliveryinput, prepinput):
+
212
+
214 class __ConfigWrapper:
+
215 """ wrapper object to access directly conf property. """
+
216 def __init__(self, config):
+
217 self.project = config.name
+
218 self.dir = config['dir']
+
219
+220 return map(lambda c: __ConfigWrapper(c), self.__configs)
+221
+
+
+
+
+
+
+
+
+
+