Quick actions

cmd+k|ctrl+k

Navigation

Languages

3 Dependency Injection ToDo

Snippet info

Language

Python

Visibility

public

Author

johan.van.breda

Created

2019-03-13T10:16:45Z

Updated

2019-03-13T13:36:39Z


class AbstractProcessor() :
    def __init__(self,data) :
        self.data = data
    def run(self) :
        pass
    
class Runner() :
    def __init__(self,processor) :
        self.processor = processor
    def process(self) :
        if self.processor :
            self.processor.run()
        
def main(argv) :
    try :
        runner = None
        if len(argv) > 1 :
            if argv[0] == 'msg' :
                # says 'the message is : <message>'
                runner = Runner(MsgProcessor(argv[1]))
            elif argv[0] == 'ask' :
                # says 'the question is : <question>'
                runner = Runner(AskProcessor(argv[1]))
            runner.process()
    except Exception as e :
        print('main: exception occurred ' + str(e))
        
if __name__ == '__main__' :
    try :
        argv = []
        argv.append('ask')
        argv.append('is this a question')
        main(argv)
    except (SystemExit,KeyboardInterrup) :
        pass
INFO