~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Patch Queue Manager
  • Date: 2011-09-08 11:01:15 UTC
  • mfrom: (6123.1.16 gpg-typo)
  • Revision ID: pqm@cupuasso-20110908110115-gbb9benwkdksvzk5
(jelmer) Fix a typo (invalid format identifier) in an error message in
 bzrlib.gpg. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
    trace,
48
48
    win32utils,
49
49
    )
50
 
from bzrlib.i18n import gettext
51
50
""")
52
51
 
53
52
from bzrlib.symbol_versioning import (
90
89
        user_encoding = get_user_encoding()
91
90
        return [a.decode(user_encoding) for a in sys.argv[1:]]
92
91
    except UnicodeDecodeError:
93
 
        raise errors.BzrError(gettext("Parameter {0!r} encoding is unsupported by {1} "
94
 
            "application locale.").format(a, user_encoding))
 
92
        raise errors.BzrError("Parameter %r encoding is unsupported by %s "
 
93
            "application locale." % (a, user_encoding))
95
94
 
96
95
 
97
96
def make_readonly(filename):
191
190
            if e.errno == errno.ENOENT:
192
191
                return False;
193
192
            else:
194
 
                raise errors.BzrError(gettext("lstat/stat of ({0!r}): {1!r}").format(f, e))
 
193
                raise errors.BzrError("lstat/stat of (%r): %r" % (f, e))
195
194
 
196
195
 
197
196
def fancy_rename(old, new, rename_func, unlink_func):
279
278
    # copy posixpath.abspath, but use os.getcwdu instead
280
279
    if not posixpath.isabs(path):
281
280
        path = posixpath.join(getcwd(), path)
282
 
    return _posix_normpath(path)
 
281
    return posixpath.normpath(path)
283
282
 
284
283
 
285
284
def _posix_realpath(path):
286
285
    return posixpath.realpath(path.encode(_fs_enc)).decode(_fs_enc)
287
286
 
288
287
 
289
 
def _posix_normpath(path):
290
 
    path = posixpath.normpath(path)
291
 
    # Bug 861008: posixpath.normpath() returns a path normalized according to
292
 
    # the POSIX standard, which stipulates (for compatibility reasons) that two
293
 
    # leading slashes must not be simplified to one, and only if there are 3 or
294
 
    # more should they be simplified as one. So we treat the leading 2 slashes
295
 
    # as a special case here by simply removing the first slash, as we consider
296
 
    # that breaking POSIX compatibility for this obscure feature is acceptable.
297
 
    # This is not a paranoid precaution, as we notably get paths like this when
298
 
    # the repo is hosted at the root of the filesystem, i.e. in "/".    
299
 
    if path.startswith('//'):
300
 
        path = path[1:]
301
 
    return path
302
 
 
303
 
 
304
288
def _win32_fixdrive(path):
305
289
    """Force drive letters to be consistent.
306
290
 
394
378
abspath = _posix_abspath
395
379
realpath = _posix_realpath
396
380
pathjoin = os.path.join
397
 
normpath = _posix_normpath
 
381
normpath = os.path.normpath
398
382
getcwd = os.getcwdu
399
383
rename = os.rename
400
384
dirname = os.path.dirname
941
925
    rps = []
942
926
    for f in ps:
943
927
        if f == '..':
944
 
            raise errors.BzrError(gettext("sorry, %r not allowed in path") % f)
 
928
            raise errors.BzrError("sorry, %r not allowed in path" % f)
945
929
        elif (f == '.') or (f == ''):
946
930
            pass
947
931
        else:
952
936
def joinpath(p):
953
937
    for f in p:
954
938
        if (f == '..') or (f is None) or (f == ''):
955
 
            raise errors.BzrError(gettext("sorry, %r not allowed in path") % f)
 
939
            raise errors.BzrError("sorry, %r not allowed in path" % f)
956
940
    return pathjoin(*p)
957
941
 
958
942
 
1170
1154
 
1171
1155
    if len(base) < MIN_ABS_PATHLENGTH:
1172
1156
        # must have space for e.g. a drive letter
1173
 
        raise ValueError(gettext('%r is too short to calculate a relative path')
 
1157
        raise ValueError('%r is too short to calculate a relative path'
1174
1158
            % (base,))
1175
1159
 
1176
1160
    rp = abspath(path)