code: def create_file_for(self, script):
          
          temp = tempfile.NamedTemporaryFile(
              prefix="pipeline-script-", mode='w+t', suffix=".sh", delete=False,
              dir=self.get_temporary_scripts_path())
  
          self.update_environment_variables(temp.name)
          rendered_script = render(script, model=self.config.model, env=self.env, item=self.config.item,
                                   variables=self.config.variables)
          if rendered_script is None:
              self.success = False
              temp.close()
              os.remove(temp.name)
              return None
  
          to_file_map = {2: lambda s: s.encode('utf-8'), 3: lambda s: s}
  
          if all(ord(ch) < 128 for ch in rendered_script) and os.path.isfile(rendered_script):
              with open(rendered_script) as handle:
                  content = str(handle.read())
                  temp.writelines(content)
          else:
              temp.write(u"#!/bin/bash\n%s" % self.render_bash_options())
              temp.write(to_file_map[sys.version_info.major](rendered_script))
          temp.close()
          # make Bash script executable
          os.chmod(temp.name, 0o700)
          return temp.name
docs: Create a temporary, executable bash file.
  
          It also does render given script (string) with the model and
          the provided environment variables and optional also an item
          when using the B{with} field.
  
          Args:
              script (str): either pather and filename or Bash code.
  
          Returns:
              str: path and filename of a temporary file.