当前位置: 首页>>代码示例>>Python>>正文


Python MEP.get方法代码示例

本文整理汇总了Python中meps.models.MEP.get方法的典型用法代码示例。如果您正苦于以下问题:Python MEP.get方法的具体用法?Python MEP.get怎么用?Python MEP.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在meps.models.MEP的用法示例。


在下文中一共展示了MEP.get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mep_raw

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import get [as 别名]
def mep_raw(request, mep_id):
    mep_ = MEP.get(mep_id)
    jsonstr = simplejson.dumps(dict(mep_), indent=4, use_decimal=True)
    context = {
        'mep_id': mep_id,
        'mep': mep_,
        'jsonstr': jsonstr,
    }
    return direct_to_template(request, 'meps/mep_raw.html', context)
开发者ID:nka11,项目名称:memopol2,代码行数:11,代码来源:views.py

示例2: test_trophies_retrieval_from_mep

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import get [as 别名]
 def test_trophies_retrieval_from_mep(self):
     """
     Test that meps' CouchDB model can retrieve associated Django trophies.
     """
     # Initialization
     a_mep = MEP.get('AlainLipietz')
     manual_trophy = ManualTrophy.objects.create(label="A manual trophy")
     auto_trophy = AutoTrophy.objects.create(label="An auto trophy")
     self.failUnlessEqual(a_mep.trophies, [])
     
     # Let's create a reward and attribute it to verify CouchDB's update
     reward = Reward.objects.create(mep_wikiname=a_mep._id, trophy=manual_trophy, reason="test")
     a_mep = MEP.get('AlainLipietz')
     self.failUnlessEqual(repr(a_mep.trophies), "[<ManualTrophy: A manual trophy>]")
     
     # OK, now we verify that deletion is triggered to CouchDB
     reward.delete()
     a_mep = MEP.get('AlainLipietz')
     self.failUnlessEqual(a_mep.trophies, [])
开发者ID:Bouska,项目名称:memopol2,代码行数:21,代码来源:tests.py

示例3: test_trophies_attribution

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import get [as 别名]
 def test_trophies_attribution(self):
     """
     Test that trophies' models can interact with CouchDB.
     """
     # Initialization
     a_mep = MEP.get('AlainLipietz')
     manual_trophy = ManualTrophy.objects.create(label="A manual trophy")
     auto_trophy = AutoTrophy.objects.create(label="An auto trophy")
     self.failUnlessEqual(a_mep.trophies_ids, [])
     
     # Let's create a reward and attribute it to verify CouchDB's update
     reward = Reward.objects.create(mep_wikiname=a_mep._id, trophy=manual_trophy, reason="test")
     a_mep = MEP.get('AlainLipietz')
     self.failUnlessEqual(a_mep.trophies_ids, [1])
     
     # OK, now we verify that deletion is triggered to CouchDB
     reward.delete()
     a_mep = MEP.get('AlainLipietz')
     self.failUnlessEqual(a_mep.trophies_ids, [])
开发者ID:Bouska,项目名称:memopol2,代码行数:21,代码来源:tests.py

示例4: mep

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import get [as 别名]
def mep(request, mep_id):
    mep_ = MEP.get(mep_id)
    mep_["achievements"] = autoTrophies(mep_)
    positions = Position.objects.filter(mep_id=mep_id)
    score_list = mep_.scores
    for score in score_list:
        score["color"] = score_to_color(int(score["value"]))
    score_list.sort(key=lambda k: datetime.strptime(k["date"], "%d/%m/%Y"))
    scores = [s["value"] for s in mep_.scores]

    if score_list:
        try:
            import numpy
            import matplotlib

            matplotlib.use("Agg")
            from matplotlib import pyplot

            pyplot.plot(scores, "bo")
            a, b = numpy.polyfit(range(len(scores)), [int(x) for x in scores], 1)
            pyplot.plot([a * int(x) + b for x in range(len(scores))])
            pyplot.legend(("Scores", "Mediane"), "best", shadow=True)
            pyplot.plot(scores)
            pyplot.axis([0, len(scores) - 1, 0, 102])
            pyplot.title("%s - Votes notes evolution over time" % (mep_.infos["name"]["full"]))
            pyplot.xticks(range(len(scores)), [k["date"] for k in score_list])
            pyplot.xlabel("Votes dates")
            pyplot.ylabel("Scores on votes")
            pyplot.savefig(
                realpath("./memopol2/%simg/trends/meps/%s-scores.png" % (settings.MEDIA_URL, mep_id)), format="png"
            )
            pyplot.clf()
        except ImportError:
            pass

    context = {
        "mep_id": mep_id,
        "mep": mep_,
        "positions": positions,
        "visible_count": len([x for x in positions if x.visible]),
        "average": sum(scores) / len(scores) if len(scores) > 0 else "",
        "score_list": score_list,
    }
    return direct_to_template(request, "meps/mep.html", context)
开发者ID:stfp,项目名称:memopol2,代码行数:46,代码来源:views.py

示例5: mep

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import get [as 别名]
def mep(request, mep_id):
    mep_ = MEP.get(mep_id)
    positions = Position.objects.filter(mep_id=mep_id)
    score_list = mep_.scores
    for score in score_list:
        score['color'] = score_to_color(int(score['value']))
    score_list.sort(key = lambda k : datetime.strptime(k['date'], "%d/%m/%Y"))
    scores = [s['value'] for s in mep_.scores]

    if score_list:
        try:
            import numpy
            import matplotlib
            matplotlib.use("Agg")
            from matplotlib import pyplot

            pyplot.plot(scores, 'bo')
            a, b = numpy.polyfit(range(len(scores)), [int(x) for x in scores], 1)
            pyplot.plot([a*int(x) + b for x in range(len(scores))])
            pyplot.legend(('Scores', 'Mediane'), 'best', shadow=True)
            pyplot.plot(scores)
            pyplot.axis([0, len(scores) - 1, 0, 102])
            pyplot.title("%s - Votes notes evolution over time" % (mep_.infos['name']['full']))
            pyplot.xticks(range(len(scores)), [k['date'] for k in score_list])
            pyplot.xlabel("Votes dates")
            pyplot.ylabel("Scores on votes")
            pyplot.savefig(realpath(".%simg/trends/meps/%s-scores.png" % (settings.MEDIA_URL, mep_id)), format="png")
            pyplot.clf()
        except ImportError:
            pass

    context = {
        'mep_id': mep_id,
        'mep': mep_,
        'positions': positions,
        'visible_count': len([x for x in positions if x.visible]),
        'average': sum(scores)/len(scores) if len(scores) > 0 else "",
        'score_list' : score_list,
    }
    return direct_to_template(request, 'meps/mep.html', context)
开发者ID:nka11,项目名称:memopol2,代码行数:42,代码来源:views.py

示例6: mep

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import get [as 别名]
 def mep(self):
     return MEP.get(self.mep_wikiname)
开发者ID:mparisot-wescale,项目名称:memopol2,代码行数:4,代码来源:models.py

示例7: setUp

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import get [as 别名]
 def setUp(self):
     # Delete all trophies for the test user
     a_mep = MEP.get('AlainLipietz')
     a_mep.trophies_ids = []
     a_mep.save()
开发者ID:Bouska,项目名称:memopol2,代码行数:7,代码来源:tests.py

示例8: mep_structure

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import get [as 别名]
def mep_structure(request, mep_id):
    mep_ = MEP.get(mep_id)
    jsonstr = simplejson.dumps(dict(mep_), indent=4, use_decimal=True)
    context = {"mep_id": mep_id, "mep": mep_, "jsonstr": jsonstr}
    return direct_to_template(request, "meps/mep_structure.html", context)
开发者ID:stfp,项目名称:memopol2,代码行数:7,代码来源:views.py

示例9: mep_json

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import get [as 别名]
def mep_json(request, mep_id):
    mep_ = MEP.get(mep_id)
    jsonstr = simplejson.dumps(dict(mep_), indent=4, use_decimal=True)
    return HttpResponse(jsonstr, content_type="application/json")
开发者ID:stfp,项目名称:memopol2,代码行数:6,代码来源:views.py

示例10: mep_json

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import get [as 别名]
def mep_json(request, mep_id):
    mep_ = MEP.get(mep_id)
    jsonstr = simplejson.dumps(dict(mep_), indent=4, use_decimal=True)
    return HttpResponse(jsonstr)
开发者ID:nka11,项目名称:memopol2,代码行数:6,代码来源:views.py


注:本文中的meps.models.MEP.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。