Writer

class simframe.io.Writer(func, datadir='data', filename='data', zfill=4, extension='out', overwrite=False, dumping=True, reader=None, verbosity=1, description='', options={})[source]

Bases: object

General class for writing output files. It should be used as wrapper for customized Writer.

Attributes
datadir

Data directory of output files.

description

Description of Writer.

dumping

If True dump files will be written.

extension

Filename extension of output files.

filename

Base filename of output files.

options

Dictionary of keyword arguments passed to customized writing routine.

overwrite

If True existing output files will be overwritten.

read

Reader object for reading output files.

verbosity

Verbosity of the writer.

zfill

Zero padding of numbered files names.

Methods

checkdatadir([datadir, createdir])

Function checks if data directory exists and creates it if necessary.

write(owner, i, forceoverwrite[, filename])

Writes output to file

writedump(frame[, filename])

Writes the Frame to dump file

Attributes Summary

datadir

Data directory of output files.

description

Description of Writer.

dumping

If True dump files will be written.

extension

Filename extension of output files.

filename

Base filename of output files.

options

Dictionary of keyword arguments passed to customized writing routine.

overwrite

If True existing output files will be overwritten.

read

Reader object for reading output files.

verbosity

Verbosity of the writer.

zfill

Zero padding of numbered files names.

Methods Summary

checkdatadir([datadir, createdir])

Function checks if data directory exists and creates it if necessary.

write(owner, i, forceoverwrite[, filename])

Writes output to file

writedump(frame[, filename])

Writes the Frame to dump file

Attributes Documentation

datadir

Data directory of output files.

description

Description of Writer.

dumping

If True dump files will be written.

extension

Filename extension of output files.

filename

Base filename of output files.

options

Dictionary of keyword arguments passed to customized writing routine.

overwrite

If True existing output files will be overwritten.

read

Reader object for reading output files.

verbosity

Verbosity of the writer.

zfill

Zero padding of numbered files names.

Methods Documentation

checkdatadir(datadir=None, createdir=False)[source]

Function checks if data directory exists and creates it if necessary.

Parameters
  • datadir (string or None, optinal, default : None) – Data directory to be checked. If None it assumes the data directory of the parent writer.

  • createdir (boolen, optional, default : False) – If True function creates data directory if it does not exist.

Returns

datadirexists – True if directory exists, False if not

Return type

boolean

write(owner, i, forceoverwrite, filename='')[source]

Writes output to file

Parameters
  • owner (Frame) – Parent Frame object

  • i (int) – Number of output

  • forceoverwrite (boolean) – If True it will forces and overwrite of the file if it exists.

  • filename (string) – If this is not “” the writer will use this filename instead of the standard scheme

writedump(frame, filename='')[source]

Writes the Frame to dump file

Parameters
  • frame (object) – object to be written to file

  • filename (str, optional, default : "") – path to file to be written if not set, filename will be <writer.datadir>/frame.dmp.