Some temporary changes to encoding.py seem to have been added to
commit
1512c0e2a64e19c8d4e5697257a4df5ddd8bc727
Author: W. Trevor King <wking@drexel.edu>
Date: Tue Nov 8 07:14:43 2011 -0500
by accident.
The initial change came from discussions with Niall Douglas, during
which I realized that "filesystem encoding" ususally means the
encoding for the *path*, not the *contents*. To avoid further
confusion I'd renamed `get_filesystem_encoding` to the less ambiguous
`get_text_file_encoding`. This commit should complete the transition.
LOGPATH = os.path.join(_THIS_DIR, logpath)
if LOGFILE == None and LOGPATH != u'none':
LOGFILE = codecs.open(LOGPATH, u'a+',
- libbe.util.encoding.get_filesystem_encoding())
+ libbe.util.encoding.get_text_file_encoding())
def close_logfile():
if LOGFILE != None and LOGPATH not in [u'stderr', u'none']:
if encoding != None:
self.encoding = encoding
else:
- self.encoding = libbe.util.encoding.get_filesystem_encoding()
+ self.encoding = libbe.util.encoding.get_text_file_encoding()
self._load_templates(template_dir)
self.min_id_length = min_id_length
import doctest
-default_encoding = libbe.util.encoding.get_filesystem_encoding()
+default_encoding = libbe.util.encoding.get_text_file_encoding()
"""Default filesystem encoding.
-Initialized with :func:`libbe.util.encoding.get_filesystem_encoding`.
+Initialized with :func:`libbe.util.encoding.get_text_file_encoding`.
"""
def path():
>>> dir.cleanup()
"""
def __init__(self, encoding=None):
- self.encoding = libbe.util.encoding.get_filesystem_encoding()
+ self.encoding = libbe.util.encoding.get_text_file_encoding()
self._spacer_dirs = ['.be', 'bugs', 'comments']
def root(self, path):
def __init__(self, *args, **kwargs):
if 'encoding' not in kwargs:
- kwargs['encoding'] = libbe.util.encoding.get_filesystem_encoding()
+ kwargs['encoding'] = libbe.util.encoding.get_text_file_encoding()
libbe.storage.base.VersionedStorage.__init__(self, *args, **kwargs)
self.versioned = False
self.interspersed_vcs_files = False
>>> del os.environ["VISUAL"]
"""
if encoding == None:
- encoding = libbe.util.encoding.get_filesystem_encoding()
+ encoding = libbe.util.encoding.get_text_file_encoding()
editor = None
for name in ('VISUAL', 'EDITOR'):
if name in os.environ and os.environ[name] != '':
def get_text_file_encoding():
"""Return the encoding that should be used for file contents
"""
- return 'utf-8'
+ return get_encoding()
def get_argv_encoding():
return get_encoding()
def get_file_contents(path, mode='r', encoding=None, decode=False):
if decode == True:
if encoding == None:
- encoding = get_filesystem_encoding()
+ encoding = get_text_file_encoding()
f = codecs.open(path, mode, encoding)
else:
f = open(path, mode)
def set_file_contents(path, contents, mode='w', encoding=None):
if type(contents) == types.UnicodeType:
if encoding == None:
- encoding = get_filesystem_encoding()
+ encoding = get_text_file_encoding()
f = codecs.open(path, mode, encoding)
else:
f = open(path, mode)