cctk.File

class cctk.File[source]

Bases: abc.ABC

Abstract class representing text files.

abstract __init__()[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__()

Initialize self.

append_to_file(filename, text)

Appends output text to a file.

read_file(filename[, lazy])

Reads a file and parses into lines.

write_file(filename, text[, overwrite_existing])

Writes output text to a file.

static append_to_file(filename, text)[source]

Appends output text to a file.

Parameters
  • filename (str) – path to file, including name (e.g. path/to/input.gjf)

  • text (str) – desired contents of file

Returns

True if write succeeded, False otherwise

static read_file(filename, lazy=False)[source]

Reads a file and parses into lines.

Parameters

filename (str) – The path to the file.

Returns

A list containing all the lines in the file.

static write_file(filename, text, overwrite_existing=True)[source]

Writes output text to a file.

Parameters
  • filename (str) – path to file, including name (e.g. path/to/input.gjf)

  • text (str) – desired contents of file

  • overwrite_existing (Bool) – whether any existing files should be overwritten or not

Returns

True if write succeeded, False otherwise