old_contents: def list_dashboards():
      import os
      wd = os.getcwd()
      os.chdir('templates/dashboards')
      dashboards = []
      for f in os.listdir("."):
          if not f.endswith(".tpl"):
              continue
          dashboards.append(f[:-4])
      os.chdir(wd)
      return sorted(dashboards)
  
new_contents: import os
  import glob
  
  
  def list_dashboards():
      tpl_list = glob.glob('templates/dashboards/*.tpl')
      dashboards = map(lambda tpl: os.path.basename(tpl)[:-4], tpl_list)
      return sorted(dashboards)
  
subject: refactor list_dashboards