~therp-nl/anybox.recipe.openerp/jbaudoux-relative_paths_resolve_conflict

« back to all changes in this revision

Viewing changes to anybox/recipe/openerp/runtime/__init__.py

[MRG] Update with target branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""
 
2
Runtime
 
3
=======
 
4
 
 
5
This subpackage provides encapsulations and entry points for the application
 
6
itself:
 
7
 
 
8
* the ``session`` module features the supporting objects for "OpenERP scripts"
 
9
  and the dedicated python interpreter.
 
10
* the ``start_openerp`` and ``test_openerp`` modules are the entry points for
 
11
  the main startup scripts.
 
12
 
 
13
This architecture is meant in particular to provide stability and uniformity
 
14
accross OpenERP major versions, so that the recipe can be leveraged by
 
15
automated deploymnent tools and continuous integration systems.
 
16
"""
 
17
 
 
18
_imported_addons = set()
 
19
 
 
20
 
 
21
def already_imported(module_name):
 
22
    """Convenience to help some OpenERP modules to avoid been imported twice.
 
23
 
 
24
    Each call of this function returns a boolean indicated whether the
 
25
    specified module was already in the ``imported_addons`` registry and add it
 
26
    inconditionnally.
 
27
 
 
28
    Thus caller code is expected to import the module right away if the
 
29
    return value was False.
 
30
    """
 
31
    name = module_name.rsplit('.', 1)[-1]
 
32
    if name in _imported_addons:
 
33
        return True
 
34
    _imported_addons.add(name)
 
35
    return False
 
36
 
 
37
 
 
38
def clear_import_registry():
 
39
    _imported_addons.clear()