8000 Fix flake8 warnings (#460) · libvips/pyvips@2437e4d · GitHub
[go: up one dir, main page]

Skip to content

Commit 2437e4d

Browse files
authored
Fix flake8 warnings (#460)
1 parent 3c92762 commit 2437e4d

File tree

5 files changed

+37
-56
lines changed

5 files changed

+37
-56
lines changed

examples/stream.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python3
22

33
import sys
4-
import gc
54
import requests
65
import pyvips
76

@@ -20,8 +19,7 @@
2019
source.on_read((lambda stream: stream.read)(stream))
2120

2221
tile = pyvips.Image.new_from_source(source, "", access="sequential")
23-
image = image.composite2(tile, "over", x= 50 * (i + 1), y= 50 * (i + 1))
22+
image = image.composite2(tile, "over", x=50 * (i + 1), y=50 * (i + 1))
2423

25-
print(f"writing output.jpg ...")
24+
print("writing output.jpg ...")
2625
image.write_to_file("output.jpg")
27-

examples/texput.log

Lines changed: 0 additions & 21 deletions
This file was deleted.

pyvips/__init__.py

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
gobject_lib = _libvips.lib
2727

2828
# now check that the binary wrapper is for the same version of libvips that
29-
# we find ourseleves linking to at runtime ... if it isn't, we must fall
29+
# we find ourseleves linking to at runtime ... if it isn't, we must fall
3030
# back to ABI mode
3131
lib_major = vips_lib.vips_version(0)
3232
lib_minor = vips_lib.vips_version(1)
3333
wrap_major = vips_lib.VIPS_MAJOR_VERSION
3434
wrap_minor = vips_lib.VIPS_MINOR_VERSION
35-
logger.debug('Module generated for libvips %s.%s' %
36-
(wrap_major, wrap_minor))
37-
logger.debug('Linked to libvips %s.%s' % (lib_major, lib_minor))
35+
logger.debug('Module generated for libvips %s.%s' %
36+
(wrap_major, wrap_minor))
37+
logger.debug('Linked to libvips %s.%s' % (lib_major, lib_minor))
3838

3939
if wrap_major != lib_major or wrap_minor != lib_minor:
4040
raise Exception('bad wrapper version')
@@ -109,16 +109,17 @@
109109

110110
ffi.cdef(cdefs(features))
111111

112+
112113
from .error import *
113114

114115
# redirect all vips warnings to logging
115116

116117
class GLogLevelFlags(object):
117-
# log flags
118+
# log flags
118119
FLAG_RECURSION = 1 << 0
119120
FLAG_FATAL = 1 << 1
120121

121-
# GLib log levels
122+
# GLib log levels
122123
LEVEL_ERROR = 1 << 2 # always fatal
123124
LEVEL_CRITICAL = 1 << 3
124125
LEVEL_WARNING = 1 << 4
@@ -127,14 +128,15 @@ class GLogLevelFlags(object):
127128
LEVEL_DEBUG = 1 << 7
128129

129130
LEVEL_TO_LOGGER = {
130-
LEVEL_DEBUG : 10,
131-
LEVEL_INFO : 20,
132-
LEVEL_MESSAGE : 20,
133-
LEVEL_WARNING : 30,
134-
LEVEL_ERROR : 40,
135-
LEVEL_CRITICAL : 50,
131+
LEVEL_DEBUG: 10,
132+
LEVEL_INFO: 20,
133+
LEVEL_MESSAGE: 20,
134+
LEVEL_WARNING: 30,
135+
LEVEL_ERROR: 40,
136+
LEVEL_CRITICAL: 50,
136137
}
137138

139+
138140
if API_mode:
139141
@ffi.def_extern()
140142
def _log_handler_callback(domain, level, message, user_data):
@@ -151,16 +153,16 @@ def _log_handler_callback(domain, level, message, user_data):
151153
# keep a ref to the cb to stop it being GCd
152154
_log_handler_cb = ffi.callback('GLogFunc', _log_handler_callback)
153155

154-
_log_handler_id = glib_lib.g_log_set_handler(_to_bytes('VIPS'),
155-
GLogLevelFlags.LEVEL_DEBUG |
156-
GLogLevelFlags.LEVEL_INFO |
157-
GLogLevelFlags.LEVEL_MESSAGE |
158-
GLogLevelFlags.LEVEL_WARNING |
159-
GLogLevelFlags.LEVEL_CRITICAL |
160-
GLogLevelFlags.LEVEL_ERROR |
161-
GLogLevelFlags.FLAG_FATAL |
162-
GLogLevelFlags.FLAG_RECURSION,
163-
_log_handler_cb, ffi.NULL)
156+
_log_handler_id = glib_lib.g_log_set_handler(_to_bytes('VIPS'),
157+
GLogLevelFlags.LEVEL_DEBUG |
158+
GLogLevelFlags.LEVEL_INFO |
159+
GLogLevelFlags.LEVEL_MESSAGE |
160+
GLogLevelFlags.LEVEL_WARNING |
161+
GLogLevelFlags.LEVEL_CRITICAL |
162+
GLogLevelFlags.LEVEL_ERROR |
163+
GLogLevelFlags.FLAG_FATAL |
164+
GLogLevelFlags.FLAG_RECURSION,
165+
_log_handler_cb, ffi.NULL)
164166

165167
# ffi doesn't like us looking up methods during shutdown: make a note of the
166168
# remove handler here
@@ -176,6 +178,7 @@ def _remove_log_handler():
176178
_remove_handler(_to_bytes('VIPS'), _log_handler_id)
177179
_log_handler_id = None
178180

181+
179182
atexit.register(_remove_log_handler)
180183

181184
from .enums import *

pyvips/base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ def enum_dict(gtype):
134134
g_enum_class = ffi.cast('GEnumClass *', g_type_class)
135135

136136
# -1 since we always have a "last" member.
137-
return {_to_string(g_enum_class.values[i].value_nick):
138-
g_enum_class.values[i].value
137+
return {_to_string(g_enum_class.values[i].value_nick):
138+
g_enum_class.values[i].value
139139
for i in range(g_enum_class.n_values - 1)}
140140

141141

@@ -145,8 +145,8 @@ def flags_dict(gtype):
145145
g_type_class = gobject_lib.g_type_class_ref(gtype)
146146
g_flags_class = ffi.cast('GFlagsClass *', g_type_class)
147147

148-
return {_to_string(g_flags_class.values[i].value_nick):
149-
g_flags_class.values[i].value
148+
return {_to_string(g_flags_class.values[i].value_nick):
149+
g_flags_class.values[i].value
150150
for i in range(g_flags_class.n_values)}
151151

152152

pyvips/pyvips_build.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from cffi import FFI
55

66
# we must have the vips package to be able to do anything
7-
if not pkgconfig.exists('vips'):
7+
if not pkgconfig.exists('vips'):
88
raise Exception('unable to find pkg-config package "vips"')
99
if pkgconfig.installed('vips', '< 8.2'):
1010
raise Exception('pkg-config "vips" is too old -- need libvips 8.2 or later')
@@ -14,7 +14,7 @@
1414
ffibuilder.set_source("_libvips",
1515
r"""
1616
#include <vips/vips.h>
17-
""",
17+
""",
1818
**pkgconfig.parse('vips'))
1919

2020
# pkgconfig 1.5+ has modversion ... otherwise, use a small shim
@@ -38,12 +38,13 @@ def modversion(package):
3838
'api': True,
3939
}
4040

41+
4142
import vdecls
4243

4344
# handy for debugging
44-
#with open('vips-source.txt','w') as f:
45-
# c = vdecls.cdefs(features)
46 5D01 -
# f.write(c)
45+
# with open('vips-source.txt','w') as f:
46+
# c = vdecls.cdefs(features)
47+
# f.write(c)
4748

4849
ffibuilder.cdef(vdecls.cdefs(features))
4950

0 commit comments

Comments
 (0)
0