Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 51d0aa8

Browse files
committed
Big code clean-up using black
1 parent 7b67ec1 commit 51d0aa8

34 files changed

+542
-500
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ History:
44

55
3.3.0 2018/08/xx
66
- Linux: add an error handler for the XServer to prevent interpreter crash (fix #61)
7+
- big code clean-up using black
78

89
3.2.1 2018/05/21
910
- new contributor: Ryan Fox

docs/source/conf.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,34 @@
55
# Add any Sphinx extension module names here, as strings. They can be
66
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
77
# ones.
8-
extensions = [
9-
'sphinx.ext.intersphinx',
10-
]
8+
extensions = ["sphinx.ext.intersphinx"]
119

1210
# Add any paths that contain templates here, relative to this directory.
13-
templates_path = ['_templates']
11+
templates_path = ["_templates"]
1412

1513
# The suffix(es) of source filenames.
1614
# You can specify multiple suffix as a list of string:
1715
#
1816
# source_suffix = ['.rst', '.md']
19-
source_suffix = '.rst'
17+
source_suffix = ".rst"
2018

2119
# The master toctree document.
22-
master_doc = 'index'
20+
master_doc = "index"
2321

2422
# General information about the project.
25-
project = 'Python MSS'
23+
project = "Python MSS"
2624
copyright = "2013-2018, Mickaël 'Tiger-222' Schoentgen & contributors"
27-
author = 'Tiger-222'
25+
author = "Tiger-222"
2826

2927
# The version info for the project you're documenting, acts as replacement for
3028
# |version| and |release|, also used in various other places throughout the
3129
# built documents.
3230
#
3331
# The short X.Y version.
34-
version = '3.3.0'
32+
version = "3.3.0"
3533

3634
# The full version, including alpha/beta/rc tags.
37-
release = 'latest'
35+
release = "latest"
3836

3937
# The language for content autogenerated by Sphinx. Refer to documentation
4038
# for a list of supported languages.
@@ -49,7 +47,7 @@
4947
exclude_patterns = []
5048

5149
# The name of the Pygments (syntax highlighting) style to use.
52-
pygments_style = 'sphinx'
50+
pygments_style = "sphinx"
5351

5452
todo_include_todos = True
5553

@@ -58,10 +56,10 @@
5856

5957
# The theme to use for HTML and HTML Help pages. See the documentation for
6058
# a list of builtin themes.
61-
html_theme = 'default'
59+
html_theme = "default"
6260

6361
# Output file base name for HTML help builder.
64-
htmlhelp_basename = 'PythonMSSdoc'
62+
htmlhelp_basename = "PythonMSSdoc"
6563

6664

6765
# -- Options for Epub output ----------------------------------------------
@@ -73,10 +71,10 @@
7371
epub_copyright = copyright
7472

7573
# A list of files that should not be packed into the epub file.
76-
epub_exclude_files = ['search.html']
74+
epub_exclude_files = ["search.html"]
7775

7876

7977
# ----------------------------------------------
8078

8179
# Example configuration for intersphinx: refer to the Python standard library.
82-
intersphinx_mapping = {'https://docs.python.org/3/': None}
80+
intersphinx_mapping = {"https://docs.python.org/3/": None}

docs/source/examples/callback.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ def on_exists(fname):
1919
"""
2020

2121
if os.path.isfile(fname):
22-
newfile = fname + '.old'
23-
print('{0} -> {1}'.format(fname, newfile))
22+
newfile = fname + ".old"
23+
print("{0} -> {1}".format(fname, newfile))
2424
os.rename(fname, newfile)
2525

2626

2727
with mss.mss() as sct:
28-
filename = sct.shot(output='mon-{mon}.png', callback=on_exists)
28+
filename = sct.shot(output="mon-{mon}.png", callback=on_exists)
2929
print(filename)

docs/source/examples/fps.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def screen_record():
2525
# 800x600 windowed mode
2626
mon = (0, 40, 800, 640)
2727

28-
title = '[PIL.ImageGrab] FPS benchmark'
28+
title = "[PIL.ImageGrab] FPS benchmark"
2929
fps = 0
3030
last_time = time.time()
3131

@@ -34,7 +34,7 @@ def screen_record():
3434
fps += 1
3535

3636
cv2.imshow(title, cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
37-
if cv2.waitKey(25) & 0xFF == ord('q'):
37+
if cv2.waitKey(25) & 0xFF == ord("q"):
3838
cv2.destroyAllWindows()
3939
break
4040

@@ -43,9 +43,9 @@ def screen_record():
4343

4444
def screen_record_efficient():
4545
# 800x600 windowed mode
46-
mon = {'top': 40, 'left': 0, 'width': 800, 'height': 640}
46+
mon = {"top": 40, "left": 0, "width": 800, "height": 640}
4747

48-
title = '[MSS] FPS benchmark'
48+
title = "[MSS] FPS benchmark"
4949
fps = 0
5050
sct = mss.mss()
5151
last_time = time.time()
@@ -55,12 +55,12 @@ def screen_record_efficient():
5555
fps += 1
5656

5757
cv2.imshow(title, img)
58-
if cv2.waitKey(25) & 0xFF == ord('q'):
58+
if cv2.waitKey(25) & 0xFF == ord("q"):
5959
cv2.destroyAllWindows()
6060
break
6161

6262
return fps
6363

6464

65-
print('PIL:', screen_record())
66-
print('MSS:', screen_record_efficient())
65+
print("PIL:", screen_record())
66+
print("MSS:", screen_record_efficient())

docs/source/examples/from_pil_tuple.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
monitor = sct.monitors[1]
1616

1717
# Capture a bbox using percent values
18-
left = monitor['left'] + monitor['width'] * 5 // 100 # 5% from the left
19-
top = monitor['top'] + monitor['height'] * 5 // 100 # 5% from the top
18+
left = monitor["left"] + monitor["width"] * 5 // 100 # 5% from the left
19+
top = monitor["top"] + monitor["height"] * 5 // 100 # 5% from the top
2020
right = left + 400 # 400px width
2121
lower = top + 400 # 400px height
2222
bbox = (left, top, right, lower)
@@ -27,4 +27,4 @@
2727
im = sct.grab(bbox)
2828

2929
# Save it!
30-
mss.tools.to_png(im.rgb, im.size, output='screenshot.png')
30+
mss.tools.to_png(im.rgb, im.size, output="screenshot.png")

docs/source/examples/linux_display_keyword.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
from mss.linux import MSS
1010

1111

12-
with MSS(display=':0.0') as sct:
12+
with MSS(display=":0.0") as sct:
1313
for filename in sct.save():
1414
print(filename)

docs/source/examples/opencv_numpy.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@
1515

1616
with mss.mss() as sct:
1717
# Part of the screen to capture
18-
monitor = {'top': 40, 'left': 0, 'width': 800, 'height': 640}
18+
monitor = {"top": 40, "left": 0, "width": 800, "height": 640}
1919

20-
while 'Screen capturing':
20+
while "Screen capturing":
2121
last_time = time.time()
2222

2323
# Get raw pixels from the screen, save it to a Numpy array
2424
img = numpy.array(sct.grab(monitor))
2525

2626
# Display the picture
27-
cv2.imshow('OpenCV/Numpy normal', img)
27+
cv2.imshow("OpenCV/Numpy normal", img)
2828

2929
# Display the picture in grayscale
3030
# cv2.imshow('OpenCV/Numpy grayscale',
3131
# cv2.cvtColor(img, cv2.COLOR_BGRA2GRAY))
3232

33-
print('fps: {0}'.format(1 / (time.time() - last_time)))
33+
print("fps: {0}".format(1 / (time.time() - last_time)))
3434

3535
# Press "q" to quit
36-
if cv2.waitKey(25) & 0xFF == ord('q'):
36+
if cv2.waitKey(25) & 0xFF == ord("q"):
3737
cv2.destroyAllWindows()
3838
break

docs/source/examples/part_of_screen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
with mss.mss() as sct:
1414
# The screen part to capture
15-
monitor = {'top': 160, 'left': 160, 'width': 160, 'height': 135}
16-
output = 'sct-{top}x{left}_{width}x{height}.png'.format(**monitor)
15+
monitor = {"top": 160, "left": 160, "width": 160, "height": 135}
16+
output = "sct-{top}x{left}_{width}x{height}.png".format(**monitor)
1717

1818
# Grab the data
1919
sct_img = sct.grab(monitor)

docs/source/examples/part_of_screen_monitor_2.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717

1818
# The screen part to capture
1919
monitor = {
20-
'top': mon['top'] + 100, # 100px from the top
21-
'left': mon['left'] + 100, # 100px from the left
22-
'width': 160,
23-
'height': 135,
24-
'mon': monitor_number,
20+
"top": mon["top"] + 100, # 100px from the top
21+
"left": mon["left"] + 100, # 100px from the left
22+
"width": 160,
23+
"height": 135,
24+
"mon": monitor_number,
2525
}
26-
output = 'sct-mon{mon}_{top}x{left}_{width}x{height}.png'.format(**monitor)
26+
output = "sct-mon{mon}_{top}x{left}_{width}x{height}.png".format(**monitor)
2727

2828
# Grab the data
2929
sct_img = sct.grab(monitor)

docs/source/examples/pil.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
sct_img = sct.grab(monitor)
1818

1919
# Create the Image
20-
img = Image.frombytes('RGB', sct_img.size, sct_img.bgra, 'raw', 'BGRX')
20+
img = Image.frombytes("RGB", sct_img.size, sct_img.bgra, "raw", "BGRX")
2121
# The same, but less efficient:
2222
# img = Image.frombytes('RGB', sct_img.size, sct_img.rgb)
2323

2424
# And save it!
25-
output = 'monitor-{0}.png'.format(num)
25+
output = "monitor-{0}.png".format(num)
2626
img.save(output)
2727
print(output)

0 commit comments

Comments
 (0)