|
|
@@ -0,0 +1,34 @@
|
|
|
+import input_sources
|
|
|
+import base
|
|
|
+import output
|
|
|
+
|
|
|
+class Help(base.BaseService):
|
|
|
+ def __init__(self, services):
|
|
|
+ self.services = services
|
|
|
+
|
|
|
+ def call(self):
|
|
|
+ if input_sources.token_available():
|
|
|
+ t = input_sources.get_token(0)
|
|
|
+ if t in self.services:
|
|
|
+ h = self.services[t].help()
|
|
|
+ if h:
|
|
|
+ output.tts(h)
|
|
|
+ else:
|
|
|
+ output.tts('No help available.')
|
|
|
+ else:
|
|
|
+ output.failure(s='The service "%s" is not available.' % t)
|
|
|
+
|
|
|
+ else:
|
|
|
+ initialized = [s for s in self.services if self.services[s].initialized]
|
|
|
+ not_initialized = [s for s in self.services if not self.services[s].initialized]
|
|
|
+
|
|
|
+ if not_initialized:
|
|
|
+ if initialized:
|
|
|
+ output.tts('Initialized: %s' % ', '.join(initialized))
|
|
|
+ if not_initialized:
|
|
|
+ output.tts('Not initialized: %s' % ', '.join(not_initialized))
|
|
|
+ else:
|
|
|
+ if initialized:
|
|
|
+ output.tts(', '.join(initialized))
|
|
|
+ def help(self):
|
|
|
+ return 'Provides help for the different services available.'
|