Add "(TS)" to the names of transport-stream .TiVo files, and use ".ts"
[pyTivo/wmcbrine/lucasnz.git] / plugins / settings / buildhelp.py
blob95b5fece47bbc7053c6739e0c84f466d0fc08acb
1 import os
3 SCRIPTDIR = os.path.dirname(__file__)
5 ## Build initial help list
6 help_list = {}
7 title = ''
8 settings_known = {}
9 mode = {}
10 options = {}
11 default = {}
12 titlemode = True
13 f = open(os.path.join(SCRIPTDIR, 'help.txt'))
14 try:
15 for line in f:
16 line = line.strip()
17 if not line or line.startswith('#'):
18 # skip blank or commented lines
19 titlemode = True
20 elif line.startswith('>'):
21 help_list[title][-1] += ' ' + line[1:]
22 elif ':' not in line:
23 if titlemode:
24 title = line
25 help_list[title] = []
26 titlemode = False
27 else:
28 help_list[title][-1] += ' ' + line
29 else:
30 titlemode = False
31 value, data = [x.strip() for x in line.split(':', 1)]
32 if value.lower() == 'available in':
33 # special setting to create section_known array
34 for section in data.split(','):
35 section = section.lower().strip()
36 if section not in settings_known:
37 settings_known[section] = []
38 settings_known[section].append(title)
39 elif value.lower() == 'mode':
40 mode[title] = data
41 elif value.lower() == 'options':
42 options[title] = data.split('/')
43 else:
44 help_list[title].append(line)
45 if value.lower() == 'default setting':
46 default[title] = data
47 finally:
48 f.close()
49 ## Done building help list
50 plugins = [p for p in os.listdir(os.path.dirname(SCRIPTDIR))
51 if not p.startswith(('__init__', 'togo', 'settings'))]
52 options['type'] = plugins
54 def gethelp():
55 return help_list
57 def getknown(section):
58 return settings_known[section]