/usr/include/openturns/swig/Object.i is in libopenturns-dev 1.7-3.
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 54 55 56 57 58 59 60 61 62 63 64 | // SWIG file Object.i
%ignore OT::Object::GetClassName;
%{
#include "Object.hxx"
%}
%include Object_doc.i
%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__
def Object__repr_html_(self):
lines = str(self).splitlines()
html = '<p>'
for i in range(len(lines)):
html += lines[i]+'<br>'+'\n'
html += '</p>'
return html
Object._repr_html_ = Object__repr_html_
%}
|