clusterjob/__init__.py
def render_script(self, scriptbody, jobscript=False):
        """Render the body of a script. This brings both the main `body`, as
        well as the `prologue`, `epilogue`, and any auxiliary scripts into the
        final form in which they will be executed.

        Rendering proceeds in the following steps:

        * Add a "shbang" (e.g. ``#!/bin/bash``) based on the `shell` attribute
          if the `scriptbody` does not yet have a shbang on the first line
          (otherwise the existing shbang will remain)

        * If rendering the body of a JobScript (`jobscript=True`), add
          backend-specific resource headers (based on the `resources`
          attribute)

        * Map environment variables to their corresponding scheduler-specific
          version, using the backend's :meth:`~clusterjob.backends.ClusterjobBackend.replace_body_vars`
          method. Note that the prologue and epilogue will not be run by a
          scheduler, and thus will not have access to the same environment
          variables as a job script.

        * Format each line with known attributes (see
          https://docs.python.org/3.5/library/string.html#formatspec).
          In order of precedence (highest to lowest), the following keys will
          be replaced:

          - keys in the `resources` attribute
          - instance attributes
          - class attributes
        """
        rendered_lines = []
        # add the resource headers
        backend = self._backends[self.backend]
        if jobscript:
            rendered_lines.extend(backend.resource_headers(self))
        # apply environment variable mappings
        scriptbody = backend.replace_body_vars(scriptbody)
        # apply attribute mappings
        mappings = dict(self.__class__.__dict__)
        mappings.update(self.__dict__)
        mappings.update(self.resources)
        for line_index, line in enumerate(scriptbody.split("\n")):
            if line_index == 0:
                if not line.startswith("#!"):
                    # add shbang for file that does not have one
                    rendered_lines.insert(0, "#!%s" % self.shell)
            try:
                rendered_lines.append(line.format(**mappings))
            except KeyError as exc:
                key = str(exc)[1:-1] # stripping out quotes
                raise KeyError("The scriptbody contains a formatting "
                    "placeholder '{"+key+"}', but there is no matching "
                    "attribute or resource entry")
        return "\n".join(rendered_lines)
Render the body of a script. This brings both the main `body`, as
        well as the `prologue`, `epilogue`, and any auxiliary scripts into the
        final form in which they will be executed.

        Rendering proceeds in the following steps:

        * Add a "shbang" (e.g. ``#!/bin/bash``) based on the `shell` attribute
          if the `scriptbody` does not yet have a shbang on the first line
          (otherwise the existing shbang will remain)

        * If rendering the body of a JobScript (`jobscript=True`), add
          backend-specific resource headers (based on the `resources`
          attribute)

        * Map environment variables to their corresponding scheduler-specific
          version, using the backend's :meth:`~clusterjob.backends.ClusterjobBackend.replace_body_vars`
          method. Note that the prologue and epilogue will not be run by a
          scheduler, and thus will not have access to the same environment
          variables as a job script.

        * Format each line with known attributes (see
          https://docs.python.org/3.5/library/string.html#formatspec).
          In order of precedence (highest to lowest), the following keys will
          be replaced:

          - keys in the `resources` attribute
          - instance attributes
          - class attributes
        
Render the body of a script.

Rendering proceeds in the following steps.

Add a "shbang"  based on the `shell` attribute
if the `scriptbody` does not yet have a shbang on the first line
(otherwise the existing shbang will remain)

If rendering the body of a JobScript (`jobscript=True`), add
backend-specific resource headers (based on the `resources`
attribute)

Map environment variables to their corresponding scheduler-specific
version, using the backend's :meth:`~clusterjob.backends.ClusterjobBackend.replace_body_vars`
method. Note that the prologue and epilogue will not be run by a
scheduler, and thus will not have access to the same environment
variables as a job script.



keys in the `resources` attribute
instance attributes
class attributes
Render the body of a script . Rendering proceeds in the following steps . Add a " shbang " based on the ` shell ` attribute if the ` scriptbody ` does not yet have a shbang on the first line ( otherwise the existing shbang will remain ) If rendering the body of a JobScript ( ` jobscript = True ` ) add backend - specific resource headers ( based on the ` resources ` attribute ) Map environment variables to their corresponding scheduler - specific version using the backend ' s : meth : ` ~clusterjob . backends . ClusterjobBackend . replace_body_vars ` method . Note that the prologue and epilogue will not be run by a scheduler and thus will not have access to the same environment variables as a job script . keys in the ` resources ` attribute instance attributes class attributes
def render_script(self, scriptbody, jobscript=False):
        rendered_lines = []
        backend = self._backends[self.backend]
        if jobscript:
            rendered_lines.extend(backend.resource_headers(self))
        scriptbody = backend.replace_body_vars(scriptbody)
        mappings = dict(self.__class__.__dict__)
        mappings.update(self.__dict__)
        mappings.update(self.resources)
        for line_index, line in enumerate(scriptbody.split("\n")):
            if line_index == 0:
                if not line.startswith("#!"):
                    rendered_lines.insert(0, "#!%s" % self.shell)
            try:
                rendered_lines.append(line.format(**mappings))
            except KeyError as exc:
                key = str(exc)[1:-1] 
                raise KeyError("The scriptbody contains a formatting "
                    "placeholder '{"+key+"}', but there is no matching "
                    "attribute or resource entry")
        return "\n".join(rendered_lines)
def render_script ( self , scriptbody , jobscript = False ) : rendered_lines = [ ] backend = self . _backends [ self . backend ] if jobscript : rendered_lines . extend ( backend . resource_headers ( self ) ) scriptbody = backend . replace_body_vars ( scriptbody ) mappings = dict ( self . __class__ . __dict__ ) mappings . update ( self . __dict__ ) mappings . update ( self . resources ) for line_index , line in enumerate ( scriptbody . split ( "\n" ) ) : if line_index == 0 : if not line . startswith ( "#!" ) : rendered_lines . insert ( 0 , "#!%s" % self . shell ) try : rendered_lines . append ( line . format ( ** mappings ) ) except KeyError as exc : key = str ( exc ) [ 1 : - 1 ] raise KeyError ( "The scriptbody contains a formatting " "placeholder '{" + key + "}', but there is no matching " "attribute or resource entry" ) return "\n" . join ( rendered_lines )
Render the body of a script.
Render the body of a script .
"""Render the body of a script. This brings both the main `body`, as
        well as the `prologue`, `epilogue`, and any auxiliary scripts into the
        final form in which they will be executed.

        Rendering proceeds in the following steps:

        * Add a "shbang" (e.g. ``#!/bin/bash``) based on the `shell` attribute
          if the `scriptbody` does not yet have a shbang on the first line
          (otherwise the existing shbang will remain)

        * If rendering the body of a JobScript (`jobscript=True`), add
          backend-specific resource headers (based on the `resources`
          attribute)

        * Map environment variables to their corresponding scheduler-specific
          version, using the backend's :meth:`~clusterjob.backends.ClusterjobBackend.replace_body_vars`
          method. Note that the prologue and epilogue will not be run by a
          scheduler, and thus will not have access to the same environment
          variables as a job script.

        * Format each line with known attributes (see
          https://docs.python.org/3.5/library/string.html#formatspec).
          In order of precedence (highest to lowest), the following keys will
          be replaced:

          - keys in the `resources` attribute
          - instance attributes
          - class attributes
        """ # add the resource headers # apply environment variable mappings # apply attribute mappings # add shbang for file that does not have one # stripping out quotes
self
scriptbody
jobscript