Initial Commit
[Projects.git] / pkgbuilds / pytivo / pkg / usr / share / pyTivo / plugins / settings / buildhelp.py
blob56b2d394bde0daf48675d33c4af920fe23f157f8
1 import os
3 SCRIPTDIR = os.path.dirname(__file__)
5 ## Build initial help list
6 help_list = {}
7 title = ''
8 settings_known = {}
9 titlemode = True
10 f = open(os.path.join(SCRIPTDIR, 'help.txt'))
11 try:
12 for line in f:
13 line = line.strip()
14 if not line or line.startswith('#'):
15 # skip blank or commented lines
16 titlemode = True
17 elif line.startswith('>'):
18 help_list[title][-1] += ' ' + line[1:]
19 elif ':' not in line:
20 if titlemode:
21 title = line
22 help_list[title] = []
23 titlemode = False
24 else:
25 help_list[title][-1] += ' ' + line
26 else:
27 titlemode = False
28 value, data = [x.strip() for x in line.split(':', 1)]
29 if value.lower() == 'available in':
30 # special setting to create section_known array
31 for section in data.split(','):
32 section = section.lower().strip()
33 if section not in settings_known:
34 settings_known[section] = []
35 settings_known[section].append(title)
36 else:
37 help_list[title].append(line)
38 finally:
39 f.close()
40 ## Done building help list
42 def gethelp():
43 return help_list
45 def getknown(section):
46 return settings_known[section]