<commit_before># -*- coding: utf-8 -*-
#!/usr/bin/env python

"""
Script for setting all budgets with budget item 13 to 14 and remove budget item 13 (total) from RSR.
"""

from django.core.management import setup_environ
from akvo import settings
setup_environ(settings)

from akvo.rsr.models import BudgetItem, BudgetItemLabel, Project


def set_budget_totals():
    '''Change all budget items with id 13 to 14'''

    print "\nGetting all budget items...\n"

    budget_items = BudgetItem.objects.filter(label_id="13")
    budgets_count = budget_items.count()

    for count, item in enumerate(budget_items, start=1):
        item.label_id = 14
        item.save()

        print "Budget item", str(item.pk), "adjusted (" + str(count), "out of", str(budgets_count) + ")..."


def remove_budgetitem_label():
    '''Remove budget item label 13 (total)'''

    BudgetItemLabel.objects.filter(id="13").delete()
    print "\nRemoved the total budget item, label 13..."


def update_budgetitem_label():
    '''Update label of budget item 14'''

    total_budget_label = BudgetItemLabel.objects.get(id="14")
    total_budget_label.label = 'total'
    total_budget_label.save()

    print "\nUpdated label of item 14 to 'total'...\n"


def update_projects():
    '''Updates all projects using the budget sum calculator'''

    print "\nGetting all projects...\n"

    projects = Project.objects.all()
    projects_count = projects.count()

    for count, project in enumerate(projects):
        project.update_budget()
        project.update_funds_needed()

        print "Updating project:", project.id, "(" + str(count), "out of", str(projects_count) + ")..."


if __name__ == '__main__':
    set_budget_totals()
    remove_budgetitem_label()
    update_budgetitem_label()
    update_projects()

    # Update all projects

    print "\nDone!\n"<commit_msg>[#471] Removed comment and added newline<commit_after># -*- coding: utf-8 -*-
#!/usr/bin/env python

"""
Script for setting all budgets with budget item 13 to 14 and remove budget item 13 (total) from RSR.
"""

from django.core.management import setup_environ
from akvo import settings
setup_environ(settings)

from akvo.rsr.models import BudgetItem, BudgetItemLabel, Project


def set_budget_totals():
    '''Change all budget items with id 13 to 14'''

    print "\nGetting all budget items...\n"

    budget_items = BudgetItem.objects.filter(label_id="13")
    budgets_count = budget_items.count()

    for count, item in enumerate(budget_items, start=1):
        item.label_id = 14
        item.save()

        print "Budget item", str(item.pk), "adjusted (" + str(count), "out of", str(budgets_count) + ")..."


def remove_budgetitem_label():
    '''Remove budget item label 13 (total)'''

    BudgetItemLabel.objects.filter(id="13").delete()
    print "\nRemoved the total budget item, label 13..."


def update_budgetitem_label():
    '''Update label of budget item 14'''

    total_budget_label = BudgetItemLabel.objects.get(id="14")
    total_budget_label.label = 'total'
    total_budget_label.save()

    print "\nUpdated label of item 14 to 'total'...\n"


def update_projects():
    '''Updates all projects using the budget sum calculator'''

    print "\nGetting all projects...\n"

    projects = Project.objects.all()
    projects_count = projects.count()

    for count, project in enumerate(projects):
        project.update_budget()
        project.update_funds_needed()

        print "Updating project:", project.id, "(" + str(count), "out of", str(projects_count) + ")..."


if __name__ == '__main__':
    set_budget_totals()
    remove_budgetitem_label()
    update_budgetitem_label()
    update_projects()

    print "\nDone!\n"
{'fraction_non_alphanumeric': 0.12958963282937366, 'fraction_numerical': 0.015928725701943845, 'mean_word_length': 3.5460122699386503, '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': '7434177', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1115, 'n_words': 321}