Trees | Indices | Help |
|
---|
|
1 ############################################################################### 2 # # 3 # Copyright (C) 2003,2007,2017 Edward d'Auvergne # 4 # # 5 # This file is part of the program relax (http://www.nmr-relax.com). # 6 # # 7 # This program is free software: you can redistribute it and/or modify # 8 # it under the terms of the GNU General Public License as published by # 9 # the Free Software Foundation, either version 3 of the License, or # 10 # (at your option) any later version. # 11 # # 12 # This program is distributed in the hope that it will be useful, # 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of # 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # 15 # GNU General Public License for more details. # 16 # # 17 # You should have received a copy of the GNU General Public License # 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. # 19 # # 20 ############################################################################### 21 22 # Module docstring. 23 """Module containing the Prototype base class for the molecule-residue-spin containers.""" 24 25 26 # Python module imports. 27 from copy import deepcopy 28 from re import search 29 3032 """Base class implementing the prototype design pattern.""" 337635 """Replacement deepcopy method.""" 36 37 # Make a new object. 38 new_obj = self.__class__.__new__(self.__class__) 39 40 # Loop over all objects in self and make deepcopies of them. 41 for name in dir(self): 42 # Skip all names begining with '__'. 43 if search('^__', name): 44 continue 45 46 # Skip the class methods. 47 if name in self.__class__.__dict__: 48 continue 49 50 # Get the object. 51 value = getattr(self, name) 52 53 # Replace the object with a deepcopy of it. 54 setattr(new_obj, name, deepcopy(value, memo)) 55 56 # Regenerate any hashes. 57 if hasattr(new_obj, '_generate_hash'): 58 new_obj._generate_hash() 59 60 # Return the new object. 61 return new_obj62 6365 """Prototype method which returns a deepcopy of the object.""" 66 67 # Make a new object. 68 new_obj = deepcopy(self) 69 70 # Regenerate any hashes. 71 if hasattr(new_obj, '_generate_hash'): 72 new_obj._generate_hash() 73 74 # Return the new object. 75 return new_obj
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Jun 8 10:44:57 2024 | http://epydoc.sourceforge.net |