CQLParser
index
/home/cheshire/cheshire/cheshire/python/CQLParser/CQLParser.py

# Author:  Rob Sanderson (azaroth@liv.ac.uk)
# Distributed and Usable under the GPL 
# Version: 1.5
# Most Recent Changes: contexts, new modifier style for 1.1
#
# With thanks to Adam from IndexData and Mike Taylor for their valuable input

 
Modules
            
PyZ3950.asn1
PyZ3950.oids
types
PyZ3950.z3950
 
Classes
            
CQLParser
ModifiableObject
Boolean
ModifierClause
PrefixableObject
SearchClause
Triple
PrefixedObject
Index
ModifierType
Relation(PrefixedObject, ModifiableObject)
Term
XCQLParser
shlex.shlex
CQLshlex
 
class Boolean(ModifiableObject)
      Object to represent a CQL boolean
 
   Methods defined here:
__init__(self, bool, mods=[])
resolvePrefix(self, name)
toCQL(self)
toXCQL(self, depth=0)
Create XCQL representation of object

Data and non-method functions defined here:
__doc__ = 'Object to represent a CQL boolean'
__module__ = 'CQLParser'
parent = None
value = ''

Methods inherited from ModifiableObject:
__getitem__(self, k)

Data and non-method functions inherited from ModifiableObject:
modifiers = []
 
class CQLParser
      Token parser to create object structure for CQL
 
   Methods defined here:
__init__(self, p)
 Initialise with shlex parser
boolean(self)
 Find boolean
clause(self)
 Find searchClause
fetch_token(self)
 Read ahead one token
is_boolean(self, token)
Is the token a boolean
modifiers(self)
prefixes(self)
Create prefixes dictionary
query(self)
 Parse query
relation(self)
 Find relation
subQuery(self)
 Find either query or clause

Data and non-method functions defined here:
__doc__ = 'Token parser to create object structure for CQL'
__module__ = 'CQLParser'
currentToken = ''
nextToken = ''
parser = ''
 
class CQLshlex(shlex.shlex)
      shlex with additions for CQL parsing
 
   Methods defined here:
__init__(self, thing)
read_token(self)
Read a token from the input stream (no pushback or inclusions)

Data and non-method functions defined here:
__doc__ = 'shlex with additions for CQL parsing'
__module__ = 'CQLParser'
commenters = ''
nextToken = ''
quotes = '"'

Methods inherited from shlex.shlex:
error_leader(self, infile=None, lineno=None)
Emit a C-compiler-like, Emacs-friendly error-message leader.
get_token(self)
Get a token from the input stream (or from stack if it's nonempty)
pop_source(self)
Pop the input source stack.
push_source(self, newstream, newfile=None)
Push an input source onto the lexer's input source stack.
push_token(self, tok)
Push a token onto the stack popped by the get_token method
sourcehook(self, newfile)
Hook called on a filename to be sourced.
 
class Index(PrefixedObject)
      Object to represent a CQL index
 
   Methods defined here:
toCQL(self)
toXCQL(self, depth=0)

Data and non-method functions defined here:
__doc__ = 'Object to represent a CQL index'
__module__ = 'CQLParser'

Methods inherited from PrefixedObject:
__init__(self, val)
__str__(self)
resolvePrefix(self)
splitValue(self)

Data and non-method functions inherited from PrefixedObject:
parent = None
prefix = ''
prefixURI = ''
value = ''
 
class ModifiableObject
       
   Methods defined here:
__getitem__(self, k)

Data and non-method functions defined here:
__doc__ = None
__module__ = 'CQLParser'
modifiers = []
 
class ModifierClause
      Object to represent a relation modifier
 
   Methods defined here:
__init__(self, type, comp='', val='')
__str__(self)
toCQL(self)
toXCQL(self, depth=0)

Data and non-method functions defined here:
__doc__ = 'Object to represent a relation modifier'
__module__ = 'CQLParser'
comparison = ''
type = None
value = ''
 
class ModifierType(PrefixedObject)
       
   Data and non-method functions defined here:
__doc__ = None
__module__ = 'CQLParser'

Methods inherited from PrefixedObject:
__init__(self, val)
__str__(self)
resolvePrefix(self)
splitValue(self)

Data and non-method functions inherited from PrefixedObject:
parent = None
prefix = ''
prefixURI = ''
value = ''
 
class PrefixableObject
      Root object for triple and searchClause
 
   Methods defined here:
__init__(self)
addPrefix(self, name, identifier)
resolvePrefix(self, name)
toXCQL(self, depth=0)

Data and non-method functions defined here:
__doc__ = 'Root object for triple and searchClause'
__module__ = 'CQLParser'
config = None
parent = None
prefixes = {}
 
class PrefixedObject
      Root object for relation, relationModifier and index
 
   Methods defined here:
__init__(self, val)
__str__(self)
resolvePrefix(self)
splitValue(self)

Data and non-method functions defined here:
__doc__ = 'Root object for relation, relationModifier and index'
__module__ = 'CQLParser'
parent = None
prefix = ''
prefixURI = ''
value = ''
 
class Relation(PrefixedObject, ModifiableObject)
      Object to represent a CQL relation
 
  
Method resolution order:
Relation
PrefixedObject
ModifiableObject

Methods defined here:
__init__(self, rel, mods=[])
toCQL(self)
toXCQL(self, depth=0)
Create XCQL representation of object

Data and non-method functions defined here:
__doc__ = 'Object to represent a CQL relation'
__module__ = 'CQLParser'

Methods inherited from PrefixedObject:
__str__(self)
resolvePrefix(self)
splitValue(self)

Data and non-method functions inherited from PrefixedObject:
parent = None
prefix = ''
prefixURI = ''
value = ''

Methods inherited from ModifiableObject:
__getitem__(self, k)

Data and non-method functions inherited from ModifiableObject:
modifiers = []
 
class SearchClause(PrefixableObject)
      Object to represent a CQL searchClause
 
   Methods defined here:
__init__(self, ind, rel, t)
getResultSetId(self)
toCQL(self)
toXCQL(self, depth=0)
Produce XCQL version of the object

Data and non-method functions defined here:
__doc__ = 'Object to represent a CQL searchClause'
__module__ = 'CQLParser'
index = None
relation = None
term = None

Methods inherited from PrefixableObject:
addPrefix(self, name, identifier)
resolvePrefix(self, name)

Data and non-method functions inherited from PrefixableObject:
config = None
parent = None
prefixes = {}
 
class Term
       
   Methods defined here:
__init__(self, v)
__str__(self)
toXCQL(self, depth=0)

Data and non-method functions defined here:
__doc__ = None
__module__ = 'CQLParser'
value = ''
 
class Triple(PrefixableObject)
      Object to represent a CQL triple
 
   Methods defined here:
getResultSetId(self, top=None)
toCQL(self)
toXCQL(self, depth=0)
Create the XCQL representation of the object

Data and non-method functions defined here:
__doc__ = 'Object to represent a CQL triple'
__module__ = 'CQLParser'
boolean = None
leftOperand = None
rightOperand = None

Methods inherited from PrefixableObject:
__init__(self)
addPrefix(self, name, identifier)
resolvePrefix(self, name)

Data and non-method functions inherited from PrefixableObject:
config = None
parent = None
prefixes = {}
 
class XCQLParser
       Parser for XCQL using some very simple DOM
 
   Methods defined here:
boolean(self, elem)
Process a <boolean>
firstChildData(self, elem)
 Find first child which is Data
firstChildElement(self, elem)
 Find first child which is an Element
prefixes(self, elem)
Process <prefixes>
relation(self, elem)
 Process a <relation>
searchClause(self, elem)
 Process a <searchClause>
triple(self, elem)
 Process a <triple>

Data and non-method functions defined here:
__doc__ = ' Parser for XCQL using some very simple DOM '
__module__ = 'CQLParser'
 
Functions
            
StringIO(...)
StringIO([s]) -- Return a StringIO-like stream for reading or writing
parse(query)
 API. Return a searchClause/triple object from CQL string
xcqlparse(query)
 API.  Return a searchClause/triple object from XML DOM objects
xmlparse(s)
 API. Return a seachClause/triple object from XML string
 
Data
             __file__ = './CQLParser.pyc'
__name__ = 'CQLParser'
booleans = ['and', 'or', 'not', 'prox']
errorOnDuplicatePrefix = 0
errorOnEmptyTerm = 0
errorOnQuotedIdentifier = 0
fullResultSetNameCheck = 1
modifierSeparator = '/'
order = ['=', '>', '>=', '<', '<=', '<>']
reservedPrefixes = {'cql': 'http://www.loc.gov/zing/cql/contextSets/cql/v1.1/', 'srw': 'http://www.loc.gov/zing/cql/srw-indexes/v1.0/'}
serverChoiceIndex = 'cql.serverchoice'
serverChoiceRelation = 'scr'
zConfig = <CQLUtils.ZCQLConfig instance>