[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:
parent
095eaa1661
commit
d60caa3897
3 changed files with 86 additions and 94 deletions
|
|
@ -75,12 +75,12 @@ def main():
|
|||
config = get_config()
|
||||
git_tool = GitTool()
|
||||
|
||||
lst_input = config.input
|
||||
if not lst_input:
|
||||
lst_input = []
|
||||
input_paths = config.input
|
||||
if not input_paths:
|
||||
input_paths = []
|
||||
if config.with_OCA:
|
||||
append_file_path_manifest(
|
||||
lst_input, DEFAULT_PATH_MANIFEST_ODOO_CONF
|
||||
input_paths, DEFAULT_PATH_MANIFEST_ODOO_CONF
|
||||
)
|
||||
if os.path.exists(".odoo-version"):
|
||||
with open(".odoo-version", "r") as f:
|
||||
|
|
@ -90,7 +90,7 @@ def main():
|
|||
"manifest", f"git_manifest_odoo{odoo_version}.xml"
|
||||
)
|
||||
if os.path.exists(path_manifest_odoo_version):
|
||||
lst_input.append(path_manifest_odoo_version)
|
||||
input_paths.append(path_manifest_odoo_version)
|
||||
else:
|
||||
print(
|
||||
f"ERROR: {path_manifest_odoo_version} does not exist"
|
||||
|
|
@ -99,21 +99,19 @@ def main():
|
|||
"manifest", f"git_manifest_odoo{odoo_version}_dev.xml"
|
||||
)
|
||||
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):
|
||||
with open(DEFAULT_PATH_INSTALLED_ODOO_VERSION, "r") as f:
|
||||
lst_installed_odoo_version = [
|
||||
a.strip() for a in f.readlines()
|
||||
]
|
||||
if lst_installed_odoo_version:
|
||||
for installed_odoo_version in lst_installed_odoo_version:
|
||||
installed_versions = [a.strip() for a in f.readlines()]
|
||||
if installed_versions:
|
||||
for installed_odoo_version in installed_versions:
|
||||
path_manifest_odoo_version = os.path.join(
|
||||
"manifest",
|
||||
f"git_manifest_{installed_odoo_version}.xml",
|
||||
)
|
||||
if os.path.exists(path_manifest_odoo_version):
|
||||
lst_input.append(path_manifest_odoo_version)
|
||||
input_paths.append(path_manifest_odoo_version)
|
||||
else:
|
||||
print(
|
||||
f"ERROR: {path_manifest_odoo_version} does not exist"
|
||||
|
|
@ -123,81 +121,81 @@ def main():
|
|||
f"git_manifest_{installed_odoo_version}_dev.xml",
|
||||
)
|
||||
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:
|
||||
append_file_path_manifest(
|
||||
lst_input, DEFAULT_PATH_MANIFEST_MOBILE_CONF
|
||||
input_paths, DEFAULT_PATH_MANIFEST_MOBILE_CONF
|
||||
)
|
||||
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(
|
||||
lst_input, DEFAULT_PATH_MANIFEST_PRIVATE_CONF
|
||||
input_paths, DEFAULT_PATH_MANIFEST_PRIVATE_CONF
|
||||
)
|
||||
|
||||
dct_remote_total = {}
|
||||
dct_project_total = {}
|
||||
remotes_total = {}
|
||||
projects_total = {}
|
||||
default_remote_total = None
|
||||
|
||||
# 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,
|
||||
dct_project,
|
||||
remotes,
|
||||
projects,
|
||||
default_remote,
|
||||
) = git_tool.get_manifest_xml_info(filename=input_path, add_root=True)
|
||||
|
||||
# Support multiple version odoo
|
||||
dct_project_copy = dct_project
|
||||
dct_project = {}
|
||||
for key, value in dct_project_copy.items():
|
||||
projects_copy = projects
|
||||
projects = {}
|
||||
for key, value in projects_copy.items():
|
||||
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
|
||||
dct_remote_total = dct_remote
|
||||
dct_project_total = dct_project
|
||||
remotes_total = remotes
|
||||
projects_total = projects
|
||||
break
|
||||
elif not index:
|
||||
# Preparation to accumulate data
|
||||
dct_remote_total = copy.deepcopy(dct_remote)
|
||||
dct_project_total = copy.deepcopy(dct_project)
|
||||
remotes_total = copy.deepcopy(remotes)
|
||||
projects_total = copy.deepcopy(projects)
|
||||
continue
|
||||
for key, value in dct_project.items():
|
||||
if key in dct_project_total.keys():
|
||||
for key, value in projects.items():
|
||||
if key in projects_total:
|
||||
if config.att_revision_only:
|
||||
revision = value.get("@revision")
|
||||
if revision:
|
||||
dct_project_total[key]["@revision"] = revision
|
||||
projects_total[key]["@revision"] = revision
|
||||
else:
|
||||
dct_project_total[key].update(value)
|
||||
projects_total[key].update(value)
|
||||
else:
|
||||
dct_project_total[key] = copy.deepcopy(value)
|
||||
projects_total[key] = copy.deepcopy(value)
|
||||
|
||||
for key, value in dct_remote.items():
|
||||
if key in dct_remote_total.keys():
|
||||
dct_remote_total[key].update(value)
|
||||
for key, value in remotes.items():
|
||||
if key in remotes_total:
|
||||
remotes_total[key].update(value)
|
||||
else:
|
||||
dct_remote_total[key] = copy.deepcopy(value)
|
||||
remotes_total[key] = copy.deepcopy(value)
|
||||
|
||||
git_tool.generate_repo_manifest(
|
||||
remotes_config=dct_remote_total,
|
||||
projects_config=dct_project_total,
|
||||
remotes_config=remotes_total,
|
||||
projects_config=projects_total,
|
||||
output=config.output,
|
||||
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):
|
||||
with open(path_manifest, "r") as f:
|
||||
csv_file = csv.DictReader(f)
|
||||
for row in csv_file:
|
||||
filepath = row.get("filepath")
|
||||
lst_input.append(filepath)
|
||||
input_paths.append(filepath)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@ from giturlparse import parse # pip install giturlparse
|
|||
from retrying import retry # pip install retrying
|
||||
|
||||
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
|
||||
|
||||
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 filename: manifest filename. Default none, or use this instead use repo_path
|
||||
: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:
|
||||
|
|
@ -401,8 +403,8 @@ class GitTool:
|
|||
if update_repo.startswith(
|
||||
os.path.join(self.odoo_version_long, "addons")
|
||||
):
|
||||
lst_path = update_repo.split("/", 1)
|
||||
update_repo = f"${{EL_HOME_ODOO_PROJECT}}/" + lst_path[1]
|
||||
path_parts = update_repo.split("/", 1)
|
||||
update_repo = f"${{EL_HOME_ODOO_PROJECT}}/" + path_parts[1]
|
||||
# str_repo = (
|
||||
# f' printf "${{EL_HOME}}/{update_repo}," >> '
|
||||
# '"${EL_CONFIG_FILE}"\n'
|
||||
|
|
@ -499,46 +501,42 @@ class GitTool:
|
|||
default_entries = []
|
||||
|
||||
# Fill with configuration
|
||||
for dct_value in remotes_config.values():
|
||||
remote_name = dct_value.get("@name")
|
||||
for entry in remotes_config.values():
|
||||
remote_name = entry.get("@name")
|
||||
if remote_name not in remote_names:
|
||||
remote_entries.append(
|
||||
OrderedDict(
|
||||
[
|
||||
("@name", remote_name),
|
||||
("@fetch", dct_value.get("@fetch")),
|
||||
("@fetch", entry.get("@fetch")),
|
||||
]
|
||||
)
|
||||
)
|
||||
remote_names.append(remote_name)
|
||||
for dct_value in projects_config.values():
|
||||
lst_project_info = [
|
||||
("@name", dct_value.get("@name")),
|
||||
("@path", dct_value.get("@path")),
|
||||
for entry in projects_config.values():
|
||||
project_attrs = [
|
||||
("@name", entry.get("@name")),
|
||||
("@path", entry.get("@path")),
|
||||
]
|
||||
if "@remote" in dct_value:
|
||||
lst_project_info.append(("@remote", dct_value.get("@remote")))
|
||||
if "@revision" in dct_value:
|
||||
lst_project_info.append(
|
||||
("@revision", dct_value.get("@revision"))
|
||||
if "@remote" in entry:
|
||||
project_attrs.append(("@remote", entry.get("@remote")))
|
||||
if "@revision" in entry:
|
||||
project_attrs.append(("@revision", entry.get("@revision")))
|
||||
if "@clone-depth" in entry:
|
||||
project_attrs.append(
|
||||
("@clone-depth", entry.get("@clone-depth"))
|
||||
)
|
||||
if "@clone-depth" in dct_value:
|
||||
lst_project_info.append(
|
||||
("@clone-depth", dct_value.get("@clone-depth"))
|
||||
)
|
||||
if "@groups" in dct_value:
|
||||
lst_project_info.append(("@groups", dct_value.get("@groups")))
|
||||
if "@upstream" in dct_value:
|
||||
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"))
|
||||
if "@groups" in entry:
|
||||
project_attrs.append(("@groups", entry.get("@groups")))
|
||||
if "@upstream" in entry:
|
||||
project_attrs.append(("@upstream", entry.get("@upstream")))
|
||||
if "@dest-branch" in entry:
|
||||
project_attrs.append(
|
||||
("@dest-branch", entry.get("@dest-branch"))
|
||||
)
|
||||
|
||||
project_entries.append(OrderedDict(lst_project_info))
|
||||
project_names.append(dct_value.get("@name"))
|
||||
project_entries.append(OrderedDict(project_attrs))
|
||||
project_names.append(entry.get("@name"))
|
||||
|
||||
for repo in repo_list:
|
||||
if not repo.is_submodule:
|
||||
|
|
@ -559,10 +557,7 @@ class GitTool:
|
|||
)
|
||||
)
|
||||
else:
|
||||
if (
|
||||
keep_original
|
||||
and repo.project_name not in projects_config
|
||||
):
|
||||
if keep_original and repo.project_name not in projects_config:
|
||||
# Exception, create a new remote to keep tracking on original
|
||||
original_organization = (
|
||||
f"{repo.original_organization}_origin"
|
||||
|
|
@ -583,22 +578,22 @@ class GitTool:
|
|||
# Add project, only unique project
|
||||
if repo.project_name not in project_names:
|
||||
project_names.append(repo.project_name)
|
||||
lst_project_info = [
|
||||
project_attrs = [
|
||||
("@name", repo.project_name),
|
||||
("@path", repo.path),
|
||||
("@remote", original_organization),
|
||||
]
|
||||
if repo.revision:
|
||||
lst_project_info.append(("@revision", repo.revision))
|
||||
project_attrs.append(("@revision", repo.revision))
|
||||
if repo.clone_depth:
|
||||
lst_project_info.append(
|
||||
project_attrs.append(
|
||||
("@clone-depth", repo.clone_depth)
|
||||
)
|
||||
if repo.sub_path == "addons":
|
||||
lst_project_info.append(("@groups", "addons"))
|
||||
project_attrs.append(("@groups", "addons"))
|
||||
else:
|
||||
lst_project_info.append(("@groups", "odoo"))
|
||||
project_entries.append(OrderedDict(lst_project_info))
|
||||
project_attrs.append(("@groups", "odoo"))
|
||||
project_entries.append(OrderedDict(project_attrs))
|
||||
|
||||
if default_remote and not default_entries:
|
||||
default_entries.append(
|
||||
|
|
@ -613,12 +608,15 @@ class GitTool:
|
|||
)
|
||||
|
||||
# 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(
|
||||
default_entries, key=lambda key: key.get("@remote")
|
||||
)
|
||||
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(
|
||||
|
|
@ -817,9 +815,7 @@ class GitTool:
|
|||
name = f"{repo_name}"
|
||||
repo_info["name"] = name
|
||||
|
||||
compare_by_name = {
|
||||
a.get("name"): a for a in compare_repos
|
||||
}
|
||||
compare_by_name = {a.get("name"): a for a in compare_repos}
|
||||
set_compare = set(compare_by_name.keys())
|
||||
|
||||
same_names = set_actual_repo.intersection(set_compare)
|
||||
|
|
@ -833,9 +829,7 @@ class GitTool:
|
|||
|
||||
matches = []
|
||||
for key in same_names:
|
||||
matches.append(
|
||||
(actual_adapted[key], compare_by_name[key])
|
||||
)
|
||||
matches.append((actual_adapted[key], compare_by_name[key]))
|
||||
|
||||
return matches, missing_names, extra_names
|
||||
|
||||
|
|
|
|||
|
|
@ -1519,7 +1519,7 @@ class TODO:
|
|||
self.dir_path = dir_path
|
||||
todo_file_browser.exit_program()
|
||||
|
||||
def callback_make_mobile_home(self, dct_config):
|
||||
def callback_make_mobile_home(self, config):
|
||||
# Read file
|
||||
default_project_name = "ERPLibre"
|
||||
default_package_name = "ca.erplibre.home"
|
||||
|
|
|
|||
Loading…
Reference in a new issue