|
10 | 10 | Note: please keep this module compatible to Python 2.6. |
11 | 11 |
|
12 | 12 | Still needed: |
13 | | - * support for built-in JPEG format |
14 | 13 | * support for additional systems |
15 | 14 |
|
16 | 15 | Many thanks to all those who helped (in no particular order): |
|
29 | 28 |
|
30 | 29 | You can always get the latest version of this module at: |
31 | 30 |
|
32 | | - https://raw.github.com/BoboTiG/python-mss/mss.py |
| 31 | + https://raw.github.com/BoboTiG/python-mss/master/mss.py |
33 | 32 |
|
34 | 33 | If that URL should fail, try contacting the author. |
35 | 34 | ''' |
@@ -244,12 +243,12 @@ def save(self, output='mss', oneshot=False): |
244 | 243 | raise ValueError('MSS: no data to process.') |
245 | 244 |
|
246 | 245 | if hasattr(self, 'save_'): |
247 | | - img_out = self.save_(output=filename) |
| 246 | + img_out = self.save_(output=filename) |
248 | 247 | else: |
249 | 248 | img = MSSImage(pixels, monitor[b'width'], monitor[b'height']) |
250 | 249 | img_out = img.dump(filename) |
251 | 250 | self.debug('save', 'img_out', img_out) |
252 | | - if img_out is not None: |
| 251 | + if img_out: |
253 | 252 | yield img_out |
254 | 253 | else: |
255 | 254 | yield filename + ' (already exists)' |
@@ -342,15 +341,14 @@ def get_pixels(self, monitor): |
342 | 341 |
|
343 | 342 | width, height = monitor[b'width'], monitor[b'height'] |
344 | 343 | left, top = monitor[b'left'], monitor[b'top'] |
345 | | - |
346 | 344 | rect = CGRect((left, top), (width, height)) |
347 | 345 | self.image = CGWindowListCreateImage( |
348 | 346 | rect, kCGWindowListOptionOnScreenOnly, |
349 | 347 | kCGNullWindowID, kCGWindowImageDefault) |
350 | 348 | return 1 |
351 | 349 |
|
352 | 350 | def save_(self, output): |
353 | | - ''' Special method to not use MSSImage class. Speedy. ''' |
| 351 | + ''' Special method to not use MSSImage class. ''' |
354 | 352 |
|
355 | 353 | self.debug('save_') |
356 | 354 |
|
@@ -719,18 +717,17 @@ def __init__(self, data=None, width=1, height=1): |
719 | 717 | self.height = int(height) |
720 | 718 |
|
721 | 719 | def dump(self, output=None): |
722 | | - ''' Dump data to the image file using file format specified by ext. |
| 720 | + ''' Dump data to the image file. |
723 | 721 | Returns to created file name if success, else None. |
724 | 722 | ''' |
725 | 723 |
|
726 | 724 | if self.data is None: |
727 | 725 | raise ValueError('MSSImage: no data to process.') |
728 | 726 |
|
729 | 727 | contents = self.png() |
730 | | - if contents: |
731 | | - with open(output, 'wb') as fileh: |
732 | | - fileh.write(contents) |
733 | | - return output |
| 728 | + with open(output, 'wb') as fileh: |
| 729 | + fileh.write(contents) |
| 730 | + return output |
734 | 731 | return None |
735 | 732 |
|
736 | 733 | def png(self): |
|
0 commit comments