parameters: (f, decode=True, stripquotes=True)
return_statement: return data
docstring: r"""
      >>> import StringIO
      >>> read_stringnl(StringIO.StringIO("'abcd'\nefg\n"))
      'abcd'
  
      >>> read_stringnl(StringIO.StringIO("\n"))
      Traceback (most recent call last):
      ...
      ValueError: no string quotes around ''
  
      >>> read_stringnl(StringIO.StringIO("\n"), stripquotes=False)
      ''
  
      >>> read_stringnl(StringIO.StringIO("''\n"))
      ''
  
      >>> read_stringnl(StringIO.StringIO('"abcd"'))
      Traceback (most recent call last):
      ...
      ValueError: no newline found when trying to read stringnl
  
      Embedded escapes are undone in the result.
      >>> read_stringnl(StringIO.StringIO(r"'a\n\\b\x00c\td'" + "\n'e'"))
      'a\n\\b\x00c\td'
docstring_summary: r"""
      >>> import StringIO
      >>> read_stringnl(StringIO.StringIO("'abcd'\nefg\n"))
      'abcd'
docstring_tokens: r >>> import StringIO >>> read_stringnl ( StringIO . StringIO ( abcd \ nefg \ n )) abcd
function: def read_stringnl(f, decode=True, stripquotes=True):
      r"""
      >>> import StringIO
      >>> read_stringnl(StringIO.StringIO("'abcd'\nefg\n"))
      'abcd'
  
      >>> read_stringnl(StringIO.StringIO("\n"))
      Traceback (most recent call last):
      ...
      ValueError: no string quotes around ''
  
      >>> read_stringnl(StringIO.StringIO("\n"), stripquotes=False)
      ''
  
      >>> read_stringnl(StringIO.StringIO("''\n"))
      ''
  
      >>> read_stringnl(StringIO.StringIO('"abcd"'))
      Traceback (most recent call last):
      ...
      ValueError: no newline found when trying to read stringnl
  
      Embedded escapes are undone in the result.
      >>> read_stringnl(StringIO.StringIO(r"'a\n\\b\x00c\td'" + "\n'e'"))
      'a\n\\b\x00c\td'
      """
  
      data = f.readline()
      if not data.endswith('\n'):
          raise ValueError("no newline found when trying to read stringnl")
      data = data[:-1]    # lose the newline
  
      if stripquotes:
          for q in "'\"":
              if data.startswith(q):
                  if not data.endswith(q):
                      raise ValueError("strinq quote %r not found at both "
                                       "ends of %r" % (q, data))
                  data = data[1:-1]
                  break
          else:
              raise ValueError("no string quotes around %r" % data)
  
      # I'm not sure when 'string_escape' was added to the std codecs; it's
      # crazy not to use it if it's there.
      if decode:
          data = data.decode('string_escape')
      return data
function_tokens: def read_stringnl ( f , decode = True , stripquotes = True ) : data = f . readline ( ) if not data . endswith ( '\n' ) : raise ValueError ( "no newline found when trying to read stringnl" ) data = data [ : - 1 ] # lose the newline if stripquotes : for q in "'\"" : if data . startswith ( q ) : if not data . endswith ( q ) : raise ValueError ( "strinq quote %r not found at both " "ends of %r" % ( q , data ) ) data = data [ 1 : - 1 ] break else : raise ValueError ( "no string quotes around %r" % data ) # I'm not sure when 'string_escape' was added to the std codecs; it's # crazy not to use it if it's there. if decode : data = data . decode ( 'string_escape' ) return data