Commits

Andi Miller committed 8778a2e

Few experimental changes

  • Participants
  • Parent commits 651ef51
  • Branches feature-modulereloading

Comments (0)

Files changed (2)

             self.userKicked = []
             self.main = []
         self.logger.log("WARN", "Loading modules")
-        i = Importer(self.logger)
-        self.functions = i.functions
-        self.joinedFunctions = i.joined
-        self.userKicked = i.userKicked
-        self.main = i.main
+        self.importer.load() # = Importer(self.logger)
+        self.functions = self.importer.functions
+        self.joinedFunctions = self.importer.joined
+        self.userKicked = self.importer.userKicked
+        self.main = self.importer.main
 
     def init(self):
+        self.importer = Importer(self.logger)
         self.loadModules()
         self.logger.log("INFO", "Starting main loop")
         if "main" in dir(self):
 from logger import Logger
 from types import FunctionType
 import re
+import sets
+
 stripinternals = lambda x:x[0:2]!="__"
 
 class Importer(object):
         self.userKicked = []
         self.joined = []
         self.main = []
+
+    def load(self):
+        oldLoadedModules = map(lambda x:x.__name__,self.loadedModules)
+        self.logger.log("INFO", "Old modules: %s" % oldLoadedModules)
         for oldmodule in self.loadedModules:
             self.loadedModules.remove(oldmodule)
             del sys.modules[oldmodule.__name__]
         for file in os.listdir("modules/"):
             if file.endswith(".py"):
                 self._import(file)
-        self.logger.log("WARN", str(self.loadedModules))
+        newModules = map(lambda x:x.__name__, self.loadedModules)
+        self.logger.log("INFO", "New modules: %s" % newModules)
+        return set(oldLoadedModules).difference(set(newModules))
+        self.logger.log("WARN", dir(filter(lambda x: x.__name__=="bitbucketlive", self.loadedModules)[0]))
 
     def _import(self,name):
         self.logger.log("INFO", "Loading modules from %s" % name)