Simplify code

This commit is contained in:
Kovid Goyal 2019-06-05 08:26:25 +05:30
parent c0a96f2087
commit 98d7fc9f39
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -714,25 +714,22 @@ def create_opts(args, debug_config=False, accumulate_bad_lines=None):
from .config import load_config from .config import load_config
config = tuple(resolve_config(SYSTEM_CONF, defconf, args.config)) config = tuple(resolve_config(SYSTEM_CONF, defconf, args.config))
if debug_config: if debug_config:
from io import StringIO print(version(add_rev=True))
dbuf = StringIO() print(' '.join(os.uname()))
print(version(add_rev=True), file=dbuf)
print(' '.join(os.uname()), file=dbuf)
if is_macos: if is_macos:
import subprocess import subprocess
print(' '.join(subprocess.check_output(['sw_vers']).decode('utf-8').splitlines()).strip(), file=dbuf) print(' '.join(subprocess.check_output(['sw_vers']).decode('utf-8').splitlines()).strip())
if os.path.exists('/etc/issue'): if os.path.exists('/etc/issue'):
print(open('/etc/issue', encoding='utf-8', errors='replace').read().strip(), file=dbuf) print(open('/etc/issue', encoding='utf-8', errors='replace').read().strip())
if os.path.exists('/etc/lsb-release'): if os.path.exists('/etc/lsb-release'):
print(open('/etc/lsb-release', encoding='utf-8', errors='replace').read().strip(), file=dbuf) print(open('/etc/lsb-release', encoding='utf-8', errors='replace').read().strip())
config = tuple(x for x in config if os.path.exists(x)) config = tuple(x for x in config if os.path.exists(x))
if config: if config:
print(green('Loaded config files:'), ', '.join(config), file=dbuf) print(green('Loaded config files:'), ', '.join(config))
overrides = (a.replace('=', ' ', 1) for a in args.override or ()) overrides = (a.replace('=', ' ', 1) for a in args.override or ())
opts = load_config(*config, overrides=overrides, accumulate_bad_lines=accumulate_bad_lines) opts = load_config(*config, overrides=overrides, accumulate_bad_lines=accumulate_bad_lines)
if debug_config: if debug_config:
if not is_macos: if not is_macos:
print('Running under:', green('Wayland' if is_wayland(opts) else 'X11'), file=dbuf) print('Running under:', green('Wayland' if is_wayland(opts) else 'X11'))
print(dbuf.getvalue())
compare_opts(opts) compare_opts(opts)
return opts return opts