prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Budget without value makes IATI export crash
  ## Test plan
  
  GIVEN the IATI export (bottom right on project page)
  WHEN a budget of the project has no value, but does have a value date / currency / label
  THEN the `value` tag of the budget item should not be generated
  AND no internal server error should be shown
  ## Issue description
  
  See http://sentry.support.akvo-ops.org/rsr/live/group/832/
  
  
  </issue>
  <code>
  [start of akvo/iati/exports/elements/budget.py]
  1 # -*- coding: utf-8 -*-
  2 
  3 # Akvo RSR is covered by the GNU Affero General Public License.
  4 # See more details in the license.txt file located at the root folder of the Akvo RSR module.
  5 # For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.
  6 
  7 from lxml import etree
  8 
  9 
  10 def budget(project):
  11     """
  12     Generate the budget elements.
  13 
  14     :param project: Project object
  15     :return: A list of Etree elements
  16     """
  17     budget_elements = []
  18 
  19     for budget_item in project.budget_items.all():
  20         if budget_item.amount or budget_item.period_start or budget_item.period_end or \
  21                 budget_item.type or budget_item.status or budget_item.value_date or \
  22                 budget_item.currency or budget_item.other_extra or budget_item.label:
  23             element = etree.Element("budget")
  24 
  25             if budget_item.type:
  26                 element.attrib['type'] = budget_item.type
  27 
  28             if budget_item.status:
  29                 element.attrib['status'] = budget_item.status
  30 
  31             if budget_item.period_start:
  32                 period_start_element = etree.SubElement(element, "period-start")
  33                 period_start_element.attrib['iso-date'] = str(budget_item.period_start)
  34 
  35             if budget_item.period_end:
  36                 period_end_element = etree.SubElement(element, "period-end")
  37                 period_end_element.attrib['iso-date'] = str(budget_item.period_end)
  38 
  39             if budget_item.amount == 0 or budget_item.amount:
  40                 value_element = etree.SubElement(element, "value")
  41                 value_element.text = str(budget_item.amount)
  42 
  43             if budget_item.value_date:
  44                 value_element.attrib['value-date'] = str(budget_item.value_date)
  45 
  46             if budget_item.currency:
  47                 value_element.attrib['currency'] = budget_item.currency
  48 
  49             if budget_item.other_extra:
  50                 value_element.attrib['{http://akvo.org/iati-activities}label'] = budget_item.\
  51                     other_extra
  52             elif budget_item.label and budget_item.label.label:
  53                 value_element.attrib['{http://akvo.org/iati-activities}label'] = budget_item.label.\
  54                     label
  55 
  56             budget_elements.append(element)
  57 
  58     return budget_elements
  59
  [end of akvo/iati/exports/elements/budget.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/akvo/iati/exports/elements/budget.py b/akvo/iati/exports/elements/budget.py
  --- a/akvo/iati/exports/elements/budget.py
  +++ b/akvo/iati/exports/elements/budget.py
  @@ -40,18 +40,17 @@
                   value_element = etree.SubElement(element, "value")
                   value_element.text = str(budget_item.amount)
   
  -            if budget_item.value_date:
  -                value_element.attrib['value-date'] = str(budget_item.value_date)
  -
  -            if budget_item.currency:
  -                value_element.attrib['currency'] = budget_item.currency
  -
  -            if budget_item.other_extra:
  -                value_element.attrib['{http://akvo.org/iati-activities}label'] = budget_item.\
  -                    other_extra
  -            elif budget_item.label and budget_item.label.label:
  -                value_element.attrib['{http://akvo.org/iati-activities}label'] = budget_item.label.\
  -                    label
  +                if budget_item.value_date:
  +                    value_element.attrib['value-date'] = str(budget_item.value_date)
  +
  +                if budget_item.currency:
  +                    value_element.attrib['currency'] = budget_item.currency
  +
  +                akvo_label = '{http://akvo.org/iati-activities}label'
  +                if budget_item.other_extra:
  +                    value_element.attrib[akvo_label] = budget_item.other_extra
  +                elif budget_item.label and budget_item.label.label:
  +                    value_element.attrib[akvo_label] = budget_item.label.label
   
               budget_elements.append(element)
  
verification_info: {"golden_diff": "diff --git a/akvo/iati/exports/elements/budget.py b/akvo/iati/exports/elements/budget.py\n--- a/akvo/iati/exports/elements/budget.py\n+++ b/akvo/iati/exports/elements/budget.py\n@@ -40,18 +40,17 @@\n                 value_element = etree.SubElement(element, \"value\")\n                 value_element.text = str(budget_item.amount)\n \n-            if budget_item.value_date:\n-                value_element.attrib['value-date'] = str(budget_item.value_date)\n-\n-            if budget_item.currency:\n-                value_element.attrib['currency'] = budget_item.currency\n-\n-            if budget_item.other_extra:\n-                value_element.attrib['{http://akvo.org/iati-activities}label'] = budget_item.\\\n-                    other_extra\n-            elif budget_item.label and budget_item.label.label:\n-                value_element.attrib['{http://akvo.org/iati-activities}label'] = budget_item.label.\\\n-                    label\n+                if budget_item.value_date:\n+                    value_element.attrib['value-date'] = str(budget_item.value_date)\n+\n+                if budget_item.currency:\n+                    value_element.attrib['currency'] = budget_item.currency\n+\n+                akvo_label = '{http://akvo.org/iati-activities}label'\n+                if budget_item.other_extra:\n+                    value_element.attrib[akvo_label] = budget_item.other_extra\n+                elif budget_item.label and budget_item.label.label:\n+                    value_element.attrib[akvo_label] = budget_item.label.label\n \n             budget_elements.append(element)\n", "issue": "Budget without value makes IATI export crash\n## Test plan\n\nGIVEN the IATI export (bottom right on project page)\nWHEN a budget of the project has no value, but does have a value date / currency / label\nTHEN the `value` tag of the budget item should not be generated\nAND no internal server error should be shown\n## Issue description\n\nSee http://sentry.support.akvo-ops.org/rsr/live/group/832/\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Akvo RSR is covered by the GNU Affero General Public License.\n# See more details in the license.txt file located at the root folder of the Akvo RSR module.\n# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.\n\nfrom lxml import etree\n\n\ndef budget(project):\n    \"\"\"\n    Generate the budget elements.\n\n    :param project: Project object\n    :return: A list of Etree elements\n    \"\"\"\n    budget_elements = []\n\n    for budget_item in project.budget_items.all():\n        if budget_item.amount or budget_item.period_start or budget_item.period_end or \\\n                budget_item.type or budget_item.status or budget_item.value_date or \\\n                budget_item.currency or budget_item.other_extra or budget_item.label:\n            element = etree.Element(\"budget\")\n\n            if budget_item.type:\n                element.attrib['type'] = budget_item.type\n\n            if budget_item.status:\n                element.attrib['status'] = budget_item.status\n\n            if budget_item.period_start:\n                period_start_element = etree.SubElement(element, \"period-start\")\n                period_start_element.attrib['iso-date'] = str(budget_item.period_start)\n\n            if budget_item.period_end:\n                period_end_element = etree.SubElement(element, \"period-end\")\n                period_end_element.attrib['iso-date'] = str(budget_item.period_end)\n\n            if budget_item.amount == 0 or budget_item.amount:\n                value_element = etree.SubElement(element, \"value\")\n                value_element.text = str(budget_item.amount)\n\n            if budget_item.value_date:\n                value_element.attrib['value-date'] = str(budget_item.value_date)\n\n            if budget_item.currency:\n                value_element.attrib['currency'] = budget_item.currency\n\n            if budget_item.other_extra:\n                value_element.attrib['{http://akvo.org/iati-activities}label'] = budget_item.\\\n                    other_extra\n            elif budget_item.label and budget_item.label.label:\n                value_element.attrib['{http://akvo.org/iati-activities}label'] = budget_item.label.\\\n                    label\n\n            budget_elements.append(element)\n\n    return budget_elements\n", "path": "akvo/iati/exports/elements/budget.py"}]}