| Trees | Indices | Help |
|---|
|
|
1 # -*- Mode: Python; test-case-name: flumotion.test.test_wizard -*- 2 # vi:si:et:sw=4:sts=4:ts=4 3 # 4 # Flumotion - a streaming media server 5 # Copyright (C) 2004,2005,2006,2007,2008 Fluendo, S.L. (www.fluendo.com). 6 # All rights reserved. 7 8 # This file may be distributed and/or modified under the terms of 9 # the GNU General Public License version 2 as published by 10 # the Free Software Foundation. 11 # This file is distributed without any warranty; without even the implied 12 # warranty of merchantability or fitness for a particular purpose. 13 # See "LICENSE.GPL" in the source distribution for more information. 14 15 # Licensees having purchased or holding a valid Flumotion Advanced 16 # Streaming Server license may use this file in accordance with the 17 # Flumotion Advanced Streaming Server Commercial License Agreement. 18 # See "LICENSE.Flumotion" in the source distribution for more information. 19 20 # Headers in this file shall remain intact. 21 22 from cStringIO import StringIO 23 from xml.sax.saxutils import quoteattr 24 25 from flumotion.common.xmlwriter import cmpComponentType, XMLWriter 26 from flumotion.configure import configure 27 28 __version__ = "$Rev: 6246 $" 29 3032 """I am responsible for writing the state of a flow created by the wizard 33 into XML. 34 I will try my best write pretty XML which can be editable by humans at a 35 later point. 36 """ 378339 """ 40 @param flowName: name of the flow 41 @param flowComponents: components to be included in the flow 42 @param atmosphereComponents: components to be included in the atmosphere 43 """ 44 super(ConfigurationWriter, self).__init__() 45 self._flowName = flowName 46 self._flowComponents = flowComponents 47 self._atmosphereComponents = atmosphereComponents 48 self._writePlanet()4951 self.pushTag('planet') 52 self._writeAtmosphere(self._atmosphereComponents) 53 self._writeFlow(self._flowName, self._flowComponents) 54 self.popTag()5557 if not components: 58 return 59 self.pushTag('atmosphere') 60 self._writeComponents(components) 61 self.popTag()6264 if not components: 65 return 66 self.pushTag('flow', [('name', flowName)]) 67 self._writeComponents(components) 68 self.popTag()6971 # FIXME: When we can depend on Python 2.4, use 72 # sorted(flow.get('components'), 73 # cmp=cmpComponentType, 74 # key=operator.attrgetter('componentType')) 75 # 76 def componentSort(a, b): 77 return cmpComponentType(a.componentType, 78 b.componentType)79 components = list(components) 80 components.sort(cmp=componentSort) 81 for component in components: 82 self._writeComponent(component)85 # Do not write components which already exists in the flow, 86 # This is used to create configuration snippets sent to the 87 # wizard which links to existing components 88 if component.exists: 89 return 90 91 # FIXME: when the wizard can be split among projects, "project" 92 # and "version" should be taken from the relevant project 93 attrs = [('name', component.name), 94 ('type', component.componentType), 95 ('project', configure.PACKAGE), 96 ('worker', component.worker), 97 ('version', configure.version)] 98 self.pushTag('component', attrs) 99 self._writeEaters(component.getEaters()) 100 self._writeProperties(component.getProperties()) 101 self._writeComponentPlugs(component.plugs) 102 self.popTag()103105 eaters = list(eaters) 106 if not eaters: 107 return 108 self.pushTag('eater', [('name', "default")]) 109 for sourceName in eaters: 110 self.writeTag('feed', data=sourceName) 111 self.popTag()112114 if not properties: 115 return 116 self.writeLine() 117 propertyNames = properties.keys() 118 propertyNames.sort() 119 for name in propertyNames: 120 value = properties[name] 121 # Fractions, perhaps we should do type introspection here? 122 if isinstance(value, tuple): 123 assert len(value) == 2 124 value = '%d/%d' % value 125 self.writeTag('property', [('name', name)], value)126128 if not plugs: 129 return 130 self.writeLine() 131 self.pushTag('plugs') 132 for plug in plugs: 133 self._writeComponentPlug(plug) 134 self.popTag()135137 self.pushTag('plug', [('type', plug.plugType)]) 138 self._writeProperties(plug.getProperties()) 139 self.popTag()140
| Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Sat Jul 26 09:43:10 2008 | http://epydoc.sourceforge.net |