Author: bugman Date: Wed Aug 19 16:09:33 2009 New Revision: 9342 URL: http://svn.gna.org/viewcvs/relax?rev=9342&view=rev Log: Removed all usages of the has_attr() dictionary method. This was down with the python 2.x to 3.x script with the commands: 2to3 -f has_key relax . -w The change is in preparation for Python 3.0, and relax still works with Python versions 2.4, 2.5, and 2.6. Modified: 1.3/colour.py 1.3/generic_fns/frq.py 1.3/generic_fns/pipes.py 1.3/generic_fns/spectrum.py 1.3/generic_fns/temperature.py 1.3/prompt/minimisation.py 1.3/specific_fns/model_free/results.py 1.3/test_suite/system_tests/scripts/omp_model_free.py 1.3/test_suite/unit_tests/_data/test___init__.py 1.3/test_suite/unit_tests/_generic_fns/test_pipes.py Modified: 1.3/colour.py URL: http://svn.gna.org/viewcvs/relax/1.3/colour.py?rev=9342&r1=9341&r2=9342&view=diff ============================================================================== --- 1.3/colour.py (original) +++ 1.3/colour.py Wed Aug 19 16:09:33 2009 @@ -148,7 +148,7 @@ colours[key] = array(colours[key], float64) # Invalid colour string. - if not colours.has_key(name): + if name not in colours: raise RelaxInvalidColourError, name # Return the RGB colour array. @@ -768,7 +768,7 @@ colours['light green'] = [144, 238, 144] # Invalid colour string. - if not colours.has_key(name): + if name not in colours: raise RelaxInvalidColourError, name # Return the RGB colour array (in numpy format and between 0 and 1). Modified: 1.3/generic_fns/frq.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/frq.py?rev=9342&r1=9341&r2=9342&view=diff ============================================================================== --- 1.3/generic_fns/frq.py (original) +++ 1.3/generic_fns/frq.py Wed Aug 19 16:09:33 2009 @@ -49,7 +49,7 @@ cdp.frq = {} # Test the frequency has not already been set. - if cdp.frq.has_key(id): + if id in cdp.frq: raise RelaxError, "The frequency for the experiment " + repr(id) + " has already been set." # Set the frequency. Modified: 1.3/generic_fns/pipes.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/pipes.py?rev=9342&r1=9341&r2=9342&view=diff ============================================================================== --- 1.3/generic_fns/pipes.py (original) +++ 1.3/generic_fns/pipes.py Wed Aug 19 16:09:33 2009 @@ -178,7 +178,7 @@ """ # Check. - if ds.has_key(name): + if name in ds: return True else: return False @@ -258,6 +258,6 @@ raise RelaxNoPipeError # Test if the data pipe exists. - if not ds.has_key(pipe_name): + if pipe_name not in ds: raise RelaxNoPipeError, pipe_name Modified: 1.3/generic_fns/spectrum.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/spectrum.py?rev=9342&r1=9341&r2=9342&view=diff ============================================================================== --- 1.3/generic_fns/spectrum.py (original) +++ 1.3/generic_fns/spectrum.py Wed Aug 19 16:09:33 2009 @@ -298,7 +298,7 @@ spect_index = cdp.spectrum_ids.index(spectrum_id) # The scaling by NC_proc. - if hasattr(cdp, 'ncproc') and cdp.ncproc.has_key(spectrum_id): + if hasattr(cdp, 'ncproc') and spectrum_id in cdp.ncproc: scale = 1.0 / 2**cdp.ncproc[spectrum_id] else: scale = 1.0 Modified: 1.3/generic_fns/temperature.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/temperature.py?rev=9342&r1=9341&r2=9342&view=diff ============================================================================== --- 1.3/generic_fns/temperature.py (original) +++ 1.3/generic_fns/temperature.py Wed Aug 19 16:09:33 2009 @@ -49,7 +49,7 @@ cdp.temperature = {} # Test the temperature has not already been set. - if cdp.temperature.has_key(id): + if id in cdp.temperature: raise RelaxError, "The temperature for the experiment " + repr(id) + " has already been set." # Set the temperature. Modified: 1.3/prompt/minimisation.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/minimisation.py?rev=9342&r1=9341&r2=9342&view=diff ============================================================================== --- 1.3/prompt/minimisation.py (original) +++ 1.3/prompt/minimisation.py Wed Aug 19 16:09:33 2009 @@ -262,39 +262,39 @@ # The function intro text is found at the end! # Keyword: func_tol. - if keywords.has_key('func_tol'): + if 'func_tol' in keywords: func_tol = keywords['func_tol'] else: func_tol = 1e-25 # Keyword: grad_tol. - if keywords.has_key('grad_tol'): + if 'grad_tol' in keywords: grad_tol = keywords['grad_tol'] else: grad_tol = None # Keyword: max_iterations. - if keywords.has_key('max_iterations'): + if 'max_iterations' in keywords: max_iterations = keywords['max_iterations'] - elif keywords.has_key('max_iter'): + elif 'max_iter' in keywords: max_iterations = keywords['max_iter'] else: max_iterations = 10000000 # Keyword: constraints. - if keywords.has_key('constraints'): + if 'constraints' in keywords: constraints = keywords['constraints'] else: constraints = True # Keyword: scaling. - if keywords.has_key('scaling'): + if 'scaling' in keywords: scaling = keywords['scaling'] else: scaling = True # Keyword: verbosity. - if keywords.has_key('verbosity'): + if 'verbosity' in keywords: verbosity = keywords['verbosity'] else: verbosity = 1 Modified: 1.3/specific_fns/model_free/results.py URL: http://svn.gna.org/viewcvs/relax/1.3/specific_fns/model_free/results.py?rev=9342&r1=9341&r2=9342&view=diff ============================================================================== --- 1.3/specific_fns/model_free/results.py (original) +++ 1.3/specific_fns/model_free/results.py Wed Aug 19 16:09:33 2009 @@ -145,7 +145,7 @@ """ # The spin info (for relax 1.2). - if col.has_key('num'): + if 'num' in col: mol_name = None res_num = int(spin_line[col['num']]) res_name = spin_line[col['name']] @@ -187,7 +187,7 @@ """ # The spin info (for relax 1.2). - if col.has_key('num'): + if 'num' in col: mol_name = None res_num = int(spin_line[col['num']]) res_name = spin_line[col['name']] Modified: 1.3/test_suite/system_tests/scripts/omp_model_free.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/scripts/omp_model_free.py?rev=9342&r1=9341&r2=9342&view=diff ============================================================================== --- 1.3/test_suite/system_tests/scripts/omp_model_free.py (original) +++ 1.3/test_suite/system_tests/scripts/omp_model_free.py Wed Aug 19 16:09:33 2009 @@ -185,7 +185,7 @@ # Loop over the data pipes. for name in self.pipes: # Create the data pipe. - if ds.has_key(name): + if name in ds: pipe.delete(name) pipe.create(name, 'mf') Modified: 1.3/test_suite/unit_tests/_data/test___init__.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/unit_tests/_data/test___init__.py?rev=9342&r1=9341&r2=9342&view=diff ============================================================================== --- 1.3/test_suite/unit_tests/_data/test___init__.py (original) +++ 1.3/test_suite/unit_tests/_data/test___init__.py Wed Aug 19 16:09:33 2009 @@ -61,7 +61,7 @@ ds.add(pipe_name='new', pipe_type='mf') # Test that the new data pipe exists. - self.assert_(ds.has_key('new')) + self.assert_('new' in ds) def test_repr(self): Modified: 1.3/test_suite/unit_tests/_generic_fns/test_pipes.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/unit_tests/_generic_fns/test_pipes.py?rev=9342&r1=9341&r2=9342&view=diff ============================================================================== --- 1.3/test_suite/unit_tests/_generic_fns/test_pipes.py (original) +++ 1.3/test_suite/unit_tests/_generic_fns/test_pipes.py Wed Aug 19 16:09:33 2009 @@ -70,7 +70,7 @@ pipes.copy('orig', 'new') # Test that the new data pipe exists. - self.assert_(ds.has_key('new')) + self.assert_('new' in ds) # Test that the new data pipe has the object 'x' and that its value is 1. self.assertEqual(ds['new'].x, 1) @@ -101,7 +101,7 @@ pipes.copy(pipe_to='new') # Test that the new data pipe exists. - self.assert_(ds.has_key('new')) + self.assert_('new' in ds) # Test that the new data pipe has the object 'x' and that its value is 1. self.assertEqual(ds['new'].x, 1) @@ -143,7 +143,7 @@ pipes.create(name, 'mf') # Test that the data pipe exists. - self.assert_(ds.has_key(name)) + self.assert_(name in ds) # Test that the current pipe is the new pipe. self.assertEqual(pipes.cdp_name(), name) @@ -183,7 +183,7 @@ pipes.delete(name) # Test that the data pipe no longer exists. - self.assert_(not ds.has_key(name)) + self.assert_(name not in ds) # Test that the current pipe is None (as the current pipe was deleted). self.assertEqual(pipes.cdp_name(), None)