~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/fileservice_lib/listing.py

  • Committer: Matt Giuca
  • Date: 2010-02-18 05:55:21 UTC
  • Revision ID: matt.giuca@gmail.com-20100218055521-tx3xuqvv01e660yi
fileservice_lib.listing: Fix some encode/decode errors. Now possible to get a file listing of a SVN directory with Unicode characters in filenames, although a lot of other things still don't work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
261
261
            ls_list = svnclient.list(path, revision=revision, recurse=False)
262
262
            for ls in ls_list:
263
263
                filename, attrs = PysvnList_to_fileinfo(path, ls)
264
 
                listing[filename.decode('utf-8')] = attrs
 
264
                if isinstance(filename, str):   # Expect a unicode from pysvn
 
265
                    filename = filename.decode('utf-8')
 
266
                listing[filename] = attrs
265
267
        else:
266
268
            status_list = svnclient.status(path, recurse=False, get_all=True,
267
269
                        update=False)
268
270
            for status in status_list:
269
271
                filename, attrs = PysvnStatus_to_fileinfo(path, status)
270
 
                listing[filename.decode('utf-8')] = attrs
 
272
                if isinstance(filename, str):   # Expect a unicode from pysvn
 
273
                    filename = filename.decode('utf-8')
 
274
                listing[filename] = attrs
271
275
    except (pysvn.ClientError, UnversionedDir), e:
272
276
        # Could indicate a serious SVN error, or just that the directory is
273
277
        # not under version control (which is perfectly normal).
315
319
    return listing
316
320
 
317
321
def _fullpath_stat_fileinfo(fullpath):
 
322
    if isinstance(fullpath, unicode):
 
323
        fullpath = fullpath.encode('utf-8')     # os.stat can't handle unicode
318
324
    file_stat = os.stat(fullpath)
319
325
    return _stat_fileinfo(fullpath, file_stat)
320
326