<commit_before># -*- coding: utf-8 -*-
import json
import urllib.request
import urllib.parse


class partido:

    def __init__(self, core, client):
        core.addCommandHandler("partido", self, chelp=
        "Muestra la afiliación política de una persona. Uso: partido <nombre completo>")

    def partido(self, bot, cli, event):
        if len(event.splitd) > 0:
            stext = urllib.parse.quote_plus(" ".join(event.splitd))
        else:
            cli.msg(event.target, "\00304Error\003: Faltan parametros")
            return 0

        wd = urllib.request.urlopen("https://www.wikidata.org/w/api.php?action=wbgetentities&sites=eswiki&titles={0}&languages=es&normalize=&props=claims&format=json".format(stext)).read().decode('utf-8', 'replace')
        
        wd = json.loads(wd)
        
        e = wd['entities'][list(wd['entities'].keys())[0]]
        
        partido = None
        
        for i in e['claims']:
            if i == "P102":
                prop = e['claims']['P102'][0]['mainsnak']['datavalue']['value']['numeric-id']
                wprop = urllib.request.urlopen("https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q{0}&languages=es&props=labels&format=json".format(prop)).read().decode('utf-8', 'replace')
                partido = json.loads(wprop)["entities"]["Q" + str(prop)]['labels']['es']['value']

        try:<commit_msg>"hay que ponerle huevo" decían..<commit_after># -*- coding: utf-8 -*-
import json
import urllib.request
import urllib.parse


class partido:

    def __init__(self, core, client):
        core.addCommandHandler("partido", self, chelp=
        "Muestra la afiliación política de una persona. Uso: partido <nombre completo>")

    def partido(self, bot, cli, event):
        if len(event.splitd) > 0:
            if event.splitd[0] == "dlcast" or event.splitd[0] == "dlcastc" or event.splitd[0] == "dlc":
                cli.msg(event.target, "\002{0}\002 milita en el \002partido de la plaza roja".format(event.splitd[0]))
                return
            stext = urllib.parse.quote_plus(" ".join(event.splitd))
        else:
            cli.msg(event.target, "\00304Error\003: Faltan parametros")
            return 0

        wd = urllib.request.urlopen("https://www.wikidata.org/w/api.php?action=wbgetentities&sites=eswiki&titles={0}&languages=es&normalize=&props=claims&format=json".format(stext)).read().decode('utf-8', 'replace')
        
        wd = json.loads(wd)
        
        e = wd['entities'][list(wd['entities'].keys())[0]]
        
        partido = None
        
        for i in e['claims']:
            if i == "P102":
                prop = e['claims']['P102'][0]['mainsnak']['datavalue']['value']['numeric-id']
                wprop = urllib.request.urlopen("https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q{0}&languages=es&props=labels&format=json".format(prop)).read().decode('utf-8', 'replace')
                partido = json.loads(wprop)["entities"]["Q" + str(prop)]['labels']['es']['value']

        try:
{'fraction_non_alphanumeric': 0.17575156921043938, 'fraction_numerical': 0.019821605550049554, 'mean_word_length': 2.785, 'pattern_counts': {'":': 3, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, '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': '4196908', 'n_tokens_mistral': 1045, 'n_tokens_neox': 1011, 'n_words': 167}