summaryrefslogtreecommitdiffstats
path: root/editor.py
diff options
context:
space:
mode:
Diffstat (limited to 'editor.py')
-rw-r--r--editor.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/editor.py b/editor.py
index fcf16386..b84a42d4 100644
--- a/editor.py
+++ b/editor.py
@@ -1,5 +1,3 @@
1# -*- coding:utf-8 -*-
2#
3# Copyright (C) 2008 The Android Open Source Project 1# Copyright (C) 2008 The Android Open Source Project
4# 2#
5# Licensed under the Apache License, Version 2.0 (the "License"); 3# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,7 +12,6 @@
14# See the License for the specific language governing permissions and 12# See the License for the specific language governing permissions and
15# limitations under the License. 13# limitations under the License.
16 14
17from __future__ import print_function
18import os 15import os
19import re 16import re
20import sys 17import sys
@@ -24,6 +21,7 @@ import tempfile
24from error import EditorError 21from error import EditorError
25import platform_utils 22import platform_utils
26 23
24
27class Editor(object): 25class Editor(object):
28 """Manages the user's preferred text editor.""" 26 """Manages the user's preferred text editor."""
29 27
@@ -57,7 +55,7 @@ class Editor(object):
57 55
58 if os.getenv('TERM') == 'dumb': 56 if os.getenv('TERM') == 'dumb':
59 print( 57 print(
60"""No editor specified in GIT_EDITOR, core.editor, VISUAL or EDITOR. 58 """No editor specified in GIT_EDITOR, core.editor, VISUAL or EDITOR.
61Tried to fall back to vi but terminal is dumb. Please configure at 59Tried to fall back to vi but terminal is dumb. Please configure at
62least one of these before using this command.""", file=sys.stderr) 60least one of these before using this command.""", file=sys.stderr)
63 sys.exit(1) 61 sys.exit(1)
@@ -104,10 +102,10 @@ least one of these before using this command.""", file=sys.stderr)
104 rc = subprocess.Popen(args, shell=shell).wait() 102 rc = subprocess.Popen(args, shell=shell).wait()
105 except OSError as e: 103 except OSError as e:
106 raise EditorError('editor failed, %s: %s %s' 104 raise EditorError('editor failed, %s: %s %s'
107 % (str(e), editor, path)) 105 % (str(e), editor, path))
108 if rc != 0: 106 if rc != 0:
109 raise EditorError('editor failed with exit status %d: %s %s' 107 raise EditorError('editor failed with exit status %d: %s %s'
110 % (rc, editor, path)) 108 % (rc, editor, path))
111 109
112 with open(path, mode='rb') as fd2: 110 with open(path, mode='rb') as fd2:
113 return fd2.read().decode('utf-8') 111 return fd2.read().decode('utf-8')