Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
0e011648
Commit
0e011648
authored
10 years ago
by
Fabien Meghazi
Browse files
Options
Downloads
Patches
Plain Diff
Moved get_module_root in openerp.modules.module
parent
5f717cfd
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
openerp/cli/scaffold.py
+1
-16
1 addition, 16 deletions
openerp/cli/scaffold.py
openerp/modules/module.py
+32
-3
32 additions, 3 deletions
openerp/modules/module.py
with
33 additions
and
19 deletions
openerp/cli/scaffold.py
+
1
−
16
View file @
0e011648
...
...
@@ -11,6 +11,7 @@ import sys
import
jinja2
from
.
import
Command
from
openerp.modules.module
import
get_module_root
MANIFEST
=
'
__openerp__
'
...
...
@@ -181,22 +182,6 @@ def directory(p, create=False):
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
)
This diff is collapsed.
Click to expand it.
openerp/modules/module.py
+
32
−
3
View file @
0e011648
...
...
@@ -37,6 +37,8 @@ import openerp.tools as tools
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
...
...
@@ -169,6 +171,33 @@ def get_module_icon(module):
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, ...)
...
...
@@ -177,7 +206,7 @@ def load_information_from_description_file(module, mod_path=None):
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
):
...
...
@@ -219,7 +248,7 @@ def load_information_from_description_file(module, mod_path=None):
#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
):
...
...
@@ -291,7 +320,7 @@ def get_modules():
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
)))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment