def serialize_item(collection, item):
 if ((item.name is None) or (item.name == '')):
  raise exceptions.RuntimeError('name unset for item!')
 if (collection.collection_type() in ['mgmtclass']):
  filename = ('/var/lib/cobbler/collections/%ses/%s' % (collection.collection_type(), item.name))
 else:
  filename = ('/var/lib/cobbler/collections/%ss/%s' % (collection.collection_type(), item.name))
 _dict = item.to_dict()
 if capi.CobblerAPI().settings().serializer_pretty_json:
  sort_keys = True
  indent = 4
 else:
  sort_keys = False
  indent = None
 filename += '.json'
 _dict = item.to_dict()
 fd = open(filename, 'w+')
 data = simplejson.dumps(_dict, encoding='utf-8', sort_keys=sort_keys, indent=indent)
 fd.write(data)
 fd.close()

def serialize_item ( collection , item ) : if ( ( item . name is None ) or ( item . name == '' ) ) : raise exceptions . RuntimeError ( 'name unset for item!' ) if ( collection . collection_type ( ) in [ 'mgmtclass' ] ) : filename = ( '/var/lib/cobbler/collections/%ses/%s' % ( collection . collection_type ( ) , item . name ) ) else : filename = ( '/var/lib/cobbler/collections/%ss/%s' % ( collection . collection_type ( ) , item . name ) ) _dict = item . to_dict ( ) if capi . CobblerAPI ( ) . settings ( ) . serializer_pretty_json : sort_keys = True indent = 4 else : sort_keys = False indent = None filename += '.json' _dict = item . to_dict ( ) fd = open ( filename , 'w+' ) data = simplejson . dumps ( _dict , encoding = 'utf-8' , sort_keys = sort_keys , indent = indent ) fd . write ( data ) fd . close ( )
save a collection item to file system .