import jinja2
from . import Command
+from openerp.modules.module import get_module_root
MANIFEST = '__openerp__'
die("%s exists but is not a directory" % p)
return expanded
-def get_module_root(path):
- """
- Get closest module's root begining from path
-
- @param path: Path from which the lookup should start
-
- @return: Module root path
- """
- # find the module's root directory
- while not os.path.exists(os.path.join(path, '%s.py' % MANIFEST)):
- new_path = os.path.abspath(os.path.join(path, os.pardir))
- if path == new_path:
- return None
- path = new_path
- return path
-
def die(message, code=1):
print >>sys.stderr, message
sys.exit(code)
import openerp.release as release
from openerp.tools.safe_eval import safe_eval as eval
+MANIFEST = '__openerp__.py'
+
_logger = logging.getLogger(__name__)
# addons path as a list
return ('/' + module + '/') + '/'.join(iconpath)
return '/base/' + '/'.join(iconpath)
+def get_module_root(path):
+ """
+ Get closest module's root begining from path
+
+ # Given:
+ # /foo/bar/module_dir/static/src/...
+
+ get_module_root('/foo/bar/module_dir/static/')
+ # returns '/foo/bar/module_dir'
+
+ get_module_root('/foo/bar/module_dir/')
+ # returns '/foo/bar/module_dir'
+
+ get_module_root('/foo/bar')
+ # returns None
+
+ @param path: Path from which the lookup should start
+
+ @return: Module root path or None if not found
+ """
+ while not os.path.exists(os.path.join(path, MANIFEST)):
+ new_path = os.path.abspath(os.path.join(path, os.pardir))
+ if path == new_path:
+ return None
+ path = new_path
+ return path
+
def load_information_from_description_file(module, mod_path=None):
"""
:param module: The name of the module (sale, purchase, ...)
if not mod_path:
mod_path = get_module_path(module)
- terp_file = mod_path and opj(mod_path, '__openerp__.py') or False
+ terp_file = mod_path and opj(mod_path, MANIFEST) or False
if terp_file:
info = {}
if os.path.isfile(terp_file):
#TODO: refactor the logger in this file to follow the logging guidelines
# for 6.0
- _logger.debug('module %s: no __openerp__.py file found.', module)
+ _logger.debug('module %s: no %s file found.', module, MANIFEST)
return {}
def init_module_models(cr, module_name, obj_list):
return name
def is_really_module(name):
- manifest_name = opj(dir, name, '__openerp__.py')
+ manifest_name = opj(dir, name, MANIFEST)
zipfile_name = opj(dir, name)
return os.path.isfile(manifest_name)
return map(clean, filter(is_really_module, os.listdir(dir)))