Author: bugman Date: Wed Oct 1 14:26:20 2008 New Revision: 7485 URL: http://svn.gna.org/viewcvs/relax?rev=7485&view=rev Log: Modified the pipe_loop() generator to return the name of the pipe, if asked for. Modified: branches/pipe_refs/generic_fns/pipes.py branches/pipe_refs/generic_fns/structure/internal.py branches/pipe_refs/generic_fns/structure/scientific.py Modified: branches/pipe_refs/generic_fns/pipes.py URL: http://svn.gna.org/viewcvs/relax/branches/pipe_refs/generic_fns/pipes.py?rev=7485&r1=7484&r2=7485&view=diff ============================================================================== --- branches/pipe_refs/generic_fns/pipes.py (original) +++ branches/pipe_refs/generic_fns/pipes.py Wed Oct 1 14:26:20 2008 @@ -189,16 +189,24 @@ print "%-20s%-20s" % (pipe_name, get_type(pipe_name)) -def pipe_loop(): +def pipe_loop(name=False): """Generator function for looping over and yielding the data pipes. - @return: The data pipes. - @rtype: PipeContainer instance + @keyword name: A flag which if True will cause the name of the pipe to be returned. + @type name: bool + @return: The data pipes, and optionally the pipe names. + @rtype: PipeContainer instance or tuple of PipeContainer instance and str if name=True """ # Loop over the keys. - for name in ds.keys(): - yield ds[name] + for key in ds.keys(): + # Return the pipe and name. + if name: + yield ds[key], key + + # Return just the pipe. + else: + yield ds[key] def pipe_names(): Modified: branches/pipe_refs/generic_fns/structure/internal.py URL: http://svn.gna.org/viewcvs/relax/branches/pipe_refs/generic_fns/structure/internal.py?rev=7485&r1=7484&r2=7485&view=diff ============================================================================== --- branches/pipe_refs/generic_fns/structure/internal.py (original) +++ branches/pipe_refs/generic_fns/structure/internal.py Wed Oct 1 14:26:20 2008 @@ -860,7 +860,7 @@ name = name + "_" + `model` # Use pointers (references) if the PDB data exists in another pipe. - for data_pipe in pipes.pipe_loop(): + for data_pipe, name in pipes.pipe_loop(name=True): # Structure exists. if hasattr(data_pipe, 'structure'): # Loop over the structures. @@ -871,7 +871,7 @@ # Print out. if verbosity: - print "Using the structures from the data pipe " + `key` + "." + print "Using the structures from the data pipe " + `name` + "." print self.structural_data[i] # Exit this function. Modified: branches/pipe_refs/generic_fns/structure/scientific.py URL: http://svn.gna.org/viewcvs/relax/branches/pipe_refs/generic_fns/structure/scientific.py?rev=7485&r1=7484&r2=7485&view=diff ============================================================================== --- branches/pipe_refs/generic_fns/structure/scientific.py (original) +++ branches/pipe_refs/generic_fns/structure/scientific.py Wed Oct 1 14:26:20 2008 @@ -547,7 +547,7 @@ name = name + "_" + `model` # Use pointers (references) if the PDB data exists in another data pipe. - for data_pipe in pipes.pipe_loop(): + for data_pipe, name in pipes.pipe_loop(name=True): # Structure exists. if hasattr(data_pipe, 'structure'): # Loop over the structures. @@ -558,7 +558,7 @@ # Print out. if verbosity: - print "Using the structures from the data pipe " + `key` + "." + print "Using the structures from the data pipe " + `name` + "." print self.structural_data[i] # Exit this function.