244
239
def get_host_name_unicode():
245
240
return _ensure_unicode(get_host_name())
248
def _ensure_with_dir(path):
249
if not os.path.split(path)[0] or path.startswith(u'*') or path.startswith(u'?'):
250
return u'./' + path, True
254
def _undo_ensure_with_dir(path, corrected):
262
def glob_expand(file_list):
263
"""Replacement for glob expansion by the shell.
265
Win32's cmd.exe does not do glob expansion (eg ``*.py``), so we do our own
268
:param file_list: A list of filenames which may include shell globs.
269
:return: An expanded list of filenames.
271
Introduced in bzrlib 0.18.
276
expanded_file_list = []
277
for possible_glob in file_list:
279
# work around bugs in glob.glob()
280
# - Python bug #1001604 ("glob doesn't return unicode with ...")
281
# - failing expansion for */* with non-iso-8859-* chars
282
possible_glob, corrected = _ensure_with_dir(possible_glob)
283
glob_files = glob.glob(possible_glob)
286
# special case to let the normal code path handle
287
# files that do not exists
288
expanded_file_list.append(
289
_undo_ensure_with_dir(possible_glob, corrected))
291
glob_files = [_undo_ensure_with_dir(elem, corrected) for elem in glob_files]
292
expanded_file_list += glob_files
294
return [elem.replace(u'\\', u'/') for elem in expanded_file_list]
297
def get_app_path(appname):
298
"""Look up in Windows registry for full path to application executable.
299
Typicaly, applications create subkey with their basename
300
in HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\
302
:param appname: name of application (if no filename extension
303
is specified, .exe used)
304
:return: full path to aplication executable from registry,
305
or appname itself if nothing found.
309
hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
310
r'SOFTWARE\Microsoft\Windows'
311
r'\CurrentVersion\App Paths')
312
except EnvironmentError:
316
if not os.path.splitext(basename)[1]:
317
basename = appname + '.exe'
320
fullpath = _winreg.QueryValue(hkey, basename)
324
_winreg.CloseKey(hkey)
329
def set_file_attr_hidden(path):
330
"""Set file attributes to hidden if possible"""
332
win32file.SetFileAttributes(path, win32file.FILE_ATTRIBUTE_HIDDEN)