~aaron-whitehouse/duplicity/08-unicode

« back to all changes in this revision

Viewing changes to duplicity/selection.py

  • Committer: Aaron A Whitehouse
  • Date: 2017-06-12 22:24:53 UTC
  • Revision ID: lists@whitehouse.kiwi.nz-20170612222453-5a5nnnp6pf9yvpm6
Replace util.py functions to and from unicode with direct calls to .encode and .decode, as it did not save much code, means the "strict"/"ignore"/"replace" decision can be made per call. Also helps narrow down on why sys.getfilesystemencoding() is not working as expected in some places.

Show diffs side-by-side

added added

removed removed

Lines of Context:
248
248
            for opt, arg in argtuples:
249
249
                # assert isinstance(opt, unicode), u"option " + util.bytes_to_uc(opt) + u" is not unicode"
250
250
                # assert isinstance(arg, unicode), u"option " + util.bytes_to_uc(arg) + u" is not unicode"
251
 
                opt = util.bytes_to_uc(opt)  # ToDo: replace once we can make commandline return unicode
252
 
                arg = util.bytes_to_uc(arg)  # ToDo: replace once we can make commandline return unicode
 
251
                # ToDo: replace the next three lines once we can make commandline return unicode
 
252
                opt = opt.decode(sys.getfilesystemencoding(), "strict")
 
253
                if not isinstance(arg, unicode):
 
254
                    # ToDo: use sys.getfilesystemencoding() once figure out why this is not working.
 
255
                    arg = arg.decode("UTF-8", "strict")  # ToDo: Change from "strict" once found problems
253
256
 
254
257
                if opt == u"--exclude":
255
258
                    self.add_selection_func(self.glob_get_sf(arg, 0))
494
497
        things similar to this.
495
498
 
496
499
        """
497
 
        assert isinstance(glob_str, unicode), u"The glob string " + util.bytes_to_uc(glob_str) + u" is not unicode"
 
500
        assert isinstance(glob_str, unicode), \
 
501
            u"The glob string " + glob_str.decode(sys.getfilesystemencoding(), "ignore") + u" is not unicode"
498
502
        ignore_case = False
499
503
 
500
504
        if glob_str.lower().startswith("ignorecase:"):