pyiron_base.jobs.job.extension.files module

class pyiron_base.jobs.job.extension.files.File(path)

Bases: object

list(lines: int | None = None)

Return file content as list of lines.

Parameters:

lines (int) – only return the first lines lines

Returns:

file content

Return type:

list of str

tail(lines: int = 100)

Print the last lines to stdout.

Parameters:

lines (int) – number of output lines

class pyiron_base.jobs.job.extension.files.FileBrowser(working_directory)

Bases: object

Allows to browse the files in a job directory.

By default this object prints itself as a listing of the job directory and the files inside.

>>> job.files
/path/to/my/job:
    pyiron.log
    error.out

Access to the names of files is provided with list()

>>> job.files.list()
['pyiron.log', 'error.out', 'INCAR']

Access to the contents of files is provided by indexing into this object, which returns a list of lines in the file

>>> job.files['error.out']
["Oh no

“, “Something went wrong! “]

The tail() method prints the last lines of a file to stdout

>>> job.files.tail('error.out', lines=1)
Something went wrong!

For files that have valid python variable names can also be accessed by attribute notation

>>> job.files.INCAR 
File('INCAR')
list() List[str]

List all files in the working directory of the job.

tail(file: str, lines: int = 100)

Print the last lines of a file.

Parameters:
  • file (str) – filename

  • lines (int) – number of lines to print

Raises:

FileNotFoundError – if the given file does not exist