aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/ui/util
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-12-14 07:37:51 -0500
committerW. Trevor King <wking@drexel.edu>2009-12-14 07:37:51 -0500
commit19fe0817ba7c2cd04caea3adfa82d4490288a548 (patch)
tree6291cac9b9861f1009d63a419c3e79879f356bc8 /libbe/ui/util
parent2f0ceedba5b6619faf476cd1aa67e826e91d5c7c (diff)
downloadbugseverywhere-19fe0817ba7c2cd04caea3adfa82d4490288a548.tar.gz
Transitioned comment to Command format
Diffstat (limited to 'libbe/ui/util')
-rw-r--r--libbe/ui/util/editor.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/libbe/ui/util/editor.py b/libbe/ui/util/editor.py
index 859cedc..83262e7 100644
--- a/libbe/ui/util/editor.py
+++ b/libbe/ui/util/editor.py
@@ -28,12 +28,12 @@ import sys
import tempfile
import libbe
+import libbe.util.encoding
+
if libbe.TESTING == True:
import doctest
-default_encoding = sys.getfilesystemencoding() or locale.getpreferredencoding()
-
comment_marker = u"== Anything below this line will be ignored\n"
class CantFindEditor(Exception):
@@ -60,7 +60,7 @@ def editor_string(comment=None, encoding=None):
>>> del os.environ["VISUAL"]
"""
if encoding == None:
- encoding = default_encoding
+ encoding = libbe.util.encoding.get_filesystem_encoding()
for name in ('VISUAL', 'EDITOR'):
try:
editor = os.environ[name]
@@ -77,9 +77,8 @@ def editor_string(comment=None, encoding=None):
os.close(fhandle)
oldmtime = os.path.getmtime(fname)
os.system("%s %s" % (editor, fname))
- f = codecs.open(fname, "r", encoding)
- output = trimmed_string(f.read())
- f.close()
+ output = libbe.util.encoding.get_file_contents(
+ fname, encoding=encoding, decode=True)
if output.rstrip('\n') == "":
output = None
finally: