/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Alexander Belchenko
  • Date: 2009-05-14 08:24:48 UTC
  • mto: This revision was merged to the branch mainline in revision 4364.
  • Revision ID: bialix@ukr.net-20090514082448-12lcq3mq3jgb4jc4
osutils.py: get_unicode_argv function (to obtain unicode command line arguments from sys.argv) moved to the beginning of module based on suggestions from review of John Meinel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
O_BINARY = getattr(os, 'O_BINARY', 0)
78
78
 
79
79
 
 
80
def get_unicode_argv():
 
81
    try:
 
82
        user_encoding = get_user_encoding()
 
83
        return [a.decode(user_encoding) for a in sys.argv[1:]]
 
84
    except UnicodeDecodeError:
 
85
        raise errors.BzrError(("Parameter '%r' is unsupported by the current "
 
86
                                                            "encoding." % a))
 
87
 
 
88
 
80
89
def make_readonly(filename):
81
90
    """Make a filename read-only."""
82
91
    mod = os.lstat(filename).st_mode
390
399
    def rmtree(path, ignore_errors=False, onerror=_win32_delete_readonly):
391
400
        """Replacer for shutil.rmtree: could remove readonly dirs/files"""
392
401
        return shutil.rmtree(path, ignore_errors, onerror)
 
402
 
 
403
    f = win32utils.get_unicode_argv     # special function or None
 
404
    if f is not None:
 
405
        get_unicode_argv = f
 
406
 
393
407
elif sys.platform == 'darwin':
394
408
    getcwd = _mac_getcwd
395
409
 
1799
1813
        finally:
1800
1814
            termios.tcsetattr(fd, termios.TCSADRAIN, settings)
1801
1815
        return ch
1802
 
 
1803
 
 
1804
 
def get_unicode_argv():
1805
 
    try:
1806
 
        user_encoding = get_user_encoding()
1807
 
        return [a.decode(user_encoding) for a in sys.argv[1:]]
1808
 
    except UnicodeDecodeError:
1809
 
        raise errors.BzrError(("Parameter '%r' is unsupported by the current "
1810
 
                                                            "encoding." % a))
1811
 
 
1812
 
if sys.platform == 'win32':
1813
 
    f = getattr(win32utils, 'get_unicode_argv', None)
1814
 
    if f is not None:
1815
 
        get_unicode_argv = f