Gaudi Framework, version v25r1

Home   Generated: Mon Mar 24 2014
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Public Attributes | List of all members
pyparsing.QuotedString Class Reference
Inheritance diagram for pyparsing.QuotedString:
Inheritance graph
[legend]
Collaboration diagram for pyparsing.QuotedString:
Collaboration graph
[legend]

Public Member Functions

def __init__
 
def parseImpl
 
def __str__
 
- Public Member Functions inherited from pyparsing.Token
def __init__
 
def setName
 
- Public Member Functions inherited from pyparsing.ParserElement
def setDefaultWhitespaceChars
 
def __init__
 
def copy
 
def setName
 
def setResultsName
 
def setBreak
 
def setParseAction
 
def addParseAction
 
def setFailAction
 
def preParse
 
def parseImpl
 
def postParse
 
def tryParse
 
def resetCache
 
def enablePackrat
 
def parseString
 
def scanString
 
def transformString
 
def searchString
 
def __add__
 
def __radd__
 
def __sub__
 
def __rsub__
 
def __mul__
 
def __rmul__
 
def __or__
 
def __ror__
 
def __xor__
 
def __rxor__
 
def __and__
 
def __rand__
 
def __invert__
 
def __call__
 
def suppress
 
def leaveWhitespace
 
def setWhitespaceChars
 
def parseWithTabs
 
def ignore
 
def setDebugActions
 
def setDebug
 
def __str__
 
def __repr__
 
def streamline
 
def checkRecursion
 
def validate
 
def parseFile
 
def getException
 
def __getattr__
 
def __eq__
 
def __ne__
 
def __hash__
 
def __req__
 
def __rne__
 

Public Attributes

 quoteChar
 
 quoteCharLen
 
 firstQuoteChar
 
 endQuoteChar
 
 endQuoteCharLen
 
 escChar
 
 escQuote
 
 unquoteResults
 
 flags
 
 pattern
 
 escCharReplacePattern
 
 re
 
 reString
 
 name
 
 errmsg
 
 mayIndexError
 
 mayReturnEmpty
 
 strRepr
 
- Public Attributes inherited from pyparsing.Token
 errmsg
 
- Public Attributes inherited from pyparsing.ParserElement
 parseAction
 
 failAction
 
 strRepr
 
 resultsName
 
 saveAsList
 
 skipWhitespace
 
 whiteChars
 
 copyDefaultWhiteChars
 
 mayReturnEmpty
 
 keepTabs
 
 ignoreExprs
 
 debug
 
 streamlined
 
 mayIndexError
 
 errmsg
 
 modalResults
 
 debugActions
 
 re
 
 callPreparse
 
 callDuringTry
 
 name
 
 myException
 

Additional Inherited Members

- Static Public Attributes inherited from pyparsing.ParserElement
string DEFAULT_WHITE_CHARS " \n\t\r"
 
tuple setDefaultWhitespaceChars staticmethod(setDefaultWhitespaceChars)
 
tuple resetCache staticmethod(resetCache)
 
tuple enablePackrat staticmethod(enablePackrat)
 

Detailed Description

Token for matching strings that are delimited by quoting characters.

Definition at line 1799 of file pyparsing.py.

Constructor & Destructor Documentation

def pyparsing.QuotedString.__init__ (   self,
  quoteChar,
  escChar = None,
  escQuote = None,
  multiline = False,
  unquoteResults = True,
  endQuoteChar = None 
)
   Defined with the following parameters:
    - quoteChar - string of one or more characters defining the quote delimiting string
    - escChar - character to escape quotes, typically backslash (default=None)
    - escQuote - special quote sequence to escape an embedded quote string (such as SQL's "" to escape an embedded ") (default=None)
    - multiline - boolean indicating whether quotes can span multiple lines (default=False)
    - unquoteResults - boolean indicating whether the matched text should be unquoted (default=True)
    - endQuoteChar - string of one or more characters defining the end of the quote delimited string (default=None => same as quoteChar)

Definition at line 1802 of file pyparsing.py.

1803  def __init__( self, quoteChar, escChar=None, escQuote=None, multiline=False, unquoteResults=True, endQuoteChar=None):
1804  """
1805  Defined with the following parameters:
1806  - quoteChar - string of one or more characters defining the quote delimiting string
1807  - escChar - character to escape quotes, typically backslash (default=None)
1808  - escQuote - special quote sequence to escape an embedded quote string (such as SQL's "" to escape an embedded ") (default=None)
1809  - multiline - boolean indicating whether quotes can span multiple lines (default=False)
1810  - unquoteResults - boolean indicating whether the matched text should be unquoted (default=True)
1811  - endQuoteChar - string of one or more characters defining the end of the quote delimited string (default=None => same as quoteChar)
1812  """
1813  super(QuotedString,self).__init__()
1814 
1815  # remove white space from quote chars - wont work anyway
1816  quoteChar = quoteChar.strip()
1817  if len(quoteChar) == 0:
1818  warnings.warn("quoteChar cannot be the empty string",SyntaxWarning,stacklevel=2)
1819  raise SyntaxError()
1820 
1821  if endQuoteChar is None:
1822  endQuoteChar = quoteChar
1823  else:
1824  endQuoteChar = endQuoteChar.strip()
1825  if len(endQuoteChar) == 0:
1826  warnings.warn("endQuoteChar cannot be the empty string",SyntaxWarning,stacklevel=2)
1827  raise SyntaxError()
1829  self.quoteChar = quoteChar
1830  self.quoteCharLen = len(quoteChar)
1831  self.firstQuoteChar = quoteChar[0]
1832  self.endQuoteChar = endQuoteChar
1833  self.endQuoteCharLen = len(endQuoteChar)
1834  self.escChar = escChar
1835  self.escQuote = escQuote
1836  self.unquoteResults = unquoteResults
1837 
1838  if multiline:
1839  self.flags = re.MULTILINE | re.DOTALL
1840  self.pattern = r'%s(?:[^%s%s]' % \
1841  ( re.escape(self.quoteChar),
1843  (escChar is not None and _escapeRegexRangeChars(escChar) or '') )
1844  else:
1845  self.flags = 0
1846  self.pattern = r'%s(?:[^%s\n\r%s]' % \
1847  ( re.escape(self.quoteChar),
1849  (escChar is not None and _escapeRegexRangeChars(escChar) or '') )
1850  if len(self.endQuoteChar) > 1:
1851  self.pattern += (
1852  '|(?:' + ')|(?:'.join(["%s[^%s]" % (re.escape(self.endQuoteChar[:i]),
1854  for i in range(len(self.endQuoteChar)-1,0,-1)]) + ')'
1855  )
1856  if escQuote:
1857  self.pattern += (r'|(?:%s)' % re.escape(escQuote))
1858  if escChar:
1859  self.pattern += (r'|(?:%s.)' % re.escape(escChar))
1860  self.escCharReplacePattern = re.escape(self.escChar)+"(.)"
1861  self.pattern += (r')*%s' % re.escape(self.endQuoteChar))
1862 
1863  try:
1864  self.re = re.compile(self.pattern, self.flags)
1865  self.reString = self.pattern
1866  except sre_constants.error:
1867  warnings.warn("invalid pattern (%s) passed to Regex" % self.pattern,
1868  SyntaxWarning, stacklevel=2)
1869  raise
1871  self.name = _ustr(self)
1872  self.errmsg = "Expected " + self.name
1873  #self.myException.msg = self.errmsg
1874  self.mayIndexError = False
1875  self.mayReturnEmpty = True

Member Function Documentation

def pyparsing.QuotedString.__str__ (   self)

Definition at line 1903 of file pyparsing.py.

1904  def __str__( self ):
1905  try:
1906  return super(QuotedString,self).__str__()
1907  except:
1908  pass
1909 
1910  if self.strRepr is None:
1911  self.strRepr = "quoted string, starting with %s ending with %s" % (self.quoteChar, self.endQuoteChar)
1912 
1913  return self.strRepr
1914 
def pyparsing.QuotedString.parseImpl (   self,
  instring,
  loc,
  doActions = True 
)

Definition at line 1876 of file pyparsing.py.

1877  def parseImpl( self, instring, loc, doActions=True ):
1878  result = instring[loc] == self.firstQuoteChar and self.re.match(instring,loc) or None
1879  if not result:
1880  exc = self.myException
1881  exc.loc = loc
1882  exc.pstr = instring
1883  raise exc
1884 
1885  loc = result.end()
1886  ret = result.group()
1887 
1888  if self.unquoteResults:
1889 
1890  # strip off quotes
1891  ret = ret[self.quoteCharLen:-self.endQuoteCharLen]
1892 
1893  if isinstance(ret,basestring):
1894  # replace escaped characters
1895  if self.escChar:
1896  ret = re.sub(self.escCharReplacePattern,"\g<1>",ret)
1897 
1898  # replace escaped quotes
1899  if self.escQuote:
1900  ret = ret.replace(self.escQuote, self.endQuoteChar)
1901 
1902  return loc, ret

Member Data Documentation

pyparsing.QuotedString.endQuoteChar

Definition at line 1831 of file pyparsing.py.

pyparsing.QuotedString.endQuoteCharLen

Definition at line 1832 of file pyparsing.py.

pyparsing.QuotedString.errmsg

Definition at line 1871 of file pyparsing.py.

pyparsing.QuotedString.escChar

Definition at line 1833 of file pyparsing.py.

pyparsing.QuotedString.escCharReplacePattern

Definition at line 1859 of file pyparsing.py.

pyparsing.QuotedString.escQuote

Definition at line 1834 of file pyparsing.py.

pyparsing.QuotedString.firstQuoteChar

Definition at line 1830 of file pyparsing.py.

pyparsing.QuotedString.flags

Definition at line 1838 of file pyparsing.py.

pyparsing.QuotedString.mayIndexError

Definition at line 1873 of file pyparsing.py.

pyparsing.QuotedString.mayReturnEmpty

Definition at line 1874 of file pyparsing.py.

pyparsing.QuotedString.name

Definition at line 1870 of file pyparsing.py.

pyparsing.QuotedString.pattern

Definition at line 1839 of file pyparsing.py.

pyparsing.QuotedString.quoteChar

Definition at line 1828 of file pyparsing.py.

pyparsing.QuotedString.quoteCharLen

Definition at line 1829 of file pyparsing.py.

pyparsing.QuotedString.re

Definition at line 1863 of file pyparsing.py.

pyparsing.QuotedString.reString

Definition at line 1864 of file pyparsing.py.

pyparsing.QuotedString.strRepr

Definition at line 1910 of file pyparsing.py.

pyparsing.QuotedString.unquoteResults

Definition at line 1835 of file pyparsing.py.


The documentation for this class was generated from the following file:
Generated at Mon Mar 24 2014 18:27:54 for Gaudi Framework, version v25r1 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004