Robot Framework
robot.utils.filereader.FileReader Class Reference

Utility to ease reading different kind of files. More...

Public Member Functions

def __enter__ (self)
 
def __exit__ (self, *exc_info)
 
def __init__ (self, source, accept_text=False)
 
def read (self)
 
def readlines (self)
 

Private Member Functions

def _decode (self, content, remove_bom=True)
 
def _get_file (self, source, accept_text)
 
def _get_path (self, source, accept_text)
 
def _is_binary_file (self)
 

Private Attributes

 _opened
 

Detailed Description

Utility to ease reading different kind of files.

Supports different sources where to read the data:

- The source can be a path to a file, either as a string or as a
  ``pathlib.Path`` instance in Python 3. The file itself must be
  UTF-8 encoded.

- Alternatively the source can be an already opened file object,
  including a StringIO or BytesIO object. The file can contain either
  Unicode text or UTF-8 encoded bytes.

- The third options is giving the source as Unicode text directly.
  This requires setting ``accept_text=True`` when creating the reader.

In all cases bytes are automatically decoded to Unicode and possible
BOM removed.

Definition at line 40 of file filereader.py.

Constructor & Destructor Documentation

◆ __init__()

def robot.utils.filereader.FileReader.__init__ (   self,
  source,
  accept_text = False 
)

Definition at line 42 of file filereader.py.

Member Function Documentation

◆ __enter__()

def robot.utils.filereader.FileReader.__enter__ (   self)

Definition at line 72 of file filereader.py.

◆ __exit__()

def robot.utils.filereader.FileReader.__exit__ (   self,
exc_info 
)

Definition at line 75 of file filereader.py.

◆ _decode()

def robot.utils.filereader.FileReader._decode (   self,
  content,
  remove_bom = True 
)
private

Definition at line 88 of file filereader.py.

◆ _get_file()

def robot.utils.filereader.FileReader._get_file (   self,
  source,
  accept_text 
)
private

Definition at line 45 of file filereader.py.

◆ _get_path()

def robot.utils.filereader.FileReader._get_path (   self,
  source,
  accept_text 
)
private

Definition at line 59 of file filereader.py.

◆ _is_binary_file()

def robot.utils.filereader.FileReader._is_binary_file (   self)
private

Definition at line 97 of file filereader.py.

◆ read()

def robot.utils.filereader.FileReader.read (   self)

Definition at line 79 of file filereader.py.

◆ readlines()

def robot.utils.filereader.FileReader.readlines (   self)

Definition at line 82 of file filereader.py.

Member Data Documentation

◆ _opened

robot.utils.filereader.FileReader._opened
private

Definition at line 43 of file filereader.py.


The documentation for this class was generated from the following file: