Package entropy :: Module dump

Module dump

source code

# DESCRIPTION: # load/save a data to file by dumping its structure

Copyright (C) 2007-2009 Fabio Erculiani

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Functions
 
dumpobj(name, my_object, complete_path=False, ignore_exceptions=True)
Dump object to file
source code
 
serialize(myobj, ser_f, do_seek=True)
Serialize object to ser_f (file)
source code
 
unserialize(serial_f)
Unserialize file to object (file)
source code
 
unserialize_string(mystring)
Unserialize pickle string to object
source code
 
serialize_string(myobj)
Serialize object to string
source code
 
loadobj(name, complete_path=False)
Load object from a file...
source code
 
getobjmtime(name)
Get dumped object mtime
source code
 
removeobj(name)
Remove cached object through its object name
source code
Variables
  D_EXT = '.dmp'
  D_DIR = '/var/lib/entropy/caches/'
  E_GID = 1000
Function Details

dumpobj(name, my_object, complete_path=False, ignore_exceptions=True)

source code 

Dump object to file

@param name -- name of the object @param my_object -- object to dump @param complete_path -- name is a complete path @param ignore_exceptions -- ignore exceptions

@return None

serialize(myobj, ser_f, do_seek=True)

source code 

Serialize object to ser_f (file)

@param myobj -- object to serialize @type myobj -- any picklable object @param ser_f -- file handle to write to @type ser_f -- file object @param do_seek -- move the file cursor to the beginning @type do_seek -- bool @return file object where data is stored to

unserialize(serial_f)

source code 

Unserialize file to object (file)

@param serial_f -- file object to read the stream to @type serial_f -- file object @return object reconstructed

unserialize_string(mystring)

source code 

Unserialize pickle string to object

@param mystring -- data stream in string form to reconstruct @type mystring -- basestring @return reconstructed object

serialize_string(myobj)

source code 

Serialize object to string

@param myobj -- object to serialize @type myobj -- any picklable object @return serialized string

loadobj(name, complete_path=False)

source code 

Load object from a file
@param name -- name of the object to load
@type name -- basestring
@param complete_path -- name is a complete serialized
    object file path to load
@type complete_path -- basestring
@return object or None

getobjmtime(name)

source code 

Get dumped object mtime

@param name -- object name @type name -- basestring @return mtime -- integer

removeobj(name)

source code 

Remove cached object through its object name

@param name -- object name @type name -- basestring @return bool -- removed or not