pyiron.base.project.path module¶

class pyiron.base.project.path.GenericPath(root_path, project_path)[source]

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()[source]

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)[source]
close()[source]

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

copy()[source]

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

Returns

Return type

ProjectPath

property history

The history of the previously opened paths

Returns

list of previously opened relative paths

Return type

list

listdir()[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, history=True)[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

removedirs(project_name=None)[source]

equivalent to os.removedirs -> remove empty dirs

Parameters

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

walk()[source]

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

Returns

Directory tree generator.

Return type

Generator