[REF] script: improve variable naming conventions

Replace Hungarian notation prefixes (lst_, dct_) with
descriptive English names for better readability across
git and todo modules.

Generated by Claude Code 2.1.72 model claude-sonnet-4-6

Co-Authored-By: Mathieu Benoit <mathben@technolibre.ca>
This commit is contained in:
Mathieu Benoit 2026-03-10 04:18:17 -04:00
parent 095eaa1661
commit d60caa3897
3 changed files with 86 additions and 94 deletions

View file

@ -75,12 +75,12 @@ def main():
config = get_config() config = get_config()
git_tool = GitTool() git_tool = GitTool()
lst_input = config.input input_paths = config.input
if not lst_input: if not input_paths:
lst_input = [] input_paths = []
if config.with_OCA: if config.with_OCA:
append_file_path_manifest( append_file_path_manifest(
lst_input, DEFAULT_PATH_MANIFEST_ODOO_CONF input_paths, DEFAULT_PATH_MANIFEST_ODOO_CONF
) )
if os.path.exists(".odoo-version"): if os.path.exists(".odoo-version"):
with open(".odoo-version", "r") as f: with open(".odoo-version", "r") as f:
@ -90,7 +90,7 @@ def main():
"manifest", f"git_manifest_odoo{odoo_version}.xml" "manifest", f"git_manifest_odoo{odoo_version}.xml"
) )
if os.path.exists(path_manifest_odoo_version): if os.path.exists(path_manifest_odoo_version):
lst_input.append(path_manifest_odoo_version) input_paths.append(path_manifest_odoo_version)
else: else:
print( print(
f"ERROR: {path_manifest_odoo_version} does not exist" f"ERROR: {path_manifest_odoo_version} does not exist"
@ -99,21 +99,19 @@ def main():
"manifest", f"git_manifest_odoo{odoo_version}_dev.xml" "manifest", f"git_manifest_odoo{odoo_version}_dev.xml"
) )
if os.path.exists(path_manifest_odoo_version): if os.path.exists(path_manifest_odoo_version):
lst_input.append(path_manifest_odoo_version) input_paths.append(path_manifest_odoo_version)
if os.path.exists(DEFAULT_PATH_INSTALLED_ODOO_VERSION): if os.path.exists(DEFAULT_PATH_INSTALLED_ODOO_VERSION):
with open(DEFAULT_PATH_INSTALLED_ODOO_VERSION, "r") as f: with open(DEFAULT_PATH_INSTALLED_ODOO_VERSION, "r") as f:
lst_installed_odoo_version = [ installed_versions = [a.strip() for a in f.readlines()]
a.strip() for a in f.readlines() if installed_versions:
] for installed_odoo_version in installed_versions:
if lst_installed_odoo_version:
for installed_odoo_version in lst_installed_odoo_version:
path_manifest_odoo_version = os.path.join( path_manifest_odoo_version = os.path.join(
"manifest", "manifest",
f"git_manifest_{installed_odoo_version}.xml", f"git_manifest_{installed_odoo_version}.xml",
) )
if os.path.exists(path_manifest_odoo_version): if os.path.exists(path_manifest_odoo_version):
lst_input.append(path_manifest_odoo_version) input_paths.append(path_manifest_odoo_version)
else: else:
print( print(
f"ERROR: {path_manifest_odoo_version} does not exist" f"ERROR: {path_manifest_odoo_version} does not exist"
@ -123,81 +121,81 @@ def main():
f"git_manifest_{installed_odoo_version}_dev.xml", f"git_manifest_{installed_odoo_version}_dev.xml",
) )
if os.path.exists(path_manifest_odoo_version): if os.path.exists(path_manifest_odoo_version):
lst_input.append(path_manifest_odoo_version) input_paths.append(path_manifest_odoo_version)
elif config.with_mobile: elif config.with_mobile:
append_file_path_manifest( append_file_path_manifest(
lst_input, DEFAULT_PATH_MANIFEST_MOBILE_CONF input_paths, DEFAULT_PATH_MANIFEST_MOBILE_CONF
) )
else: else:
append_file_path_manifest(lst_input, DEFAULT_PATH_MANIFEST_CONF) append_file_path_manifest(input_paths, DEFAULT_PATH_MANIFEST_CONF)
append_file_path_manifest( append_file_path_manifest(
lst_input, DEFAULT_PATH_MANIFEST_PRIVATE_CONF input_paths, DEFAULT_PATH_MANIFEST_PRIVATE_CONF
) )
dct_remote_total = {} remotes_total = {}
dct_project_total = {} projects_total = {}
default_remote_total = None default_remote_total = None
# Be sure all input is unique # Be sure all input is unique
lst_input = list(set(lst_input)) input_paths = list(set(input_paths))
for index, input_path in enumerate(lst_input): for index, input_path in enumerate(input_paths):
( (
dct_remote, remotes,
dct_project, projects,
default_remote, default_remote,
) = git_tool.get_manifest_xml_info(filename=input_path, add_root=True) ) = git_tool.get_manifest_xml_info(filename=input_path, add_root=True)
# Support multiple version odoo # Support multiple version odoo
dct_project_copy = dct_project projects_copy = projects
dct_project = {} projects = {}
for key, value in dct_project_copy.items(): for key, value in projects_copy.items():
new_key = f"{key}+{value.get('@path')}" new_key = f"{key}+{value.get('@path')}"
dct_project[new_key] = value projects[new_key] = value
if len(lst_input) == 1: if len(input_paths) == 1:
# Only 1 input, same output # Only 1 input, same output
dct_remote_total = dct_remote remotes_total = remotes
dct_project_total = dct_project projects_total = projects
break break
elif not index: elif not index:
# Preparation to accumulate data # Preparation to accumulate data
dct_remote_total = copy.deepcopy(dct_remote) remotes_total = copy.deepcopy(remotes)
dct_project_total = copy.deepcopy(dct_project) projects_total = copy.deepcopy(projects)
continue continue
for key, value in dct_project.items(): for key, value in projects.items():
if key in dct_project_total.keys(): if key in projects_total:
if config.att_revision_only: if config.att_revision_only:
revision = value.get("@revision") revision = value.get("@revision")
if revision: if revision:
dct_project_total[key]["@revision"] = revision projects_total[key]["@revision"] = revision
else: else:
dct_project_total[key].update(value) projects_total[key].update(value)
else: else:
dct_project_total[key] = copy.deepcopy(value) projects_total[key] = copy.deepcopy(value)
for key, value in dct_remote.items(): for key, value in remotes.items():
if key in dct_remote_total.keys(): if key in remotes_total:
dct_remote_total[key].update(value) remotes_total[key].update(value)
else: else:
dct_remote_total[key] = copy.deepcopy(value) remotes_total[key] = copy.deepcopy(value)
git_tool.generate_repo_manifest( git_tool.generate_repo_manifest(
remotes_config=dct_remote_total, remotes_config=remotes_total,
projects_config=dct_project_total, projects_config=projects_total,
output=config.output, output=config.output,
default_remote=default_remote_total, default_remote=default_remote_total,
) )
def append_file_path_manifest(lst_input, path_manifest): def append_file_path_manifest(input_paths, path_manifest):
if os.path.exists(path_manifest): if os.path.exists(path_manifest):
with open(path_manifest, "r") as f: with open(path_manifest, "r") as f:
csv_file = csv.DictReader(f) csv_file = csv.DictReader(f)
for row in csv_file: for row in csv_file:
filepath = row.get("filepath") filepath = row.get("filepath")
lst_input.append(filepath) input_paths.append(filepath)
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -17,7 +17,9 @@ from giturlparse import parse # pip install giturlparse
from retrying import retry # pip install retrying from retrying import retry # pip install retrying
from script.git import github_api from script.git import github_api
from script.git.repo_url import get_transformed_repo_info_from_url as _get_transformed_repo_info from script.git.repo_url import (
get_transformed_repo_info_from_url as _get_transformed_repo_info,
)
from script.git.repo_url import get_url as _get_url from script.git.repo_url import get_url as _get_url
SOURCE_REPO_ADDONS_FILE = "source_repo_addons.csv" SOURCE_REPO_ADDONS_FILE = "source_repo_addons.csv"
@ -300,7 +302,7 @@ class GitTool:
:param repo_path: path of repo to get information about submodule :param repo_path: path of repo to get information about submodule
:param filename: manifest filename. Default none, or use this instead use repo_path :param filename: manifest filename. Default none, or use this instead use repo_path
:param add_root: add information about root repository :param add_root: add information about root repository
:return: dct_remote, dct_project, default_remote :return: remotes_by_name, projects_by_name, default_remote
""" """
if filename is None: if filename is None:
@ -401,8 +403,8 @@ class GitTool:
if update_repo.startswith( if update_repo.startswith(
os.path.join(self.odoo_version_long, "addons") os.path.join(self.odoo_version_long, "addons")
): ):
lst_path = update_repo.split("/", 1) path_parts = update_repo.split("/", 1)
update_repo = f"${{EL_HOME_ODOO_PROJECT}}/" + lst_path[1] update_repo = f"${{EL_HOME_ODOO_PROJECT}}/" + path_parts[1]
# str_repo = ( # str_repo = (
# f' printf "${{EL_HOME}}/{update_repo}," >> ' # f' printf "${{EL_HOME}}/{update_repo}," >> '
# '"${EL_CONFIG_FILE}"\n' # '"${EL_CONFIG_FILE}"\n'
@ -499,46 +501,42 @@ class GitTool:
default_entries = [] default_entries = []
# Fill with configuration # Fill with configuration
for dct_value in remotes_config.values(): for entry in remotes_config.values():
remote_name = dct_value.get("@name") remote_name = entry.get("@name")
if remote_name not in remote_names: if remote_name not in remote_names:
remote_entries.append( remote_entries.append(
OrderedDict( OrderedDict(
[ [
("@name", remote_name), ("@name", remote_name),
("@fetch", dct_value.get("@fetch")), ("@fetch", entry.get("@fetch")),
] ]
) )
) )
remote_names.append(remote_name) remote_names.append(remote_name)
for dct_value in projects_config.values(): for entry in projects_config.values():
lst_project_info = [ project_attrs = [
("@name", dct_value.get("@name")), ("@name", entry.get("@name")),
("@path", dct_value.get("@path")), ("@path", entry.get("@path")),
] ]
if "@remote" in dct_value: if "@remote" in entry:
lst_project_info.append(("@remote", dct_value.get("@remote"))) project_attrs.append(("@remote", entry.get("@remote")))
if "@revision" in dct_value: if "@revision" in entry:
lst_project_info.append( project_attrs.append(("@revision", entry.get("@revision")))
("@revision", dct_value.get("@revision")) if "@clone-depth" in entry:
project_attrs.append(
("@clone-depth", entry.get("@clone-depth"))
) )
if "@clone-depth" in dct_value: if "@groups" in entry:
lst_project_info.append( project_attrs.append(("@groups", entry.get("@groups")))
("@clone-depth", dct_value.get("@clone-depth")) if "@upstream" in entry:
) project_attrs.append(("@upstream", entry.get("@upstream")))
if "@groups" in dct_value: if "@dest-branch" in entry:
lst_project_info.append(("@groups", dct_value.get("@groups"))) project_attrs.append(
if "@upstream" in dct_value: ("@dest-branch", entry.get("@dest-branch"))
lst_project_info.append(
("@upstream", dct_value.get("@upstream"))
)
if "@dest-branch" in dct_value:
lst_project_info.append(
("@dest-branch", dct_value.get("@dest-branch"))
) )
project_entries.append(OrderedDict(lst_project_info)) project_entries.append(OrderedDict(project_attrs))
project_names.append(dct_value.get("@name")) project_names.append(entry.get("@name"))
for repo in repo_list: for repo in repo_list:
if not repo.is_submodule: if not repo.is_submodule:
@ -559,10 +557,7 @@ class GitTool:
) )
) )
else: else:
if ( if keep_original and repo.project_name not in projects_config:
keep_original
and repo.project_name not in projects_config
):
# Exception, create a new remote to keep tracking on original # Exception, create a new remote to keep tracking on original
original_organization = ( original_organization = (
f"{repo.original_organization}_origin" f"{repo.original_organization}_origin"
@ -583,22 +578,22 @@ class GitTool:
# Add project, only unique project # Add project, only unique project
if repo.project_name not in project_names: if repo.project_name not in project_names:
project_names.append(repo.project_name) project_names.append(repo.project_name)
lst_project_info = [ project_attrs = [
("@name", repo.project_name), ("@name", repo.project_name),
("@path", repo.path), ("@path", repo.path),
("@remote", original_organization), ("@remote", original_organization),
] ]
if repo.revision: if repo.revision:
lst_project_info.append(("@revision", repo.revision)) project_attrs.append(("@revision", repo.revision))
if repo.clone_depth: if repo.clone_depth:
lst_project_info.append( project_attrs.append(
("@clone-depth", repo.clone_depth) ("@clone-depth", repo.clone_depth)
) )
if repo.sub_path == "addons": if repo.sub_path == "addons":
lst_project_info.append(("@groups", "addons")) project_attrs.append(("@groups", "addons"))
else: else:
lst_project_info.append(("@groups", "odoo")) project_attrs.append(("@groups", "odoo"))
project_entries.append(OrderedDict(lst_project_info)) project_entries.append(OrderedDict(project_attrs))
if default_remote and not default_entries: if default_remote and not default_entries:
default_entries.append( default_entries.append(
@ -613,12 +608,15 @@ class GitTool:
) )
# Order in alphabetic # Order in alphabetic
sorted_remotes = sorted(remote_entries, key=lambda key: key.get("@name")) sorted_remotes = sorted(
remote_entries, key=lambda key: key.get("@name")
)
sorted_defaults = sorted( sorted_defaults = sorted(
default_entries, key=lambda key: key.get("@remote") default_entries, key=lambda key: key.get("@remote")
) )
sorted_projects = sorted( sorted_projects = sorted(
project_entries, key=lambda key: key.get("@name") + key.get("@path") project_entries,
key=lambda key: key.get("@name") + key.get("@path"),
) )
manifest_dict = OrderedDict( manifest_dict = OrderedDict(
@ -817,9 +815,7 @@ class GitTool:
name = f"{repo_name}" name = f"{repo_name}"
repo_info["name"] = name repo_info["name"] = name
compare_by_name = { compare_by_name = {a.get("name"): a for a in compare_repos}
a.get("name"): a for a in compare_repos
}
set_compare = set(compare_by_name.keys()) set_compare = set(compare_by_name.keys())
same_names = set_actual_repo.intersection(set_compare) same_names = set_actual_repo.intersection(set_compare)
@ -833,9 +829,7 @@ class GitTool:
matches = [] matches = []
for key in same_names: for key in same_names:
matches.append( matches.append((actual_adapted[key], compare_by_name[key]))
(actual_adapted[key], compare_by_name[key])
)
return matches, missing_names, extra_names return matches, missing_names, extra_names

View file

@ -1519,7 +1519,7 @@ class TODO:
self.dir_path = dir_path self.dir_path = dir_path
todo_file_browser.exit_program() todo_file_browser.exit_program()
def callback_make_mobile_home(self, dct_config): def callback_make_mobile_home(self, config):
# Read file # Read file
default_project_name = "ERPLibre" default_project_name = "ERPLibre"
default_package_name = "ca.erplibre.home" default_package_name = "ca.erplibre.home"