ape.parts.storage.base_storage.BaseStorage

class ape.parts.storage.base_storage.BaseStorage

A base-class based on file-objects

BaseStorage Constructor

__init__()

BaseStorage Constructor

Methods

__init__() BaseStorage Constructor
close() Closes self.file if it exists, sets self.closed to True
log_error(error[, message]) Logs the error in bold red
open(name) Opens a file for writing
write(text[, exceptions]) Writes the text to the file
writeline(text) Adds newline to end of text and writes it to the file
writelines(texts[, exceptions]) Writes the lines to the file

Attributes

file The open file object
logger
return:A logging object.
close()

Closes self.file if it exists, sets self.closed to True

log_error(error, message='')

Logs the error in bold red

Param:
  • error: error type (prefix in red and bold)
  • message: descriptive message (red but not bold)
open(name)

Opens a file for writing

Param:
  • name: a basename (no path) for the file
Returns:

copy of self with file as open file and closed set to False

write(text, exceptions=(<type 'exceptions.AttributeError'>, <type 'exceptions.ValueError'>))

Writes the text to the file

Param:
  • text: text to write to the file
  • exceptions: exceptions to catch if the file is closed
Raise:

ApeError if one of the exceptions is raised

writeline(text)

Adds newline to end of text and writes it to the file

writelines(texts, exceptions=(<type 'exceptions.AttributeError'>, <type 'exceptions.ValueError'>))

Writes the lines to the file

Param:
  • texts: collection of strings
  • exceptions: exceptions to catch if the file is closed
file

The open file object

logger
Returns:A logging object.

Navigation