[UPD] script pycharm configuration: support private csv configuration

This commit is contained in:
Mathieu Benoit 2025-05-04 05:31:44 -04:00
parent 60aa747023
commit cde4320dc2

View file

@ -9,6 +9,7 @@ import logging
import os
import subprocess
import sys
import io
import xmltodict
@ -31,6 +32,9 @@ VCS_WORKSPACE = os.path.join(IDEA_PATH, "vcs.xml")
PATH_EXCLUDE_FOLDER = "./conf/pycharm_exclude_folder.txt"
PATH_DEFAULT_CONFIGURATION = "./conf/pycharm_default_configuration.csv"
PATH_DEFAULT_CONFIGURATION_PRIVATE = (
"./conf/pycharm_default_configuration.private.csv"
)
def get_config():
@ -315,7 +319,15 @@ def add_configuration(dct_xml, file_name, config):
_logger.error(f"Cannot read file '{PATH_DEFAULT_CONFIGURATION}'")
return has_change
with open(PATH_DEFAULT_CONFIGURATION) as txt:
for default_conf in csv.DictReader(txt):
content1 = txt.read()
if os.path.isfile(PATH_DEFAULT_CONFIGURATION_PRIVATE):
with open(PATH_DEFAULT_CONFIGURATION_PRIVATE) as txt:
content2 = txt.read()
merged_content = content1 + content2
else:
merged_content = content1
txt_merged = io.StringIO(merged_content)
for default_conf in csv.DictReader(txt_merged):
conf_name = default_conf.get("name")
conf_folder = default_conf.get("folder")
conf_script_path = default_conf.get("script_path")
@ -331,10 +343,7 @@ def add_configuration(dct_xml, file_name, config):
s_unique_key = (
f"d {conf_folder} s {conf_script_path} p {conf_parameter}"
)
if (
config.overwrite
or s_unique_key not in lst_unique_configuration
):
if config.overwrite or s_unique_key not in lst_unique_configuration:
# add it!
if not config.overwrite and conf_name in lst_configuration:
_logger.error(