Skip to content

Commit 59f6a6b

Browse files
authored
Merge pull request #1386 from AndreMiras/feature/linter_fixes
Linter fixes E114, E127, E128, E129
2 parents 9724ebe + 839342f commit 59f6a6b

File tree

21 files changed

+223
-179
lines changed

21 files changed

+223
-179
lines changed

pythonforandroid/bdistapk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def _set_user_options():
136136
for i, arg in enumerate(sys.argv):
137137
if arg.startswith('--'):
138138
if ('=' in arg or
139-
(i < (len(sys.argv) - 1) and not sys.argv[i+1].startswith('-'))):
139+
(i < (len(sys.argv) - 1) and not sys.argv[i+1].startswith('-'))):
140140
user_options.append((arg[2:].split('=')[0] + '=', None, None))
141141
else:
142142
user_options.append((arg[2:], None, None))

pythonforandroid/bootstraps/pygame/build/build.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ def select(fn):
133133
fn = realpath(fn)
134134
assert(fn.startswith(d))
135135
fn = fn[len(d):]
136-
if (fn.startswith('/site-packages/') or
137-
fn.startswith('/config/') or
138-
fn.startswith('/lib-dynload/') or
139-
fn.startswith('/libpymodules.so')):
136+
if (fn.startswith('/site-packages/')
137+
or fn.startswith('/config/')
138+
or fn.startswith('/lib-dynload/')
139+
or fn.startswith('/libpymodules.so')):
140140
return False
141141
return fn
142142

pythonforandroid/bootstraps/pygame/build/buildlib/argparse.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,8 @@ def _split_lines(self, text, width):
651651

652652
def _fill_text(self, text, width, indent):
653653
text = self._whitespace_matcher.sub(' ', text).strip()
654-
return _textwrap.fill(text, width, initial_indent=indent,
655-
subsequent_indent=indent)
654+
return _textwrap.fill(
655+
text, width, initial_indent=indent, subsequent_indent=indent)
656656

657657
def _get_help_string(self, action):
658658
return action.help
@@ -2070,8 +2070,8 @@ def _parse_optional(self, arg_string):
20702070

20712071
# if multiple actions match, the option string was ambiguous
20722072
if len(option_tuples) > 1:
2073-
options = ', '.join([option_string
2074-
for action, option_string, explicit_arg in option_tuples])
2073+
options = ', '.join(
2074+
[option_string for action, option_string, explicit_arg in option_tuples])
20752075
tup = arg_string, options
20762076
self.error(_('ambiguous option: %s could match %s') % tup)
20772077

pythonforandroid/bootstraps/sdl2/build/build.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ def select(fn):
137137
fn = realpath(fn)
138138
assert(fn.startswith(d))
139139
fn = fn[len(d):]
140-
if (fn.startswith('/site-packages/') or
141-
fn.startswith('/config/') or
142-
fn.startswith('/lib-dynload/') or
143-
fn.startswith('/libpymodules.so')):
140+
if (fn.startswith('/site-packages/')
141+
or fn.startswith('/config/')
142+
or fn.startswith('/lib-dynload/')
143+
or fn.startswith('/libpymodules.so')):
144144
return False
145145
return fn
146146

pythonforandroid/bootstraps/service_only/build/build.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ def select(fn):
128128
fn = realpath(fn)
129129
assert(fn.startswith(d))
130130
fn = fn[len(d):]
131-
if (fn.startswith('/site-packages/') or
132-
fn.startswith('/config/') or
133-
fn.startswith('/lib-dynload/') or
134-
fn.startswith('/libpymodules.so')):
131+
if (fn.startswith('/site-packages/')
132+
or fn.startswith('/config/')
133+
or fn.startswith('/lib-dynload/')
134+
or fn.startswith('/libpymodules.so')):
135135
return False
136136
return fn
137137

pythonforandroid/bootstraps/webview/build/build.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ def select(fn):
129129
fn = realpath(fn)
130130
assert(fn.startswith(d))
131131
fn = fn[len(d):]
132-
if (fn.startswith('/site-packages/') or
133-
fn.startswith('/config/') or
134-
fn.startswith('/lib-dynload/') or
135-
fn.startswith('/libpymodules.so')):
132+
if (fn.startswith('/site-packages/')
133+
or fn.startswith('/config/')
134+
or fn.startswith('/lib-dynload/')
135+
or fn.startswith('/libpymodules.so')):
136136
return False
137137
return fn
138138

pythonforandroid/build.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,19 @@ class Context(object):
2323
will be instantiated and used to hold all the build state.'''
2424

2525
env = environ.copy()
26-
root_dir = None # the filepath of toolchain.py
27-
storage_dir = None # the root dir where builds and dists will be stored
28-
29-
build_dir = None # in which bootstraps are copied for building
30-
# and recipes are built
31-
dist_dir = None # the Android project folder where everything ends up
32-
libs_dir = None # where Android libs are cached after build but
33-
# before being placed in dists
26+
# the filepath of toolchain.py
27+
root_dir = None
28+
# the root dir where builds and dists will be stored
29+
storage_dir = None
30+
31+
# in which bootstraps are copied for building
32+
# and recipes are built
33+
build_dir = None
34+
# the Android project folder where everything ends up
35+
dist_dir = None
36+
# where Android libs are cached after build
37+
# but before being placed in dists
38+
libs_dir = None
3439
aars_dir = None
3540

3641
ccache = None # whether to use ccache
@@ -178,12 +183,14 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir,
178183
sdk_dir = None
179184
if user_sdk_dir:
180185
sdk_dir = user_sdk_dir
181-
if sdk_dir is None: # This is the old P4A-specific var
186+
# This is the old P4A-specific var
187+
if sdk_dir is None:
182188
sdk_dir = environ.get('ANDROIDSDK', None)
183-
if sdk_dir is None: # This seems used more conventionally
189+
# This seems used more conventionally
190+
if sdk_dir is None:
184191
sdk_dir = environ.get('ANDROID_HOME', None)
185-
if sdk_dir is None: # Checks in the buildozer SDK dir, useful
186-
# for debug tests of p4a
192+
# Checks in the buildozer SDK dir, useful for debug tests of p4a
193+
if sdk_dir is None:
187194
possible_dirs = glob.glob(expanduser(join(
188195
'~', '.buildozer', 'android', 'platform', 'android-sdk-*')))
189196
possible_dirs = [d for d in possible_dirs if not
@@ -842,8 +849,8 @@ def copylibs_function(soname, objs_paths, extra_link_dirs=[], env=None):
842849
if needso:
843850
lib = needso.group(1)
844851
if (lib not in needed_libs
845-
and lib not in found_libs
846-
and lib not in blacklist_libs):
852+
and lib not in found_libs
853+
and lib not in blacklist_libs):
847854
needed_libs.append(needso.group(1))
848855

849856
sofiles += found_sofiles

pythonforandroid/recipe.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def download(self):
367367
debug('* Expected md5sum: {}'.format(expected_md5))
368368
raise ValueError(
369369
('Generated md5sum does not match expected md5sum '
370-
'for {} recipe').format(self.name))
370+
'for {} recipe').format(self.name))
371371
else:
372372
info('{} download already cached, skipping'.format(self.name))
373373

@@ -410,10 +410,11 @@ def unpack(self, arch):
410410
try:
411411
sh.unzip(extraction_filename)
412412
except (sh.ErrorReturnCode_1, sh.ErrorReturnCode_2):
413-
pass # return code 1 means unzipping had
414-
# warnings but did complete,
415-
# apparently happens sometimes with
416-
# github zips
413+
# return code 1 means unzipping had
414+
# warnings but did complete,
415+
# apparently happens sometimes with
416+
# github zips
417+
pass
417418
import zipfile
418419
fileh = zipfile.ZipFile(extraction_filename, 'r')
419420
root_directory = fileh.filelist[0].filename.split('/')[0]
@@ -765,8 +766,8 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
765766
env['PYTHON_ROOT'] = self.ctx.get_python_install_dir()
766767
env['CFLAGS'] += ' -I' + env[
767768
'PYTHON_ROOT'] + '/include/python2.7'
768-
env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + \
769-
' -lpython2.7'
769+
env['LDFLAGS'] += (
770+
' -L' + env['PYTHON_ROOT'] + '/lib' + ' -lpython2.7')
770771
elif self.ctx.python_recipe.from_crystax:
771772
ndk_dir_python = join(self.ctx.ndk_dir, 'sources',
772773
'python', python_version)
@@ -783,9 +784,9 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
783784
env['CFLAGS'] += ' -I' + env[
784785
'PYTHON_ROOT'] + '/include/python{}m'.format(
785786
python_short_version)
786-
env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + \
787-
' -lpython{}m'.format(
788-
python_short_version)
787+
env['LDFLAGS'] += (
788+
' -L' + env['PYTHON_ROOT'] + '/lib' +
789+
' -lpython{}m'.format(python_short_version))
789790
hppath = []
790791
hppath.append(join(dirname(self.hostpython_location), 'Lib'))
791792
hppath.append(join(hppath[0], 'site-packages'))
@@ -920,12 +921,14 @@ def get_recipe_env(self, arch):
920921
arch_noeabi=arch.arch.replace('eabi', '')
921922
)
922923
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
923-
env['CFLAGS'] += " -I{ctx.ndk_dir}/platforms/android-{ctx.android_api}/arch-{arch_noeabi}/usr/include" \
924-
" -I{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/include" \
925-
" -I{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/libs/{arch.arch}/include".format(**keys)
924+
env['CFLAGS'] += (
925+
" -I{ctx.ndk_dir}/platforms/android-{ctx.android_api}/arch-{arch_noeabi}/usr/include" +
926+
" -I{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/include" +
927+
" -I{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/libs/{arch.arch}/include".format(**keys))
926928
env['CXXFLAGS'] = env['CFLAGS'] + ' -frtti -fexceptions'
927-
env['LDFLAGS'] += " -L{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/libs/{arch.arch}" \
928-
" -lgnustl_shared".format(**keys)
929+
env['LDFLAGS'] += (
930+
" -L{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/libs/{arch.arch}" +
931+
" -lgnustl_shared".format(**keys))
929932

930933
return env
931934

pythonforandroid/recipes/Pillow/__init__.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def get_recipe_env(self, arch=None):
2929

3030
ndk_dir = self.ctx.ndk_platform
3131
ndk_lib_dir = join(ndk_dir, 'usr', 'lib')
32-
ndk_include_dir = (join(self.ctx.ndk_dir, 'sysroot', 'usr', 'include')
32+
ndk_include_dir = (
33+
join(self.ctx.ndk_dir, 'sysroot', 'usr', 'include')
3334
if py_ver == '2.7' else join(ndk_dir, 'usr', 'include'))
3435

3536
png = self.get_recipe('png', self.ctx)
@@ -48,23 +49,24 @@ def get_recipe_env(self, arch=None):
4849
cflags += ' -I{} -L{}'.format(jpeg_jni_dir, jpeg_lib_dir)
4950
cflags += ' -I{} -L{}'.format(ndk_include_dir, ndk_lib_dir)
5051

51-
gcc_lib = (shprint(sh.gcc, '-print-libgcc-file-name')
52-
.stdout.decode('utf-8').split('\n')[0])
52+
gcc_lib = shprint(
53+
sh.gcc, '-print-libgcc-file-name').stdout.decode('utf-8').split('\n')[0]
5354
gcc_include = join(dirname(gcc_lib), 'include')
5455
cflags += ' -I{}'.format(gcc_include)
5556

5657
if self.ctx.ndk == 'crystax':
57-
py_inc_dir = join(self.ctx.ndk_dir, 'sources', 'python', py_ver,
58-
'include', 'python')
59-
py_lib_dir = join(self.ctx.ndk_dir, 'sources', 'python', py_ver,
60-
'libs', arch.arch)
58+
py_inc_dir = join(
59+
self.ctx.ndk_dir, 'sources', 'python', py_ver, 'include', 'python')
60+
py_lib_dir = join(
61+
self.ctx.ndk_dir, 'sources', 'python', py_ver, 'libs', arch.arch)
6162
cflags += ' -I{}'.format(py_inc_dir)
6263
env['LDFLAGS'] += ' -L{} -lpython{}m'.format(py_lib_dir, py_ver)
6364

6465
env['LDFLAGS'] += ' {} -L{}'.format(env['CFLAGS'], self.ctx.libs_dir)
6566
if cflags not in env['CFLAGS']:
6667
env['CFLAGS'] += cflags
67-
env['LDSHARED'] = '{} {}'.format(env['CC'],
68+
env['LDSHARED'] = '{} {}'.format(
69+
env['CC'],
6870
'-pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions')
6971
return env
7072

pythonforandroid/recipes/android/__init__.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,24 @@ def prebuild_arch(self, arch):
5555
'JNI_NAMESPACE': jni_ns,
5656
}
5757

58-
with current_directory(self.get_build_dir(arch.arch)):
59-
with open(join('android', 'config.pxi'), 'w') as fpxi:
60-
with open(join('android', 'config.h'), 'w') as fh:
61-
with open(join('android', 'config.py'), 'w') as fpy:
62-
for key, value in config.items():
63-
fpxi.write(tpxi.format(key, repr(value)))
64-
fpy.write(tpy.format(key, repr(value)))
65-
fh.write(th.format(key, value if isinstance(value, int)
66-
else '"{}"'.format(value)))
67-
self.config_env[key] = str(value)
68-
69-
if is_sdl2:
70-
fh.write('JNIEnv *SDL_AndroidGetJNIEnv(void);\n')
71-
fh.write('#define SDL_ANDROID_GetJNIEnv SDL_AndroidGetJNIEnv\n')
72-
elif is_pygame:
73-
fh.write('JNIEnv *SDL_ANDROID_GetJNIEnv(void);\n')
58+
with (
59+
current_directory(self.get_build_dir(arch.arch))), (
60+
open(join('android', 'config.pxi'), 'w')) as fpxi, (
61+
open(join('android', 'config.h'), 'w')) as fh, (
62+
open(join('android', 'config.py'), 'w')) as fpy:
63+
for key, value in config.items():
64+
fpxi.write(tpxi.format(key, repr(value)))
65+
fpy.write(tpy.format(key, repr(value)))
66+
fh.write(th.format(key,
67+
value if isinstance(value, int)
68+
else '"{}"'.format(value)))
69+
self.config_env[key] = str(value)
70+
71+
if is_sdl2:
72+
fh.write('JNIEnv *SDL_AndroidGetJNIEnv(void);\n')
73+
fh.write('#define SDL_ANDROID_GetJNIEnv SDL_AndroidGetJNIEnv\n')
74+
elif is_pygame:
75+
fh.write('JNIEnv *SDL_ANDROID_GetJNIEnv(void);\n')
7476

7577

7678
recipe = AndroidRecipe()

0 commit comments

Comments
 (0)