Style fixes and removal of unused imports in soc.logic modules.
authorPawel Solyga <Pawel.Solyga@gmail.com>
Fri, 03 Apr 2009 17:30:36 +0000
changeset 2073 6eb9b4652c80
parent 2072 eb4565a8e5b4
child 2074 5c75312566d5
Style fixes and removal of unused imports in soc.logic modules. Patch by: Pawel Solyga Reviewed by: to-be-reviewed
app/soc/logic/allocations.py
app/soc/logic/cleaning.py
app/soc/logic/dicts.py
app/soc/logic/mail_dispatcher.py
--- a/app/soc/logic/allocations.py	Fri Apr 03 17:29:36 2009 +0000
+++ b/app/soc/logic/allocations.py	Fri Apr 03 17:30:36 2009 +0000
@@ -22,7 +22,6 @@
   ]
 
 
-import itertools
 import math
 
 
@@ -64,11 +63,14 @@
     self.adjusted_slots = {}
     self.adjusted_orgs = []
     self.locked_orgs = []
+    self.unlocked_orgs = []
     self.unlocked_applications = []
     self.slots = slots
     self.max_slots_per_org = max_slots_per_org
     self.min_slots_per_org = min_slots_per_org
     self.orgs = set(orgs)
+    self.popularity = None
+    self.total_popularity = None
     self.initial_popularity = popularity
     self.mentors = mentors
     self.iterative = iterative
@@ -95,7 +97,7 @@
       return self.preprocessingAllocation()
 
   def buildSets(self):
-    """Allocates slots with the specified constraints
+    """Allocates slots with the specified constraints.
     """
 
     popularity = self.initial_popularity.copy()
@@ -223,7 +225,7 @@
     # adjust the popularity so that the invariants are always met
     for org in unlocked_orgs:
       popularity = self.popularity[org]
-      mentors = self.mentors[org]
+      # mentors = self.mentors[org]
 
       slots = (float(popularity)/float(total_popularity))*available_slots
       slots = self.rangeSlots(slots, org)
@@ -246,7 +248,8 @@
     slots_left = available_slots - sum(allocations.values())
 
     # add leftover slots, sorted by slack, decending
-    for org, slack in sorted(slack.iteritems(), key=lambda (k,v): v, reverse=True):
+    for org, slack in sorted(slack.iteritems(), 
+        key=lambda (k, v): v, reverse=True):
       if slots_left < 1:
         break
 
--- a/app/soc/logic/cleaning.py	Fri Apr 03 17:29:36 2009 +0000
+++ b/app/soc/logic/cleaning.py	Fri Apr 03 17:30:36 2009 +0000
@@ -604,7 +604,8 @@
   """
 
   def wrapper(self):
-
+    """Decorator wrapper method.
+    """
     from soc.logic.models.mentor import logic as mentor_logic
     from soc.logic.models.organization import logic as org_logic
     from soc.logic.models.student import logic as student_logic
--- a/app/soc/logic/dicts.py	Fri Apr 03 17:29:36 2009 +0000
+++ b/app/soc/logic/dicts.py	Fri Apr 03 17:30:36 2009 +0000
@@ -168,10 +168,10 @@
     tmpresult = []
 
     # Iterate over all we gathered so far
-    for filter in result:
+    for current_filter in result:
       for value in values:
         # Create a new dict from the current filter
-        newdict = dict(filter)
+        newdict = dict(current_filter)
 
         # And create a new dict that also has the current key/value pair
         newdict[key] = value
--- a/app/soc/logic/mail_dispatcher.py	Fri Apr 03 17:29:36 2009 +0000
+++ b/app/soc/logic/mail_dispatcher.py	Fri Apr 03 17:30:36 2009 +0000
@@ -117,7 +117,7 @@
   try:
     # send the message
     message.send()
-  except Exception, exception:
+  except mail.Error, exception:
     import logging
     logging.info(context)
     logging.exception(exception)