Skip to content

Commit cf6697f

Browse files
author
BoboTiG
committed
Get rid of byte keys
1 parent c8cef38 commit cf6697f

File tree

4 files changed

+44
-44
lines changed

4 files changed

+44
-44
lines changed

mss/base.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,28 +120,28 @@ def to_png(self, data, output):
120120

121121
p__ = pack
122122
line = self.width * 3
123-
png_filter = p__(b'>B', 0)
123+
png_filter = p__('>B', 0)
124124
scanlines = b''.join(
125125
[png_filter + data[y * line:y * line + line]
126126
for y in range(self.height)])
127127

128-
magic = p__(b'>8B', 137, 80, 78, 71, 13, 10, 26, 10)
128+
magic = p__('>8B', 137, 80, 78, 71, 13, 10, 26, 10)
129129

130130
# Header: size, marker, data, CRC32
131131
ihdr = [b'', b'IHDR', b'', b'']
132-
ihdr[2] = p__(b'>2I5B', self.width, self.height, 8, 2, 0, 0, 0)
133-
ihdr[3] = p__(b'>I', crc32(b''.join(ihdr[1:3])) & 0xffffffff)
134-
ihdr[0] = p__(b'>I', len(ihdr[2]))
132+
ihdr[2] = p__('>2I5B', self.width, self.height, 8, 2, 0, 0, 0)
133+
ihdr[3] = p__('>I', crc32(b''.join(ihdr[1:3])) & 0xffffffff)
134+
ihdr[0] = p__('>I', len(ihdr[2]))
135135

136136
# Data: size, marker, data, CRC32
137137
idat = [b'', b'IDAT', compress(scanlines), b'']
138-
idat[3] = p__(b'>I', crc32(b''.join(idat[1:3])) & 0xffffffff)
139-
idat[0] = p__(b'>I', len(idat[2]))
138+
idat[3] = p__('>I', crc32(b''.join(idat[1:3])) & 0xffffffff)
139+
idat[0] = p__('>I', len(idat[2]))
140140

141141
# Footer: size, marker, None, CRC32
142142
iend = [b'', b'IEND', b'', b'']
143-
iend[3] = p__(b'>I', crc32(iend[1]) & 0xffffffff)
144-
iend[0] = p__(b'>I', len(iend[2]))
143+
iend[3] = p__('>I', crc32(iend[1]) & 0xffffffff)
144+
iend[0] = p__('>I', len(iend[2]))
145145

146146
with open(output, 'wb') as fileh:
147147
fileh.write(magic)

mss/darwin.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ def enum_display_monitors(self, force=False):
106106

107107
# All monitors
108108
self.monitors.append({
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))
109+
'left': int(get_infinity()),
110+
'top': int(get_infinity()),
111+
'width': int(get_infinity(True)),
112+
'height': int(get_infinity(True))
113113
})
114114

115115
# Each monitors
@@ -130,19 +130,19 @@ def enum_display_monitors(self, force=False):
130130
if rotations[rot] in ['left', 'right']:
131131
width, height = height, width
132132
self.monitors.append({
133-
b'left': int(left),
134-
b'top': int(top),
135-
b'width': int(width),
136-
b'height': int(height)
133+
'left': int(left),
134+
'top': int(top),
135+
'width': int(width),
136+
'height': int(height)
137137
})
138138

139139
return self.monitors
140140

141141
def get_pixels(self, monitor):
142142
''' Retrieve all pixels from a monitor. Pixels have to be RGB. '''
143143

144-
width, height = monitor[b'width'], monitor[b'height']
145-
left, top = monitor[b'left'], monitor[b'top']
144+
width, height = monitor['width'], monitor['height']
145+
left, top = monitor['left'], monitor['top']
146146
rect = CGRect((left, top), (width, height))
147147

148148
image_ref = self.core.CGWindowListCreateImage(rect, 1, 0, 0)

mss/linux.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,10 @@ def enum_display_monitors(self, force=False):
220220
gwa = XWindowAttributes()
221221
self.xlib.XGetWindowAttributes(self.display, self.root, byref(gwa))
222222
self.monitors.append({
223-
b'left': int(gwa.x),
224-
b'top': int(gwa.y),
225-
b'width': int(gwa.width),
226-
b'height': int(gwa.height)
223+
'left': int(gwa.x),
224+
'top': int(gwa.y),
225+
'width': int(gwa.width),
226+
'height': int(gwa.height)
227227
})
228228

229229
# Each monitors
@@ -235,10 +235,10 @@ def enum_display_monitors(self, force=False):
235235
crtc = self.xrandr.XRRGetCrtcInfo(self.display, mon,
236236
mon.contents.crtcs[num])
237237
self.monitors.append({
238-
b'left': int(crtc.contents.x),
239-
b'top': int(crtc.contents.y),
240-
b'width': int(crtc.contents.width),
241-
b'height': int(crtc.contents.height)
238+
'left': int(crtc.contents.x),
239+
'top': int(crtc.contents.y),
240+
'width': int(crtc.contents.width),
241+
'height': int(crtc.contents.height)
242242
})
243243
self.xrandr.XRRFreeCrtcInfo(crtc)
244244
self.xrandr.XRRFreeScreenResources(mon)
@@ -248,9 +248,9 @@ def enum_display_monitors(self, force=False):
248248
def get_pixels(self, monitor):
249249
''' Retrieve all pixels from a monitor. Pixels have to be RGB. '''
250250

251-
self.width = monitor[b'width']
252-
self.height = monitor[b'height']
253-
left, top = monitor[b'left'], monitor[b'top']
251+
self.width = monitor['width']
252+
self.height = monitor['height']
253+
left, top = monitor['left'], monitor['top']
254254
zpixmap = 2
255255
allplanes = self.xlib.XAllPlanes()
256256

@@ -289,9 +289,9 @@ def pix(pixel, _resultats={}, p__=pack):
289289
# pylint: disable=dangerous-default-value
290290

291291
if pixel not in _resultats:
292-
_resultats[pixel] = p__(b'<B', (pixel & rmask) >> 16) + \
293-
p__(b'<B', (pixel & gmask) >> 8) + \
294-
p__(b'<B', pixel & bmask)
292+
_resultats[pixel] = p__('<B', (pixel & rmask) >> 16) + \
293+
p__('<B', (pixel & gmask) >> 8) + \
294+
p__('<B', pixel & bmask)
295295
return _resultats[pixel]
296296

297297
self.width = ximage.contents.width

mss/windows.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ def enum_display_monitors(self, force=False):
6060
top = windll.user32.GetSystemMetrics(sm_yvirtualscreen)
6161
bottom = windll.user32.GetSystemMetrics(sm_cyvirtualscreen)
6262
self.monitors.append({
63-
b'left': int(left),
64-
b'top': int(top),
65-
b'width': int(right - left),
66-
b'height': int(bottom - top)
63+
'left': int(left),
64+
'top': int(top),
65+
'width': int(right - left),
66+
'height': int(bottom - top)
6767
})
6868

6969
# Each monitors
@@ -75,10 +75,10 @@ def _callback(monitor, data, rect, dc_):
7575
del monitor, data, dc_
7676
rct = rect.contents
7777
self.monitors.append({
78-
b'left': int(rct.left),
79-
b'top': int(rct.top),
80-
b'width': int(rct.right - rct.left),
81-
b'height': int(rct.bottom - rct.top)
78+
'left': int(rct.left),
79+
'top': int(rct.top),
80+
'width': int(rct.right - rct.left),
81+
'height': int(rct.bottom - rct.top)
8282
})
8383
return 1
8484

@@ -119,9 +119,9 @@ def get_pixels(self, monitor):
119119
Thanks to http://stackoverflow.com/a/3688682
120120
'''
121121

122-
self.width = monitor[b'width']
123-
self.height = monitor[b'height']
124-
left, top = monitor[b'left'], monitor[b'top']
122+
self.width = monitor['width']
123+
self.height = monitor['height']
124+
left, top = monitor['left'], monitor['top']
125125
srcdc = None
126126
memdc = None
127127
bmp = None

0 commit comments

Comments
 (0)