<commit_before>#!/usr/bin/python
# -*- coding:Utf-8 -*-

import json

from urllib import urlopen

from django.conf import settings

from meps.models import MEP
from memopol2.utils import update_search_index

from current_meps_json_2_sql import manage_mep, clean

if __name__ == "__main__":
    print "load json"
    print "fetch json from %s" % settings.PARLTRACK_URL +  "/search?s_meps=on&q=+&format=json"
    meps = json.load(urlopen(settings.PARLTRACK_URL + "/search?s_meps=on&q=+&format=json"))
    a = 0
    for mep_json in meps["items"]:
        a += 1
        print a, "-", mep_json["Name"]["full"]
        in_db_mep = MEP.objects.filter(ep_id=mep_json["UserID"])
        if in_db_mep:
            mep = in_db_mep[0]
            manage_mep(mep, mep_json)
    clean()
    update_search_index()

# vim:set shiftwidth=4 tabstop=4 expandtab:<commit_msg>[mod] cache dump of all meps in update_meps.py<commit_after>#!/usr/bin/python
# -*- coding:Utf-8 -*-

from os import path
import json

from urllib import urlopen

from django.conf import settings

from meps.models import MEP
from memopol2.utils import update_search_index

from current_meps_json_2_sql import manage_mep, clean

if __name__ == "__main__":
    print "load json"
    print "fetch json from %s" % settings.PARLTRACK_URL +  "/search?s_meps=on&q=+&format=json"
    if not path.exists("all_meps.json"):
        open("all_meps.json", "w").write(urlopen(settings.PARLTRACK_URL + "/search?s_meps=on&q=+&format=json").read())
    meps = json.load(open("all_meps.json"))
    a = 0
    for mep_json in meps["items"]:
        a += 1
        print a, "-", mep_json["Name"]["full"]
        in_db_mep = MEP.objects.filter(ep_id=mep_json["UserID"])
        if in_db_mep:
            mep = in_db_mep[0]
            manage_mep(mep, mep_json)
    clean()
    update_search_index()

# vim:set shiftwidth=4 tabstop=4 expandtab:
{'fraction_non_alphanumeric': 0.13159296750133193, 'fraction_numerical': 0.008524240809802876, 'mean_word_length': 3.514423076923077, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2939353', 'n_tokens_mistral': 713, 'n_tokens_neox': 712, 'n_words': 147}