Nicely align setting names and values.
This commit is contained in:
parent
bd7c5c2110
commit
4f354ab291
7
av98.py
7
av98.py
|
@ -989,15 +989,18 @@ Slow internet connection? Use 'set timeout' to be more patient.""")
|
|||
@restricted
|
||||
def do_set(self, line):
|
||||
"""View or set various options."""
|
||||
# Compute some constants for pretty alignment
|
||||
ljust = max((len(k) for k in self.options.keys()))
|
||||
rjust = max((len(str(v)) for v in self.options.values()))
|
||||
if not line.strip():
|
||||
# Show all current settings
|
||||
for option in sorted(self.options.keys()):
|
||||
print("%s %s" % (option, self.options[option]))
|
||||
print("%s %s" % (option.ljust(ljust+4), str(self.options[option]).rjust(rjust)))
|
||||
elif len(line.split()) == 1:
|
||||
# Show current value of one specific setting
|
||||
option = line.strip()
|
||||
if option in self.options:
|
||||
print("%s %s" % (option, self.options[option]))
|
||||
print("%s %s" % (option.ljust(ljust+4), str(self.options[option]).rjust(rjust)))
|
||||
else:
|
||||
print("Unrecognised option %s" % option)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue