Application storage#
- class project_composer.app_storage.AppNode(name, push_end=False)[source]#
Bases:
object
Class to store application payload as an object.
- Parameters:
name (string) – The application module name.
- Keyword Arguments:
push_end (boolean) – Application parameter to describe that it should be pushed to end of the ordered application list.
- name#
The application name comes from its directory name in application repository.
- Type:
string
- dependencies#
List of AppNode objects. Only filled once
AppStore
resolving has been done.- Type:
list
- dependency_names#
List of string names. It is mostly used in
AppStore
preparation until it has done resolving.- Type:
list
- push_end#
“Push end” mode value.
- Type:
boolean
- add_dependency(node)[source]#
Add a dependency object to the object registry
AppNode.dependencies
.A dependency which already exists in registry is not added twice.
- Parameters:
node (AppNode) – Dependency object to add.
- add_dependency_name(name)[source]#
Add a dependency name to the name registry
AppNode.dependency_names
.A dependency name which already exists in registry is not added twice.
- Parameters:
node (string) – Dependency name to add.
- to_dict(flat=False)[source]#
Serialize the object attribute as a dictionnary.
- Keyword Arguments:
flat (boolean) – If set to True, the dependencies are returned as a list of names (string) instead of AppNode objects.
- Returns:
Application payload including dependencies as
AppNode
objects.- Return type:
dict
- class project_composer.app_storage.AppStore(default_app=None)[source]#
Bases:
object
Store a collection of applications and manage their dependencies.
Application collection is a list of dictionnaries with the following structure:
[ { "name": String, "push_end": Boolean, "dependencies": List[String..] }, ]
Internally, every application are stored as an
AppNode
object.- Keyword Arguments:
default_app (string) – Application name to attach as dependencies for applications that don’t have any dependency. The name must exists in given collection. By default no default dependency is applied.
- default_app#
The value of
default_app
argument.- Type:
string
- processed_apps#
Internal list of processed applications (translated to AppNode) filled by
AppStore.process_collection()
.- Type:
list
- get_app(name, default=None)[source]#
Get an app object from processed app list.
- Parameters:
name (string) – The name to get from processed applications.
- Keyword Arguments:
default (object) – Default value to use when given name is not retrieved from processed applications.
- Returns:
Application object.
- Return type:
- process_collection(collection)[source]#
Correctly store a collection of apps.
This must be called before “resolve” since it register app nodes before linking their node dependencies.
Also this is linear workflow only, at this point the list is not safe for circular references.
- Parameters:
collection (list) – List of application datas. Each app data must have a non empty
name
item. Also accept an optional itemdependencies
which is a list of dependency names and an optionalpush_end
item.
- dependency_resolver(node, resolved, unresolved)[source]#
Recursive dependency resolver.
This follow application dependencies to position them in the resolved list such a dependency is always after the application which require it.
- Parameters:
node (AppNode) – Application object to walk in.
resolved (list) – List of resolved application objects. Updated during resolving. This is commonly the value you will use to get the resolved and ordered applications.
unresolved (list) – List of unresolved application objects. Updated during resolving.
- resolve(collection, flat=False, no_ordering=False)[source]#
Resolve app list in order of app dependencies such as an app is always after all its dependencies.
- Parameters:
collection (list) – List of application payloads to work on.
- Keyword Arguments:
flat (boolean) – If True, returned list will be AppNode payload. Default to False.
no_ordering (boolean) – If
True
theAppStore.resolve()
directly return the AppNode list with original order from collection. There won’t be any resolution. Default isFalse
.
- Returns:
List of AppNode object or payload (dict) respectively depending flat mode is False or True.
- Return type:
list