From: ageay Date: Fri, 4 Jan 2013 11:14:13 +0000 (+0000) Subject: python len(MEDFileFieldMultiTS) X-Git-Tag: V6_main_FINAL~431 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6172624602bddf76aa9bf4ff0f4ac40f1711a17a;p=tools%2Fmedcoupling.git python len(MEDFileFieldMultiTS) --- diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index f99f6635b..8dab91281 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -1207,9 +1207,14 @@ namespace ParaMEDMEM } std::string __str__() const throw(INTERP_KERNEL::Exception) - { - return self->simpleRepr(); - } + { + return self->simpleRepr(); + } + + int __len__() const throw(INTERP_KERNEL::Exception) + { + return self->getNumberOfTS(); + } MEDFileField1TS *__getitem__(PyObject *elt0) const throw(INTERP_KERNEL::Exception) { diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index 891d19c11..aee3876cb 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -384,6 +384,7 @@ class MEDLoaderTest(unittest.TestCase): mm.write("Pyfile17_bis.med",2) ff=MEDFileFieldMultiTS("Pyfile17.med") tsExpected=[[1,2],[3,4],[5,6]] + self.assertEqual(3,len(ff)) for pos,f1ts in enumerate(ff): self.assertEqual(tsExpected[pos],f1ts.getTime()[:2]) self.assertEqual(type(f1ts),MEDFileField1TS)