Skip to content

Commit

Permalink
Format with Black
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Jun 13, 2019
1 parent 5631718 commit 4712200
Show file tree
Hide file tree
Showing 14 changed files with 715 additions and 548 deletions.
53 changes: 29 additions & 24 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,26 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode',
'sphinx.ext.intersphinx']
extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode", "sphinx.ext.intersphinx"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The encoding of source files.
# source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = u'Pillow (PIL Fork)'
copyright = u'1995-2011 Fredrik Lundh, 2010-2019 Alex Clark and Contributors'
author = u'Fredrik Lundh, Alex Clark and Contributors'
project = u"Pillow (PIL Fork)"
copyright = u"1995-2011 Fredrik Lundh, 2010-2019 Alex Clark and Contributors"
author = u"Fredrik Lundh, Alex Clark and Contributors"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand All @@ -75,7 +74,7 @@

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
exclude_patterns = ["_build"]

# The reST default role (used for this markup: `text`) to use for all
# documents.
Expand All @@ -93,7 +92,7 @@
# show_authors = False

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
Expand Down Expand Up @@ -140,7 +139,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static', 'resources']
html_static_path = ["_static", "resources"]

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
Expand Down Expand Up @@ -203,20 +202,17 @@
# html_search_scorer = 'scorer.js'

# Output file base name for HTML help builder.
htmlhelp_basename = 'PillowPILForkdoc'
htmlhelp_basename = "PillowPILForkdoc"

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
# 'preamble': '',

# Latex figure (float) alignment
# 'figure_align': 'htbp',
}
Expand All @@ -225,8 +221,13 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'PillowPILFork.tex', u'Pillow (PIL Fork) Documentation',
u'Alex Clark', 'manual'),
(
master_doc,
"PillowPILFork.tex",
u"Pillow (PIL Fork) Documentation",
u"Alex Clark",
"manual",
)
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -255,8 +256,7 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'pillowpilfork', u'Pillow (PIL Fork) Documentation',
[author], 1)
(master_doc, "pillowpilfork", u"Pillow (PIL Fork) Documentation", [author], 1)
]

# If true, show URL addresses after external links.
Expand All @@ -269,10 +269,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'PillowPILFork', u'Pillow (PIL Fork) Documentation',
author, 'PillowPILFork',
'Pillow is the friendly PIL fork by Alex Clark and Contributors.',
'Miscellaneous'),
(
master_doc,
"PillowPILFork",
u"Pillow (PIL Fork) Documentation",
author,
"PillowPILFork",
"Pillow is the friendly PIL fork by Alex Clark and Contributors.",
"Miscellaneous",
)
]

# Documents to append as an appendix to all manuals.
Expand All @@ -289,4 +294,4 @@


def setup(app):
app.add_javascript('js/script.js')
app.add_javascript("js/script.js")
29 changes: 12 additions & 17 deletions docs/example/DdsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
DDS_ALPHA = DDPF_ALPHA
DDS_PAL8 = DDPF_PALETTEINDEXED8

DDS_HEADER_FLAGS_TEXTURE = (DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH |
DDSD_PIXELFORMAT)
DDS_HEADER_FLAGS_TEXTURE = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT
DDS_HEADER_FLAGS_MIPMAP = DDSD_MIPMAPCOUNT
DDS_HEADER_FLAGS_VOLUME = DDSD_DEPTH
DDS_HEADER_FLAGS_PITCH = DDSD_PITCH
Expand Down Expand Up @@ -94,9 +93,9 @@


def _decode565(bits):
a = ((bits >> 11) & 0x1f) << 3
b = ((bits >> 5) & 0x3f) << 2
c = (bits & 0x1f) << 3
a = ((bits >> 11) & 0x1F) << 3
b = ((bits >> 5) & 0x3F) << 2
c = (bits & 0x1F) << 3
return a, b, c


Expand Down Expand Up @@ -145,7 +144,7 @@ def _dxt1(data, width, height):
r, g, b = 0, 0, 0

idx = 4 * ((y + j) * width + x + i)
ret[idx:idx+4] = struct.pack('4B', r, g, b, 255)
ret[idx : idx + 4] = struct.pack("4B", r, g, b, 255)

return bytes(ret)

Expand All @@ -167,7 +166,7 @@ def _dxtc_alpha(a0, a1, ac0, ac1, ai):
elif ac == 6:
alpha = 0
elif ac == 7:
alpha = 0xff
alpha = 0xFF
else:
alpha = ((6 - ac) * a0 + (ac - 1) * a1) // 5

Expand All @@ -180,8 +179,7 @@ def _dxt5(data, width, height):

for y in range(0, height, 4):
for x in range(0, width, 4):
a0, a1, ac0, ac1, c0, c1, code = struct.unpack("<2BHI2HI",
data.read(16))
a0, a1, ac0, ac1, c0, c1, code = struct.unpack("<2BHI2HI", data.read(16))

r0, g0, b0 = _decode565(c0)
r1, g1, b1 = _decode565(c1)
Expand All @@ -202,7 +200,7 @@ def _dxt5(data, width, height):
r, g, b = _c3(r0, r1), _c3(g0, g1), _c3(b0, b1)

idx = 4 * ((y + j) * width + x + i)
ret[idx:idx+4] = struct.pack('4B', r, g, b, alpha)
ret[idx : idx + 4] = struct.pack("4B", r, g, b, alpha)

return bytes(ret)

Expand Down Expand Up @@ -230,8 +228,7 @@ def _open(self):
# pixel format
pfsize, pfflags = struct.unpack("<2I", header.read(8))
fourcc = header.read(4)
bitcount, rmask, gmask, bmask, amask = struct.unpack("<5I",
header.read(20))
bitcount, rmask, gmask, bmask, amask = struct.unpack("<5I", header.read(20))

if fourcc == b"DXT1":
self.decoder = "DXT1"
Expand All @@ -240,9 +237,7 @@ def _open(self):
else:
raise NotImplementedError("Unimplemented pixel format %r" % fourcc)

self.tile = [
(self.decoder, (0, 0) + self.size, 0, (self.mode, 0, 1))
]
self.tile = [(self.decoder, (0, 0) + self.size, 0, (self.mode, 0, 1))]

def load_seek(self, pos):
pass
Expand Down Expand Up @@ -270,8 +265,8 @@ def decode(self, buffer):
return 0, 0


Image.register_decoder('DXT1', DXT1Decoder)
Image.register_decoder('DXT5', DXT5Decoder)
Image.register_decoder("DXT1", DXT1Decoder)
Image.register_decoder("DXT5", DXT5Decoder)


def _validate(prefix):
Expand Down
34 changes: 21 additions & 13 deletions mp_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import sys

try:
MAX_PROCS = int(os.environ.get('MAX_CONCURRENCY', min(4, cpu_count())))
MAX_PROCS = int(os.environ.get("MAX_CONCURRENCY", min(4, cpu_count())))
except NotImplementedError:
MAX_PROCS = None

Expand All @@ -26,9 +26,17 @@ def _mp_compile_one(tp):
return


def _mp_compile(self, sources, output_dir=None, macros=None,
include_dirs=None, debug=0, extra_preargs=None,
extra_postargs=None, depends=None):
def _mp_compile(
self,
sources,
output_dir=None,
macros=None,
include_dirs=None,
debug=0,
extra_preargs=None,
extra_postargs=None,
depends=None,
):
"""Compile one or more source files.
see distutils.ccompiler.CCompiler.compile for comments.
Expand All @@ -37,16 +45,16 @@ def _mp_compile(self, sources, output_dir=None, macros=None,
# entirely or implement _compile().

macros, objects, extra_postargs, pp_opts, build = self._setup_compile(
output_dir, macros, include_dirs, sources, depends, extra_postargs)
output_dir, macros, include_dirs, sources, depends, extra_postargs
)
cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)

pool = Pool(MAX_PROCS)
try:
print("Building using %d processes" % pool._processes)
except Exception:
pass
arr = [(self, obj, build, cc_args, extra_postargs, pp_opts)
for obj in objects]
arr = [(self, obj, build, cc_args, extra_postargs, pp_opts) for obj in objects]
pool.map_async(_mp_compile_one, arr)
pool.close()
pool.join()
Expand All @@ -56,8 +64,8 @@ def _mp_compile(self, sources, output_dir=None, macros=None,

def install():

fl_win = sys.platform.startswith('win')
fl_cygwin = sys.platform.startswith('cygwin')
fl_win = sys.platform.startswith("win")
fl_cygwin = sys.platform.startswith("cygwin")

if fl_win or fl_cygwin:
# Windows barfs on multiprocessing installs
Expand All @@ -72,11 +80,11 @@ def install():
Pool(2)
CCompiler.compile = _mp_compile
except Exception as msg:
print("Exception installing mp_compile, proceeding without:"
"%s" % msg)
print("Exception installing mp_compile, proceeding without: %s" % msg)
else:
print("Single threaded build, not installing mp_compile:"
"%s processes" % MAX_PROCS)
print(
"Single threaded build, not installing mp_compile: %s processes" % MAX_PROCS
)


# We monkeypatch Python 2.7
Expand Down
11 changes: 6 additions & 5 deletions selftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ def testimage():

exit_status = 0

print("-"*68)
print("-" * 68)
print("Pillow", Image.__version__, "TEST SUMMARY ")
print("-"*68)
print("-" * 68)
print("Python modules loaded from", os.path.dirname(Image.__file__))
print("Binary modules loaded from", os.path.dirname(Image.core.__file__))
print("-"*68)
print("-" * 68)
for name, feature in [
("pil", "PIL CORE"),
("tkinter", "TKINTER"),
Expand All @@ -180,16 +180,17 @@ def testimage():
("jpg_2000", "OPENJPEG (JPEG2000)"),
("zlib", "ZLIB (PNG/ZIP)"),
("libtiff", "LIBTIFF"),
("raqm", "RAQM (Bidirectional Text)")
("raqm", "RAQM (Bidirectional Text)"),
]:
if features.check(name):
print("---", feature, "support ok")
else:
print("***", feature, "support not installed")
print("-"*68)
print("-" * 68)

# use doctest to make sure the test program behaves as documented!
import doctest

print("Running selftest:")
status = doctest.testmod(sys.modules[__name__])
if status[0]:
Expand Down
Loading

0 comments on commit 4712200

Please sign in to comment.