<commit_before>import sys
import csv
import os
import re
import calendar
from datetime import datetime,date,timedelta
from decimal import Decimal


from history.models import NonEventProject,NonEventProjectParticipant,ProjectReport,NonEventParticipantAlt
from requirements.models import ProgressItem
from mig_main.models import AcademicTerm,OfficerPosition,Status,UserProfile,MemberProfile

cal_dict = {v:k for k,v in enumerate(calendar.month_name)}
def add_tutoring_to_project_report(id_num):
    pr = NonEventProject.objects.get(id=id_num)
    term = AcademicTerm.objects.get(semester_type__name='Winter',year=2014)
    related_progress = ProgressItem.objects.filter(event_type__name='Tutoring Hours',term=term).order_by('member').distinct()
    participants = {}
    for progress in related_progress:
        if progress.member in participants:
            participants[progress.member]+=progress.amount_completed
        else:
            participants[progress.member]=progress.amount_completed

    for member in participants:
        nepp=NonEventProjectParticipant(project=pr,participant=member,hours=participants[member])
        nepp.save()

def add_F13_from_csv(file_name):
    print 'function closed, bug off'
    return
    project_name_col        =   1
    project_beg_mon_col     =   2
    project_beg_day_col     =   3
    project_beg_year_col    =   4
    project_end_mon_col     =   5
    project_end_day_col     =   6
    project_end_year_col    =   7
    project_new_col         =   8<commit_msg>Working on #19<commit_after>import sys
import csv
import os
import re
import calendar
from datetime import datetime,date,timedelta
from decimal import Decimal


from history.models import NonEventProject,NonEventProjectParticipant,ProjectReport,NonEventParticipantAlt,Distinction
from requirements.models import ProgressItem,DistinctionType
from mig_main.models import AcademicTerm,OfficerPosition,Status,UserProfile,MemberProfile
from mig_main.utility import get_previous_full_term

cal_dict = {v:k for k,v in enumerate(calendar.month_name)}
def add_da_pa_status_manually(uniqname,distinction,terms):
    user = MemberProfile.objects.get(uniqname=uniqname)
    term = AcademicTerm.objects.get(year=2014,semester_type__name='Fall')
    while terms>user.get_num_terms_distinction(distinction):
        if not Distinction.objects.filter(member=user,term=term,distinction_type=distinction).exists():
            d = Distinction(member=user,term=term,distinction_type=distinction)
            if distinction.name=='Active':
                d.gift='N/A'
            else:
                d.gift='Unknown'
            d.save()
        term=get_previous_full_term(term)
        if term < user.init_term:
            print 'ran out of terms'
            break
        
def add_tutoring_to_project_report(id_num):
    pr = NonEventProject.objects.get(id=id_num)
    term = AcademicTerm.objects.get(semester_type__name='Winter',year=2014)
    related_progress = ProgressItem.objects.filter(event_type__name='Tutoring Hours',term=term).order_by('member').distinct()
    participants = {}
    for progress in related_progress:
        if progress.member in participants:
            participants[progress.member]+=progress.amount_completed
        else:
            participants[progress.member]=progress.amount_completed

    for member in participants:
        nepp=NonEventProjectParticipant(project=pr,participant=member,hours=participants[member])
        nepp.save()

def add_F13_from_csv(file_name):
    print 'function closed, bug off'
    return
    project_name_col        =   1
    project_beg_mon_col     =   2
    project_beg_day_col     =   3
    project_beg_year_col    =   4
    project_end_mon_col     =   5
    project_end_day_col     =   6
    project_end_year_col    =   7
    project_new_col         =   8
{'fraction_non_alphanumeric': 0.07573779054583442, 'fraction_numerical': 0.008879603029511622, 'mean_word_length': 3.8115577889447234, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '5690187', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1122, 'n_words': 208}