|
1 # |
|
2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 # All rights reserved. |
|
4 # This component and the accompanying materials are made available |
|
5 # under the terms of "Eclipse Public License v1.0" |
|
6 # which accompanies this distribution, and is available |
|
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 # |
|
9 # Initial Contributors: |
|
10 # Nokia Corporation - initial contribution. |
|
11 # |
|
12 # Contributors: |
|
13 # |
|
14 # Description: |
|
15 # |
|
16 ''' |
|
17 Convert project ConE plugin |
|
18 ''' |
|
19 |
|
20 import re |
|
21 import os |
|
22 import sys |
|
23 import logging |
|
24 import xml.parsers.expat |
|
25 import shutil |
|
26 import fnmatch |
|
27 |
|
28 try: |
|
29 from cElementTree import ElementTree |
|
30 except ImportError: |
|
31 try: |
|
32 from elementtree import ElementTree |
|
33 except ImportError: |
|
34 try: |
|
35 from xml.etree import cElementTree as ElementTree |
|
36 except ImportError: |
|
37 from xml.etree import ElementTree |
|
38 |
|
39 import __init__ |
|
40 |
|
41 from cone.storage import filestorage |
|
42 from cone.public import exceptions,plugin,utils,api |
|
43 |
|
44 class ConvertProjectImpl(plugin.ImplBase): |
|
45 """ |
|
46 Class to implements ConE plugin that convert old configuration to |
|
47 configuration project. Some extra functions supported in the top |
|
48 of normal file copying functions. For example creation of layer and |
|
49 configuration root files automatically. |
|
50 """ |
|
51 |
|
52 IMPL_TYPE_ID = "convertprojectml" |
|
53 |
|
54 |
|
55 def __init__(self,ref,configuration): |
|
56 """ |
|
57 Overloading the default constructor |
|
58 """ |
|
59 plugin.ImplBase.__init__(self,ref,configuration) |
|
60 self.desc = "" |
|
61 self.logger = logging.getLogger('cone.convertprojectml(%s)' % self.ref) |
|
62 self.errors = False |
|
63 |
|
64 #Internal plugin data |
|
65 self.project_data = {} |
|
66 self.layers = [] |
|
67 |
|
68 def generate(self, context=None): |
|
69 """ |
|
70 Generate the given implementation. |
|
71 """ |
|
72 |
|
73 #Generating content |
|
74 fullOutputPath = self.output |
|
75 if self.project_data.has_key("path"): |
|
76 targetPath = utils.resourceref.norm(self.project_data["path"]) |
|
77 if targetPath and targetPath != "": |
|
78 fullOutputPath = os.path.join(fullOutputPath, targetPath) |
|
79 |
|
80 fs = filestorage.FileStorage(fullOutputPath, "w") |
|
81 newProject = api.Project(fs) |
|
82 for layer in self.layers: |
|
83 layer.generate(newProject, self.configuration.get_storage().get_path()) |
|
84 newProject.close() |
|
85 |
|
86 #Opening project again to validate the content and remove illegal includes. |
|
87 if self.project_data.has_key("validate") and self.project_data["validate"] != "false": |
|
88 fs = filestorage.FileStorage(fullOutputPath, "w") |
|
89 validateProject = api.Project(fs) |
|
90 for conf in validateProject.list_configurations(): |
|
91 validateProject.get_configuration(conf).list_all_configurations() |
|
92 validateProject.close() |
|
93 |
|
94 return |
|
95 |
|
96 def generate_layers(self,layers): |
|
97 """ |
|
98 Generate the given Configuration layers. |
|
99 """ |
|
100 self.logger.info('Generating layers %s' % layers) |
|
101 self.generate() |
|
102 |
|
103 return |
|
104 |
|
105 def has_ref(self,ref): |
|
106 """ |
|
107 @returns True if the implementation uses the given ref as input value. |
|
108 Otherwise return False. |
|
109 """ |
|
110 |
|
111 return None |
|
112 |
|
113 #================================================================= |
|
114 class ConvertProjectLayer(object): |
|
115 """ |
|
116 Object presenting layer in convertprojectml file. |
|
117 """ |
|
118 |
|
119 def __init__(self, path): |
|
120 if path != None: |
|
121 self.path = path |
|
122 else: |
|
123 self.path = "" |
|
124 self.folders = [] |
|
125 self.files = [] |
|
126 |
|
127 def __str__(self): |
|
128 retStr = "" |
|
129 retStr += "\nPath: %s\n" % self.path |
|
130 retStr +="Folders:\n" |
|
131 for folder in self.folders: |
|
132 retStr += folder.__str__() |
|
133 retStr +="Files:\n" |
|
134 for file in self.files: |
|
135 retStr += file.__str__() |
|
136 return retStr |
|
137 |
|
138 def generate(self, project, old_structure_root): |
|
139 """ |
|
140 Function to handle generation to one folder. |
|
141 """ |
|
142 |
|
143 #Create layer folder. |
|
144 project.get_storage().create_folder(utils.resourceref.norm(self.path)) |
|
145 #print "Created Layer:", utils.resourceref.norm(self.path) |
|
146 |
|
147 for folder in self.folders: |
|
148 folder.generate(project, old_structure_root) |
|
149 |
|
150 for f in self.files: |
|
151 f.generate(project, old_structure_root) |
|
152 |
|
153 return |
|
154 |
|
155 def addFolder(self, folder): |
|
156 self.folders.append(folder) |
|
157 |
|
158 def addFile(self, file): |
|
159 self.files.append(file) |
|
160 |
|
161 def getProjectPath(self): |
|
162 return self.path |
|
163 |
|
164 |
|
165 class ConvertProjectFolder(object): |
|
166 """ |
|
167 Object presenting folder in convertprojectml file. |
|
168 """ |
|
169 |
|
170 def __init__(self, path, parent=None): |
|
171 if path != None: |
|
172 self.path = path |
|
173 else: |
|
174 self.path = "" |
|
175 self.filters = [] |
|
176 self.parent = parent |
|
177 |
|
178 def __str__(self): |
|
179 retStr = "" |
|
180 retStr += "\tPath: %s\n" % self.path |
|
181 retStr +="\tFilters:\n" |
|
182 for filter in self.filters: |
|
183 retStr += filter.__str__() |
|
184 return retStr |
|
185 |
|
186 def generate(self, project, old_structure_root): |
|
187 |
|
188 #Adding new folder to project. |
|
189 project.get_storage().create_folder(utils.resourceref.norm(self.getProjectPath())) |
|
190 #print "Created folder:", utils.resourceref.norm(self.getProjectPath()) |
|
191 |
|
192 for filter in self.filters: |
|
193 filter.generate(project, old_structure_root, "folder") |
|
194 return |
|
195 |
|
196 def addFilter(self, filter): |
|
197 self.filters.append(filter) |
|
198 |
|
199 def getProjectPath(self): |
|
200 return os.path.join(self.parent.getProjectPath(), self.path) |
|
201 |
|
202 class ConvertProjectFile(object): |
|
203 """ |
|
204 Object presenting file in convertprojectml file. |
|
205 """ |
|
206 |
|
207 def __init__(self, path, type, parent=None): |
|
208 if path != None: |
|
209 self.path = path |
|
210 else: |
|
211 self.path = "" |
|
212 if type != None: |
|
213 self.type = type |
|
214 else: |
|
215 self.type = "" |
|
216 |
|
217 self.filters = [] |
|
218 self.parent = parent |
|
219 self.meta = [] |
|
220 self.desc = "" |
|
221 |
|
222 def __str__(self): |
|
223 retStr = "" |
|
224 retStr += "\tPath: %s\n" % self.path |
|
225 retStr += "\tType: %s\n" % self.type |
|
226 retStr +="\tFilters:\n" |
|
227 for filter in self.filters: |
|
228 retStr += filter.__str__() |
|
229 return retStr |
|
230 |
|
231 def generate(self, project, old_structure_root): |
|
232 for filter in self.filters: |
|
233 filter.generate(project, old_structure_root, self.type) |
|
234 |
|
235 if self.type == "configuration_root": |
|
236 #Adding metadata |
|
237 config = project.get_configuration(utils.resourceref.norm(self.path)) |
|
238 if self.meta: |
|
239 if not config.meta: |
|
240 config.meta = [] |
|
241 for meta in self.meta: |
|
242 config.meta.add(meta[0], meta[1], meta[2], meta[3]) |
|
243 if self.desc: |
|
244 config.desc = self.desc |
|
245 |
|
246 config.save() |
|
247 return |
|
248 |
|
249 def addFilter(self, filter): |
|
250 self.filters.append(filter) |
|
251 |
|
252 def addMeta(self, meta): |
|
253 self.meta = meta |
|
254 |
|
255 def addDescription(self, desc): |
|
256 self.desc = desc |
|
257 |
|
258 def getProjectPath(self): |
|
259 return os.path.join(self.parent.getProjectPath(), self.path) |
|
260 |
|
261 class ConvertProjectFilter(object): |
|
262 """ |
|
263 Object presenting filter in convertprojectml file. |
|
264 """ |
|
265 |
|
266 def __init__(self, action, data, parent=None, remove_includes = "false", recursive = "false"): |
|
267 self.action = action |
|
268 self.data = data |
|
269 self.parent = parent |
|
270 if remove_includes: |
|
271 self.remove_includes = remove_includes |
|
272 else: |
|
273 self.remove_includes = "false" |
|
274 if recursive: |
|
275 self.recursive = recursive |
|
276 else: |
|
277 self.recursive = "false" |
|
278 |
|
279 def __str__(self): |
|
280 retStr = "" |
|
281 retStr += "\t\tAction: %s\n" % self.action |
|
282 retStr += "\t\tData: %s\n" % self.data |
|
283 return retStr |
|
284 |
|
285 def generate(self, project, old_structure_root, type="none"): |
|
286 """ |
|
287 @param project: New configuration project |
|
288 @type project: |
|
289 @param old_structure_root: Path to old projects root. |
|
290 @type old_structure_root: |
|
291 |
|
292 """ |
|
293 |
|
294 if type == "" or type == "folder": |
|
295 self.handleAddRemove(project, old_structure_root) |
|
296 elif type == "layer_root": |
|
297 self.handleLayerRoot(project) |
|
298 elif type == "configuration_root": |
|
299 self.handleConfigurationRoot(project) |
|
300 else: |
|
301 #raise exceptions.NotSupportedException("Type: %s not supported as file type" % repr(type)) |
|
302 pass |
|
303 return |
|
304 |
|
305 def handleAddRemove(self, project, old_structure_root): |
|
306 """ |
|
307 """ |
|
308 |
|
309 pathPart, wildCardPart = self.separatePathAndWildcard(self.data) |
|
310 filesToProcess = [] |
|
311 if wildCardPart == "": |
|
312 #No wildcards found. |
|
313 if self.recursive == "false": |
|
314 source = os.path.join(old_structure_root, pathPart) |
|
315 targetDir = self.resolveTargetDir(project, source) |
|
316 filesToProcess.append({"source": source, "targetDir": targetDir}) |
|
317 else: |
|
318 #recursive search for directory entries. |
|
319 directoryPath = os.path.join(old_structure_root, pathPart) |
|
320 if os.path.isdir(directoryPath): |
|
321 for root, dirs, files in os.walk(directoryPath): |
|
322 for f in files: |
|
323 #Handling files. |
|
324 source = os.path.join(root, f) |
|
325 targetDir = self.resolveTargetDir(project, source) |
|
326 filesToProcess.append({"source": source, "targetDir": targetDir}) |
|
327 |
|
328 for d in dirs: |
|
329 #Handling directories to get empty folders included also. |
|
330 source = os.path.join(root, d) |
|
331 targetDir = self.resolveTargetDir(project, source) |
|
332 filesToProcess.append({"source": source, "targetDir": targetDir}) |
|
333 |
|
334 else: |
|
335 #Need to handle wildcard part |
|
336 filesToProcess = self.getFilesByWildcard(os.path.join(old_structure_root, pathPart)\ |
|
337 ,wildCardPart, project) |
|
338 |
|
339 for f in filesToProcess: |
|
340 source = f["source"] |
|
341 targetDir = f["targetDir"] |
|
342 |
|
343 if source.lower().find(".svn") != -1: |
|
344 #Ignoring svn files |
|
345 continue |
|
346 |
|
347 if os.path.isfile(source): |
|
348 #targetDir = self.resolveTargetDir(project, f) |
|
349 if self.action == "add": |
|
350 if not os.path.exists(targetDir): |
|
351 os.makedirs(targetDir) |
|
352 shutil.copy2(source, targetDir) |
|
353 elif self.action == "remove": |
|
354 targetFile = os.path.join(targetDir, os.path.split(source)[1]) |
|
355 os.remove(targetFile) |
|
356 elif os.path.isdir(source): |
|
357 folderToCreate = os.path.join(targetDir, os.path.split(source)[1]) |
|
358 if not os.path.isdir(folderToCreate): |
|
359 os.makedirs(folderToCreate) |
|
360 |
|
361 def resolveTargetDir(self, project, filepath): |
|
362 """ |
|
363 """ |
|
364 if self.recursive == "false": |
|
365 return os.path.join(project.get_storage().get_path(), self.getProjectPath()) |
|
366 else: |
|
367 retPath = os.path.join(project.get_storage().get_path(), self.getProjectPath()) |
|
368 startFound = 0 |
|
369 |
|
370 for item in os.path.normpath(filepath).split("\\"): |
|
371 if self.data.find(item) != -1: |
|
372 startFound = 1 |
|
373 if startFound and self.data.find(item) == -1: |
|
374 retPath = os.path.join(retPath, item) |
|
375 return os.path.split(retPath)[0] |
|
376 |
|
377 |
|
378 def handleLayerRoot(self, project): |
|
379 """ |
|
380 """ |
|
381 |
|
382 pathPart, wildCardPart = self.separatePathAndWildcard(self.data) |
|
383 filesToProcess = [] |
|
384 |
|
385 if wildCardPart == "": |
|
386 #No wildcards found. Checking still if path has folder and file elements |
|
387 |
|
388 folderPath, filePart = os.path.split(pathPart) |
|
389 if folderPath == "": |
|
390 #filename only |
|
391 pathPart = "" |
|
392 else: |
|
393 #file and folder |
|
394 pathPart = folderPath |
|
395 |
|
396 source = os.path.join(project.get_storage().get_path(), self.getProjectPath(), pathPart, filePart) |
|
397 filesToProcess.append({"source": source, "targetDir": None}) |
|
398 |
|
399 else: |
|
400 #Need to handle wildcard part |
|
401 fullSearchPath = os.path.join(project.get_storage().get_path(), self.getProjectPath(), pathPart) |
|
402 filesToProcess = self.getFilesByWildcard(fullSearchPath, wildCardPart, project) |
|
403 |
|
404 #Creating rootfile. |
|
405 rootFilePath = os.path.join(self.getProjectPath(), self.parent.path) |
|
406 config = project.create_configuration(utils.resourceref.norm(rootFilePath)) |
|
407 |
|
408 #Adding defined includes. |
|
409 for f in filesToProcess: |
|
410 source = f["source"] |
|
411 #Getting path in configuration project and adding it as include. |
|
412 filePath = utils.resourceref.norm(os.path.join(pathPart, os.path.split(source)[1])) |
|
413 config.include_configuration(filePath) |
|
414 if self.remove_includes == "true": |
|
415 self.removeIncludes(config.get_configuration(filePath)) |
|
416 config.save() |
|
417 |
|
418 def removeIncludes(self, config): |
|
419 """ |
|
420 @param config: Configuration object that is processed |
|
421 |
|
422 @return: None |
|
423 """ |
|
424 |
|
425 #Getting all configurations from included configuration. |
|
426 configList = config.list_configurations() |
|
427 for item in configList: |
|
428 config.remove_configuration(utils.resourceref.norm(item)) |
|
429 |
|
430 config.save() |
|
431 |
|
432 |
|
433 def handleConfigurationRoot(self, project): |
|
434 """ |
|
435 """ |
|
436 #Always in the root of the project |
|
437 configname = utils.resourceref.norm(self.parent.path) |
|
438 if configname in project.list_configurations(): |
|
439 config = project.get_configuration(configname) |
|
440 else: |
|
441 config = project.create_configuration(utils.resourceref.norm(self.parent.path)) |
|
442 config.include_configuration(utils.resourceref.norm(self.data)) |
|
443 config.save() |
|
444 |
|
445 |
|
446 def getProjectPath(self): |
|
447 if isinstance(self.parent, ConvertProjectFile): |
|
448 #print "FILE", self.parent.parent.getProjectPath() |
|
449 return self.parent.parent.getProjectPath() |
|
450 else: |
|
451 #print "other" |
|
452 return self.parent.getProjectPath() |
|
453 |
|
454 |
|
455 def getFilesByWildcard(self, folder, wildcard, project): |
|
456 """ |
|
457 @param folder: folder where matching is made |
|
458 @type folder: string |
|
459 @param wildcard: wildcard pattern |
|
460 @type wildcard: string |
|
461 """ |
|
462 |
|
463 #Array of files and folders matching with the wildcard. |
|
464 retArray = [] |
|
465 if os.path.isdir(folder): |
|
466 for root, dirs, files in os.walk(folder): |
|
467 if self.recursive == "false" and os.path.normpath(root) != os.path.normpath(folder): |
|
468 #No recursive search used and therefore only topmost directory is handled. |
|
469 continue |
|
470 else: |
|
471 for f in files: |
|
472 if fnmatch.fnmatch(os.path.join(root, f), wildcard): |
|
473 source = os.path.join(root, f) |
|
474 targetDir = self.resolveTargetDir(project, source) |
|
475 retArray.append({"source": source, "targetDir": targetDir}) |
|
476 |
|
477 for d in dirs: |
|
478 if fnmatch.fnmatch(os.path.join(root, d), wildcard): |
|
479 source = os.path.join(root, d) |
|
480 targetDir = self.resolveTargetDir(project, source) |
|
481 retArray.append({"source": source, "targetDir": targetDir}) |
|
482 |
|
483 return retArray |
|
484 |
|
485 def separatePathAndWildcard(self, data): |
|
486 """ |
|
487 @param data: data from XML that may contain path and wildcard parts |
|
488 @type data: string |
|
489 |
|
490 @return: Path and wildcard parts separately. |
|
491 """ |
|
492 pathPart = "" |
|
493 wildCardPart = "" |
|
494 |
|
495 if data.find("*") == -1: |
|
496 #Only supported wildcard is currently * |
|
497 pathPart = data |
|
498 wildCardPart ="" |
|
499 else: |
|
500 #Some wildcards found. Wildcards are supported only in the last segment. |
|
501 pathPart, wildCardPart = os.path.split(data) |
|
502 |
|
503 return pathPart, wildCardPart |
|
504 |
|
505 |
|
506 #================================================================= |
|
507 |
|
508 class ConvertProjectReader(plugin.ReaderBase): |
|
509 """ |
|
510 Parses a single convertprojectml file |
|
511 """ |
|
512 |
|
513 NAMESPACE = 'http://www.s60.com/xml/convertprojectml/1' |
|
514 FILE_EXTENSIONS = ['convertprojectml'] |
|
515 |
|
516 def __init__(self): |
|
517 self.desc = None |
|
518 self.output_dir = None |
|
519 self.input_dir = None |
|
520 self.namespaces = [self.NAMESPACE] |
|
521 self.project_data = {} |
|
522 self.layers = [] |
|
523 |
|
524 @classmethod |
|
525 def read_impl(cls, resource_ref, configuration, etree): |
|
526 reader = ConvertProjectReader() |
|
527 reader.from_etree(etree, configuration.get_storage().get_path()) |
|
528 |
|
529 impl = ConvertProjectImpl(resource_ref, configuration) |
|
530 impl.project_data = reader.project_data |
|
531 impl.layers = reader.layers |
|
532 return impl |
|
533 |
|
534 def from_etree(self, etree, old_structure_root = ""): |
|
535 self.project_data = self.parse_attributes(etree, "targetProject") |
|
536 self.layers = self.parse_layers(etree) |
|
537 for fe in self.parse_foreach(etree, old_structure_root): |
|
538 self.layers.append(fe) |
|
539 |
|
540 #for l in self.layers: |
|
541 #print l |
|
542 return |
|
543 |
|
544 def parse_foreach(self, etree, old_structure_root): |
|
545 layersTmp = [] |
|
546 for fe in etree.findall("{%s}foreach" % self.namespaces[0]): |
|
547 variable = fe.get("variable") |
|
548 data = fe.get("data") |
|
549 folders = [] |
|
550 for item in os.listdir(os.path.join(old_structure_root, data)): |
|
551 if os.path.isdir(os.path.join(old_structure_root, data, item)) and item != '.svn': |
|
552 folders.append(item) |
|
553 |
|
554 for folder in folders: |
|
555 mapping_data = {variable: folder} |
|
556 for layer in fe.findall("{%s}layer" % self.namespaces[0]): |
|
557 layersTmp.append(self.parse_layer(layer, mapping_data)) |
|
558 |
|
559 return layersTmp |
|
560 |
|
561 def parse_layers(self,etree): |
|
562 layersTmp = [] |
|
563 for layer in etree.findall("{%s}layer" % self.namespaces[0]): |
|
564 layersTmp.append(self.parse_layer(layer)) |
|
565 |
|
566 return layersTmp |
|
567 |
|
568 def parse_layer(self, etree, mapping_data=None): |
|
569 path = self.handleMapping(etree.get("path"), mapping_data) |
|
570 |
|
571 layerObject = ConvertProjectLayer(path) |
|
572 for folder in etree.findall("{%s}folder" % self.namespaces[0]): |
|
573 layerObject.addFolder(self.parse_folder(folder, layerObject, mapping_data)) |
|
574 |
|
575 for f in etree.findall("{%s}file" % self.namespaces[0]): |
|
576 layerObject.addFile(self.parse_file(f, layerObject, mapping_data)) |
|
577 |
|
578 return layerObject |
|
579 |
|
580 def parse_folder(self, etree, parent, mapping_data=None): |
|
581 path = self.handleMapping(etree.get("path"), mapping_data) |
|
582 |
|
583 folderObject = ConvertProjectFolder(path, parent) |
|
584 for filter in etree.findall("{%s}filter" % self.namespaces[0]): |
|
585 #Remove includes supported only for files. |
|
586 folderObject.addFilter(self.parse_filter(filter, folderObject, mapping_data)) |
|
587 return folderObject |
|
588 |
|
589 def parse_file(self, etree, parent, mapping_data=None): |
|
590 path = self.handleMapping(etree.get("path"), mapping_data) |
|
591 type = self.handleMapping(etree.get("type"), mapping_data) |
|
592 |
|
593 fileObject = ConvertProjectFile(path, type, parent) |
|
594 for filter in etree.findall("{%s}filter" % self.namespaces[0]): |
|
595 fileObject.addFilter(self.parse_filter(filter, fileObject, mapping_data)) |
|
596 |
|
597 metaElement = etree.find("{%s}meta" % self.namespaces[0]) |
|
598 namespacePattern = re.compile("\{(.*)\}(.*)") |
|
599 metaArray = [] #tag, value, ns, attrs |
|
600 if metaElement: |
|
601 for item in metaElement.getiterator(): |
|
602 mo = namespacePattern.search(item.tag) |
|
603 if mo: |
|
604 if mo.group(2) != "meta": |
|
605 tmpArray = [] |
|
606 tmpArray.append(mo.group(2)) #Tag name |
|
607 tmpArray.append(item.text) #value |
|
608 tmpArray.append(mo.group(1)) #Namespace |
|
609 tmpDict = {} |
|
610 for attribute in item.keys(): |
|
611 tmpDict[attribute] = item.get(attribute) |
|
612 tmpArray.append(tmpDict) |
|
613 metaArray.append(tmpArray) |
|
614 |
|
615 descElement = etree.find("{%s}desc" % self.namespaces[0]) |
|
616 description = "" |
|
617 if descElement != None: |
|
618 description = descElement.text |
|
619 |
|
620 fileObject.addMeta(metaArray) |
|
621 fileObject.addDescription(description) |
|
622 return fileObject |
|
623 |
|
624 def parse_filter(self, etree, parent, mapping_data=None): |
|
625 """ |
|
626 """ |
|
627 data = self.handleMapping(etree.get("data"), mapping_data) |
|
628 action = self.handleMapping(etree.get("action"), mapping_data) |
|
629 remove_includes = self.handleMapping(etree.get("remove_includes"), mapping_data) |
|
630 recursive = self.handleMapping(etree.get("recursive"), mapping_data) |
|
631 |
|
632 return ConvertProjectFilter(action, data, parent, remove_includes, recursive) |
|
633 |
|
634 |
|
635 def parse_rule(self, etree, parent): |
|
636 return {"name": etree.get("name"), "type": etree.get("type"), "data": etree.get("data")} |
|
637 |
|
638 def parse_attributes(self, etree, tagName): |
|
639 tmpDict = {} |
|
640 tmpElement = etree.find("{%s}%s" % (self.namespaces[0], tagName)) |
|
641 for attribute in tmpElement.keys(): |
|
642 tmpDict[attribute] = tmpElement.get(attribute) |
|
643 return tmpDict |
|
644 |
|
645 def handleMapping(self, data, mapping): |
|
646 """ |
|
647 """ |
|
648 |
|
649 retStr = data |
|
650 |
|
651 if mapping != None and data != None: |
|
652 for key in mapping.keys(): |
|
653 retStr = retStr.replace(key, mapping[key]) |
|
654 return retStr |
|
655 |
|
656 |
|
657 |
|
658 |
|
659 |
|
660 |
|
661 |
|
662 |
|
663 |
|
664 |
|
665 |