Skip to content

Commit 84f048f

Browse files
author
BoboTiG
committed
- Fix pylint: invalid attribute name
- Fix pylint: invalid argument name - Fix pylint: unused argument
1 parent 35b36c0 commit 84f048f

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

mss/linux.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
from __future__ import absolute_import
66

7+
import struct
78
import sys
89
from ctypes import (
910
POINTER, Structure, byref, c_char_p, c_int, c_int32, c_long, c_uint,
1011
c_uint32, c_ulong, c_ushort, c_void_p, cast, cdll, create_string_buffer)
1112
from ctypes.util import find_library
1213
from os import environ
1314
from os.path import abspath, dirname, isfile, realpath
14-
from struct import pack
1515

1616
from .helpers import MSS, ScreenshotError, arch
1717

@@ -245,13 +245,14 @@ def get_pixels_slow(self, ximage):
245245
'''
246246

247247
# @TODO: this part takes most of the time. Need a better solution.
248-
def pix(pixel, _resultats={}, _b=pack): # pylint: disable=W0102
248+
def pix(pixel, _resultats={}, pack=struct.pack): # pylint: disable=W0102
249249
''' Apply shifts to a pixel to get the RGB values.
250250
This method uses of memoization.
251251
'''
252252
if pixel not in _resultats:
253-
_resultats[pixel] = _b(b'<B', (pixel & rmask) >> 16) + \
254-
_b(b'<B', (pixel & gmask) >> 8) + _b(b'<B', pixel & bmask)
253+
_resultats[pixel] = pack(b'<B', (pixel & rmask) >> 16) + \
254+
pack(b'<B', (pixel & gmask) >> 8) + \
255+
pack(b'<B', pixel & bmask)
255256
return _resultats[pixel]
256257

257258
width = ximage.contents.width

mss/windows.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ def __init__(self):
4040
def _set_argtypes(self):
4141
''' Functions arguments. '''
4242

43-
self.MONITORENUMPROC = WINFUNCTYPE(INT, DWORD, DWORD, POINTER(RECT),
43+
self.monitorenumproc = WINFUNCTYPE(INT, DWORD, DWORD, POINTER(RECT),
4444
DOUBLE)
4545
windll.user32.GetSystemMetrics.argtypes = [INT]
4646
windll.user32.EnumDisplayMonitors.argtypes = [HDC, c_void_p,
47-
self.MONITORENUMPROC,
47+
self.monitorenumproc,
4848
LPARAM]
4949
windll.user32.GetWindowDC.argtypes = [HWND]
5050
windll.gdi32.CreateCompatibleDC.argtypes = [HDC]
@@ -91,10 +91,13 @@ def enum_display_monitors(self, screen=-1):
9191
}
9292
else:
9393

94-
def _callback(monitor, dc, rect, data):
95-
''' Callback for MONITORENUMPROC() function, it will return
94+
def _callback(monitor, data, rect, dc_):
95+
''' Callback for monitorenumproc() function, it will return
9696
a RECT with appropriate values.
9797
'''
98+
del monitor
99+
del data
100+
del dc_
98101
rct = rect.contents
99102
monitors.append({
100103
b'left': int(rct.left),
@@ -105,7 +108,7 @@ def _callback(monitor, dc, rect, data):
105108
return 1
106109

107110
monitors = []
108-
callback = self.MONITORENUMPROC(_callback)
111+
callback = self.monitorenumproc(_callback)
109112
windll.user32.EnumDisplayMonitors(0, 0, callback, 0)
110113
for mon in monitors:
111114
yield mon

0 commit comments

Comments
 (0)