8000 Fixes linter E203 E231 E261 E302 E303 E305 W291 W293 W391 by AndreMiras · Pull Request #1286 · kivy/python-for-android · GitHub
[go: up one dir, main page]

Skip to content

Fixes linter E203 E231 E261 E302 E303 E305 W291 W293 W391 #1286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pythonforandroid/bdistapk.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def initialize_options(self):
for (option, (source, value)) in option_dict.items():
setattr(self, option, str(value))


def finalize_options(self):

setup_options = self.distribution.get_option_dict('apk')
Expand Down Expand Up @@ -133,7 +132,7 @@ def prepare_build_dir(self):
def _set_user_options():
# This seems like a silly way to do things, but not sure if there's a
# better way to pass arbitrary options onwards to p4a
user_options = [('requirements=', None, None),]
user_options = [('requirements=', None, None), ]
for i, arg in enumerate(sys.argv):
if arg.startswith('--'):
if ('=' in arg or
Expand All @@ -144,4 +143,5 @@ def _set_user_options():

BdistAPK.user_options = user_options

_set_user_options()

_set_user_options()
1 change: 1 addition & 0 deletions pythonforandroid/bootstraps/empty/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ def run_distribute(self):
print('empty bootstrap has no distribute')
exit(1)


bootstrap = EmptyBootstrap()
4 changes: 2 additions & 2 deletions pythonforandroid/bootstraps/pygame/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def run_distribute(self):
shprint(sh.mkdir, '-p', join('private', 'include', 'python2.7'))

shprint(sh.mv, join('libs', arch.arch, 'libpymodules.so'), 'private/')
shprint(sh.cp, join('python-install', 'include' , 'python2.7', 'pyconfig.h'), join('private', 'include', 'python2.7/'))
shprint(sh.cp, join('python-install', 'include', 'python2.7', 'pyconfig.h'), join('private', 'include', 'python2.7/'))

info('Removing some unwanted files')
shprint(sh.rm, '-f', join('private', 'lib', 'libpython2.7.so'))
Expand All @@ -91,8 +91,8 @@ def run_distribute(self):
shprint(sh.rm, '-rf', 'lib-dynload/_ctypes_test.so')
shprint(sh.rm, '-rf', 'lib-dynload/_testcapi.so')


self.strip_libraries(arch)
super(PygameBootstrap, self).run_distribute()


bootstrap = PygameBootstrap()
1 change: 1 addition & 0 deletions pythonforandroid/bootstraps/pygame/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ def make_package(args):
print('Did you install ant on your system ?')
sys.exit(-1)


def parse_args(args=None):
import argparse

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@
import sys as _sys
import textwrap as _textwrap


def _(s):
return s


try:
_set = set
except NameError:
Expand All @@ -123,6 +125,7 @@ def _sorted(iterable, reverse=False):
def _callable(obj):
return hasattr(obj, '__call__') or hasattr(obj, '__bases__')


# silence Python 2.6 buggy warnings about Exception.message
if _sys.version_info[:2] == (2, 6):
import warnings
Expand All @@ -145,6 +148,7 @@ def _callable(obj):
# Utility functions and classes
# =============================


class _AttributeHolder(object):
"""Abstract base class that provides __repr__.

Expand Down Expand Up @@ -1165,6 +1169,7 @@ def __repr__(self):
# Optional and Positional Parsing
# ===========================


class Namespace(_AttributeHolder):
"""Simple object for storing attributes.

Expand Down Expand Up @@ -1265,7 +1270,6 @@ def get_default(self, dest):
return action.default
return self._defaults.get(dest, None)


# =======================
# Adding argument actions
# =======================
Expand Down
6 changes: 2 additions & 4 deletions pythonforandroid/bootstraps/sdl2/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def make_package(args):
if args.intent_filters:
with open(args.intent_filters) as fd:
args.intent_filters = fd.read()

args.add_activity = args.add_activity or []

args.activity_launch_mode = args.activity_launch_mode or ''
Expand Down Expand Up @@ -355,7 +355,6 @@ def make_package(args):
key=LooseVersion)
build_tools_version = build_tools_versions[-1]


render(
'AndroidManifest.tmpl.xml',
'src/main/AndroidManifest.xml',
Expand All @@ -371,7 +370,6 @@ def make_package(args):
remove('AndroidManifest.xml')
shutil.copy(join('src', 'main', 'AndroidManifest.xml'),
'AndroidManifest.xml')


render(
'strings.tmpl.xml',
Expand Down Expand Up @@ -402,13 +400,13 @@ def make_package(args):
'custom_rules.xml',
args=args)


if args.sign:
render('build.properties', 'build.properties')
else:
if exists('build.properties'):
os.remove('build.properties')


def parse_args(args=None):
global BLACKLIST_PATTERNS, WHITELIST_PATTERNS, PYTHON
default_android_api = 12
Expand Down
1 change: 0 additions & 1 deletion pythonforandroid/bootstraps/service_only/__init__.py 10000
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ def run_distribute(self):
site_packages_dir = join(abspath(curdir),
site_packages_dir)


self.strip_libraries(arch)
self.fry_eggs(site_packages_dir)
super(ServiceOnlyBootstrap, self).run_distribute()
Expand Down
6 changes: 3 additions & 3 deletions pythonforandroid/bootstraps/service_only/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
environment = jinja2.Environment(loader=jinja2.FileSystemLoader(
join(curdir, 'templates')))


def render(template, dest, **kwargs):
'''Using jinja2, render `template` to the filename `dest`, supplying the

Expand Down Expand Up @@ -104,6 +105,7 @@ def listfiles(d):
for fn in listfiles(subdir):
yield fn


def make_python_zip():
'''
Search for all the python related files, and construct the pythonXX.zip
Expand All @@ -120,7 +122,6 @@ def make_python_zip():
global python_files
d = realpath(join('private', 'lib', 'python2.7'))


def select(fn):
if is_blacklist(fn):
return False
Expand All @@ -147,6 +148,7 @@ def select(fn):
zf.write(fn, afn)
zf.close()


def make_tar(tfn, source_dirs, ignore_path=[]):
'''
Make a zip file `fn` from the contents of source_dis.
Expand Down Expand Up @@ -242,7 +244,6 @@ def make_package(args):
# if args.dir:
# make_tar('assets/public.mp3', [args.dir], args.ignore_path)


# # Build.
# try:
# for arg in args.command:< 10000 /td>
Expand All @@ -252,7 +253,6 @@ def make_package(args):
# print 'Did you install ant on your system ?'
# sys.exit(-1)


# Prepare some variables for templating process

# default_icon = 'templates/kivy-icon.png'
Expand Down
5 changes: 3 additions & 2 deletions pythonforandroid/bootstraps/webview/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import glob
import sh


class WebViewBootstrap(Bootstrap):
name = 'webview'

Expand Down Expand Up @@ -59,7 +60,7 @@ def run_distribute(self):

if exists(join('libs', arch.arch, 'libpymodules.so')):
shprint(sh.mv, join('libs', arch.arch, 'libpymodules.so'), 'private/')
shprint(sh.cp, join('python-install', 'include' , 'python2.7', 'pyconfig.h'), join('private', 'include', 'python2.7/'))
shprint(sh.cp, join('python-install', 'include', 'python2.7', 'pyconfig.h'), join('private', 'include', 'python2.7/'))

info('Removing some unwanted files')
shprint(sh.rm, '-f', join('private', 'lib', 'libpython2.7.so'))
Expand Down Expand Up @@ -110,9 +111,9 @@ def run_distribute(self):
site_packages_dir = join(abspath(curdir),
site_packages_dir)


self.strip_libraries(arch)
self.fry_eggs(site_packages_dir)
super(WebViewBootstrap, self).run_distribute()


bootstrap = WebViewBootstrap()
8 changes: 4 additions & 4 deletions pythonforandroid/bootstraps/webview/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

# pyc/py
'*.pyc',
# '*.py',
# '*.py',

# temp files
'~',
Expand All @@ -54,6 +54,7 @@
environment = jinja2.Environment(loader=jinja2.FileSystemLoader(
join(curdir, 'templates')))


def render(template, dest, **kwargs):
'''Using jinja2, render `template` to the filename `dest`, supplying the

Expand Down Expand Up @@ -105,6 +106,7 @@ def listfiles(d):
for fn in listfiles(subdir):
yield fn


def make_python_zip():
'''
Search for all the python related files, and construct the pythonXX.zip
Expand All @@ -121,7 +123,6 @@ def make_python_zip():
global python_files
d = realpath(join('private', 'lib', 'python2.7'))


def select(fn):
if is_blacklist(fn):
return False
Expand All @@ -148,6 +149,7 @@ def select(fn):
zf.write(fn, afn)
zf.close()


def make_tar(tfn, source_dirs, ignore_path=[]):
'''
Make a zip file `fn` from the contents of source_dis.
Expand Down Expand Up @@ -244,7 +246,6 @@ def make_package(args):
# if args.dir:
# make_tar('assets/public.mp3', [args.dir], args.ignore_path)


# # Build.
# try:
# for arg in args.command:
Expand All @@ -254,7 +255,6 @@ def make_package(args):
# print 'Did you install ant on your system ?'
# sys.exit(-1)


# Prepare some variables for templating process

default_icon = 'templates/kivy-icon.png'
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Context(object):

recipe_build_order = None # Will hold the list of all built recipes

symlink_java_src = False # If True, will symlink instead of copying during build
symlink_java_src = False # If True, will symlink instead of copying during build

java_build_tool = 'auto'

Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __repr__(self):
return str(self)

@classmethod
def get_distribution(cls, ctx, name=None, recipes=[],
def get_distribution(cls, ctx, name=None, recipes=[],
force_build=False,
extra_dist_dirs=[],
require_perfect_match=False):
Expand Down
2 changes: 2 additions & 0 deletions pythonforandroid/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def format(self, record):
Err_Style.RESET_ALL) + record.msg
return super(LevelDifferentiatingFormatter, self).format(record)


logger = logging.getLogger('p4a')
if not hasattr(logger, 'touched'): # Necessary as importlib reloads
# this, which would add a second
Expand Down Expand Up @@ -71,6 +72,7 @@ def __getattr__(self, key):
def enable(self, enable):
self._enabled = enable


Out_Style = colorama_shim(Colo_Style)
Out_Fore = colorama_shim(Colo_Fore)
Err_Style = colorama_shim(Colo_Style)
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/patching.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def is_x(**kwargs):
return uname()[0] == platform
return is_x


is_linux = is_platform('Linux')
is_darwin = is_platform('Darwin')

Expand Down Expand Up @@ -68,4 +69,3 @@ def is_ndk(ndk):
def is_x(recipe, **kwargs):
return recipe.ctx.ndk == ndk
return is_x

9 changes: 3 additions & 6 deletions pythonforandroid/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,6 @@ def install_python_package(self, arch, name=None, env=None, is_dir=True):
with current_directory(self.get_build_dir(arch.arch)):
hostpython = sh.Command(self.hostpython_location)


if self.ctx.python_recipe.from_crystax:
hpenv = env.copy()
shprint(hostpython, 'setup.py', 'install', '-O2',
Expand Down Expand Up @@ -880,6 +879,7 @@ def rebuild_compiled_components(self, arch, env):
shprint(hostpython, 'setup.py', self.build_cmd, '-v', _env=env,
*self.setup_extra_args)


class CppCompiledComponentsPythonRecipe(CompiledComponentsPythonRecipe):
""" Extensions that require the cxx-stl """
call_hostpython_via_targetpython = False
Expand All @@ -902,22 +902,19 @@ def get_recipe_env(self, arch):
" -lpython2.7" \
" -lgnustl_shared".format(**keys)


return env

def build_compiled_components(self,arch):
def build_compiled_components(self, arch):
super(CppCompiledComponentsPythonRecipe, self).build_compiled_components(arch)

# Copy libgnustl_shared.so
with current_directory(self.get_build_dir(arch.arch)):
sh.cp(
"{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/libs/{arch.arch}/libgnustl_shared.so".format(ctx=self.ctx,arch=arch),
"{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/libs/{arch.arch}/libgnustl_shared.so".format(ctx=self.ctx, arch=arch),
self.ctx.get_libs_dir(arch.arch)
)




class CythonRecipe(PythonRecipe):
pre_build_ext = False
cythonize = True
Expand Down
3 changes: 2 additions & 1 deletion pythonforandroid/recipes/android/src/android/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'on_new_intent': [],
'on_activity_result': [] }


class NewIntentListener(PythonJavaClass):
__javainterfaces__ = [JNI_NAMESPACE + '/PythonActivity$NewIntentListener']
__javacontext__ = 'app'
Expand Down Expand Up @@ -46,6 +47,7 @@ def bind(**kwargs):
_activity.registerActivityResultListener(listener)
_callbacks[event].append(listener)


def unbind(**kwargs):
for event, callback in kwargs.items():
if event not in _callbacks:
Expand All @@ -58,4 +60,3 @@ def unbind(**kwargs):
_activity.unregisterNewIntentListener(listener)
elif event == 'on_activity_result':
_activity.unregisterActivityResultListener(listener)

1 change: 0 additions & 1 deletion pythonforandroid/recipes/android/src/android/billing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
===================

'''

Loading
0