Statistics
| Revision:

gvsig-scripting / org.gvsig.scripting / trunk / org.gvsig.scripting / org.gvsig.scripting.app / org.gvsig.scripting.app.mainplugin / src / main / resources-plugin / scripting / lib / pylint / test / input / func_noerror_new_style_class_py_30.py @ 745

History | View | Annotate | Download (1.22 KB)

1
"""check builtin data descriptors such as mode and name attributes
2
on a file are correctly handled
3

4
bug notified by Pierre Rouleau on 2005-04-24
5
"""
6
from __future__ import print_function
7
__revision__ = None
8

    
9
class File(file):  # pylint: disable=file-builtin
10
    """ Testing new-style class inheritance from file"""
11

    
12
    #
13
    def __init__(self, name, mode="r", buffering=-1, verbose=False):
14
        """Constructor"""
15

    
16
        self.was_modified = False
17
        self.verbose = verbose
18
        super(File, self).__init__(name, mode, buffering)
19
        if self.verbose:
20
            print("File %s is opened.  The mode is: %s" % (self.name,
21
                                                           self.mode))
22

    
23
    #
24
    def write(self, a_string):
25
        """ Write a string to the file."""
26

    
27
        super(File, self).write(a_string)
28
        self.was_modified = True
29

    
30
    #
31
    def writelines(self, sequence):
32
        """ Write a sequence of strings to the file. """
33

    
34
        super(File, self).writelines(sequence)
35
        self.was_modified = True
36

    
37
    #
38
    def close(self):
39
        """Close the file."""
40

    
41
        if self.verbose:
42
            print("Closing file %s" % self.name)
43

    
44
        super(File, self).close()
45
        self.was_modified = False