pyiron_base.jobs.job.extension.files.FileBrowser

pyiron_base.jobs.job.extension.files.FileBrowser#

class pyiron_base.jobs.job.extension.files.FileBrowser(working_directory: str)[source]#

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')
__init__(working_directory: str)[source]#

Methods

__init__(working_directory)

list()

List all files in the working directory of the job.

tail(file[, lines])

Print the last lines of a file.

list() List[str][source]#

List all files in the working directory of the job.

tail(file: str, lines: int = 100) None[source]#

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