pyiron_base.project.path module

Classes for representing the file system path in pyiron

class pyiron_base.project.path.GenericPath(root_path, project_path)

Bases: object

Basic class to represent a project path in PyIron. A path consists of two parts, the root part which defines directory path where the project repository is located (top_level_path) and the project part which defines the relative path from the root_path to the project.

This class is meant for storing and accessing a path, not for moving around which is done by the ProjectPath class.

Parameters:
  • root_path (str) – absolute path name of the repository

  • project_path (str) – relative path to the specific project

.. attribute:: root_path

the pyiron user directory, defined in the .pyiron configuration

.. attribute:: project_path

the relative path of the current project / folder starting from the root path of the pyiron user directory

.. attribute:: path

the absolute path of the current project / folder

.. attribute:: base_name

the name of the current project / folder

Author: Jan Janssen

property base_name

The name of the current project folder

Returns:

name of the current project folder

Return type:

str

copy()

Copy the GenericPath object

Returns:

independent GenericPath object pointing to the same project folder

Return type:

GenericPath

property path

The absolute path to of the current object.

Returns:

current project path

Return type:

str

property project_path

the relative path of the current project / folder starting from the root path of the pyiron user directory

Returns:

relative path of the current project / folder

Return type:

str

property root_path

the pyiron user directory, defined in the .pyiron configuration

Returns:

pyiron user directory of the current project

Return type:

str

class pyiron_base.project.path.ProjectPath(path)

Bases: GenericPath

close()

return to the path before the last open if no history exists nothing happens

copy()

copy the path without the history, i.e., to going back with close is not possible

Return type:

ProjectPath

property history

The history of the previously opened paths

Returns:

list of previously opened relative paths

Return type:

list

listdir()

equivalent to os.listdir list all files and directories in this path

Returns:

list of folders and files in the current project path

Return type:

list

open(rel_path, history=True)

if rel_path exist set the project path to this directory if not create it and go there

Parameters:
  • rel_path (str) – path relative to the current project path

  • history (bool) – By default pyiron stores a history of previously opened paths

Returns:

New ProjectPath object pointing to the relative path

Return type:

ProjectPath

removedirs(project_name=None)

equivalent to os.removedirs -> remove empty dirs

Parameters:

project_name (str) – relative path to the project folder to be deleted

walk()

equivalent to os.listdir list all files and directories in this path

Returns:

Directory tree generator.

Return type:

Generator