Skip to content

Commit ddf751a

Browse files
author
BoboTiG
committed
Mac: corrections (flake8 and coala)
1 parent 916c5ad commit ddf751a

1 file changed

Lines changed: 23 additions & 25 deletions

File tree

mss/darwin.py

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,40 @@
66

77
# pylint: disable=import-error
88

9-
from sys import maxsize
109
from ctypes import (
11-
POINTER, Structure, c_double, byref, c_int32, c_long, c_uint32, c_float,
12-
c_uint8, c_bool, c_ubyte, c_void_p, cast, cdll)
10+
POINTER, Structure, byref, c_double, c_float, c_int32, c_ubyte, c_uint32,
11+
c_void_p, cast, cdll)
1312
from ctypes.util import find_library
13+
from sys import maxsize
1414

1515
from .base import MSSBase
1616
from .exception import ScreenshotError
1717

1818
__all__ = ['MSS']
1919

2020

21-
CGFloat = c_double if maxsize > 2 ** 32 else c_float
21+
def cgfloat():
22+
''' Get the appropriate value for a float. '''
23+
24+
return c_double if maxsize > 2 ** 32 else c_float
25+
26+
27+
def get_infinity(maxi=False):
28+
''' Get infinity "numbers". '''
29+
30+
return 1.7976931348623157e+308 if maxi else -8.988465674311579e+307
2231

2332

2433
class CGPoint(Structure):
2534
''' Structure that contains coordinates of a rectangle. '''
2635

27-
_fields_ = [('x', CGFloat), ('y', CGFloat)]
36+
_fields_ = [('x', cgfloat()), ('y', cgfloat())]
2837

2938

3039
class CGSize(Structure):
3140
''' Structure that contains dimensions of an rectangle. '''
3241

33-
_fields_ = [('width', CGFloat), ('height', CGFloat)]
42+
_fields_ = [('width', cgfloat()), ('height', cgfloat())]
3443

3544

3645
class CGRect(Structure):
@@ -46,7 +55,7 @@ class MSS(MSSBase):
4655

4756
max_displays = 32 # Could be augmented, if needed ...
4857

49-
def __init__(self, display=None):
58+
def __init__(self):
5059
''' MacOS X initialisations. '''
5160

5261
coregraphics = find_library('CoreGraphics')
@@ -97,17 +106,18 @@ def enum_display_monitors(self, force=False):
97106

98107
# All monitors
99108
self.monitors.append({
100-
b'left': int(get_infinity('min')),
101-
b'top': int(get_infinity('min')),
102-
b'width': int(get_infinity('max')),
103-
b'height': int(get_infinity('max'))
109+
b'left': int(get_infinity()),
110+
b'top': int(get_infinity()),
111+
b'width': int(get_infinity(True)),
112+
b'height': int(get_infinity(True))
104113
})
105114

106115
# Each monitors
107116
display_count = c_uint32(0)
108117
active_displays = (c_uint32 * self.max_displays)()
109-
self.core.CGGetActiveDisplayList(self.max_displays, active_displays,
110-
byref(display_count))
118+
self.core.CGGetActiveDisplayList(self.max_displays,
119+
active_displays,
120+
byref(display_count))
111121
rotations = {0.0: 'normal', 90.0: 'right', -90.0: 'left'}
112122
for idx in range(display_count.value):
113123
display = active_displays[idx]
@@ -156,15 +166,3 @@ def get_pixels(self, monitor):
156166
image_data[2::4], image_data[1::4], image_data[0::4]
157167
self.image = bytes(image)
158168
return self.image
159-
160-
161-
def get_infinity(what='all'):
162-
''' Get infinity "numbers". '''
163-
164-
min_ = -8.988465674311579e+307
165-
max_ = 1.7976931348623157e+308
166-
if what == 'min':
167-
return min_
168-
elif what == 'max':
169-
return max_
170-
return (min_, max_)

0 commit comments

Comments
 (0)