import os
import json

from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt

from . import actions


def info(request, uuid):
    """
    Return the Twillio ML that we generated when the user
    called /call
    """
    data = open(os.path.join("/tmp", uuid + ".xml")).read()
    return HttpResponse(data, content_type="text/xml")


import os

from django.http import HttpResponse

def info(request, uuid):
    """
    Return the Twillio ML that we generated when the user called /call
    """

    with open(os.path.join('/tmp', '%s.xml' % uuid)) as f:
        data = f.read()

    return HttpResponse(data, content_type='text/xml')

Tidy imports and opening the tmpfile
Tidy imports and opening the tmpfile

  import os
- import json
  
  from django.http import HttpResponse
- from django.views.decorators.csrf import csrf_exempt
- 
- from . import actions
- 
  
  def info(request, uuid):
      """
-     Return the Twillio ML that we generated when the user
+     Return the Twillio ML that we generated when the user called /call
-     called /call
      """
-     data = open(os.path.join("/tmp", uuid + ".xml")).read()
-     return HttpResponse(data, content_type="text/xml")
  
+     with open(os.path.join('/tmp', '%s.xml' % uuid)) as f:
+         data = f.read()
  
+     return HttpResponse(data, content_type='text/xml')
+ 
Tidy imports and opening the tmpfile
## Code Before:
import os
import json

from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt

from . import actions


def info(request, uuid):
    """
    Return the Twillio ML that we generated when the user
    called /call
    """
    data = open(os.path.join("/tmp", uuid + ".xml")).read()
    return HttpResponse(data, content_type="text/xml")


## Instruction:
Tidy imports and opening the tmpfile
## Code After:
import os

from django.http import HttpResponse

def info(request, uuid):
    """
    Return the Twillio ML that we generated when the user called /call
    """

    with open(os.path.join('/tmp', '%s.xml' % uuid)) as f:
        data = f.read()

    return HttpResponse(data, content_type='text/xml')
