-
Notifications
You must be signed in to change notification settings - Fork 0
/
pathConv_py27.py
53 lines (44 loc) · 1.51 KB
/
pathConv_py27.py
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
52
53
# pathConv
# Python 2.7 for PyInstaller on Mac
# Operates on the clipboard in Windows
# Converts Windows Path to Unix
# Converts Unix Path to Windows
import Tkinter as tk
import tkMessageBox as msg
def notValidMsg():
msg.showinfo("Info", "Not a valid source path.")
def main():
root = tk.Tk()
root.withdraw()
path = root.clipboard_get()
if path:
# The first item in reps will always be used when converting to Unix
reps = ["/Volumes/Shogun", "Shogun"]
if "/" in path:
if not "\\" in path:
reps = ["/Volumes/Shogun", "Shogun"]
for rep in reps:
if path.startswith(rep):
path = path.replace(rep, "X:", 1)
break
path = path.replace("/", "\\")
root.clipboard_clear()
root.clipboard_append(path)
print "Converted Unix Path to Windows."
msg.showinfo("Info", "Converted Unix Path to Windows.")
else:
notValidMsg()
else:
if "\\" in path:
path = path.replace("\\", "/")
if path.startswith("X:"):
path = path.replace("X:", reps[0], 1)
root.clipboard_clear()
root.clipboard_append(path)
msg.showinfo("Info", "Converted Windows Path to Unix.")
else:
notValidMsg()
else:
notValidMsg()
if __name__ == "__main__":
main()