# HG changeset patch
# User Vincent Hatakeyama <vincent.hatakeyama@xcg-consulting.fr>
# Date 1650533069 -7200
#      Thu Apr 21 11:24:29 2022 +0200
# Node ID a982f5cd6ecb55dde18a81d43c0f6fa519b36bb4
# Parent  fcec01f8b0e2a99811e91e3b9557d85644a1c7af
✨ Also mount songs when running pylint with docker_pylint

diff --git a/NEWS.rst b/NEWS.rst
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -2,6 +2,11 @@
 History
 =======
 
+16.3.0
+------
+
+Also mount songs when running pylint with ``docker_pylint``.
+
 16.2.0
 ------
 
diff --git a/odoo_scripts/docker_client.py b/odoo_scripts/docker_client.py
--- a/odoo_scripts/docker_client.py
+++ b/odoo_scripts/docker_client.py
@@ -1,4 +1,4 @@
-"""Class that encapsulate the docker client"""
+"""Class that encapsulate the docker client and provide common methods"""
 import atexit
 import logging
 import os
@@ -202,3 +202,24 @@
         mount_dict[full_target_path] = full_project_path
 
     return mount_list, mount_dict
+
+
+def anthem_mounts(project_path: str, pythons: tuple[str]) -> List[Mount]:
+    """Return a list of monts for all the anthem songs present in the super project."""
+    mounts: List[Mount] = []
+    # also mount songs for anthem to avoid having to rebuild the image when they
+    # are changed.
+    if os.path.exists("songs"):
+        for root, dirs, _files in os.walk("songs"):
+            for directory in dirs:
+                # with older odoo this will not be set
+                for python in pythons:
+                    mounts.append(
+                        Mount(
+                            f"/usr/local/lib/{python}/dist-packages/{root}/{directory}",
+                            os.path.join(project_path, root, directory),
+                            "bind",
+                            read_only=True,
+                        )
+                    )
+    return mounts
diff --git a/odoo_scripts/docker_dev_start.py b/odoo_scripts/docker_dev_start.py
--- a/odoo_scripts/docker_dev_start.py
+++ b/odoo_scripts/docker_dev_start.py
@@ -28,7 +28,7 @@
     Config,
 )
 from .docker_build import add_build_options, build_local_image, get_build_options
-from .docker_client import DockerClient, modules_mount
+from .docker_client import DockerClient, anthem_mounts, modules_mount
 from .docker_flake8 import apply_flake8, parser_add_flake8_group
 from .docker_isort import apply_isort, parser_add_isort_group
 from .docker_postgresql import POSTGRES_PASSWORD, docker_run_postgresql
@@ -956,21 +956,7 @@
                 read_only=True,
             )
         )
-        # also mount songs for anthem to avoid having to rebuild the image when they
-        # are changed.
-        if os.path.exists("songs"):
-            for root, dirs, _files in os.walk("songs"):
-                for dir in dirs:
-                    # with older odoo this will not be set
-                    for python in pythons:
-                        mounts.append(
-                            Mount(
-                                f"/usr/local/lib/{python}/dist-packages/{root}/{dir}",
-                                os.path.join(project_path, root, dir),
-                                "bind",
-                                read_only=True,
-                            )
-                        )
+        mounts.extend(anthem_mounts(project_path, pythons))
 
         options["environment"].update(
             {
diff --git a/odoo_scripts/docker_pylint.py b/odoo_scripts/docker_pylint.py
--- a/odoo_scripts/docker_pylint.py
+++ b/odoo_scripts/docker_pylint.py
@@ -10,14 +10,14 @@
 
 from docker.types import Mount
 
-from .config import ODOO_15, Config
+from .config import ODOO_7, ODOO_8, ODOO_10, ODOO_11, ODOO_13, ODOO_15, Config
 from .docker_build import add_build_options, build_local_image, get_build_options
-from .docker_client import DockerClient, modules_mount
+from .docker_client import DockerClient, anthem_mounts, modules_mount
 from .parsing import apply, basic_parser
 
-__version__ = "1.0.0"
+__version__ = "1.1.0"
 __date__ = "2022-01-26"
-__updated__ = "2022-01-27"
+__updated__ = "2022-04-20"
 
 _logger = logging.getLogger(__name__)
 
@@ -26,16 +26,11 @@
 
 
 def __parser():
-    program_version = __version__
-    program_build_date = str(__updated__)
-    program_version_message = "%%(prog)s %s (%s)" % (
-        program_version,
-        program_build_date,
-    )
-    program_shortdesc = __doc__.split(".", maxsplit=1)[0]
-    program_license = """%s
+    program_version_message = f"%(prog)s {__version__} ({__updated__})"
+    program_short_description = __doc__.split(".", maxsplit=1)[0]
+    program_license = f"""{program_short_description}
 
-      Created by Vincent Hatakeyama on %s.
+      Created by Vincent Hatakeyama on {__date__}.
       Copyright 2022 XCG Consulting. All rights reserved.
 
       Licensed under the MIT License
@@ -44,10 +39,7 @@
       or conditions of any kind, either express or implied.
 
     USAGE
-    """ % (
-        program_shortdesc,
-        str(__date__),
-    )
+    """
     parser = basic_parser(program_license, program_version_message)
     return parser
 
@@ -86,35 +78,35 @@
     project_path = os.path.realpath(".")
 
     # always use project image
-    c = Config()
+    config = Config()
 
-    odoo_type = c.odoo_type
+    odoo_type = config.odoo_type
 
     mounts: List[Mount] = []
     environment = {}
     target_source_dict: Dict[str, str] = {}
 
     # odoo configuration is not read so put the modules in the path
-    if odoo_type in ("odoo10", "odoo11", "odoo13", ODOO_15):
-        if odoo_type == "odoo10":
+    if odoo_type in (ODOO_10, ODOO_11, ODOO_13, ODOO_15):
+        if odoo_type == ODOO_10:
             pythons = ("python2.7",)
-        elif odoo_type == "odoo11":
+        elif odoo_type == ODOO_11:
             pythons = ("python3.5", "python3.6")
-        elif odoo_type == "odoo13":
+        elif odoo_type == ODOO_13:
             pythons = ("python3.8",)
         elif odoo_type == ODOO_15:
             pythons = ("python3.9",)
         for python in pythons:
             result = modules_mount(
-                c.modules,
+                config.modules,
                 project_path,
                 f"/usr/local/lib/{python}/dist-packages/odoo/addons",
             )
             mounts.extend(result[0])
             target_source_dict.update(result[1])
-    elif odoo_type in ("odoo7", "odoo8"):
+    elif odoo_type in (ODOO_7, ODOO_8):
         mounts, target_source_dict = modules_mount(
-            c.modules, project_path, "/opt/odoo/sources/odoo/addons"
+            config.modules, project_path, "/opt/odoo/sources/odoo/addons"
         )
 
     # Add a volume to store cache
@@ -124,12 +116,14 @@
     mounts.append(Mount(cache_target_path, cache_volume_name))
     environment["PYLINTHOME"] = cache_target_path
 
+    mounts.extend(anthem_mounts(project_path, pythons))
+
     build_local_image(build_options)
 
     _logger.info("Running pylint")
     return DockerClient.run(
-        c.local_image,
-        c.local_tag,
+        config.local_image,
+        config.local_tag,
         {
             "entrypoint": "pylint",
             "command": modules + ["--load-plugins=pylint_odoo"],