<s> from foam . sfa . rspecs . elements . element import Element <EOL> from foam . sfa . rspecs . elements . sliver import Sliver <EOL> from foam . sfa . rspecs . elements . versions . pgv2DiskImage import PGv2DiskImage <EOL> from foam . sfa . rspecs . elements . versions . plosv1FWRule import PLOSv1FWRule <EOL> class OcfOfSlivers : <EOL> @ staticmethod <EOL> def add_slivers ( xml , slivers ) : <EOL> if not slivers : <EOL> return <EOL> if not isinstance ( slivers , list ) : <EOL> slivers = [ slivers ] <EOL> for sliver in slivers : <EOL> sliver_elem = xml . add_element ( '<STR_LIT>' ) <EOL> if sliver . get ( '<STR_LIT:type>' ) : <EOL> sliver_elem . set ( '<STR_LIT:name>' , sliver [ '<STR_LIT:type>' ] ) <EOL> attrs = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> for attr in attrs : <EOL> if sliver . get ( attr ) : <EOL> sliver_elem . set ( attr , sliver [ attr ] ) <EOL> images = sliver . get ( '<STR_LIT>' ) <EOL> if images and isinstance ( images , list ) : <EOL> PGv2DiskImage . add_images ( sliver_elem , images ) <EOL> fw_rules = sliver . get ( '<STR_LIT>' ) <EOL> if fw_rules and isinstance ( fw_rules , list ) : <EOL> PLOSv1FWRule . add_rules ( sliver_elem , fw_rules ) <EOL> PGv2SliverType . add_sliver_attributes ( sliver_elem , sliver . get ( '<STR_LIT>' , [ ] ) ) <EOL> @ staticmethod <EOL> def add_sliver_attributes ( xml , attributes ) : <EOL> if attributes : <EOL> for attribute in attributes : <EOL> if attribute [ '<STR_LIT:name>' ] == '<STR_LIT>' : <EOL> xml . add_element ( '<STR_LIT>' % xml . namespaces [ '<STR_LIT>' ] , name = attribute [ '<STR_LIT:value>' ] ) <EOL> elif attribute [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> attrib_elem = xml . add_element ( '<STR_LIT>' % self . namespaces [ '<STR_LIT>' ] ) <EOL> attrib_dict = eval ( tag [ '<STR_LIT:value>' ] ) <EOL> for ( key , value ) in attrib_dict . items ( ) : <EOL> attrib_elem . set ( key , value ) <EOL> @ staticmethod <EOL> def get_sliver_attributes ( xml , filter = { } ) : <EOL> return [ ] </s>
