Package logilab :: Package common :: Module fileutils :: Class ProtectedFile
[show private | hide private]
[frames | no frames]

Type ProtectedFile

object --+    
         |    
      file --+
             |
            ProtectedFile


a special file-object class that automatically that automatically does a 'chmod +w' when needed

XXX: for now, the way it is done allows 'normal file-objects' to be created during the ProtectedFile object lifetime. One way to circumvent this would be to chmod / unchmod on each write operation.

One other way would be to :


Method Summary
  __init__(self, filepath, mode)
  __del__(self)
  close(self)
restore mode before closing
  _restore_mode(self)
restores the original mode if needed
    Inherited from file
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __iter__(x)
x.__iter__() <==> iter(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
integer "file descriptor" fileno()
This is needed for lower-level file interfaces, such os.read().
None flush()
flush() -> None.
true or false isatty()
isatty() -> true or false.
  next(x)
x.next() -> the next value, or raise StopIteration
read at most size bytes, returned as a string read(size)
If the size argument is negative or omitted, read until EOF is reached.
Undocumented readinto()
readinto() -> Undocumented.
next line from the file, as a string readline(size)
Retain newline.
list of strings, each a line from the file readlines(size)
Call readline() repeatedly and return a list of the lines so read.
None seek(offset, whence)
Argument offset is a byte count.
current file position, an integer (may be a long integer). tell()
tell() -> current file position, an integer (may be a long integer).
None truncate(size)
Size defaults to the current file position, as returned by tell().
None write(str)
Note that due to buffering, flush() or close() may be needed before the file on disk reflects the data written.
None writelines(sequence_of_strings)
Note that newlines are not added.
returns self xreadlines()
For backward compatibility.
    Inherited from object
  __hash__(x)
x.__hash__() <==> hash(x)
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __str__(x)
x.__str__() <==> str(x)

Class Variable Summary
    Inherited from file
getset_descriptor closed = <attribute 'closed' of 'file' objects>
member_descriptor encoding = <member 'encoding' of 'file' objects>
member_descriptor mode = <member 'mode' of 'file' objects>
member_descriptor name = <member 'name' of 'file' objects>
getset_descriptor newlines = <attribute 'newlines' of 'file' objects>
member_descriptor softspace = <member 'softspace' of 'file' objects>

Method Details

close(self)

restore mode before closing

Overrides:
__builtin__.file.close

_restore_mode(self)

restores the original mode if needed


Generated by Epydoc 2.1 on Thu Apr 14 11:37:32 2005 http://epydoc.sf.net