'Writes all the source code files for the given routines.
The generated source is returned as a list of (filename, contents)
tuples, or is written to files (see below).  Each filename consists
of the given prefix, appended with an appropriate extension.
Parameters
routines : list
A list of Routine instances to be written
prefix : string
The prefix for the output files
to_files : bool, optional
When True, the output is written to files.  Otherwise, a list
of (filename, contents) tuples is returned.  [default: False]
header : bool, optional
When True, a header comment is included on top of each source
file. [default: True]
empty : bool, optional
When True, empty lines are included to structure the source
files. [default: True]'

def write(self, routines, prefix, to_files=False, header=True, empty=True):

    if to_files:
        for dump_fn in self.dump_fns:
            filename = ('%s.%s' % (prefix, dump_fn.extension))
            with open(filename, 'w') as f:
                dump_fn(self, routines, f, prefix, header, empty)
    else:
        result = []
        for dump_fn in self.dump_fns:
            filename = ('%s.%s' % (prefix, dump_fn.extension))
            contents = StringIO()
            dump_fn(self, routines, contents, prefix, header, empty)
            result.append((filename, contents.getvalue()))
        return result
