Python os.O_TEXT() Examples

The following are code examples for showing how to use os.O_TEXT(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the exmaples you don't like. You can also save this page to your account.

Example 1
Project: baiji   Author: bodylabs   File: cached_file.py    (license) View Source Project 6 votes vote down vote up
def flags(self):
        '''
        Adapted from http://hg.python.org/cpython/file/84cf25da86e8/Lib/_pyio.py#l154

        See also open(2) which explains the modes

        os.O_BINARY and os.O_TEXT are only available on Windows.
        '''
        return (
            ((self.reading and not self.updating) and os.O_RDONLY or 0) |
            ((self.writing and not self.updating) and os.O_WRONLY or 0) |
            ((self.creating_exclusively and not self.updating) and os.O_EXCL or 0) |
            (self.updating and os.O_RDWR or 0) |
            (self.appending and os.O_APPEND or 0) |
            ((self.writing or self.creating_exclusively) and os.O_CREAT or 0) |
            (self.writing and os.O_TRUNC or 0) |
            ((self.binary and hasattr(os, 'O_BINARY')) and os.O_BINARY or 0) |
            ((self.text and hasattr(os, 'O_TEXT')) and os.O_TEXT or 0)
        ) 
Example 2
Project: PythonForWindows   Author: hakril   File: winutils.py    (BSD 3-Clause "New" or "Revised" License) View Source Project 5 votes vote down vote up
def create_file_from_handle(handle, mode="r"):
    """Return a Python :class:`file` around a ``Windows`` HANDLE"""
    fd = msvcrt.open_osfhandle(handle, os.O_TEXT)
    return os.fdopen(fd, mode, 0) 
Example 3
Project: viewvc   Author: viewvc   File: win32popen.py    (license) View Source Project 5 votes vote down vote up
def File2FileObject(pipe, mode):
  """Make a C stdio file object out of a win32 file handle"""
  if mode.find('r') >= 0:
    wmode = os.O_RDONLY
  elif mode.find('w') >= 0:
    wmode = os.O_WRONLY
  if mode.find('b') >= 0:
    wmode = wmode | os.O_BINARY
  if mode.find('t') >= 0:
    wmode = wmode | os.O_TEXT
  return os.fdopen(msvcrt.open_osfhandle(pipe.Detach(),wmode),mode)