# HG changeset patch
# User Vincent Hatakeyama <vincent.hatakeyama@xcg-consulting.fr>
# Date 1571313123 -7200
#      Thu Oct 17 13:52:03 2019 +0200
# Node ID a44ec8c6a8f6d427f29c1b4e1c8f47f0f6cc4df8
# Parent  635c0ccad6dcee7aa4108b882e74876f59bf5d8a
🔨 split list_modules from docker_build_copy to be able to call it separately

diff --git a/docker_build_copy b/docker_build_copy
--- a/docker_build_copy
+++ b/docker_build_copy
@@ -19,12 +19,7 @@
 # Copy modules when specified
 if [[ -n "$odoo_modules" ]];
 then
-    if type "python3" > /dev/null;
-    then
-	python3 -B -c "import configparser ; c = configparser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print(','.join(c.get('odoo_scripts', 'module_list').split()))" > $project_home/odoo_modules_list
-    else
-	python2 -B -c "import ConfigParser ; c = ConfigParser.SafeConfigParser() ; c.read('${project_home}/setup.cfg') ; print(','.join(c.get('odoo_scripts', 'module_list').split()))" > $project_home/odoo_modules_list
-    fi
+    ${here}/list_modules
     mkdir -p $project_home/odoo_modules
     set -e
     rsync --delete -C --exclude='.hg*' --exclude='.git*' --links --exclude='*.pyc' -r --times $(eval echo $odoo_modules) $project_home/odoo_modules
diff --git a/docker_build_copy b/list_modules
copy from docker_build_copy
copy to list_modules
--- a/docker_build_copy
+++ b/list_modules
@@ -1,33 +1,16 @@
 #!/bin/zsh
+# TODO change to a pure python3 script installed with setup.py as an entrypoint
 # vim: set shiftwidth=4 softtabstop=4:
 
-# Create docker script (copy)
+# Create the file odoo_modules_list from setup.cfg
 
 # template version 2.7
 
-# TODO add a way to bypass the value, maybe with a key in the setup.cfg file
 here=$(dirname $0)
 project_home=$(cd $here && cd .. && echo $PWD)
-static_dir=$project_home/static/
 if type "python3" > /dev/null;
 then
-    odoo_modules="$(python3 -B -c "import configparser ; c = configparser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print (c.has_option('odoo_scripts', 'modules') and ' '.join(c.get('odoo_scripts', 'modules').split()) or '')")"
+    python3 -B -c "import configparser ; c = configparser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print(','.join(c.get('odoo_scripts', 'module_list').split()))" > $project_home/odoo_modules_list
 else
-    odoo_modules="$(python2 -B -c "import ConfigParser ; c = ConfigParser.SafeConfigParser() ; c.read('${project_home}/setup.cfg') ; print (c.has_option('odoo_scripts', 'modules') and ' '.join(c.get('odoo_scripts', 'modules').split()) or '')")"
+    python2 -B -c "import ConfigParser ; c = ConfigParser.SafeConfigParser() ; c.read('${project_home}/setup.cfg') ; print(','.join(c.get('odoo_scripts', 'module_list').split()))" > $project_home/odoo_modules_list
 fi
-
-# Copy modules when specified
-if [[ -n "$odoo_modules" ]];
-then
-    if type "python3" > /dev/null;
-    then
-	python3 -B -c "import configparser ; c = configparser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print(','.join(c.get('odoo_scripts', 'module_list').split()))" > $project_home/odoo_modules_list
-    else
-	python2 -B -c "import ConfigParser ; c = ConfigParser.SafeConfigParser() ; c.read('${project_home}/setup.cfg') ; print(','.join(c.get('odoo_scripts', 'module_list').split()))" > $project_home/odoo_modules_list
-    fi
-    mkdir -p $project_home/odoo_modules
-    set -e
-    rsync --delete -C --exclude='.hg*' --exclude='.git*' --links --exclude='*.pyc' -r --times $(eval echo $odoo_modules) $project_home/odoo_modules
-    # this only sync static from our modules
-    rsync --include='/*/static/***' --exclude='/*/*' -r --times --prune-empty-dirs $(eval echo $odoo_modules) $static_dir
-fi