Back to index

plone3  3.1.7
Classes | Functions | Variables
icalendar.parser Namespace Reference

Classes

class  Parameters
class  Contentline
class  Contentlines

Functions

def paramVal
 Property parameter stuff.
def validate_token
def validate_param_value
def dQuote
def q_split
def q_join

Variables

list SequenceTypes = [TupleType, ListType]
tuple NAME = re.compile('[\w-]+')
tuple UNSAFE_CHAR = re.compile('[\x00-\x08\x0a-\x1f\x7F",:;]')QUNSAFE_CHAR = re.compile('[\x00-\x08\x0a-\x1f\x7F"]')
tuple FOLD = re.compile('([\r]?\n)+[ \t]{1}')
tuple QUOTABLE = re.compile('[,;:].')

Function Documentation

def icalendar.parser.dQuote (   val)
Parameter values containing [,;:] must be double quoted
>>> dQuote('Max')
'Max'
>>> dQuote('Rasmussen, Max')
'"Rasmussen, Max"'
>>> dQuote('name:value')
'"name:value"'

Definition at line 52 of file parser.py.

00052 
00053 def dQuote(val):
00054     """
00055     Parameter values containing [,;:] must be double quoted
00056     >>> dQuote('Max')
00057     'Max'
00058     >>> dQuote('Rasmussen, Max')
00059     '"Rasmussen, Max"'
00060     >>> dQuote('name:value')
00061     '"name:value"'
00062     """
00063     if QUOTABLE.search(val):
00064         return '"%s"' % val
00065     return val
00066 
# parsing helper

Here is the caller graph for this function:

Property parameter stuff.

Definition at line 26 of file parser.py.

00026 
00027 def paramVal(val):
00028     "Returns a parameter value"
00029     if type(val) in SequenceTypes:
00030         return q_join(val)
00031     return dQuote(val)
00032 
# Could be improved

Here is the call graph for this function:

Here is the caller graph for this function:

def icalendar.parser.q_join (   lst,
  sep = ' 
)
Joins a list on sep, quoting strings with QUOTABLE chars
>>> s = ['Max', 'Moller', 'Rasmussen, Max']
>>> q_join(s)
'Max,Moller,"Rasmussen, Max"'

Definition at line 88 of file parser.py.

00088 
00089 def q_join(lst, sep=','):
00090     """
00091     Joins a list on sep, quoting strings with QUOTABLE chars
00092     >>> s = ['Max', 'Moller', 'Rasmussen, Max']
00093     >>> q_join(s)
00094     'Max,Moller,"Rasmussen, Max"'
00095     """
00096     return sep.join([dQuote(itm) for itm in lst])

Here is the call graph for this function:

Here is the caller graph for this function:

def icalendar.parser.q_split (   st,
  sep = ' 
)
Splits a string on char, taking double (q)uotes into considderation
>>> q_split('Max,Moller,"Rasmussen, Max"')
['Max', 'Moller', '"Rasmussen, Max"']

Definition at line 67 of file parser.py.

00067 
00068 def q_split(st, sep=','):
00069     """
00070     Splits a string on char, taking double (q)uotes into considderation
00071     >>> q_split('Max,Moller,"Rasmussen, Max"')
00072     ['Max', 'Moller', '"Rasmussen, Max"']
00073     """
00074     result = []
00075     cursor = 0
00076     length = len(st)
00077     inquote = 0
00078     for i in range(length):
00079         ch = st[i]
00080         if ch == '"':
00081             inquote = not inquote
00082         if not inquote and ch == sep:
00083             result.append(st[cursor:i])
00084             cursor = i + 1
00085         if i + 1 == length:
00086             result.append(st[cursor:])
00087     return result

Here is the caller graph for this function:

def icalendar.parser.validate_param_value (   value,
  quoted = True 
)

Definition at line 44 of file parser.py.

00044 
00045 def validate_param_value(value, quoted=True):
00046     validator = UNSAFE_CHAR
00047     if quoted:
00048         validator = QUNSAFE_CHAR
00049     if validator.findall(value):
00050         raise ValueError, value

Here is the caller graph for this function:

Definition at line 38 of file parser.py.

00038 
00039 def validate_token(name):
00040     match = NAME.findall(name)
00041     if len(match) == 1 and name == match[0]:
00042         return
00043     raise ValueError, name

Here is the caller graph for this function:


Variable Documentation

tuple icalendar.parser.FOLD = re.compile('([\r]?\n)+[ \t]{1}')

Definition at line 36 of file parser.py.

tuple icalendar.parser.NAME = re.compile('[\w-]+')

Definition at line 33 of file parser.py.

tuple icalendar.parser.QUOTABLE = re.compile('[,;:].')

Definition at line 51 of file parser.py.

list icalendar.parser.SequenceTypes = [TupleType, ListType]

Definition at line 17 of file parser.py.

tuple icalendar.parser.UNSAFE_CHAR = re.compile('[\x00-\x08\x0a-\x1f\x7F",:;]')QUNSAFE_CHAR = re.compile('[\x00-\x08\x0a-\x1f\x7F"]')

Definition at line 34 of file parser.py.