open_file — Camelot documentation

### Navigation

- index
- modules |
- next |
- previous |
- Camelot documentation »
- Camelot API »
- view »
- action_steps »

# open_file

class `camelot.view.action_steps.open_file.` `OpenFile`(path)

  Open a file with the preferred application from the user. The absolute path is preferred, as this is most likely to work when running from an egg and in all kinds of setups.

  Parameters: | path – the absolute path to the file to open

  The `yield` statement will return `True` if the file was opend successfull.

  classmethod `create_temporary_file`(suffix)

    Create a temporary filename that can be used to write to, and open later on.

    Parameters: | suffix – the suffix of the file to create
    Returns: | the filename of the temporary file

  `get_path`()

    Returns: | the path to the file that will be opened, use this method

    to verify the content of the file in unit tests

class `camelot.view.action_steps.open_file.` `OpenJinjaTemplate`(environment, template, suffix='.txt', context={})

  Render a jinja template into a temporary file and open that file with the prefered application of the user.

  Parameters: | environment – a `jinja2.Environment` object to be used to load templates from. template – the name of the template as it can be fetched from the Jinja environment. suffix – the suffix of the temporary file to create, this will determine the application used to open the file. context – a dictionary with objects to be used when rendering the template

class `camelot.view.action_steps.open_file.` `OpenStream`(stream, suffix='.txt')

  Write a stream to a temporary file and open that file with the preferred application of the user.

  Parameters: | stream – the stream to write to a file suffix – the suffix of the temporary file

### Navigation

- index
- modules |
- next |
- previous |
- Camelot documentation »
- Camelot API »
- view »
- action_steps »

Comments
blog comments powered by Disqus