Debian Codegraph @

plyer/platforms/ios/camera.py

raw symbols SCIP
1 from os import remove
2 from plyer.facades import Camera
3
4 from plyer.utils import reify
5
6
7 class iOSCamera(Camera):
8
9 @reify
10 def photos(self):
11 # pyPhotoLibrary is a ios recipe/module that
12 # interacts with the gallery and the camera on ios.
13 from photolibrary import PhotosLibrary
14 return PhotosLibrary()
15
16 def _take_picture(self, on_complete, filename=None):
17 assert on_complete is not None
18 self.on_complete = on_complete
19 self.filename = filename
20 photos = self.photos
21
22 if not photos.isCameraAvailable():
23 # no camera hardware
24 return False
25
26 photos.bind(on_image_captured=self.capture_callback)
27 self._capture_filename = filename
28 photos.capture_image(filename)
29 return True
30
31 def capture_callback(self, photolibrary):
32 # Image was chosen
33
34 # unbind
35 self.photos.unbind(on_image_captured=self.capture_callback)
36
37 if self.on_complete(self.filename):
38 self._remove(self.filename)
39
40 def _take_video(self, on_complete, filename=None):
41 assert on_complete is not None
42 raise NotImplementedError
43
44 def _remove(self, fn):
45 try:
46 remove(fn)
47 except OSError:
48 print('Could not remove photo!')
49
50
51 def instance():
52 return iOSCamera()