palgen.palgen#

Module Contents#

class palgen.palgen.Extensions(dict=None, /, **kwargs)#
palgen.palgen.Extensions _collections_abc.Collection _collections_abc.Collection _collections_abc.Container _collections_abc.Container _collections_abc.Collection->_collections_abc.Container _collections_abc.Iterable _collections_abc.Iterable _collections_abc.Collection->_collections_abc.Iterable _collections_abc.Sized _collections_abc.Sized _collections_abc.Collection->_collections_abc.Sized _collections_abc.Mapping _collections_abc.Mapping _collections_abc.Mapping->_collections_abc.Collection _collections_abc.MutableMapping _collections_abc.MutableMapping _collections_abc.MutableMapping->_collections_abc.Mapping collections.UserDict collections.UserDict collections.UserDict->_collections_abc.MutableMapping palgen.palgen.Extensions palgen.palgen.Extensions palgen.palgen.Extensions palgen.palgen.Extensions->collections.UserDict

A MutableMapping is a generic container for associating key/value pairs.

This class provides concrete generic implementations of all methods except for __getitem__, __setitem__, __delitem__, __iter__, and __len__.

property runnable: dict[str, palgen.loaders.ExtensionInfo]#

Get all runnable extensions. Runnable extensions are all private and public extensions, including inherited ones.

Returns:

A dictionary of runnable extensions

Return type:

dict[str, Type[Extension]]

property exportable: dict[str, palgen.loaders.ExtensionInfo]#

Get all exportable extensions. Exportable extensions are public extensions. Private and inherited ones are not exportable.

Returns:

A dictionary of exportable extensions

Return type:

dict[str, Type[Extension]]

property builtin: dict[str, palgen.loaders.ExtensionInfo]#

Get all built-in extensions.

Returns:

A dictionary of built-in extensions.

Return type:

dict[str, ExtensionInfo]

property private: dict[str, palgen.loaders.ExtensionInfo]#

Get all private extensions.

Private extensions are not accessible externally and are not inherited.

Returns:

A dictionary of private extensions.

Return type:

dict[str, ExtensionInfo]

property inherited: dict[str, palgen.loaders.ExtensionInfo]#

Get all inherited extensions.

Inherited extensions are those inherited from parent classes.

Returns:

A dictionary of inherited extensions.

Return type:

dict[str, ExtensionInfo]

property local: dict[str, palgen.loaders.ExtensionInfo]#

Get all local extensions.

Local extensions are those defined in the current project, excluding inherited and built-in ones.

Returns:

A dictionary of local extensions.

Return type:

dict[str, ExtensionInfo]

__slots__ = ()#
__abc_tpflags__#
__reversed__#
__class_getitem__#
extend(loader, paths, inherited=False)#
Parameters:
  • loader (palgen.loaders.Loader) –

  • paths (Iterable[pathlib.Path | str]) –

  • inherited (bool) –

manifest(relative_to=None)#

Returns exportable extensions and their file paths as TOML-formatted string.

Returns:

TOML representation of exportable extensions.

Return type:

str

Parameters:

relative_to (Optional[pathlib.Path]) –

__len__()#
__getitem__(key)#
__setitem__(key, item)#
__delitem__(key)#
__iter__()#
__contains__(key)#
__repr__()#

Return repr(self).

__or__(other)#
__ror__(other)#
__ior__(other)#
__copy__()#
copy()#
classmethod fromkeys(iterable, value=None)#
pop(key, default=__marker)#

D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()#

D.popitem() -> (k, v), remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty.

clear()#

D.clear() -> None. Remove all items from D.

update(other=(), /, **kwds)#

D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

setdefault(key, default=None)#

D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D

get(key, default=None)#

D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.

keys()#

D.keys() -> a set-like object providing a view on D’s keys

items()#

D.items() -> a set-like object providing a view on D’s items

values()#

D.values() -> an object providing a view on D’s values

__eq__(other)#

Return self==value.

classmethod __subclasshook__(C)#

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

class palgen.palgen.Palgen(config_file, settings=None)#
palgen.palgen.Palgen palgen.palgen.Palgen palgen.palgen.Palgen palgen.palgen.Palgen pathlib.Path pathlib.Path pathlib.Path->palgen.palgen.Palgen config_path pathlib.Path->palgen.palgen.Palgen root pathlib.PurePath pathlib.PurePath pathlib.Path->pathlib.PurePath

Palgen application. Loads and verifies config_file

Parameters:
  • config_file (str | Path) – Project configuration file

  • settings (Optional[palgen.schemas.PalgenSettings]) –

Raises:
  • ValidationError – Incorrect or missing project configuration

  • FileNotFoundError – Config file does not exist

__slots__ = ('__dict__', 'config_path', 'root', 'settings', 'project', 'options', 'output_path')#
files()#

List of all input files. This is pre-filtered to exclude everything ignored through .gitignore files.

First access to this can be slow, since it has to walk the entire source tree once. After that it’ll be in cache.

Returns:

input files

Return type:

list[Path]

extensions()#

Discovered extensions.

First access to this can be slow, since it has to actually load the extensions.

Return type:

Extensions

get_command(command)#
Parameters:

command (str | palgen.loaders.ExtensionInfo) –

Return type:

Optional[click.Group | click.Command]

run(name, settings)#

Runs the specified extension with the given settings.

Parameters:
  • name (str) – The name of the extension to run.

  • settings (dict) – A dictionary of settings to use when running the extension.

Raises:

SystemExit – Terminates if running the extension threw any uncaught exceptions.

Returns:

Files generated by the extension.

Return type:

list[Path]

run_all()#

Runs all extensions enabled in the settings.

This method will try running all extensions enabled in the palgen.toml settings file. If a extension is not found or isn’t runnable it will be skipped.

Return type:

None

__eq__(other)#

Return self==value.

Return type:

bool