lazy file

Implements a Lazy File class

Associated with a file which is regenerated afresh and never read from. This class doesn’t write the actual file till the file is closed even then it writes only if the new contents and the current contents are different.

class flash.flmake.lazy_file.LazyFile(filename)[source]

Defines a file like class which supports the following:

  • __init__ associates a real file with this class
  • write adds a line for writing to the file (but does not actually write)
  • close reads the real file, compares it with buffer contents if doesnot match rewrites the entire file, else silently returns.

NOTE: Useful only if you want to rewrite the entire file, small files (memory requirement)

Usage:

file = LazyFile("filename")
file.write(string1)
file.write(string2)
...
file.write(stringn)
file.close() --> if reqd this is the one which really does all the writing

Previous topic

help command

Next topic

library union

This Page