~russell/ibid/jira-plugin

« back to all changes in this revision

Viewing changes to ibid/plugins/help.py

  • Committer: Stefano Rivera
  • Date: 2009-03-05 16:33:12 UTC
  • mto: This revision was merged to the branch mainline in revision 560.
  • Revision ID: stefano@rivera.za.net-20090305163312-yz582e9ytzt72v94
Convertion of tabs to spaces. Addition of vi configuration lines.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
help = {'help': u'Provides help and usage information about plugins.'}
7
7
 
8
8
class Help(Processor):
9
 
        u"""features
10
 
        help [<feature>]
11
 
        usage <feature>"""
12
 
        feature = 'help'
13
 
 
14
 
        @match(r'^help$')
15
 
        def intro(self, event):
16
 
                event.addresponse(u'Use "features" to get a list of available features. "help <feature>" will give a description of the feature, and "usage <feature>" will describe how to use it.')
17
 
 
18
 
        @match(r'^features$')
19
 
        def features(self, event):
20
 
                features = []
21
 
 
22
 
                for processor in ibid.processors:
23
 
                        module = eval(processor.__module__)
24
 
                        if hasattr(module, 'help'):
25
 
                                for feature in module.help.keys():
26
 
                                        if feature not in features:
27
 
                                                features.append(feature)
28
 
 
29
 
                event.addresponse(u' '.join(features))
30
 
 
31
 
        @match(r'^help\s+(.+)$')
32
 
        def help(self, event, feature):
33
 
                feature = feature.lower()
34
 
 
35
 
                for processor in ibid.processors:
36
 
                        module = eval(processor.__module__)
37
 
                        if hasattr(module, 'help') and feature in module.help:
38
 
                                event.addresponse(module.help[feature])
39
 
                                return
40
 
 
41
 
                event.addresponse(u"I can't help you with %s" % feature)
42
 
 
43
 
        @match(r'^(?:usage|how\s+do\s+I\s+use)\s+(.+)$')
44
 
        def usage(self, event, feature):
45
 
                feature = feature.lower()
46
 
 
47
 
                for processor in ibid.processors:
48
 
                        for name, klass in inspect.getmembers(processor, inspect.isclass):
49
 
                                if hasattr(klass, 'feature') and klass.feature == feature and klass.__doc__:
50
 
                                        for line in klass.__doc__.splitlines():
51
 
                                                event.addresponse('Usage: %s' % line.strip())
52
 
 
53
 
                if not event.responses:
54
 
                        event.addresponse(u"I don't know how to use %s either" % feature)
 
9
    u"""features
 
10
    help [<feature>]
 
11
    usage <feature>"""
 
12
    feature = 'help'
 
13
 
 
14
    @match(r'^help$')
 
15
    def intro(self, event):
 
16
        event.addresponse(u'Use "features" to get a list of available features. '
 
17
            u'"help <feature>" will give a description of the feature, and "usage <feature>" will describe how to use it.')
 
18
 
 
19
    @match(r'^features$')
 
20
    def features(self, event):
 
21
        features = []
 
22
 
 
23
        for processor in ibid.processors:
 
24
            module = eval(processor.__module__)
 
25
            if hasattr(module, 'help'):
 
26
                for feature in module.help.keys():
 
27
                    if feature not in features:
 
28
                        features.append(feature)
 
29
 
 
30
        event.addresponse(u' '.join(features))
 
31
 
 
32
    @match(r'^help\s+(.+)$')
 
33
    def help(self, event, feature):
 
34
        feature = feature.lower()
 
35
 
 
36
        for processor in ibid.processors:
 
37
            module = eval(processor.__module__)
 
38
            if hasattr(module, 'help') and feature in module.help:
 
39
                event.addresponse(module.help[feature])
 
40
                return
 
41
 
 
42
        event.addresponse(u"I can't help you with %s" % feature)
 
43
 
 
44
    @match(r'^(?:usage|how\s+do\s+I\s+use)\s+(.+)$')
 
45
    def usage(self, event, feature):
 
46
        feature = feature.lower()
 
47
 
 
48
        for processor in ibid.processors:
 
49
            for name, klass in inspect.getmembers(processor, inspect.isclass):
 
50
                if hasattr(klass, 'feature') and klass.feature == feature and klass.__doc__:
 
51
                    for line in klass.__doc__.splitlines():
 
52
                        event.addresponse('Usage: %s' % line.strip())
 
53
 
 
54
        if not event.responses:
 
55
            event.addresponse(u"I don't know how to use %s either" % feature)
 
56
 
 
57
# vi: set et sta sw=4 ts=4: