1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 """
23 To provide connectivity with file.
24
25 Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
26 GNU General Public License.
27 """
28
29 from etl.connector import connector
30
32 """
33 This is an ETL connector that is used to provide connectivity with file.
34 """
35 - def __init__(self, uri, bufsize=-1, encoding='utf-8', name='file_connector'):
36 """
37 Required Parameters
38 uri : Path of file.
39
40 Extra Parameters
41 bufsize : Buffer size for reading data.
42 encoding : Encoding format.
43 name : Name of connector.
44 """
45 super(file_connector, self).__init__(name)
46 self._type = 'connector.file_connector'
47 self.bufsize = bufsize
48 self.encoding = encoding
49 self.uri = uri
50
51 - def open(self, mode='r'):
52 """
53 Opens file connections.
54 """
55 super(file_connector, self).open()
56 return file(self.uri, mode)
57
58
59 - def close(self, connector):
65
67 """
68 Overrides copy method.
69 """
70 res = file_connector(self.uri, self.bufsize, self.encoding, self.name)
71 return res
72
77
78 if __name__ == '__main__':
79 test()
80