[UPD] script pycharm configuration: support private csv configuration
This commit is contained in:
parent
60aa747023
commit
cde4320dc2
1 changed files with 113 additions and 104 deletions
|
|
@ -9,6 +9,7 @@ import logging
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import io
|
||||||
|
|
||||||
import xmltodict
|
import xmltodict
|
||||||
|
|
||||||
|
|
@ -31,6 +32,9 @@ VCS_WORKSPACE = os.path.join(IDEA_PATH, "vcs.xml")
|
||||||
|
|
||||||
PATH_EXCLUDE_FOLDER = "./conf/pycharm_exclude_folder.txt"
|
PATH_EXCLUDE_FOLDER = "./conf/pycharm_exclude_folder.txt"
|
||||||
PATH_DEFAULT_CONFIGURATION = "./conf/pycharm_default_configuration.csv"
|
PATH_DEFAULT_CONFIGURATION = "./conf/pycharm_default_configuration.csv"
|
||||||
|
PATH_DEFAULT_CONFIGURATION_PRIVATE = (
|
||||||
|
"./conf/pycharm_default_configuration.private.csv"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_config():
|
def get_config():
|
||||||
|
|
@ -315,7 +319,15 @@ def add_configuration(dct_xml, file_name, config):
|
||||||
_logger.error(f"Cannot read file '{PATH_DEFAULT_CONFIGURATION}'")
|
_logger.error(f"Cannot read file '{PATH_DEFAULT_CONFIGURATION}'")
|
||||||
return has_change
|
return has_change
|
||||||
with open(PATH_DEFAULT_CONFIGURATION) as txt:
|
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_name = default_conf.get("name")
|
||||||
conf_folder = default_conf.get("folder")
|
conf_folder = default_conf.get("folder")
|
||||||
conf_script_path = default_conf.get("script_path")
|
conf_script_path = default_conf.get("script_path")
|
||||||
|
|
@ -331,10 +343,7 @@ def add_configuration(dct_xml, file_name, config):
|
||||||
s_unique_key = (
|
s_unique_key = (
|
||||||
f"d {conf_folder} s {conf_script_path} p {conf_parameter}"
|
f"d {conf_folder} s {conf_script_path} p {conf_parameter}"
|
||||||
)
|
)
|
||||||
if (
|
if config.overwrite or s_unique_key not in lst_unique_configuration:
|
||||||
config.overwrite
|
|
||||||
or s_unique_key not in lst_unique_configuration
|
|
||||||
):
|
|
||||||
# add it!
|
# add it!
|
||||||
if not config.overwrite and conf_name in lst_configuration:
|
if not config.overwrite and conf_name in lst_configuration:
|
||||||
_logger.error(
|
_logger.error(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue