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


class countries:

    def __init__(self, core, client):
        core.addCommandHandler("pais", self, chelp="Muestra información de un país. Uso: pais <código del país>",
        alias=["país", "country"])

    def pais(self, bot, cli, ev):
        if len(ev.splitd) == 0:
            cli.msg(ev.target, "\00304Error\003: Faltan parametros")
            return 0
        p = " ".join(ev.splitd)
        if len(p) > 3:
            try:
                p = self.getcountries()[p.lower()]
            except:
                cli.msg(ev.target, "País no encontrado. Intente con el código del país?")
                return
        try:
            r = urllib.request.urlopen("http://restcountries.eu/rest/v1/alpha/{0}".format(p)).read().decode('utf-8', 'replace')
        except urllib.error.HTTPError:
            cli.msg(ev.target, "País no encontrado?")
            
        resp = json.loads(r)

        currs = []
        for i in resp['currencies']:
            currs.append(self.getcurrs()[i] + " (" + i + ")")
        
        langs = []
        for i in resp['languages']:
            langs.append(self.getlangs()[i])
        
        if resp['timezones'] == None:
            resp['timezones'] = ['N/A']

        resp['region'] = self.getregion(resp['region'])
        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(urllib.parse.quote_plus(self.countryfromcode()[p.upper()]))).read().decode('utf-8', 'replace')
        wd = json.loads(wd)
        presi = ""
        gobi = ""
        e = wd['entities'][list(wd['entities'].keys())[0]]
        presimark = "Presidente"
        for i in e['claims']:

            if i == "P30":
                prop = e['claims']['P30'][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')
                resp['region'] = json.loads(wprop)["entities"]["Q" + str(prop)]['labels']['es']['value']
            elif i == "P35":
                prop = e['claims']['P35'][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')
                presi = json.loads(wprop)["entities"]["Q" + str(prop)]['labels']['es']['value']
                try:
                    prop = e['claims']['P35'][0]['qualifiers']['P39'][0]['datavalue']['value']['numeric-id']
                except:
                    continue
                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')
                try:
                    presimark = json.loads(wprop)["entities"]["Q" + str(prop)]['labels']['es']['value']
                except:
                    presimark = "Presidente"
            elif i == "P122":
                prop = e['claims']['P122'][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')
                gobi = json.loads(wprop)["entities"]["Q" + str(prop)]['labels']['es']['value']
            elif i == "P1082":
                resp['population'] = int(e['claims']['P1082'][0]['mainsnak']['datavalue']['value']['amount'][1:])
            else:
                pass
                            
        send = "\002{1}\002: Continente: \002{0}\002, Capital: \002{2}\002, moneda: \002{3}\002, población: \002{4}\002".format(resp['region'], resp['translations']['es'], resp['capital'], ", ".join(currs), "{0:,}".format(resp['population']).replace(",", "."))
        send = send + ", superficie: \002{0}\002 km²".format("{0:,}".format(resp['area']).replace(",", "."))
        send = send + ", idiomas: \002{0}\002, zonas horarias: \002{1}\002".format(", ".join(langs), ", ".join(resp['timezones']))
        send = send + ", código telefónico: \002{0}\002".format(", ".join(resp['callingCodes']))
        if presi != "":
            send = send + ", {1}: \002{0}\002".format(presi, presimark)<commit_msg>Dejando de mostrar los dígitos decimales en la superficie.<commit_after># -*- coding: utf-8 -*-
import json
import urllib.request
import urllib.parse
import re


class countries:

    def __init__(self, core, client):
        core.addCommandHandler("pais", self, chelp="Muestra información de un país. Uso: pais <código del país>",
        alias=["país", "country"])

    def pais(self, bot, cli, ev):
        if len(ev.splitd) == 0:
            cli.msg(ev.target, "\00304Error\003: Faltan parametros")
            return 0
        p = " ".join(ev.splitd)
        if len(p) > 3:
            try:
                p = self.getcountries()[p.lower()]
            except:
                cli.msg(ev.target, "País no encontrado. Intente con el código del país?")
                return
        try:
            r = urllib.request.urlopen("http://restcountries.eu/rest/v1/alpha/{0}".format(p)).read().decode('utf-8', 'replace')
        except urllib.error.HTTPError:
            cli.msg(ev.target, "País no encontrado?")
            
        resp = json.loads(r)

        currs = []
        for i in resp['currencies']:
            currs.append(self.getcurrs()[i] + " (" + i + ")")
        
        langs = []
        for i in resp['languages']:
            langs.append(self.getlangs()[i])
        
        if resp['timezones'] == None:
            resp['timezones'] = ['N/A']

        resp['region'] = self.getregion(resp['region'])
        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(urllib.parse.quote_plus(self.countryfromcode()[p.upper()]))).read().decode('utf-8', 'replace')
        wd = json.loads(wd)
        presi = ""
        gobi = ""
        e = wd['entities'][list(wd['entities'].keys())[0]]
        presimark = "Presidente"
        for i in e['claims']:

            if i == "P30":
                prop = e['claims']['P30'][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')
                resp['region'] = json.loads(wprop)["entities"]["Q" + str(prop)]['labels']['es']['value']
            elif i == "P35":
                prop = e['claims']['P35'][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')
                presi = json.loads(wprop)["entities"]["Q" + str(prop)]['labels']['es']['value']
                try:
                    prop = e['claims']['P35'][0]['qualifiers']['P39'][0]['datavalue']['value']['numeric-id']
                except:
                    continue
                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')
                try:
                    presimark = json.loads(wprop)["entities"]["Q" + str(prop)]['labels']['es']['value']
                except:
                    presimark = "Presidente"
            elif i == "P122":
                prop = e['claims']['P122'][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')
                gobi = json.loads(wprop)["entities"]["Q" + str(prop)]['labels']['es']['value']
            elif i == "P1082":
                resp['population'] = int(e['claims']['P1082'][0]['mainsnak']['datavalue']['value']['amount'][1:])
            else:
                pass
                            
        send = "\002{1}\002: Continente: \002{0}\002, Capital: \002{2}\002, moneda: \002{3}\002, población: \002{4}\002".format(resp['region'], resp['translations']['es'], resp['capital'], ", ".join(currs), "{0:,}".format(resp['population']).replace(",", "."))
        send = send + ", superficie: \002{0}\002 km²".format("{0:,}".format(int(resp['area'])).replace(",", "."))
        send = send + ", idiomas: \002{0}\002, zonas horarias: \002{1}\002".format(", ".join(langs), ", ".join(resp['timezones']))
        send = send + ", código telefónico: \002{0}\002".format(", ".join(resp['callingCodes']))
        if presi != "":
            send = send + ", {1}: \002{0}\002".format(presi, presimark)
{'fraction_non_alphanumeric': 0.21052060737527115, 'fraction_numerical': 0.02863340563991323, 'mean_word_length': 2.576803723816912, 'pattern_counts': {'":': 10, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 10, 'lorem ipsum': 0, 'www.': 10, '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': '1053644', 'n_tokens_mistral': 3188, 'n_tokens_neox': 3034, 'n_words': 423}