Module shipyard :: Class Writer
[hide private]
[frames] | no frames]

Class Writer

source code

object --+
         |
        Writer

Writer for Shipyard files

Instance Methods [hide private]
 
__init__(self, keys=None, comment='#', continuation=' ', coding=None, ignore_values=None)
Constructor
source code
 
write(self, output, record)
Write a record
source code
 
write_many(self, output, records)
Write a list record
source code
 
write_comment(self, output, comment)
Write a comment
source code
 
write_coding(self, output, template='-*- coding: %s -*-\n\n')
Write a coding line for the coding given in __init__().
source code
 
write_full(self, output, records)
Writes a list of records.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, keys=None, comment='#', continuation=' ', coding=None, ignore_values=None)
(Constructor)

source code 
Constructor
Parameters:
  • keys (list of strings) - list of keys this writer accepts
  • comment (string) - mark that starts a comment line
  • continuation (string) - mark that starts a continuation line
  • coding (string) - character encoding to use
  • ignore_values (set or None) - fields containing this values aren't written
Overrides: object.__init__

write(self, output, record)

source code 

Write a record

If in __init__() keys is given only those values are written

Parameters:
  • output (needs a method write that takes a string parameter) - output to write to
  • record (dict) - record to write

write_many(self, output, records)

source code 

Write a list record

If in __init__() keys is given only those values are written

Parameters:
  • output (needs a method write that takes a string parameter) - output to write to
  • records (list of dicts) - records to write

write_comment(self, output, comment)

source code 

Write a comment

If in __init__() keys is given only those values are written

Parameters:
  • output (needs a method write that takes a string parameter) - output to write to
  • comment (string) - comment to write

write_coding(self, output, template='-*- coding: %s -*-\n\n')

source code 
Write a coding line for the coding given in __init__(). Does nothing if no coding is given.
Parameters:
  • output (needs a method write that takes a string parameter) - output to write to
  • template (string) - template string for the coding line. A comment mark is prepended

write_full(self, output, records)

source code 
Writes a list of records. An outpout file is created if output is a string. A coding line is writen if self.coding is not None.
Parameters:
  • output (string or file-like) - outpout to write to. If it is an instance of basestring it's taken as a file name, otherwise its write() methode is used
  • records (list of dicts) - records to write