old_contents: """JPEG 2000 File Reader"""
  from __future__ import absolute_import
  
  __author__ = "Keith Hughitt"
  __email__ = "keith.hughitt@nasa.gov"
  
  import os
  import subprocess
  import tempfile
  from xml.etree import cElementTree as ET
  
  from matplotlib.image import imread
  from glymur import Jp2k
  
  from sunpy.util.xml import xml_to_dict
  from sunpy.io.header import FileHeader
  
  __all__ = ['read', 'get_header', 'write']
  
  def read(filepath):
      """
      Reads a JPEG2000 file
  
      Parameters
      ----------
      filepath : string
          The file to be read
  
      j2k_to_image : string
          binary to use for reading?
  
      Returns
      -------
      pairs : list
          A list of (data, header) tuples
      """
      header = get_header(filepath)
      data = Jp2k(filepath).read()
  
      return [(data, header[0])]
  
  def get_header(filepath):
      """
      Reads the header from the file
  
      Parameters
      ----------
      filepath : string
          The file to be read
  
      Returns
      -------
      headers : list
          A list of headers read from the file
      """
      jp2 = Jp2k(filepath)
      xml_box = [box for box in jp2.box if box.box_id == 'xml ']
      xmlstring = ET.tostring(xml_box[0].xml.find('fits'))
      pydict = xml_to_dict(xmlstring)["fits"]
  
      #Fix types
      for k, v in pydict.items():
          if v.isdigit():
              pydict[k] = int(v)
          elif _is_float(v):
              pydict[k] = float(v)
  
      # Remove newlines from comment
      if 'comment' in pydict:
          pydict['comment'] = pydict['comment'].replace("\n", "")
  
      return [FileHeader(pydict)]
  
  def write(fname, data, header):
      """
      Place holder for required file writer
      """
      raise NotImplementedError("No jp2 writer is implemented")
  
  def _is_float(s):
      """Check to see if a string value is a valid float"""
      try:
          float(s)
          return True
      except ValueError:
          return False
  
  def _which(program):
      """Checks for existence of executable
  
      Source: http://stackoverflow.com/questions/377017/test-if-executable-exists-in-python/377028#377028
      """
      def is_exe(fpath):
          return os.path.exists(fpath) and os.access(fpath, os.X_OK)
  
      fpath, fname = os.path.split(program) #pylint: disable=W0612
  
      if fpath:
          if is_exe(program):
              return program
      else:
          for path in os.environ["PATH"].split(os.pathsep):
              exe_file = os.path.join(path, program)
              if is_exe(exe_file):
                  return exe_file
  
      return None
  
new_contents: """JPEG 2000 File Reader"""
  from __future__ import absolute_import
  
  __author__ = "Keith Hughitt"
  __email__ = "keith.hughitt@nasa.gov"
  
  import os
  import subprocess
  import tempfile
  from xml.etree import cElementTree as ET
  
  from matplotlib.image import imread
  from glymur import Jp2k
  
  from sunpy.util.xml import xml_to_dict
  from sunpy.io.header import FileHeader
  
  __all__ = ['read', 'get_header', 'write']
  
  def read(filepath):
      """
      Reads a JPEG2000 file
  
      Parameters
      ----------
      filepath : string
          The file to be read
  
      j2k_to_image : string
          binary to use for reading?
  
      Returns
      -------
      pairs : list
          A list of (data, header) tuples
      """
      header = get_header(filepath)
      data = Jp2k(filepath).read()
  
      return [(data, header[0])]
  
  def get_header(filepath):
      """
      Reads the header from the file
  
      Parameters
      ----------
      filepath : string
          The file to be read
  
      Returns
      -------
      headers : list
          A list of headers read from the file
      """
      jp2 = Jp2k(filepath)
      xml_box = [box for box in jp2.box if box.box_id == 'xml ']
      xmlstring = ET.tostring(xml_box[0].xml.find('fits'))
      pydict = xml_to_dict(xmlstring)["fits"]
  
      #Fix types
      for k, v in pydict.items():
          if v.isdigit():
              pydict[k] = int(v)
          elif _is_float(v):
              pydict[k] = float(v)
  
      # Remove newlines from comment
      if 'comment' in pydict:
          pydict['comment'] = pydict['comment'].replace("\n", "")
  
      return [FileHeader(pydict)]
  
  def write(fname, data, header):
      """
      Place holder for required file writer
      """
      raise NotImplementedError("No jp2 writer is implemented")
  
subject: remove more old stuff from jp2