diff --git a/Examples/PythonPackageExample/LICENSE b/Examples/PythonPackageExample/LICENSE index 791c0015e4..91aacba82c 100644 --- a/Examples/PythonPackageExample/LICENSE +++ b/Examples/PythonPackageExample/LICENSE @@ -1,9 +1,38 @@ -Copyright (c) 2012, Kenneth Reitz - +======================================================================= +Copyright (c) 2003-2012 German Cancer Research Center, +Division of Medical and Biological Informatics All rights reserved. -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +Redistribution and use in source and binary forms, with or +without modification, are permitted provided that the +following conditions are met: + + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + + * Neither the name of the German Cancer Research Center, + nor the names of its contributors may be used to endorse + or promote products derived from this software without + specific prior written permission. -Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +======================================================================= \ No newline at end of file diff --git a/Examples/PythonPackageExample/samplepackage/helpers.py b/Examples/PythonPackageExample/samplepackage/helpers.py index f480e72aec..e06baccab5 100644 --- a/Examples/PythonPackageExample/samplepackage/helpers.py +++ b/Examples/PythonPackageExample/samplepackage/helpers.py @@ -1,7 +1,24 @@ +""" +=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +=================================================================== +""" # this is a list of thoughts which is used by the thinker thoughts = ["itk", "genius", "core", "blue", "vtk", "grand", "berry", "delicious"] # it is only in a separate file to show how to # import other modules in thinker.py diff --git a/Examples/PythonPackageExample/samplepackage/tests/test_advanced.py b/Examples/PythonPackageExample/samplepackage/tests/test_advanced.py index 322e587c16..a277354e63 100644 --- a/Examples/PythonPackageExample/samplepackage/tests/test_advanced.py +++ b/Examples/PythonPackageExample/samplepackage/tests/test_advanced.py @@ -1,35 +1,53 @@ +""" +=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +=================================================================== +""" + # -*- coding: utf-8 -*- import unittest from samplepackage.thinker import Thinker class AdvancedTestSuite(unittest.TestCase): """Advanced test cases.""" def setUp(self): # like in JUnit/CppUnit we can define setUp and tearDown methods # create a thinker with 5 thoughts: self.nr_thoughts = 5 self.thinker = Thinker(self.nr_thoughts) def test_thoughts(self): """ test if the correct number of thoughts is produced :return: """ self.assertEquals(self.nr_thoughts, len(self.thinker.think()), "correct number of thoughts is produced") def test_constructor(self): """ test if trying to construct a thinker without argument raises an error :return: """ with self.assertRaises(TypeError): Thinker() if __name__ == '__main__': unittest.main() diff --git a/Examples/PythonPackageExample/samplepackage/tests/test_basic.py b/Examples/PythonPackageExample/samplepackage/tests/test_basic.py index f1864e176e..ae6f2303e2 100644 --- a/Examples/PythonPackageExample/samplepackage/tests/test_basic.py +++ b/Examples/PythonPackageExample/samplepackage/tests/test_basic.py @@ -1,16 +1,34 @@ +""" +=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +=================================================================== +""" + # -*- coding: utf-8 -*- import unittest class BasicTestSuite(unittest.TestCase): """Basic test cases. This is just a fake, go to test_advanced for a real test""" def test_absolute_truth_and_meaning(self): assert True if __name__ == '__main__': unittest.main() diff --git a/Examples/PythonPackageExample/samplepackage/thinker.py b/Examples/PythonPackageExample/samplepackage/thinker.py index 15aacc3cf9..9807f11d8f 100644 --- a/Examples/PythonPackageExample/samplepackage/thinker.py +++ b/Examples/PythonPackageExample/samplepackage/thinker.py @@ -1,53 +1,76 @@ +''' +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ +''' + + # -*- coding: utf-8 -*- # packages/modules included in pythons go here import random import logging # installed packages go here # our own modules/packages go here from helpers import thoughts # a free floating function def get_thought(): """Get a random thought.""" return random.choice(thoughts) class Thinker: """ A class which produces thoughts """ def __init__(self, number_of_thoughts): """ This is a constructor. Define variables here. If you do it in the classes namespace instead it will be equivalent to a static variable in C++ :param number_of_thoughts: the number of thoughts we want to produce :return: """ # underscore is standard for members in python: self.number_of_thoughts = number_of_thoughts def think(self): """ Member function which uses the number_of_thoughts to "think :return: a list of thoughts, length depending on your number of thoughts """ thought_list = [] try: thought_list = [get_thought() for _ in range(self.number_of_thoughts)] except IndexError: logging.error("Just showing off the logging module here") return thought_list def think_out_loud(self): + """ + Think and print these thoughts on the console. + :return: + """ current_thoughts = self.think() print "currently I'm thinking of..." for thought in current_thoughts: print thought