def to_script(self, wf_name='wf'):
        self._closed()
        script = []
        #        print('doc =
')
        params = []
        returns = []
        for name, typ in self.wf_inputs.items():
            params.append('{}=\'{}\''.format(name, typ))
            returns.append(name)
        script.append('{} = {}.add_inputs({})'.format(
            ', '.join(returns), wf_name, ', '.join(params)))
        returns = []
        for name, step in self.wf_steps.items():
            pyname = step.python_name
            returns = ['{}_{}'.format(pyname, o) for o in step['out']]
            params = ['{}={}'.format(name, python_name(param))
                      for name, param in step['in'].items()]
            script.append('{} = {}.{}({})'.format(
                ', '.join(returns), wf_name, pyname, ', '.join(params)))
        params = []
        for name, details in self.wf_outputs.items():
            params.append('{}={}'.format(
                name, python_name(details['outputSource'])))
        script.append('{}.add_outputs({})'.format(wf_name, ', '.join(params)))
        return '\n'.join(script)