From a219dcb78daf58ecf592ffd4a0e9d187ca9f0b81 Mon Sep 17 00:00:00 2001 From: William McBrine Date: Sat, 21 Feb 2009 05:35:58 -0500 Subject: [PATCH] Pythonic. --- plugins/admin/buildhelp.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/plugins/admin/buildhelp.py b/plugins/admin/buildhelp.py index 9d62884..5a3087b 100644 --- a/plugins/admin/buildhelp.py +++ b/plugins/admin/buildhelp.py @@ -11,35 +11,32 @@ f = open(os.path.join(SCRIPTDIR, 'help.txt')) try: for line in f: line = line.strip() - if multiline != '': - if (line.rfind('+\\') + 2) == len(line): - multiline += line[0:(len(line) - 2)] - continue + if multiline: + if line.endswith('+\\'): + multiline += line[:-2] else: multiline += line help_list[title].append(multiline) multiline = '' - continue - if line == '' or line.find('#') >= 0: + continue + if not line or line.startswith('#'): # skip blank or commented lines continue - if line.find(':') <= 0: + if ':' not in line: title = line help_list[title] = [] else: - value = line.split(':', 1)[0].strip() - data = line.split(':', 1)[1].strip() + value, data = [x.strip() for x in line.split(':', 1)] if value.lower() == 'available in': # special setting to create section_known array - data = data.split(',') - for section in data: + for section in data.split(','): section = section.lower().strip() if section not in settings_known: settings_known[section] = [] settings_known[section].append(title) else: - if (line.rfind('+\\') + 2) == len(line): - multiline += line[0:(len(line) - 2)] + if line.endswith('+\\'): + multiline += line[:-2] else: help_list[title].append(line) finally: -- 2.11.4.GIT