mirror of
https://github.com/kiviktnm/decman.git
synced 2026-09-19 12:08:28 +00:00
decman.modules should be a list
This commit is contained in:
+5
-3
@@ -7,6 +7,8 @@ This contains the documentation for decman. Each plugin has its own documentatio
|
||||
- [aur](/docs/aur.md)
|
||||
- [flatpak](/docs/flatpak.md)
|
||||
|
||||
Check out [extras](docs/extras.md) for documentation for built-in modules.
|
||||
|
||||
## Quick notes
|
||||
|
||||
"Decman source" or "source" refers to your system configuration. It is set using the `--source` command line argument with decman.
|
||||
@@ -210,11 +212,11 @@ A **Module** is the primary unit for grouping related files, directories, packag
|
||||
|
||||
Each module is uniquely identified by its `name`.
|
||||
|
||||
Remember to add modules to decman.
|
||||
Remember to add modules to decman. Modules are added to a list to preserve deterministic execution order for hooks.
|
||||
|
||||
```py
|
||||
import decman
|
||||
decman.modules |= {MyModule()}
|
||||
decman.modules += [MyModule()]
|
||||
```
|
||||
|
||||
### Basic Structure
|
||||
@@ -418,7 +420,7 @@ This method only gathers information. It doesn't apply it.
|
||||
```py
|
||||
from decman import Store, Module
|
||||
|
||||
def process_modules(self, store: Store, modules: set[Module]):
|
||||
def process_modules(self, store: Store, modules: list[Module]):
|
||||
...
|
||||
|
||||
# Toy example for setting modules as changed
|
||||
|
||||
@@ -79,6 +79,11 @@ class MyModule(decman.Module):
|
||||
|
||||
If these sets change, this plugin will flag the module as changed. The module's `on_change` method will be executed.
|
||||
|
||||
## Keys used in the decman store
|
||||
|
||||
- `aur_packages_for_module`
|
||||
- `custom_packages_for_module`
|
||||
|
||||
## Configuration
|
||||
|
||||
This module has partially the same configuration with pacman. You'll have to define pacman output keywords and database options again.
|
||||
|
||||
@@ -47,6 +47,11 @@ class MyModule(decman.Module):
|
||||
|
||||
If packages or user packages change, this plugin will flag the module as changed. The module's `on_change` method will be executed.
|
||||
|
||||
## Keys used in the decman store
|
||||
|
||||
- `flatpaks_for_module`
|
||||
- `user_flatpaks_for_module`
|
||||
|
||||
## Configuration
|
||||
|
||||
It's possible to override the commands this plugin uses. Create your own `FlatpakCommands` class and override methods returning commands. These are the defaults.
|
||||
|
||||
@@ -232,8 +232,6 @@ class MyModule(Module):
|
||||
|
||||
#### New
|
||||
|
||||
`decman.modules` is now a set instead of a list. If you wish to have multiple instances of the same module class, just name them differently. Name needs to be unique accross modules.
|
||||
|
||||
Modules no longer have `version`s or `enabled` values. A module is enabled when it gets added to `decman.modules` and disabled when it gets removed from `decman.modules`. Versions are no longer needed because `after_version_change` has been removed and `on_change` has been added. `on_change` is executed automatically after the content of the module changes. `on_disable` will be executed automatically when the module is removed from `decman.modules`. It is no longer a instance method. Instead it must be a self-contained method with no references outside it. Not even imports.
|
||||
|
||||
Module methods will get a `Store` instance passed to them as an argument. It can be used to store key-value pairs between decman runs.
|
||||
@@ -245,7 +243,7 @@ import decman
|
||||
from decman import Module, Store, prg, sh
|
||||
from decman.plugins import pacman, aur, systemd, flatpak
|
||||
|
||||
decman.modules |= {MyModule()}
|
||||
decman.modules += [MyModule()]
|
||||
|
||||
class MyModule(Module):
|
||||
def __init__(self):
|
||||
|
||||
@@ -42,6 +42,10 @@ class MyModule(decman.Module):
|
||||
|
||||
If this set changes, this plugin will flag the module as changed. The module's `on_change` method will be executed.
|
||||
|
||||
## Keys used in the decman store
|
||||
|
||||
- `packages_for_module`
|
||||
|
||||
## Configuration
|
||||
|
||||
This plugin has a pacman output highlight function. If pacman output contains some keywords, it will be highlighted. You can disable this feature or set the keywords.
|
||||
|
||||
@@ -45,6 +45,11 @@ class MyModule(decman.Module):
|
||||
|
||||
If units or user units change, this plugin will flag the module as changed. The module's `on_change` method will be executed.
|
||||
|
||||
## Keys used in the decman store
|
||||
|
||||
- `systemd_units_for_module`
|
||||
- `systemd_user_units_for_module`
|
||||
|
||||
## Configuration
|
||||
|
||||
It's possible to override the commands this plugin uses. Create your own `SystemdCommands` class and override methods returning commands. These are the defaults.
|
||||
|
||||
Reference in New Issue
Block a user