From a0101df246c7c1a6ec262191815e615e647b6348 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 23 Aug 2024 23:55:59 -0400 Subject: [PATCH] [FIX] script pycharm configuration: dynamic way to find iml file - depend on project name, the iml filename change, so use a dynamic way to find it, take first --- script/ide/pycharm_configuration.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/script/ide/pycharm_configuration.py b/script/ide/pycharm_configuration.py index d5d22bb..4df53c2 100755 --- a/script/ide/pycharm_configuration.py +++ b/script/ide/pycharm_configuration.py @@ -5,6 +5,7 @@ import logging import os import subprocess import sys +import glob import xmltodict @@ -16,7 +17,6 @@ PROJECT_NAME = os.path.basename(os.getcwd()) IDEA_PATH = "./.idea" IDEA_MISC = os.path.join(IDEA_PATH, "misc.xml") IDEA_WORKSPACE = os.path.join(IDEA_PATH, "workspace.xml") -IDEA_PROJECT_IML = os.path.join(IDEA_PATH, PROJECT_NAME + ".iml") PATH_EXCLUDE_FOLDER = "./conf/pycharm_exclude_folder.txt" if os.path.isfile(PATH_EXCLUDE_FOLDER): @@ -99,16 +99,20 @@ def main(): f"Missing {IDEA_PATH} path, are you sure you run this script at root" " of the project, are you sure you have a Pycharm project?", ) + # Find a file ended by iml and take it + project_path = None + for file in glob.glob(IDEA_PATH + "/*.iml"): + project_path = file + break die( - not os.path.isfile(IDEA_PROJECT_IML), - f"Missing {IDEA_PROJECT_IML} file, wait after Pycharm analyze file to" + not project_path, + f"Missing .iml file into {IDEA_PATH}, wait after Pycharm analyze file to" " create Python environnement.", ) + if config.init: has_execute = True - read_xml_and_execute( - IDEA_PROJECT_IML, add_exclude_folder, "init", config - ) + read_xml_and_execute(project_path, add_exclude_folder, "init", config) die( not os.path.isfile(IDEA_MISC),