parameters: (path)
return_statement: return None
docstring: Replace #!python with #!/path/to/python
      Return True if file was changed.
docstring_summary: Replace #!python with #!/path/to/python
      Return True if file was changed.
docstring_tokens: Replace #!python with #! / path / to / python Return True if file was changed .
function: def fix_script(path):
      # type: (str) -> Optional[bool]
      """Replace #!python with #!/path/to/python
      Return True if file was changed."""
      # XXX RECORD hashes will need to be updated
      if os.path.isfile(path):
          with open(path, 'rb') as script:
              firstline = script.readline()
              if not firstline.startswith(b'#!python'):
                  return False
              exename = sys.executable.encode(sys.getfilesystemencoding())
              firstline = b'#!' + exename + os.linesep.encode("ascii")
              rest = script.read()
          with open(path, 'wb') as script:
              script.write(firstline)
              script.write(rest)
          return True
      return None
function_tokens: def fix_script ( path ) : # type: (str) -> Optional[bool] # XXX RECORD hashes will need to be updated if os . path . isfile ( path ) : with open ( path , 'rb' ) as script : firstline = script . readline ( ) if not firstline . startswith ( b'#!python' ) : return False exename = sys . executable . encode ( sys . getfilesystemencoding ( ) ) firstline = b'#!' + exename + os . linesep . encode ( "ascii" ) rest = script . read ( ) with open ( path , 'wb' ) as script : script . write ( firstline ) script . write ( rest ) return True return None