# ! /Usr/bin/ENV Python # -*-Coding: UTF-8 -*- Import Syssys. Path. append ( " .. " ) Import Common Class Component: Def _ Init __ (Self, data): Self. url = Data [ " URL " ] Self. noteid = Data [ " Noteid " ] Self. userid = Data [ " Userid " ] Self. folderid = Data [ " Folderid " ] Def Execute (Self ): Pass Class Notecomponent (Component ): Def _ Init __ (Self, Data, Component = None): Self. Component = Component component. _ Init __ (Self, data) Def Setcomponent (self, component): Self. Component = Component Class Htmlcatcher (notecomponent ): Def Execute (Self ): If Self. Component! = None: self.component.exe cute () Print Self. _ Class __ . _ Name __ Class Imagecatcher (notecomponent ): Def Execute (Self ): If Self. Component! = None: self.component.exe cute () Print Self. _ Class __ . _ Name __ Class Sharenotecomponet (notecomponent ): Def Execute (Self ): If Self. Component! = None: self.component.exe cute () Print Self. _ Class __ . _ Name __ Def Process (Message): Component = None If Message [ ' Type ' ] & Common. catch_page: Component = Htmlcatcher (Message [ " Data " ]) If Message [ ' Type ' ] & Common. catch_image: component1 = Imagecatcher (Message [ " Data " ]) Component1.setcomponent (Component) Component = Component1 If Message [ ' Type ' ] & Common. save_shared: component1 = Sharenotecomponet (Message [ " Data " ]) Component1.setcomponent (Component) Component = Component1 component.exe cute () If _ Name __ = " _ Main __ " : Message ={ # "Type": Common. catch_page, # "Type": Common. catch_image | common. save_shared, " Type " : Common. catch_page | common. save_shared | Common. catch_image, " Data " :{ " URL " : " Http://www.baidu.com " , " Noteid " 100 , " Userid " 100 , " Folderid " 100 ,} Process (Message)