-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprosync_utils.py
More file actions
51 lines (40 loc) · 1.05 KB
/
prosync_utils.py
File metadata and controls
51 lines (40 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
ProSync Utilities
Gemeinsame Hilfsfunktionen für ProSync-Komponenten
"""
import os
import sys
import subprocess
def open_file_cross_platform(path: str) -> None:
"""
Öffnet eine Datei mit dem Standard-Programm des Betriebssystems.
Args:
path: Pfad zur zu öffnenden Datei
Returns:
None
"""
if not os.path.exists(path):
return
if sys.platform == 'win32':
os.startfile(path)
elif sys.platform == 'darwin':
subprocess.call(['open', path])
else:
subprocess.call(['xdg-open', path])
def open_folder_cross_platform(path: str) -> None:
"""
Öffnet den Ordner einer Datei im Datei-Explorer.
Args:
path: Pfad zur Datei (der Ordner wird geöffnet)
Returns:
None
"""
folder = os.path.dirname(path)
if not os.path.exists(folder):
return
if sys.platform == 'win32':
os.startfile(folder)
elif sys.platform == 'darwin':
subprocess.call(['open', folder])
else:
subprocess.call(['xdg-open', folder])