<commit_before>from django.core.management.base import BaseCommand, CommandError
from summary_data.models import Authorized_Candidate_Committees
from ftpdata.models import CandComLink, Committee, Candidate


election_year = 2014
cycle = str(election_year)

class Command(BaseCommand):
    help = "Set the authorized candidate committees"
    requires_model_validation = False
    
    def handle(self, *args, **options):
        ccls = CandComLink.objects.filter(cycle=election_year, cmte_dsgn__in=['A', 'P'], fec_election_yr=election_year)
        
        for ccl in ccls:
            try:
                acc = Authorized_Candidate_Committees.objects.get(candidate_id=ccl.cand_id, committee_id=ccl.cmte_id)
            except Authorized_Candidate_Committees.DoesNotExist:
                
                cm_name = None
                try:
                    cm = Committee.objects.get(cycle=election_year, cmte_id=ccl.cmte_id)
                    cm_name = cm.cmte_name
                except Committee.DoesNotExist:
                    pass
                
                acc = Authorized_Candidate_Committees.objects.create(
                    candidate_id = ccl.cand_id,
                    committee_id = ccl.cmte_id,
                    committee_name = cm_name,
                    com_type = ccl.cmte_tp,
                    is_pcc = ccl.cmte_dsgn == 'P'
                )

        
        <commit_msg>change pop_auth_committees for new cycle<commit_after>from django.core.management.base import BaseCommand, CommandError
from summary_data.models import Authorized_Candidate_Committees
from ftpdata.models import CandComLink, Committee, Candidate
from django.conf import settings


try:
    CURRENT_CYCLE = settings.CURRENT_CYCLE
except:
    print "Missing current cycle list. Defaulting to 2016. "
    CURRENT_CYCLE = ['2016']


class Command(BaseCommand):
    help = "Set the authorized candidate committees"
    requires_model_validation = False
    
    def handle(self, *args, **options):
        ccls = CandComLink.objects.filter(cycle=CURRENT_CYCLE, cmte_dsgn__in=['A', 'P'], fec_election_yr=int(CURRENT_CYCLE))
        
        for ccl in ccls:
            try:
                acc = Authorized_Candidate_Committees.objects.get(candidate_id=ccl.cand_id, committee_id=ccl.cmte_id)
            except Authorized_Candidate_Committees.DoesNotExist:
                
                cm_name = None
                try:
                    cm = Committee.objects.get(cycle=CURRENT_CYCLE, cmte_id=ccl.cmte_id)
                    cm_name = cm.cmte_name
                except Committee.DoesNotExist:
                    pass
                
                acc = Authorized_Candidate_Committees.objects.create(
                    candidate_id = ccl.cand_id,
                    committee_id = ccl.cmte_id,
                    committee_name = cm_name,
                    com_type = ccl.cmte_tp,
                    is_pcc = ccl.cmte_dsgn == 'P'
                )

        
        
{'fraction_non_alphanumeric': 0.06928714190539641, 'fraction_numerical': 0.003997335109926716, 'mean_word_length': 1.9586206896551723, 'pattern_counts': {'":': 0, '<': 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': '4153644', 'n_tokens_mistral': 904, 'n_tokens_neox': 850, 'n_words': 162}