pyiron_base.project.path.ProjectPath#

class pyiron_base.project.path.ProjectPath(path)[source]#

Bases: GenericPath

__init__(path)[source]#

Open a new or an existing project. The project is defined by providing a relative or an absolute path. If no path is provided the current working directory is used. This is the main class to walk inside the project structure, create new jobs, subprojects etc. Note: Changing the path has no effect on the current working directory

Parameters:

path (GenericPath, str) – path of the project defined by GenericPath, absolute or relative (with respect to current working directory) path

root_path#
the pyiron user directory, defined in the .pyiron configuration
project_path#
the relative path of the current project / folder starting from the root path
of the pyiron user directory
path#
the absolute path of the current project / folder
base_name#
the name of the current project / folder
history#
previously opened projects / folders

Methods

__init__(path)

Open a new or an existing project.

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

listdir()

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

open(rel_path[, history])

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

removedirs([project_name])

equivalent to os.removedirs -> remove empty dirs

walk()

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

Attributes

base_name

The name of the current project folder

history

The history of the previously opened paths

path

The absolute path to of the current object.

project_path

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

root_path

the pyiron user directory, defined in the .pyiron configuration

property base_name: str#

The name of the current project folder

Returns:

name of the current project folder

Return type:

str

close() None[source]#

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

copy() ProjectPath[source]#

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

Return type:

ProjectPath

property history: list#

The history of the previously opened paths

Returns:

list of previously opened relative paths

Return type:

list

listdir() list[source]#

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: str, history: bool = True) ProjectPath[source]#

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

property path: str#

The absolute path to of the current object.

Returns:

current project path

Return type:

str

property project_path: str#

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

removedirs(project_name: str | None = None)[source]#

equivalent to os.removedirs -> remove empty dirs

Parameters:

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

property root_path: str#

the pyiron user directory, defined in the .pyiron configuration

Returns:

pyiron user directory of the current project

Return type:

str

walk() Iterator[tuple[str, list[str], list[str]]][source]#

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

Returns:

Directory tree generator.

Return type:

Generator