<commit_before>from celery.decorators import task
from eve_proxy.models import CachedDocument
from eve_api.utils import basic_xml_parse_doc
from eve_api.models import EVESkill, EVESkillGroup

@task()
def import_eve_skills():
    """
    Imports the skill tree and groups
    """

    char_doc = CachedDocument.objects.api_query('/eve/SkillTree.xml.aspx')
    d = basic_xml_parse_doc(char_doc)['eveapi']
    if 'error' in d:
        return
    values = d['result']

    for group in values['skillGroups']:
        gobj, created = EVESkillGroup.objects.get_or_create(id=group['groupID'])
        if created:
            gobj.name = group['groupName']
            gobj.save()

        for skill in group['skills']:
            skillobj, created = EVESkill.objects.get_or_create(id=skill['typeID'])
            if created or not skillobj.name or not skillobj.group:
                skillobj.name = skill['typeName']
                skillobj.group = gobj
                skillobj.save()
<commit_msg>Support if skill group/types are changed<commit_after>from celery.decorators import task
from eve_proxy.models import CachedDocument
from eve_api.utils import basic_xml_parse_doc
from eve_api.models import EVESkill, EVESkillGroup

@task()
def import_eve_skills():
    """
    Imports the skill tree and groups
    """

    char_doc = CachedDocument.objects.api_query('/eve/SkillTree.xml.aspx')
    d = basic_xml_parse_doc(char_doc)['eveapi']
    if 'error' in d:
        return
    values = d['result']

    for group in values['skillGroups']:
        gobj, created = EVESkillGroup.objects.get_or_create(id=group['groupID'])
        if created or not gobj.name or not gobj.name == group['groupName']:
            gobj.name = group['groupName']
            gobj.save()

        for skill in group['skills']:
            skillobj, created = EVESkill.objects.get_or_create(id=skill['typeID'])
            if created or not skillobj.name or not skillobj.group or not skillobj.name == skill['typeName']:
                skillobj.name = skill['typeName']
                skillobj.group = gobj
                skillobj.save()

{'fraction_non_alphanumeric': 0.10411736867013724, 'fraction_numerical': 0.0, 'mean_word_length': 2.836660617059891, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '5187264', 'n_tokens_mistral': 654, 'n_tokens_neox': 643, 'n_words': 154}