parameters: (self)
return_statement: return self.decode(data)
docstring: Read and decode a single file and return the data (Unicode string).
docstring_summary: Read and decode a single file and return the data (Unicode string).
docstring_tokens: Read and decode a single file and return the data ( Unicode string ) .
function: def read(self):
          """
          Read and decode a single file and return the data (Unicode string).
          """
          try: # In Python < 2.5, try...except has to be nested in try...finally.
              try:
                  if self.source is sys.stdin and sys.version_info >= (3,0):
                      # read as binary data to circumvent auto-decoding
                      data = self.source.buffer.read()
                      # normalize newlines
                      data = b('\n').join(data.splitlines()) + b('\n')
                  else:
                      data = self.source.read()
              except (UnicodeError, LookupError), err: # (in Py3k read() decodes)
                  if not self.encoding and self.source_path:
                      # re-read in binary mode and decode with heuristics
                      b_source = open(self.source_path, 'rb')
                      data = b_source.read()
                      b_source.close()
                      # normalize newlines
                      data = b('\n').join(data.splitlines()) + b('\n')
                  else:
                      raise
          finally:
              if self.autoclose:
                  self.close()
          return self.decode(data)
function_tokens: def read ( self ) : try : # In Python < 2.5, try...except has to be nested in try...finally. try : if self . source is sys . stdin and sys . version_info >= ( 3 , 0 ) : # read as binary data to circumvent auto-decoding data = self . source . buffer . read ( ) # normalize newlines data = b ( '\n' ) . join ( data . splitlines ( ) ) + b ( '\n' ) else : data = self . source . read ( ) except ( UnicodeError , LookupError ) , err : # (in Py3k read() decodes) if not self . encoding and self . source_path : # re-read in binary mode and decode with heuristics b_source = open ( self . source_path , 'rb' ) data = b_source . read ( ) b_source . close ( ) # normalize newlines data = b ( '\n' ) . join ( data . splitlines ( ) ) + b ( '\n' ) else : raise finally : if self . autoclose : self . close ( ) return self . decode ( data )