Commits

Aleš Erjavec  committed 3c47a79

Changed the global 'addons_corrupted' flag to a function.

  • Participants
  • Parent commits 705107a

Comments (0)

Files changed (3)

File Orange/OrangeCanvas/orngCanvas.pyw

         t = time.time()
         lastRefresh = self.settings["lastAddonsRefresh"]
         dlg = orngDlgs.AddOnManagerDialog(self, self)
-        if t - lastRefresh > 7*24*3600 or Orange.utils.addons.addons_corrupted:
+        if t - lastRefresh > 7*24*3600 or Orange.utils.addons.addons_corrupted():
             dlg.show()
-            if Orange.utils.addons.addons_corrupted or \
+            if Orange.utils.addons.addons_corrupted() or \
                QMessageBox.question(self, "Refresh",
                                     "List of add-ons in repository has not been refreshed for more than a week. Do you want to download the list now?",
                                      QMessageBox.Yes | QMessageBox.Default,

File Orange/OrangeCanvas/orngDlgs.py

         if self.loadtimefn:
             lastRefresh = self.loadtimefn()
         t = time.time()
-        if t - lastRefresh > 7*24*3600 or Orange.utils.addons.addons_corrupted:
-            if Orange.utils.addons.addons_corrupted or \
+        if t - lastRefresh > 7*24*3600 or Orange.utils.addons.addons_corrupted():
+            if Orange.utils.addons.addons_corrupted() or \
                QMessageBox.question(self, "Refresh",
                                     "List of available add-ons has not been refreshed for more than a week. Do you want to download the list now?",
                                      QMessageBox.Yes | QMessageBox.Default,

File Orange/utils/addons.py

         addons = shelve.open(AOLIST_FILE, 'n')
     return addons
 
-global addons_corrupted
-with closing(open_addons()) as addons:
-    addons_corrupted = len(addons)==0
 
-del addons
+def addons_corrupted():
+    with closing(open_addons()) as addons:
+        return len(addons) == 0
 
 addon_refresh_callback = []
 
     except:
         readthedocs = None
 
-    global addons_corrupted
     docs = {}
     if progress_callback:
         progress_callback(len(pkg_dict)+1, 1)
                     warnings.warn('Could not load data for the following add-on: %s'%name)
             if progress_callback:
                 progress_callback(len(pkg_dict)+1, i+2)
-        addons_corrupted = False
 
     rebuild_index()