code: def get_file_language(filename, text=None):
      
      ext = osp.splitext(filename)[1]
      if ext.startswith('.'):
          ext = ext[1:] # file extension with leading dot
      language = ext
      if not ext:
          if text is None:
              text, _enc = encoding.read(filename)
          for line in text.splitlines():
              if not line.strip():
                  continue
              if line.startswith('#!'):
                 shebang = line[2:]
                 if 'python' in shebang:
                     language = 'python'
              else:
                  break
      return language
docs: Get file language from filename