Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
plistlib.PlistParser Class Reference

List of all members.

Public Member Functions

def __init__
def parse
def handleBeginElement
def handleEndElement
def handleData
def addObject
def getData
def begin_dict
def end_dict
def end_key
def begin_array
def end_array
def end_true
def end_false
def end_integer
def end_real
def end_string
def end_data
def end_date

Public Attributes

 stack
 currentKey
 root
 parser
 data

Detailed Description

Definition at line 359 of file plistlib.py.


Constructor & Destructor Documentation

Definition at line 361 of file plistlib.py.

00361 
00362     def __init__(self):
00363         self.stack = []
00364         self.currentKey = None
00365         self.root = None

Here is the caller graph for this function:


Member Function Documentation

def plistlib.PlistParser.addObject (   self,
  value 
)

Definition at line 389 of file plistlib.py.

00389 
00390     def addObject(self, value):
00391         if self.currentKey is not None:
00392             if not isinstance(self.stack[-1], type({})):
00393                 raise ValueError("unexpected element at line %d" %
00394                                  self.parser.CurrentLineNumber)
00395             self.stack[-1][self.currentKey] = value
00396             self.currentKey = None
00397         elif not self.stack:
00398             # this is the root object
00399             self.root = value
00400         else:
00401             if not isinstance(self.stack[-1], type([])):
00402                 raise ValueError("unexpected element at line %d" %
00403                                  self.parser.CurrentLineNumber)
00404             self.stack[-1].append(value)

Here is the call graph for this function:

Here is the caller graph for this function:

def plistlib.PlistParser.begin_array (   self,
  attrs 
)

Definition at line 428 of file plistlib.py.

00428 
00429     def begin_array(self, attrs):
00430         a = []
00431         self.addObject(a)
        self.stack.append(a)

Here is the call graph for this function:

def plistlib.PlistParser.begin_dict (   self,
  attrs 
)

Definition at line 412 of file plistlib.py.

00412 
00413     def begin_dict(self, attrs):
00414         d = _InternalDict()
00415         self.addObject(d)
        self.stack.append(d)

Here is the call graph for this function:

Definition at line 432 of file plistlib.py.

00432 
00433     def end_array(self):
00434         self.stack.pop()

Definition at line 445 of file plistlib.py.

00445 
00446     def end_data(self):
        self.addObject(Data.fromBase64(self.getData().encode("utf-8")))

Here is the call graph for this function:

Definition at line 447 of file plistlib.py.

00447 
00448     def end_date(self):
00449         self.addObject(_dateFromString(self.getData()))

Here is the call graph for this function:

Definition at line 416 of file plistlib.py.

00416 
00417     def end_dict(self):
00418         if self.currentKey:
00419             raise ValueError("missing value for key '%s' at line %d" %
00420                              (self.currentKey,self.parser.CurrentLineNumber))
00421         self.stack.pop()

Definition at line 437 of file plistlib.py.

00437 
00438     def end_false(self):
        self.addObject(False)

Here is the call graph for this function:

Definition at line 439 of file plistlib.py.

00439 
00440     def end_integer(self):
        self.addObject(int(self.getData()))

Here is the call graph for this function:

Definition at line 422 of file plistlib.py.

00422 
00423     def end_key(self):
00424         if self.currentKey or not isinstance(self.stack[-1], type({})):
00425             raise ValueError("unexpected key at line %d" %
00426                              self.parser.CurrentLineNumber)
00427         self.currentKey = self.getData()

Here is the call graph for this function:

Definition at line 441 of file plistlib.py.

00441 
00442     def end_real(self):
        self.addObject(float(self.getData()))

Here is the call graph for this function:

Definition at line 443 of file plistlib.py.

00443 
00444     def end_string(self):
        self.addObject(self.getData())

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 435 of file plistlib.py.

00435 
00436     def end_true(self):
        self.addObject(True)

Here is the call graph for this function:

Definition at line 405 of file plistlib.py.

00405 
00406     def getData(self):
00407         data = ''.join(self.data)
00408         self.data = []
00409         return data

Here is the caller graph for this function:

def plistlib.PlistParser.handleBeginElement (   self,
  element,
  attrs 
)

Definition at line 375 of file plistlib.py.

00375 
00376     def handleBeginElement(self, element, attrs):
00377         self.data = []
00378         handler = getattr(self, "begin_" + element, None)
00379         if handler is not None:
00380             handler(attrs)

def plistlib.PlistParser.handleData (   self,
  data 
)

Definition at line 386 of file plistlib.py.

00386 
00387     def handleData(self, data):
00388         self.data.append(data)

def plistlib.PlistParser.handleEndElement (   self,
  element 
)

Definition at line 381 of file plistlib.py.

00381 
00382     def handleEndElement(self, element):
00383         handler = getattr(self, "end_" + element, None)
00384         if handler is not None:
00385             handler()

Here is the call graph for this function:

def plistlib.PlistParser.parse (   self,
  fileobj 
)

Definition at line 366 of file plistlib.py.

00366 
00367     def parse(self, fileobj):
00368         from xml.parsers.expat import ParserCreate
00369         self.parser = ParserCreate()
00370         self.parser.StartElementHandler = self.handleBeginElement
00371         self.parser.EndElementHandler = self.handleEndElement
00372         self.parser.CharacterDataHandler = self.handleData
00373         self.parser.ParseFile(fileobj)
00374         return self.root

Here is the caller graph for this function:


Member Data Documentation

Definition at line 363 of file plistlib.py.

Definition at line 376 of file plistlib.py.

Definition at line 368 of file plistlib.py.

Definition at line 364 of file plistlib.py.

Definition at line 362 of file plistlib.py.


The documentation for this class was generated from the following file: