1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
class Camera(object):
'''Camera facade.
'''
def take_picture(self, filename, on_complete):
'''Ask the OS to capture a picture, and store it at filename.
When the capture is done, on_complete will be called with the filename
as an argument. If the callback returns True, the filename will be
unlinked.
:param filename: Name of the image file
:param on_complete: Callback that will be called when the operation is
done
:type filename: str
:type on_complete: callable
'''
self._take_picture(filename=filename, on_complete=on_complete)
def take_video(self, filename, on_complete):
'''Ask the OS to capture a video, and store it at filename.
When the capture is done, on_complete will be called with the filename
as an argument. If the callback returns True, the filename will be
unlinked.
:param filename: Name of the video file
:param on_complete: Callback that will be called when the operation is
done
:type filename: str
:type on_complete: callable
'''
self._take_video(filename=filename, on_complete=on_complete)
# private
def _take_picture(self, **kwargs):
raise NotImplementedError()
def _take_video(self, **kwargs):
raise NotImplementedError()
|