def get_file_language(filename, text=None):
 ext = osp.splitext(filename)[1]
 if ext.startswith('.'):
  ext = ext[1:]
 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

def get_file_language ( filename , text = None ) : ext = osp . splitext ( filename ) [ 1 ] if ext . startswith ( '.' ) : ext = ext [ 1 : ] 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
get file language from filename .