Pyjo.Home - Home sweet home

from Pyjo.Home import Home

# Find and manage the project root directory
home = Home()
home.detect()
print(home.child('templates', 'layouts', 'default.html.ep'))
print(f'{home}')

# Or import the module, as in Google Python Style Guide

import Pyjo.Home

# Find and manage the project root directory
home = Pyjo.Home.new()
home.detect()
print(home.child('templates', 'layouts', 'default.html.ep'))
print(f'{home}')

Pyjo.Home is a container for home directories based on Pyjo.File.

See also

Pyjoyment, https://mojolicious.org.

Ported from Mojo::Home of Mojolicious 9.49.

class Pyjo.Home.Pyjo_Home(*parts: Anything)[source]

Pyjo.Home inherits all methods from Pyjo.File and implements the following new ones.

detect(cls: type | ModuleType | str | None = None) → Self[source]
home = home.detect()
home = home.detect(MyApp)
home = home.detect('My.App')

Detect home directory from the value of the PYJO_HOME environment variable or the location of the application class: a class, its module, or the dotted name of a module that is loaded. The directory of the module’s file, less the parts of the name of the module and a lib, blib/lib or src directory, is the home.

rel_file(path: str) → Self[source]
path = home.rel_file('foo/bar.html')

Return a new Pyjo.Home object relative to the home directory.