|
76 |
class Flavor( JSON_Object ): |
76 |
class Flavor( JSON_Object ): |
77 |
'''Defines a flavor of a module. This provides another name and icon |
77 |
'''Defines a flavor of a module. This provides another name and icon |
78 |
in the overview and may influence the behaviour of the module.''' |
78 |
in the overview and may influence the behaviour of the module.''' |
79 |
def __init__( self, id = '', icon = '', name = '', description = '' ): |
79 |
def __init__( self, id = '', icon = '', name = '', description = '', overwrites = [] ): |
80 |
self.id = id |
80 |
self.id = id |
81 |
self.name = name |
81 |
self.name = name |
82 |
self.description = description |
82 |
self.description = description |
83 |
self.icon = icon |
83 |
self.icon = icon |
|
|
84 |
self.overwrites = overwrites |
84 |
|
85 |
|
85 |
class Module( JSON_Object ): |
86 |
class Module( JSON_Object ): |
86 |
'''Represents an command attribute''' |
87 |
'''Represents an command attribute''' |
|
141 |
'''Retrieve list of flavor objects''' |
142 |
'''Retrieve list of flavor objects''' |
142 |
for elem in self.findall( 'module/flavor' ): |
143 |
for elem in self.findall( 'module/flavor' ): |
143 |
flavor = Flavor( elem.get( 'id' ), elem.get( 'icon' ) ) |
144 |
flavor = Flavor( elem.get( 'id' ), elem.get( 'icon' ) ) |
|
|
145 |
flavor.overwrites = elem.get( 'overwrites', '' ).split( ',' ) |
144 |
flavor.name = elem.find( 'name' ).text |
146 |
flavor.name = elem.find( 'name' ).text |
145 |
flavor.description = elem.find( 'description' ).text |
147 |
flavor.description = elem.find( 'description' ).text |
146 |
yield flavor |
148 |
yield flavor |
|
236 |
if not at_least_one_command and mod.flavors: |
238 |
if not at_least_one_command and mod.flavors: |
237 |
mod.flavors.remove( flavor ) |
239 |
mod.flavors.remove( flavor ) |
238 |
|
240 |
|
|
|
241 |
overwrites = set() |
242 |
for flavor in mod.flavors: |
243 |
overwrites.update( flavor.overwrites ) |
244 |
|
245 |
mod.flavors = JSON_List( filter( lambda f: f.id not in overwrites, mod.flavors ) ) |
246 |
|
239 |
return modules |
247 |
return modules |
240 |
|
248 |
|
241 |
def module_providing( self, modules, command ): |
249 |
def module_providing( self, modules, command ): |