~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/win32utils.py

  • Committer: Kuno Meyer
  • Date: 2007-07-24 19:40:40 UTC
  • mto: This revision was merged to the branch mainline in revision 2655.
  • Revision ID: kuno.meyer@gmx.ch-20070724194040-ocyjulqhy31xe3j1
Extended tests for unicode chars outside of the iso-8859-* range
Two workarounds for incorrect glob.glob() implementation

Show diffs side-by-side

added added

removed removed

Lines of Context:
240
240
    return _ensure_unicode(get_host_name())
241
241
 
242
242
 
 
243
def _ensure_with_dir(path):
 
244
    if not os.path.split(path)[0] or path.startswith(u'*') or path.startswith(u'?'):
 
245
        return u'./' + path, True
 
246
    else:
 
247
        return path, False
 
248
    
 
249
def _undo_ensure_with_dir(path, corrected):
 
250
    if corrected:
 
251
        return path[2:]
 
252
    else:
 
253
        return path
 
254
 
 
255
 
 
256
 
243
257
def glob_expand(file_list):
244
258
    """Replacement for glob expansion by the shell.
245
259
 
256
270
    import glob
257
271
    expanded_file_list = []
258
272
    for possible_glob in file_list:
 
273
        
 
274
        # work around bugs in glob.glob()
 
275
        # - Python bug #1001604 ("glob doesn't return unicode with ...")
 
276
        # - failing expansion for */* with non-iso-8859-* chars
 
277
        possible_glob, corrected = _ensure_with_dir(possible_glob)
259
278
        glob_files = glob.glob(possible_glob)
260
279
 
261
280
        if glob_files == []:
262
281
            # special case to let the normal code path handle
263
282
            # files that do not exists
264
 
            expanded_file_list.append(possible_glob)
 
283
            expanded_file_list.append(
 
284
                _undo_ensure_with_dir(possible_glob, corrected))
265
285
        else:
 
286
            glob_files = [_undo_ensure_with_dir(elem, corrected) for elem in glob_files]
266
287
            expanded_file_list += glob_files
267
 
    expanded_file_list = [_ensure_unicode(elem) for elem in expanded_file_list]
268
 
    expanded_file_list = [elem.replace(u'\\', u'/') for elem in expanded_file_list] 
269
 
    return expanded_file_list
 
288
            
 
289
    return [elem.replace(u'\\', u'/') for elem in expanded_file_list]