|
@@ -0,0 +1,69 @@
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
+from __future__ import unicode_literals
|
|
|
+from django.conf import settings
|
|
|
+from api.utils.command import list_files_and_folders
|
|
|
+from git.repo.base import Repo
|
|
|
+from git.repo.fun import is_git_dir
|
|
|
+from git.util import join_path
|
|
|
+
|
|
|
+'''
|
|
|
+'''
|
|
|
+def get_users_folders():
|
|
|
+ fullpath = join_path(settings.GIT_PATH)
|
|
|
+ folders = list_files_and_folders(fullpath)
|
|
|
+
|
|
|
+ return folders.get('items', [])
|
|
|
+
|
|
|
+'''
|
|
|
+'''
|
|
|
+def get_repos_paths():
|
|
|
+ users_folders = get_users_folders()
|
|
|
+ repos = []
|
|
|
+
|
|
|
+ for folder in users_folders:
|
|
|
+ fullpath = join_path(settings.GIT_PATH, folder)
|
|
|
+ subfolders = list_files_and_folders(fullpath)
|
|
|
+
|
|
|
+ for subfolder in subfolders.get('items', []):
|
|
|
+ fullpath = join_path(settings.GIT_PATH, folder, subfolder)
|
|
|
+
|
|
|
+ if not is_git_dir(fullpath):
|
|
|
+ continue
|
|
|
+
|
|
|
+ repos.append(fullpath)
|
|
|
+
|
|
|
+ return repos
|
|
|
+
|
|
|
+'''
|
|
|
+'''
|
|
|
+def get_odoo_modules_repos_paths():
|
|
|
+ repos_paths = get_repos_paths()
|
|
|
+ modules_paths = []
|
|
|
+
|
|
|
+ for repo_path in repos_paths:
|
|
|
+ r = Repo(repo_path)
|
|
|
+
|
|
|
+ try:
|
|
|
+ if '__openerp__.py' in [o.path for o in r.tree()]:
|
|
|
+ modules_paths.append(repo_path)
|
|
|
+ except ValueError:
|
|
|
+ continue
|
|
|
+ finally:
|
|
|
+ r.close()
|
|
|
+
|
|
|
+ return modules_paths
|
|
|
+
|
|
|
+'''
|
|
|
+'''
|
|
|
+def get_odoo_modules_repos_names(include_owners=False):
|
|
|
+ repos_paths = get_odoo_modules_repos_paths()
|
|
|
+ repos_names = []
|
|
|
+
|
|
|
+ for repos_path in repos_paths:
|
|
|
+ last_slash_index = repos_path.rindex('/')
|
|
|
+ last_dot_index = repos_path.rindex('.')
|
|
|
+
|
|
|
+ name = repos_path[last_slash_index + 1:last_dot_index]
|
|
|
+ repos_names.append(name)
|
|
|
+
|
|
|
+ return repos_names
|