Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
plistlib.PlistWriter Class Reference
Inheritance diagram for plistlib.PlistWriter:
Inheritance graph
[legend]
Collaboration diagram for plistlib.PlistWriter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def writeValue
def writeData
def writeDict
def writeArray
def beginElement
def endElement
def simpleElement
def writeln

Public Attributes

 file
 stack
 indentLevel
 indent

Detailed Description

Definition at line 196 of file plistlib.py.


Constructor & Destructor Documentation

def plistlib.PlistWriter.__init__ (   self,
  file,
  indentLevel = 0,
  indent = b"\t",
  writeHeader = 1 
)

Definition at line 198 of file plistlib.py.

00198 
00199     def __init__(self, file, indentLevel=0, indent=b"\t", writeHeader=1):
00200         if writeHeader:
00201             file.write(PLISTHEADER)
00202         DumbXMLWriter.__init__(self, file, indentLevel, indent)

Here is the caller graph for this function:


Member Function Documentation

def plistlib.DumbXMLWriter.beginElement (   self,
  element 
) [inherited]

Definition at line 122 of file plistlib.py.

00122 
00123     def beginElement(self, element):
00124         self.stack.append(element)
00125         self.writeln("<%s>" % element)
00126         self.indentLevel += 1

Here is the call graph for this function:

Here is the caller graph for this function:

def plistlib.DumbXMLWriter.endElement (   self,
  element 
) [inherited]

Definition at line 127 of file plistlib.py.

00127 
00128     def endElement(self, element):
00129         assert self.indentLevel > 0
00130         assert self.stack.pop() == element
00131         self.indentLevel -= 1
00132         self.writeln("</%s>" % element)

Here is the call graph for this function:

Here is the caller graph for this function:

def plistlib.DumbXMLWriter.simpleElement (   self,
  element,
  value = None 
) [inherited]

Definition at line 133 of file plistlib.py.

00133 
00134     def simpleElement(self, element, value=None):
00135         if value is not None:
00136             value = _escape(value)
00137             self.writeln("<%s>%s</%s>" % (element, value, element))
00138         else:
00139             self.writeln("<%s/>" % element)

Here is the call graph for this function:

Here is the caller graph for this function:

def plistlib.PlistWriter.writeArray (   self,
  array 
)

Definition at line 249 of file plistlib.py.

00249 
00250     def writeArray(self, array):
00251         self.beginElement("array")
00252         for value in array:
00253             self.writeValue(value)
00254         self.endElement("array")
00255 

Here is the call graph for this function:

Here is the caller graph for this function:

def plistlib.PlistWriter.writeData (   self,
  data 
)

Definition at line 228 of file plistlib.py.

00228 
00229     def writeData(self, data):
00230         self.beginElement("data")
00231         self.indentLevel -= 1
00232         maxlinelength = 76 - len(self.indent.replace(b"\t", b" " * 8) *
00233                                  self.indentLevel)
00234         for line in data.asBase64(maxlinelength).split(b"\n"):
00235             if line:
00236                 self.writeln(line)
00237         self.indentLevel += 1
00238         self.endElement("data")

Here is the call graph for this function:

Here is the caller graph for this function:

def plistlib.PlistWriter.writeDict (   self,
  d 
)

Definition at line 239 of file plistlib.py.

00239 
00240     def writeDict(self, d):
00241         self.beginElement("dict")
00242         items = sorted(d.items())
00243         for key, value in items:
00244             if not isinstance(key, str):
00245                 raise TypeError("keys must be strings")
00246             self.simpleElement("key", key)
00247             self.writeValue(value)
00248         self.endElement("dict")

Here is the call graph for this function:

Here is the caller graph for this function:

def plistlib.DumbXMLWriter.writeln (   self,
  line 
) [inherited]

Definition at line 140 of file plistlib.py.

00140 
00141     def writeln(self, line):
00142         if line:
00143             # plist has fixed encoding of utf-8
00144             if isinstance(line, str):
00145                 line = line.encode('utf-8')
00146             self.file.write(self.indentLevel * self.indent)
00147             self.file.write(line)
00148         self.file.write(b'\n')
00149 
00150 
00151 # Contents should conform to a subset of ISO 8601
00152 # (in particular, YYYY '-' MM '-' DD 'T' HH ':' MM ':' SS 'Z'.  Smaller units may be omitted with
#  a loss of precision)

Here is the caller graph for this function:

def plistlib.PlistWriter.writeValue (   self,
  value 
)

Definition at line 203 of file plistlib.py.

00203 
00204     def writeValue(self, value):
00205         if isinstance(value, str):
00206             self.simpleElement("string", value)
00207         elif isinstance(value, bool):
00208             # must switch for bool before int, as bool is a
00209             # subclass of int...
00210             if value:
00211                 self.simpleElement("true")
00212             else:
00213                 self.simpleElement("false")
00214         elif isinstance(value, int):
00215             self.simpleElement("integer", "%d" % value)
00216         elif isinstance(value, float):
00217             self.simpleElement("real", repr(value))
00218         elif isinstance(value, dict):
00219             self.writeDict(value)
00220         elif isinstance(value, Data):
00221             self.writeData(value)
00222         elif isinstance(value, datetime.datetime):
00223             self.simpleElement("date", _dateToString(value))
00224         elif isinstance(value, (tuple, list)):
00225             self.writeArray(value)
00226         else:
00227             raise TypeError("unsupported type: %s" % type(value))

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 117 of file plistlib.py.

Definition at line 120 of file plistlib.py.

Definition at line 119 of file plistlib.py.

Definition at line 118 of file plistlib.py.


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