forked from theinternetftw/xyppy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRunner.py
22 lines (20 loc) · 834 Bytes
/
Runner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import tkinter.filedialog as tkFileDialog
from tkinter import *
import subprocess
import re
import os
#filetypes = (
# ("Python files", "*.py *.pyw", "TEXT"),
# ("Text files", "*.txt", "TEXT"),
# ("All files", "*"),
# )
filetypes = (("DAT files","*.DAT"),)
Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
filename = tkFileDialog.askopenfilename(filetypes=filetypes)
#Must process files and folders to remove spaces since they parse as separate arguments.
#For example, 'C:/Users/My Games/Cool Game/' will be 3 command line arguments due to 2 spaces.
#This regex changes it to 'C:/Users/"My Games"/"Cool Game"/'
regex = "(?<=\/)[^\/]+\s[^\/]+(?=\/)"
replacement = "\"\g<0>\""
filename = re.sub(regex,replacement,filename)
subprocess.Popen("python -m xyppy " + filename)