ManifestCollection
The ManifestCollection class represents a collection of Odoo module manifests.
- class oduit.manifest_collection.ManifestCollection[source]
Bases:
objectRepresents a collection of Odoo module manifests.
- add(addon_name: str, manifest: Manifest) None[source]
Add a manifest to the collection.
- Parameters:
addon_name – Name of the addon
manifest – Manifest instance to add
- remove(addon_name: str) None[source]
Remove a manifest from the collection.
- Parameters:
addon_name – Name of the addon to remove
- Raises:
KeyError – If addon_name is not in the collection
- get(addon_name: str) Manifest | None[source]
Get a manifest by addon name.
- Parameters:
addon_name – Name of the addon
- Returns:
Manifest instance or None if not found
- __getitem__(addon_name: str) Manifest[source]
Get a manifest by addon name using dict-like access.
- Parameters:
addon_name – Name of the addon
- Returns:
Manifest instance
- Raises:
KeyError – If addon_name is not in the collection
- __contains__(addon_name: str) bool[source]
Check if an addon is in the collection.
- Parameters:
addon_name – Name of the addon to check
- Returns:
True if addon exists in collection, False otherwise
- __iter__() Iterator[str][source]
Iterate over addon names in the collection.
- Returns:
Iterator over addon names
- items() Iterator[tuple[str, Manifest]][source]
Get iterator over (addon_name, manifest) pairs.
- Returns:
Iterator of tuples containing addon name and Manifest
- values() Iterator[Manifest][source]
Get iterator over manifests.
- Returns:
Iterator over Manifest instances
- get_all_dependencies() set[str][source]
Get all unique codependencies across all manifests in the collection.
- Returns:
Set of all codependency names
- get_installable_addons() list[str][source]
Get list of all installable addon names.
- Returns:
List of addon names that are installable
- get_auto_install_addons() list[str][source]
Get list of all auto-install addon names.
- Returns:
List of addon names that are auto-installable
- filter_by_dependency(dependency_name: str) ManifestCollection[source]
Create a new collection with only addons that depend on a specific module.
- Parameters:
dependency_name – Name of the dependency to filter by
- Returns:
New ManifestCollection containing only matching addons
Class Reference
- class oduit.manifest_collection.ManifestCollection[source]
Bases:
objectRepresents a collection of Odoo module manifests.
- add(addon_name: str, manifest: Manifest) None[source]
Add a manifest to the collection.
- Parameters:
addon_name – Name of the addon
manifest – Manifest instance to add
- remove(addon_name: str) None[source]
Remove a manifest from the collection.
- Parameters:
addon_name – Name of the addon to remove
- Raises:
KeyError – If addon_name is not in the collection
- get(addon_name: str) Manifest | None[source]
Get a manifest by addon name.
- Parameters:
addon_name – Name of the addon
- Returns:
Manifest instance or None if not found
- __getitem__(addon_name: str) Manifest[source]
Get a manifest by addon name using dict-like access.
- Parameters:
addon_name – Name of the addon
- Returns:
Manifest instance
- Raises:
KeyError – If addon_name is not in the collection
- __contains__(addon_name: str) bool[source]
Check if an addon is in the collection.
- Parameters:
addon_name – Name of the addon to check
- Returns:
True if addon exists in collection, False otherwise
- __iter__() Iterator[str][source]
Iterate over addon names in the collection.
- Returns:
Iterator over addon names
- items() Iterator[tuple[str, Manifest]][source]
Get iterator over (addon_name, manifest) pairs.
- Returns:
Iterator of tuples containing addon name and Manifest
- values() Iterator[Manifest][source]
Get iterator over manifests.
- Returns:
Iterator over Manifest instances
- get_all_dependencies() set[str][source]
Get all unique codependencies across all manifests in the collection.
- Returns:
Set of all codependency names
- get_installable_addons() list[str][source]
Get list of all installable addon names.
- Returns:
List of addon names that are installable
- get_auto_install_addons() list[str][source]
Get list of all auto-install addon names.
- Returns:
List of addon names that are auto-installable
- filter_by_dependency(dependency_name: str) ManifestCollection[source]
Create a new collection with only addons that depend on a specific module.
- Parameters:
dependency_name – Name of the dependency to filter by
- Returns:
New ManifestCollection containing only matching addons
Usage Examples
Basic Collection Operations
from oduit.manifest_collection import ManifestCollection
from oduit.manifest import Manifest
# Create a collection
collection = ManifestCollection()
# Add manifests
manifest1 = Manifest('/path/to/module1')
manifest2 = Manifest('/path/to/module2')
collection.add('module1', manifest1)
collection.add('module2', manifest2)
# Check collection size
print(f"Collection has {len(collection)} modules")
# Check if module exists
if 'module1' in collection:
print("module1 is in collection")
Accessing Manifests
# Get a manifest
manifest = collection.get('module1')
if manifest:
print(f"Version: {manifest.version}")
# Using dict-like access
manifest = collection['module1']
# Iterate over module names
for module_name in collection:
print(f"Module: {module_name}")
# Iterate over items
for name, manifest in collection.items():
print(f"{name}: {manifest.version}")
Filtering and Analysis
# Get all dependencies
all_deps = collection.get_all_dependencies()
print(f"All dependencies: {all_deps}")
# Get installable addons
installable = collection.get_installable_addons()
print(f"Installable: {installable}")
# Get auto-install addons
auto_install = collection.get_auto_install_addons()
print(f"Auto-install: {auto_install}")
# Filter by dependency
sale_dependent = collection.filter_by_dependency('sale')
print(f"Modules depending on sale: {list(sale_dependent)}")
Validation
# Validate all manifests
issues = collection.validate_all()
if issues:
print("Validation issues found:")
for addon_name, warnings in issues.items():
print(f" {addon_name}:")
for warning in warnings:
print(f" - {warning}")
else:
print("All manifests are valid")
Collection Management
# Remove a manifest
collection.remove('module1')
# Clear all manifests
collection.clear()
# String representation
print(collection) # ManifestCollection(2 manifests)
print(repr(collection)) # ManifestCollection([module1, module2])