Author: bugman Date: Wed Apr 9 11:13:23 2008 New Revision: 5483 URL: http://svn.gna.org/viewcvs/relax?rev=5483&view=rev Log: Created the MoleculeContainer.is_empty() method. Modified: 1.3/data/mol_res_spin.py Modified: 1.3/data/mol_res_spin.py URL: http://svn.gna.org/viewcvs/relax/1.3/data/mol_res_spin.py?rev=5483&r1=5482&r2=5483&view=diff ============================================================================== --- 1.3/data/mol_res_spin.py (original) +++ 1.3/data/mol_res_spin.py Wed Apr 9 11:13:23 2008 @@ -377,6 +377,43 @@ return text + def is_empty(self): + """Method for testing if this MoleculeContainer object is empty. + + @return: True if this container is empty and the molecule name has not been set, False + otherwise. + @rtype: bool + """ + + # The molecule name has been set. + if self.name != None: + return False + + # An object has been added to the container. + for name in dir(self): + # Skip the objects initialised in __init__(). + if name == 'name' or name == 'select' or name == 'res': + continue + + # Skip the MoleculeContainer methods. + if name == 'is_empty': + continue + + # Skip special objects. + if match("^__", name): + continue + + # An object has been added. + return False + + # The residue list is not empty. + if not self.res.is_empty(): + return False + + # The MoleculeContainer is unmodified. + return True + + class MoleculeList(list): """List type data container for the molecule specific data."""