diff options
Diffstat (limited to 'editor.py')
| -rw-r--r-- | editor.py | 10 |
1 files changed, 4 insertions, 6 deletions
| @@ -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 | ||
| 17 | from __future__ import print_function | ||
| 18 | import os | 15 | import os |
| 19 | import re | 16 | import re |
| 20 | import sys | 17 | import sys |
| @@ -24,6 +21,7 @@ import tempfile | |||
| 24 | from error import EditorError | 21 | from error import EditorError |
| 25 | import platform_utils | 22 | import platform_utils |
| 26 | 23 | ||
| 24 | |||
| 27 | class Editor(object): | 25 | class 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. |
| 61 | Tried to fall back to vi but terminal is dumb. Please configure at | 59 | Tried to fall back to vi but terminal is dumb. Please configure at |
| 62 | least one of these before using this command.""", file=sys.stderr) | 60 | least 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') |
