Fix my busted 1512c0e2a64e patch to libbe/util/encoding.py.
authorW. Trevor King <wking@drexel.edu>
Mon, 14 Nov 2011 02:06:43 +0000 (21:06 -0500)
committerW. Trevor King <wking@drexel.edu>
Mon, 14 Nov 2011 02:06:43 +0000 (21:06 -0500)
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.

interfaces/email/interactive/be-handle-mail
libbe/command/html.py
libbe/storage/util/config.py
libbe/storage/vcs/base.py
libbe/ui/util/editor.py
libbe/util/encoding.py

index e20934a4bd56fa7012d734a254747bbee8a4532f..1a48ead470f3b10ac1992e64ace71d107d992c26 100755 (executable)
@@ -721,7 +721,7 @@ def open_logfile(logpath=None):
             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']:
index 7420ce8ab5ef879b4530d581f3a0edf75cc44371..a6bd2a27e3fd172a7f4e5191bb7af055140827e3 100644 (file)
@@ -149,7 +149,7 @@ class HTMLGen (object):
         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
 
index 714d4e78f8f779adae905069e162fedfb492e68c..d138bf4bd392653a5927bf02a87c52d6cc89458c 100644 (file)
@@ -31,10 +31,10 @@ if libbe.TESTING == True:
     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():
index 22874a5a12f24d990fb218091d112e5ec458b0d7..eaaf2d8c1908dc5999548dc99c1fc852c82e00ba 100644 (file)
@@ -199,7 +199,7 @@ class CachedPathID (object):
     >>> 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):
@@ -350,7 +350,7 @@ class VCS (libbe.storage.base.VersionedStorage):
 
     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
index 206e9c4117bfa7eec768b613caf79c825c4ed5b1..fb511599663f72b9795c5da27681961fa3379545 100644 (file)
@@ -65,7 +65,7 @@ def editor_string(comment=None, encoding=None):
     >>> 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] != '':
index 8663744da2e373fb3c7b6f2599eeeaeada094ab1..949b3cecdcff659afc3b7c23dc848fb1a0bc0e57 100644 (file)
@@ -54,7 +54,7 @@ def get_output_encoding():
 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()
@@ -75,7 +75,7 @@ def known_encoding(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)
@@ -86,7 +86,7 @@ def get_file_contents(path, mode='r', encoding=None, decode=False):
 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)