~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-25 15:01:52 UTC
  • mto: This revision was merged to the branch mainline in revision 1962.
  • Revision ID: john@arbash-meinel.com-20060825150152-006e591e9cfb120e
Change the name of the test classes (test_lang => test_locale), move the function into osutils.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""bzr library"""
18
18
 
 
19
from bzrlib.osutils import get_user_encoding
 
20
 
19
21
 
20
22
IGNORE_FILENAME = ".bzrignore"
21
23
 
22
 
import os
23
 
import sys
24
 
 
25
 
 
26
 
def get_user_encoding():
27
 
    if sys.platform == 'darwin':
28
 
        # work around egregious python 2.4 bug
29
 
        sys.platform = 'posix'
30
 
        import locale
31
 
        sys.platform = 'darwin'
32
 
    else:
33
 
        import locale
34
 
    # XXX: This probably belongs in osutils instead
35
 
    user_encoding = None
36
 
    try:
37
 
        user_encoding = locale.getpreferredencoding()
38
 
    except locale.Error, e:
39
 
        sys.stderr.write('WARNING: %s\n'
40
 
                         '  Could not determine your preferred encoding.\n'
41
 
                         '  Usually, this is because python does not support'
42
 
                         ' your LANG (%r)\n'
43
 
                         "  Using 'ascii' encoding.\n"
44
 
                         % (e, os.environ.get('LANG')))
45
 
 
46
 
    if user_encoding is None:
47
 
        return 'ascii'
48
 
    return user_encoding
49
 
 
 
24
 
 
25
# XXX: Compatibility. This should probably be deprecated
50
26
user_encoding = get_user_encoding()
51
27
 
52
28