polychemprint3.utility.fileHandler module

Specifies interface for classes that will handle rw ‘data’ files.

First created on Sun Oct 20 00:03:21 2019
Revised: 20/10/2019 00:34:27
Author: Bijal Patel
class polychemprint3.utility.fileHandler.fileHandler(fullFilePath=None, **kwargs)

Bases: object

Class for objects that can read/write to file

appendToFile(outString)

Appends to file with new content from outString.

Parameters:outString (String) – the string to write to the file
Returns:True/False if writing passes/fails + errors
Return type:bool
overWriteToFile(outString)

Completely overwrites file with new content from outString.

Parameters:outString (String) – the string to write to the file
Returns:True/False if writing passes/fails + errors
Return type:bool
peekFile(numLines)

Reads numLines from file and returns.

Parameters:numLines (int) – number of lines to read in from file
Returns:
  • bool – True/ False if read successful
  • [lines] – array of strings read in or [“Failed”]
readFullFile()

Reads the entire file into memory as a list of strings.

Returns:
  • bool – True/False if read passes/fails + errors
  • [lines] – array of strings read in or [“Failed”]
testFileIO(modeString)

Tests if file can be opened and closed.

Parameters:modeString (String) – mode with which to open file (“r,w,r+,a”)
Returns:True/False if test passes/fails + errors
Return type:bool