Support opening 'project' files like .csproj
This commit is contained in:
parent
ba1c32b383
commit
b0cfe40b96
|
@ -21,25 +21,29 @@ def get_application_desktop_file_info(application: str, prefix: str) -> str:
|
||||||
return line
|
return line
|
||||||
|
|
||||||
|
|
||||||
def get_project_type(project) -> str:
|
def get_project_type(project) -> (str, str):
|
||||||
|
ret = ("idea", None)
|
||||||
for file in os.listdir(project):
|
for file in os.listdir(project):
|
||||||
if file.endswith("pom.xml"):
|
if file.endswith("pom.xml"):
|
||||||
return "idea"
|
return ("idea", None)
|
||||||
if file.endswith("package.json"):
|
if file.endswith("package.json"):
|
||||||
return "webstorm"
|
return ("webstorm", None)
|
||||||
if file.endswith("cargo.toml") or file.endswith(".c"):
|
if file.endswith("cargo.toml") or file.endswith(".c"):
|
||||||
return "clion"
|
return ("clion", None)
|
||||||
if file.endswith(".csproj") or file.endswith("DotSettings"):
|
if file.endswith(".csproj"):
|
||||||
return "rider"
|
return ("rider", file)
|
||||||
|
if file.endswith("DotSettings"):
|
||||||
|
# Allow .csproj to override this value
|
||||||
|
ret = ("rider", None)
|
||||||
if file.endswith(".py"):
|
if file.endswith(".py"):
|
||||||
return "pycharm"
|
return ("pycharm", None)
|
||||||
if file.endswith(".go"):
|
if file.endswith(".go"):
|
||||||
return "goland"
|
return ("goland", None)
|
||||||
return "idea"
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def get_icon(project: str) -> str | None:
|
def get_icon(project: str) -> str | None:
|
||||||
project_type = get_project_type(project)
|
(project_type, _) = get_project_type(project)
|
||||||
if project_type is None:
|
if project_type is None:
|
||||||
return None
|
return None
|
||||||
icon_line = get_application_desktop_file_info(project_type, 'Icon')
|
icon_line = get_application_desktop_file_info(project_type, 'Icon')
|
||||||
|
@ -47,9 +51,12 @@ def get_icon(project: str) -> str | None:
|
||||||
|
|
||||||
|
|
||||||
def open_project(project: str) -> ():
|
def open_project(project: str) -> ():
|
||||||
project_type = get_project_type(project)
|
(project_type, file) = get_project_type(project)
|
||||||
if project_type is None:
|
if project_type is None:
|
||||||
return
|
return
|
||||||
|
if file is not None:
|
||||||
|
project = f'{project}/{file}'
|
||||||
|
|
||||||
command = get_application_desktop_file_info(project_type, 'Exec')[6:-5]
|
command = get_application_desktop_file_info(project_type, 'Exec')[6:-5]
|
||||||
subprocess.Popen([command + " " + project], shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
subprocess.Popen([command + " " + project], shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue