MissingPy-0.10.4: Haskell interface to Python

MaintainerJohn Goerzen,

Python.Objects.File

Contents

Description

Maintainer : jgoerzen@complete.org Stability : provisional Portability: portable

Python file-like objects

Written by John Goerzen, jgoerzen@complete.org

This module provides a Haskell interface to work with Python file-like objects. The Haskell interface is a System.IO.HVIO interface, which is similar in concept to the Python file-like object system.

You can create such objects by using openPyFile from this module, or MissingPy.FileArchive.GZip.openGz or MissingPy.FileArchive.BZip2.openBz2.

Functions that you can use to operate on these objects are defined at System.IO.HVIO.

Synopsis

PyFile Objects

data PyFile Source

The basic type for a Python file or file-like object.

PyFiles are a member of System.IO.HVIO and can be used as any other Haskell HVFS object such as a Handle.

PyFile objects cannot reliably detect EOF when asked by vIsEOF, but can detect it and raise the appropriate IOError when it is reached. Also, PyFile objects cannot determine if they are readable, writable, or seekable in advance.

Instances

mkPyFile :: PyObject -> PyFileSource

Takes a PyObject representing a Python file or file-like object and makes it into a PyFile.

fromPyFile :: PyFile -> PyObjectSource

Extracts the PyObject representing this PyFile.

openPyFile :: FilePath -> IOMode -> IO PyFileSource

Convert a Haskell open mode to a Python mode string

Open a file on disk and return a PyFile.

pyfwrap :: PyFile -> (PyObject -> IO a) -> IO aSource

Wrap an operation, raising exceptions in the IO monad as appropriate.