nodes: 0, module; 1, function_definition; 2, function_name:is_python_script; 3, parameters; 4, block; 5, identifier:filename; 6, expression_statement; 7, if_statement; 8, if_statement; 9, try_statement; 10, return_statement; 11, string; 12, call; 13, block; 14, not_operator; 15, block; 16, block; 17, except_clause; 18, False; 19, string_content:Checks a file to see if it's a python script of some sort.; 20, attribute; 21, argument_list; 22, return_statement; 23, call; 24, return_statement; 25, with_statement; 26, identifier:IOError; 27, block; 28, call; 29, identifier:endswith; 30, string; 31, True; 32, attribute; 33, argument_list; 34, False; 35, with_clause; 36, block; 37, pass_statement; 38, attribute; 39, argument_list; 40, string_content:.py; 41, attribute; 42, identifier:isfile; 43, identifier:filename; 44, with_item; 45, if_statement; 46, return_statement; 47, identifier:filename; 48, identifier:lower; 49, identifier:os; 50, identifier:path; 51, as_pattern; 52, comparison_operator:fp.read(2) != b'#!'; 53, block; 54, call; 55, call; 56, as_pattern_target; 57, call; 58, string; 59, return_statement; 60, attribute; 61, argument_list; 62, identifier:open; 63, argument_list; 64, identifier:fp; 65, attribute; 66, argument_list; 67, string_content:#!; 68, False; 69, identifier:re; 70, identifier:match; 71, string; 72, call; 73, identifier:filename; 74, string; 75, identifier:fp; 76, identifier:read; 77, integer:2; 78, string_content:.*python; 79, identifier:str_; 80, argument_list; 81, string_content:rb; 82, call; 83, attribute; 84, argument_list; 85, identifier:fp; 86, identifier:readline
code: def is_python_script(filename):
      '''Checks a file to see if it's a python script of some sort.
      '''
      if filename.lower().endswith('.py'):
          return True
  
      if not os.path.isfile(filename):
          return False
  
      try:
          with open(filename, 'rb') as fp:
              if fp.read(2) != b'#!':
                  return False
              return re.match(r'.*python', str_(fp.readline()))
      except IOError:
          pass
  
      return False