1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-02-24 19:22:13 +01:00

Implement functions to get defaults for editor/pager.

These are platform specific, for example on Debian we want to use
the ones provided by sensible-utils.
This commit is contained in:
Michal Čihař 2010-06-09 14:20:48 +02:00
parent 163b3e3dfa
commit 42b5f3961d

View File

@ -2585,6 +2585,38 @@ def read_meta_from_spec(specfile, *args):
return spec_data
def get_default_editor():
import platform
system = platform.system()
if system == 'Windows':
return 'notepad'
if system == 'Linux':
try:
# Python 2.6
dist = platform.linux_distributionx()[0]
except AttributeError:
dist = platform.dist()[0]
if dist == 'debian':
return 'editor'
return 'vim'
return 'vi'
def get_default_pager():
import platform
system = platform.system()
if system == 'Windows':
return 'less'
if system == 'Linux':
try:
# Python 2.6
dist = platform.linux_distributionx()[0]
except AttributeError:
dist = platform.dist()[0]
if dist == 'debian':
return 'pager'
return 'less'
return 'more'
def run_pager(message):
import tempfile, sys