/usr/include/openturns/swig/Object.i is in python-openturns-dev 1.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | // SWIG file Object.i
// @author schueller
// @date 2012-01-02 11:44:01 +0100 (Mon, 02 Jan 2012)
%{
#include "Object.hxx"
%}
%include Object.hxx
namespace OT{ %extend Object { Object(const Object & other) { return new OT::Object(other); } } }
%pythoncode %{
import os
def Object___getstate__(self):
state = dict()
study = Study()
filename = Path.BuildTemporaryFileName('xmlfileXXXXXX')
# assume xml support
# should use BinaryStorageManager
with open(filename, 'rb+') as infile:
study.setStorageManager(XMLStorageManager(filename))
study.add('instance', self)
study.save()
infile.seek(0)
state['xmldata'] = infile.read()
os.remove(filename)
return state
Object.__getstate__ = Object___getstate__
def Object___setstate__(self, state):
# call ctor to initialize underlying cxx obj
# as it is instanciated from object.__new__
self.__init__()
study = Study()
filename = Path.BuildTemporaryFileName('xmlfileXXXXXX')
with open(filename, 'rb+') as outfile:
outfile.write(state['xmldata'])
outfile.seek(0)
study.setStorageManager(XMLStorageManager(filename))
study.load()
study.fillObject('instance', self)
os.remove(filename)
Object.__setstate__ = Object___setstate__
%}
|