15 |
import os.path |
import os.path |
16 |
from tempfile import mktemp |
from tempfile import mktemp |
17 |
|
|
18 |
from string import split, join |
from string import join |
19 |
|
|
20 |
from Thuban import _ |
from Thuban import _ |
21 |
|
|
29 |
|
|
30 |
# split the filenames into their components. remove the first item |
# split the filenames into their components. remove the first item |
31 |
# since it will be always empty because both names are absolute. |
# since it will be always empty because both names are absolute. |
32 |
dir_parts = split(dir, sep)[1:] |
dir_parts = dir.split(sep)[1:] |
33 |
absname_parts = split(absname, sep)[1:] |
absname_parts = absname.split(sep)[1:] |
34 |
|
|
35 |
# count the number of common parts at the start of dir_parts and |
# count the number of common parts at the start of dir_parts and |
36 |
# absname_parts |
# absname_parts |
153 |
return relative_filename_common(dir_rest, absname_rest, "\\") |
return relative_filename_common(dir_rest, absname_rest, "\\") |
154 |
|
|
155 |
def get_application_dir(): |
def get_application_dir(): |
156 |
"""Determine the path to the .thuban directory. |
"""Determine the path to the .thuban directory. Create the directory |
157 |
|
if it doesn't exist. |
158 |
|
|
159 |
Under posix systems use the os.expanduser() method. |
Under posix systems use the os.expanduser() method. |
160 |
Under Win32 try to read the "Explorer/Shell Folders/" value "AppData". |
Under Win32 try to read the "Explorer/Shell Folders/" value "AppData". |
161 |
""" |
""" |
162 |
|
|
163 |
if os.name == 'posix': |
if os.name == 'posix': |
164 |
return os.path.expanduser("~/.thuban") |
dir = os.path.expanduser("~/.thuban") |
165 |
|
if not os.path.isdir(dir): |
166 |
|
os.mkdir(dir) |
167 |
|
return dir |
168 |
elif os.name == 'nt': |
elif os.name == 'nt': |
169 |
regkey = 1 |
regkey = 1 |
170 |
try: |
try: |