🗑️ Linter fixes and README.md update

Linter fixes:
- E123 closing bracket does not match indentation of opening bracket's line
- E125 continuation line with same indent as next logical line
- E231 missing whitespace after ','
- E265 block comment should start with '# '
- E302 expected 2 blank lines, found 1
- E305 expected 2 blank lines after class or function definition, found 1
- E731 do not assign a lambda expression, use a def
- F401 imported but unused
- F821 undefined name
- W605 invalid escape sequence

Also removes a Python 2 reference from the README.md
This commit is contained in:
Andre Miras 2020-05-19 00:10:21 +02:00
parent 4333b9c048
commit c0ccfda405
14 changed files with 35 additions and 68 deletions

View file

@ -77,7 +77,7 @@ jobs:
- uses: actions/checkout@v2
- name: Try Python 2 install
run: |
# we don't want to build to fail with the exit 1 so we catch with "||"
# we don't want the build to fail with the exit 1 so we catch with "||"
python2 -m pip install -e . 2> error.log || echo Failing as expected
cat error.log
grep "Unsupported Python version" error.log

View file

@ -18,10 +18,8 @@ project, and for iOS via the kivy-ios project. iOS and OSX are still under work.
For Android, buildozer will automatically download and prepare the
build dependencies. For more information, see
[Android-SDK-NDK-Information](https://github.com/kivy/kivy/wiki/Android-SDK-NDK-Information). We
recommend targeting Python 3 on Android, but you can target both
Python 3 and Python 2 regardless of which version you use with
buildozer on the desktop.
[Android-SDK-NDK-Information](https://github.com/kivy/kivy/wiki/Android-SDK-NDK-Information).
Note that only Python 3 is supported.
Note that this tool has nothing to do with the eponymous online build service
[buildozer.io](http://buildozer.io).

View file

@ -617,10 +617,6 @@ class Buildozer:
def file_extract(self, archive, cwd=None):
if archive.endswith('.tgz') or archive.endswith('.tar.gz'):
# XXX tarfile doesn't work for NDK-r8c :(
#tf = tarfile.open(archive, 'r:*')
#tf.extractall(path=cwd)
#tf.close()
self.cmd('tar xzf {0}'.format(archive), cwd=cwd)
return
@ -830,7 +826,6 @@ class Buildozer:
main_py = join(self.app_dir, 'service', 'main.py')
if not self.file_exists(main_py):
#self.error('Unable to patch main_py to add applibs directory.')
return
header = (b'import sys, os; '
@ -847,7 +842,7 @@ class Buildozer:
'''Return a "valid" name from a name with lot of invalid chars
(allowed characters: a-z, A-Z, 0-9, -, _)
'''
return re.sub('[^a-zA-Z0-9_\-]', '_', name)
return re.sub(r'[^a-zA-Z0-9_\-]', '_', name)
@property
def root_dir(self):
@ -1249,6 +1244,7 @@ def set_config_from_envs(config):
for token in config.options(section):
set_config_token_from_env(section, token, config)
def set_config_token_from_env(section, token, config):
'''Given a config section and token, checks for an appropriate
environment variable. If the variable exists, sets the config entry to

View file

@ -6,14 +6,13 @@ This was needed to correctly support db between Python 2 and 3.
__all__ = ["JsonStore"]
import io
import sys
from json import load, dump, dumps
from json import load, dump
from os.path import exists
class JsonStore:
def __init__(self, filename):
super().__init__()
self.filename = filename
self.data = {}
if exists(filename):

View file

@ -41,6 +41,7 @@ class Infinity:
def __neg__(self):
return NegativeInfinity
Infinity = Infinity()
@ -73,4 +74,5 @@ class NegativeInfinity:
def __neg__(self):
return Infinity
NegativeInfinity = NegativeInfinity()

View file

@ -162,6 +162,7 @@ def _legacy_cmpkey(version):
return epoch, parts
# Deliberately not anchored to the start and end of the string, to make it
# easier for 3rd party code to reuse
VERSION_PATTERN = r"""

View file

@ -19,5 +19,6 @@ def main():
Buildozer().error('%s' % error)
sys.exit(1)
if __name__ == '__main__':
main()

View file

@ -27,7 +27,6 @@ except ImportError:
from ConfigParser import SafeConfigParser
try:
import termios
import tty
has_termios = True
except ImportError:
has_termios = False
@ -131,7 +130,7 @@ class BuildozerRemote(Buildozer):
self.package_full_name)
self.debug('Remote build directory: {}'.format(self.remote_build_dir))
self._ssh_mkdir(self.remote_build_dir)
self._ssh_sync(__path__[0])
self._ssh_sync(__path__[0]) # noqa: F821 undefined name
def _sync_application_sources(self):
self.info('Synchronize application sources')
@ -200,9 +199,6 @@ class BuildozerRemote(Buildozer):
def _ssh_command(self, command):
self.debug('Execute remote command {}'.format(command))
#shell = self._ssh_client.invoke_shell()
#shell.sendall(command)
#shell.sendall('\nexit\n')
transport = self._ssh_client.get_transport()
channel = transport.open_session()
try:
@ -220,8 +216,6 @@ class BuildozerRemote(Buildozer):
def _posix_shell(self, chan):
oldtty = termios.tcgetattr(stdin)
try:
#tty.setraw(stdin.fileno())
#tty.setcbreak(stdin.fileno())
chan.settimeout(0.0)
while True:
@ -234,7 +228,6 @@ class BuildozerRemote(Buildozer):
break
stdout.write(x)
stdout.flush()
#print len(x), repr(x)
except socket.timeout:
pass
if stdin in r:
@ -274,6 +267,7 @@ class BuildozerRemote(Buildozer):
# user hit ^Z or F6
pass
def main():
try:
BuildozerRemote().run_command(sys.argv[1:])
@ -282,5 +276,6 @@ def main():
except BuildozerException as error:
Buildozer().error('%s' % error)
if __name__ == '__main__':
main()

View file

@ -2,6 +2,7 @@ from sys import exit
import os
from os.path import join
def no_config(f):
f.__no_config = True
return f
@ -9,7 +10,6 @@ def no_config(f):
class Target:
def __init__(self, buildozer):
super().__init__()
self.buildozer = buildozer
self.build_mode = 'debug'
self.platform_update = False

View file

@ -24,7 +24,6 @@ import os
import io
import re
import ast
import sh
from pipes import quote
from sys import platform, executable
from buildozer import BuildozerException, USE_COLOR
@ -740,7 +739,7 @@ class TargetAndroid(Target):
try:
with open(join(self.p4a_dir, "setup.py")) as fd:
setup = fd.read()
deps = re.findall("^\s*install_reqs = (\[[^\]]*\])", setup, re.DOTALL | re.MULTILINE)[0]
deps = re.findall(r"^\s*install_reqs = (\[[^\]]*\])", setup, re.DOTALL | re.MULTILINE)[0]
deps = ast.literal_eval(deps)
except IOError:
self.buildozer.error('Failed to read python-for-android setup.py at {}'.format(
@ -1360,6 +1359,7 @@ def get_target(buildozer):
buildozer.targetname = "android"
return TargetAndroid(buildozer)
def generate_dist_folder_name(base_dist_name, arch_names=None):
"""Generate the distribution folder name to use, based on a
combination of the input arguments.

View file

@ -59,6 +59,7 @@ li { padding: 1em; }
</html>
'''
class TargetIos(Target):
targetname = "ios"
@ -113,7 +114,7 @@ class TargetIos(Target):
# we need to extract the requirements that kivy-ios knows about
available_modules = self.get_available_packages()
onlyname = lambda x: x.split('==')[0]
onlyname = lambda x: x.split('==')[0] # noqa: E731 do not assign a lambda expression, use a def
ios_requirements = [x for x in app_requirements if onlyname(x) in
available_modules]
@ -401,5 +402,6 @@ class TargetIos(Target):
with open(password_file, 'wb') as fd:
fd.write(password.encode())
def get_target(buildozer):
return TargetIos(buildozer)

View file

@ -6,25 +6,10 @@ import sys
if sys.platform != 'darwin':
raise NotImplementedError('This will only work on osx')
#Global variables
#Global imports
import traceback
import os
import io
from pipes import quote
from sys import platform, executable
from buildozer import BuildozerException
from buildozer.target import Target
from os import environ
from os.path import (exists, join, realpath, expanduser,
basename, relpath, abspath, dirname)
from shutil import copyfile
from glob import glob
from os.path import exists, join, abspath, dirname
from subprocess import check_call, check_output
from buildozer.libs.version import parse
class TargetOSX(Target):
targetname = "osx"
@ -139,7 +124,6 @@ class TargetOSX(Target):
'--bundlename={}'.format(title),
'--bundleid={}'.format(domain),
'--bundleversion={}'.format(version),
#'--deps={}'.format(','.join(app_deps)),
'--displayname={}'.format(title)
]
if icon:

View file

@ -1,5 +1,4 @@
import os
import sys
import pytest
import codecs
import tempfile

12
tox.ini
View file

@ -21,22 +21,12 @@ commands = flake8 buildozer/ tests/
ignore =
E121, # continuation line under-indented for hanging indent
E122, # continuation line missing indentation or outdented
E123, # closing bracket does not match indentation of opening bracket's line
E125, # continuation line with same indent as next logical line
E126, # continuation line over-indented for hanging indent
E127, # continuation line over-indented for visual indent
E128, # continuation line under-indented for visual indent
E131, # continuation line unaligned for hanging indent
E231, # missing whitespace after ','
E265, # block comment should start with '# '
E302, # expected 2 blank lines, found 1
E305, # expected 2 blank lines after class or function definition, found 1
E402, # module level import not at top of file
E501, # line too long
E722, # do not use bare 'except'
E731, # do not assign a lambda expression, use a def
F401, # imported but unused
F821, # undefined name
W503, # line break before binary operator
W504, # line break after binary operator
W605 # invalid escape sequence
W504 # line break after binary operator