
import os
import re
import requests


USD_TO_CAD = 1.3139  # backup


def get_rate():
    """Get USD to CAD rate."""
    try:
        r = requests.get('http://download.finance.yahoo.com/d/quotes.csv?s=USDCAD=X&f=nl1d1', timeout=5)
        return float(r.text.split(',')[1])
    except Exception:
        return USD_TO_CAD


def usd_to_cad(item, **kwargs):
    """Convert USD to CAD."""

    rate = get_rate()
    if os.environ.get('BEHAVE_TESTING'):
        rate = USD_TO_CAD

    def convert(match):
        usd = float(match.group(1))
        cad = rate * usd
        return 'CAD %d' % cad

    item['body_html'] = re.sub('\$([0-9]+)', convert, item['body_html'])
    return item

name = 'usd_to_cad'
label = 'Convert USD to CAD'
shortcut = 'd'
callback = usd_to_cad
desks = ['SPORTS DESK', 'POLITICS']


import os
import re
import requests


USD_TO_CAD = 1.3139  # backup


def get_rate():
    """Get USD to CAD rate."""
    try:
        r = requests.get('http://download.finance.yahoo.com/d/quotes.csv?s=USDCAD=X&f=nl1d1', timeout=5)
        return float(r.text.split(',')[1])
    except Exception:
        return USD_TO_CAD


def usd_to_cad(item, **kwargs):
    """Convert USD to CAD."""

    rate = get_rate()
    if os.environ.get('BEHAVE_TESTING'):
        rate = USD_TO_CAD

    def convert(match):
        usd = float(match.group(1))
        cad = rate * usd
        return 'CAD %d' % cad

    item['body_html'] = re.sub('\$([0-9]+)', convert, item['body_html'])
    return item

name = 'usd_to_cad'
label = 'Convert USD to CAD'
shortcut = 'd'
callback = usd_to_cad

Delete the desks settings for macro
fix(macro): Delete the desks settings for macro

  
  import os
  import re
  import requests
  
  
  USD_TO_CAD = 1.3139  # backup
  
  
  def get_rate():
      """Get USD to CAD rate."""
      try:
          r = requests.get('http://download.finance.yahoo.com/d/quotes.csv?s=USDCAD=X&f=nl1d1', timeout=5)
          return float(r.text.split(',')[1])
      except Exception:
          return USD_TO_CAD
  
  
  def usd_to_cad(item, **kwargs):
      """Convert USD to CAD."""
  
      rate = get_rate()
      if os.environ.get('BEHAVE_TESTING'):
          rate = USD_TO_CAD
  
      def convert(match):
          usd = float(match.group(1))
          cad = rate * usd
          return 'CAD %d' % cad
  
      item['body_html'] = re.sub('\$([0-9]+)', convert, item['body_html'])
      return item
  
  name = 'usd_to_cad'
  label = 'Convert USD to CAD'
  shortcut = 'd'
  callback = usd_to_cad
- desks = ['SPORTS DESK', 'POLITICS']
  
Delete the desks settings for macro
## Code Before:

import os
import re
import requests


USD_TO_CAD = 1.3139  # backup


def get_rate():
    """Get USD to CAD rate."""
    try:
        r = requests.get('http://download.finance.yahoo.com/d/quotes.csv?s=USDCAD=X&f=nl1d1', timeout=5)
        return float(r.text.split(',')[1])
    except Exception:
        return USD_TO_CAD


def usd_to_cad(item, **kwargs):
    """Convert USD to CAD."""

    rate = get_rate()
    if os.environ.get('BEHAVE_TESTING'):
        rate = USD_TO_CAD

    def convert(match):
        usd = float(match.group(1))
        cad = rate * usd
        return 'CAD %d' % cad

    item['body_html'] = re.sub('\$([0-9]+)', convert, item['body_html'])
    return item

name = 'usd_to_cad'
label = 'Convert USD to CAD'
shortcut = 'd'
callback = usd_to_cad
desks = ['SPORTS DESK', 'POLITICS']

## Instruction:
Delete the desks settings for macro
## Code After:

import os
import re
import requests


USD_TO_CAD = 1.3139  # backup


def get_rate():
    """Get USD to CAD rate."""
    try:
        r = requests.get('http://download.finance.yahoo.com/d/quotes.csv?s=USDCAD=X&f=nl1d1', timeout=5)
        return float(r.text.split(',')[1])
    except Exception:
        return USD_TO_CAD


def usd_to_cad(item, **kwargs):
    """Convert USD to CAD."""

    rate = get_rate()
    if os.environ.get('BEHAVE_TESTING'):
        rate = USD_TO_CAD

    def convert(match):
        usd = float(match.group(1))
        cad = rate * usd
        return 'CAD %d' % cad

    item['body_html'] = re.sub('\$([0-9]+)', convert, item['body_html'])
    return item

name = 'usd_to_cad'
label = 'Convert USD to CAD'
shortcut = 'd'
callback = usd_to_cad
