ManifestCollection

The ManifestCollection class represents a collection of Odoo module manifests.

class oduit.manifest_collection.ManifestCollection[source]

Bases: object

Represents a collection of Odoo module manifests.

__init__() None[source]

Initialize an empty ManifestCollection.

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

__len__() int[source]

Get the number of manifests in the collection.

Returns:

Number of manifests

__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

keys() Iterator[str][source]

Get iterator over addon names.

Returns:

Iterator over addon names

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

validate_all() dict[str, list[str]][source]

Validate all manifests in the collection.

Returns:

Dictionary mapping addon names to lists of validation warnings (only includes addons with warnings)

clear() None[source]

Remove all manifests from the collection.

__str__() str[source]

String representation of the collection.

__repr__() str[source]

Developer representation of the collection.

Class Reference

class oduit.manifest_collection.ManifestCollection[source]

Bases: object

Represents a collection of Odoo module manifests.

__init__() None[source]

Initialize an empty ManifestCollection.

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

__len__() int[source]

Get the number of manifests in the collection.

Returns:

Number of manifests

__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

keys() Iterator[str][source]

Get iterator over addon names.

Returns:

Iterator over addon names

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

validate_all() dict[str, list[str]][source]

Validate all manifests in the collection.

Returns:

Dictionary mapping addon names to lists of validation warnings (only includes addons with warnings)

clear() None[source]

Remove all manifests from the collection.

__str__() str[source]

String representation of the collection.

__repr__() str[source]

Developer representation of the collection.

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])