示例#1
0
文件: models.py 项目: quantum13/hgh
 def update_from_response(self, response):
     """updates hero with info from auth response"""
     UNIT_PROP_LIMIT = 20
     PROPS_MAX = {
         'forks': 5000,
         'watchers': 17000,
         'open_issues': 600,
         }
     for key, val in response.items():
         if key != 'id' and not val is None and hasattr(self, key):
             if key in PROPS_MAX:
                 setattr(self, key, formulas.scale_prop(val, UNIT_PROP_LIMIT, PROPS_MAX[key]))
             else:
                 setattr(self, key, val)
示例#2
0
文件: models.py 项目: quantum13/hgh
 def update_from_response(self, response):
     """updates hero with info from auth response"""
     NO_MAX = 0
     PROPS_MAX = {
         'public_repos': 400,
         'followers': 8000,
         'following': 30,
         'public_gists': 200,
         'hireable': NO_MAX
     }
     HERO_PROP_LIMIT = 10
     for key, val in response.iteritems():
         if key != 'id' and not val is None and hasattr(self, key):
             prop_max = PROPS_MAX.get(key, NO_MAX)
             if prop_max==NO_MAX:
                 setattr(self, key, val)
             else:
                 setattr(self, key, formulas.scale_prop(val, HERO_PROP_LIMIT, prop_max))