Skip to content

Commit 43d4c19

Browse files
committed
Pep8 fixes
1 parent 69f0fc2 commit 43d4c19

File tree

1 file changed

+99
-43
lines changed

1 file changed

+99
-43
lines changed

src/build.py

Lines changed: 99 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@
6060

6161

6262
def render(template, dest, **kwargs):
63-
'''
64-
Using jinja2, render `template` to the filename `dest`, supplying the keyword
65-
arguments as template parameters.
63+
'''Using jinja2, render `template` to the filename `dest`, supplying the
64+
65+
keyword arguments as template parameters.
6666
'''
6767

6868
template = environment.get_template(template)
@@ -87,7 +87,7 @@ def is_whitelist(name):
8787

8888
def is_blacklist(name):
8989
if is_whitelist(name):
90-
return False
90+
return False
9191
return match_filename(BLACKLIST_PATTERNS, name)
9292

9393
def match_filename(pattern_list, name):
@@ -174,7 +174,8 @@ def select(fn):
174174
for sd in source_dirs:
175175
sd = realpath(sd)
176176
compile_dir(sd)
177-
files += [(x, relpath(realpath(x), sd)) for x in listfiles(sd) if select(x)]
177+
files += [(x, relpath(realpath(x), sd)) for x in listfiles(sd)
178+
if select(x)]
178179

179180
# create tar.gz of thoses files
180181
tf = tarfile.open(tfn, 'w:gz')
@@ -220,9 +221,11 @@ def make_package(args):
220221
if args.icon_name:
221222
args.icon_name = args.icon_name.decode('utf-8')
222223

223-
versioned_name = args.name.replace(' ', '').replace('\'', '') + '-' + args.version
224+
versioned_name = (args.name.replace(' ', '').replace('\'', '') +
225+
'-' + args.version)
224226

225-
# Android SDK rev14 needs two ant execs (ex: debug installd) and new build.xml
227+
# Android SDK rev14 needs two ant execs (ex: debug installd) and
228+
# new build.xml
226229
build_tpl = 'build.xml'
227230

228231
if not args.icon_name:
@@ -257,7 +260,8 @@ def make_package(args):
257260
if args.ouya_category:
258261
args.ouya_category = args.ouya_category.upper()
259262
if args.ouya_category not in ('GAME', 'APP'):
260-
print 'Invalid --ouya-category argument. should be one of GAME or APP'
263+
print('Invalid --ouya-category argument. should be one of'
264+
'GAME or APP')
261265
sys.exit(-1)
262266

263267
# Get target android API
@@ -324,13 +328,15 @@ def make_package(args):
324328

325329
# Copy over the icon and presplash files.
326330
shutil.copy(args.icon or default_icon, 'res/drawable/icon.png')
327-
shutil.copy(args.presplash or default_presplash, 'res/drawable/presplash.jpg')
331+
shutil.copy(args.presplash or default_presplash,
332+
'res/drawable/presplash.jpg')
328333

329334
# If OUYA support was requested, copy over the OUYA icon
330335
if args.ouya_category:
331336
if not os.path.isdir('res/drawable-xhdpi'):
332337
os.mkdir('res/drawable-xhdpi')
333-
shutil.copy(args.ouya_icon or default_ouya_icon, 'res/drawable-xhdpi/ouya_icon.png')
338+
shutil.copy(args.ouya_icon or default_ouya_icon,
339+
'res/drawable-xhdpi/ouya_icon.png')
334340

335341
# If extra Java jars were requested, copy them into the libs directory
336342
if args.add_jar:
@@ -359,41 +365,90 @@ def make_package(args):
359365
tools directory of the Android SDK.
360366
''')
361367

362-
ap.add_argument('--package', dest='package', help='The name of the java package the project will be packaged under.', required=True)
363-
ap.add_argument('--name', dest='name', help='The human-readable name of the project.', required=True)
364-
ap.add_argument('--version', dest='version', help='The version number of the project. This should consist of numbers and dots, and should have the same number of groups of numbers as previous versions.', required=True)
365-
ap.add_argument('--numeric-version', dest='numeric_version', help='The numeric version number of the project. If not given, this is automatically computed from the version.')
366-
ap.add_argument('--dir', dest='dir', help='The directory containing public files for the project.')
367-
ap.add_argument('--private', dest='private', help='The directory containing additional private files for the project.')
368+
ap.add_argument('--package', dest='package',
369+
help=('The name of the java package the project will be'
370+
' packaged under.'),
371+
required=True)
372+
ap.add_argument('--name', dest='name',
373+
help=('The human-readable name of the project.'),
374+
required=True)
375+
ap.add_argument('--version', dest='version',
376+
help=('The version number of the project. This should '
377+
'consist of numbers and dots, and should have the '
378+
'same number of groups of numbers as previous '
379+
'versions.'),
380+
required=True)
381+
ap.add_argument('--numeric-version', dest='numeric_version',
382+
help=('The numeric version number of the project. If not '
383+
'given, this is automatically computed from the '
384+
'version.'))
385+
ap.add_argument('--dir', dest='dir',
386+
help=('The directory containing public files for the '
387+
'project.'))
388+
ap.add_argument('--private', dest='private',
389+
help=('The directory containing additional private files '
390+
'for the project.'))
368391
ap.add_argument('--launcher', dest='launcher', action='store_true',
369-
help='Provide this argument to build a multi-app launcher, rather than a single app.')
370-
ap.add_argument('--icon-name', dest='icon_name', help='The name of the project\'s launcher icon.')
392+
help=('Provide this argument to build a multi-app '
393+
'launcher, rather than a single app.'))
394+
ap.add_argument('--icon-name', dest='icon_name',
395+
help='The name of the project\'s launcher icon.')
371396
ap.add_argument('--orientation', dest='orientation', default='landscape',
372-
help='The orientation that the game will display in. Usually one of "landscape", "portrait" or "sensor"')
373-
ap.add_argument('--permission', dest='permissions', action='append', help='The permissions to give this app.')
374-
ap.add_argument('--ignore-path', dest='ignore_path', action='append', help='Ignore path when building the app')
375-
ap.add_argument('--icon', dest='icon', help='A png file to use as the icon for the application.')
376-
ap.add_argument('--presplash', dest='presplash', help='A jpeg file to use as a screen while the application is loading.')
377-
ap.add_argument('--ouya-category', dest='ouya_category', help='Valid values are GAME and APP. This must be specified to enable OUYA console support.')
378-
ap.add_argument('--ouya-icon', dest='ouya_icon', help='A png file to use as the icon for the application if it is installed on an OUYA console.')
379-
ap.add_argument('--install-location', dest='install_location', default='auto', help='The default install location. Should be "auto", "preferExternal" or "internalOnly".')
380-
ap.add_argument('--compile-pyo', dest='compile_pyo', action='store_true', help='Compile all .py files to .pyo, and only distribute the compiled bytecode.')
381-
ap.add_argument('--intent-filters', dest='intent_filters', help='Add intent-filters xml rules to the AndroidManifest.xml file. The argument is a filename containing xml. The filename should be located relative to the python-for-android directory')
382-
ap.add_argument('--with-billing', dest='billing_pubkey', help='If set, the billing service will be added')
397+
help=('The orientation that the game will display in. '
398+
'Usually one of "landscape", "portrait" or "sensor"'))
399+
ap.add_argument('--permission', dest='permissions', action='append',
400+
help='The permissions to give this app.')
401+
ap.add_argument('--ignore-path', dest='ignore_path', action='append',
402+
help='Ignore path when building the app')
403+
ap.add_argument('--icon', dest='icon',
404+
help='A png file to use as the icon for the application.')
405+
ap.add_argument('--presplash', dest='presplash',
406+
help=('A jpeg file to use as a screen while the '
407+
'application is loading.'))
408+
ap.add_argument('--ouya-category', dest='ouya_category',
409+
help=('Valid values are GAME and APP. This must be '
410+
'specified to enable OUYA console support.'))
411+
ap.add_argument('--ouya-icon', dest='ouya_icon',
412+
help=('A png file to use as the icon for the application '
413+
'if it is installed on an OUYA console.'))
414+
ap.add_argument('--install-location', dest='install_location',
415+
default='auto',
416+
help=('The default install location. Should be "auto", '
417+
'"preferExternal" or "internalOnly".'))
418+
ap.add_argument('--compile-pyo', dest='compile_pyo', action='store_true',
419+
help=('Compile all .py files to .pyo, and only distribute '
420+
'the compiled bytecode.'))
421+
ap.add_argument('--intent-filters', dest='intent_filters',
422+
help=('Add intent-filters xml rules to the '
423+
'AndroidManifest.xml file. The argument is a '
424+
'filename containing xml. The filename should be '
425+
'located relative to the python-for-android '
426+
'directory'))
427+
ap.add_argument('--with-billing', dest='billing_pubkey',
428+
help='If set, the billing service will be added')
383429
ap.add_argument('--blacklist', dest='blacklist',
384-
default=join(curdir, 'blacklist.txt'),
385-
help='Use a blacklist file to match unwanted file in the final APK')
430+
default=join(curdir, 'blacklist.txt'),
431+
help=('Use a blacklist file to match unwanted file in '
432+
'the final APK'))
386433
ap.add_argument('--whitelist', dest='whitelist',
387-
default=join(curdir, 'whitelist.txt'),
388-
help='Use a whitelist file to prevent blacklisting of file in the final APK')
389-
ap.add_argument('--sdk', dest='sdk_version', default='8', help='Android SDK version to use. Default to 8')
390-
ap.add_argument('--minsdk', dest='min_sdk_version', default='8', help='Minimum Android SDK version to use. Default to 8')
434+
default=join(curdir, 'whitelist.txt'),
435+
help=('Use a whitelist file to prevent blacklisting of '
436+
'file in the final APK'))
437+
ap.add_argument('--sdk', dest='sdk_version', default='8',
438+
help='Android SDK version to use. Default to 8')
439+
ap.add_argument('--minsdk', dest='min_sdk_version', default='8',
440+
help='Minimum Android SDK version to use. Default to 8')
391441
ap.add_argument('--window', dest='window', action='store_true',
392442
help='Indicate if the application will be windowed')
393443
ap.add_argument('--wakelock', dest='wakelock', action='store_true',
394444
help='Indicate if the application needs the device to stay on')
395-
ap.add_argument('command', nargs='*', help='The command to pass to ant (debug, release, installd, installr)')
396-
ap.add_argument('--add-jar', dest='add_jar', action='append', help='Add a Java .jar to the libs, so you can access its classes with pyjnius. You can specify this argument more than once to include multiple jars')
445+
ap.add_argument('command', nargs='*',
446+
help=('The command to pass to ant (debug, release, '
447+
'installd, installr)'))
448+
ap.add_argument('--add-jar', dest='add_jar', action='append',
449+
help=('Add a Java .jar to the libs, so you can access its '
450+
'classes with pyjnius. You can specify this argument '
451+
'more than once to include multiple jars'))
397452
ap.add_argument('--meta-data', dest='meta_data', action='append',
398453
help='Custom key=value to add in application metadata')
399454

@@ -413,19 +468,20 @@ def make_package(args):
413468

414469
if args.compile_pyo:
415470
if PYTHON is None:
416-
ap.error('To use --compile-pyo, you need Python 2.7.1 installed and in your PATH.')
471+
ap.error('To use --compile-pyo, you need Python 2.7.1 installed '
472+
'and in your PATH.')
417473
BLACKLIST_PATTERNS += ['*.py', '*.pyc']
418474

419475
if args.blacklist:
420476
with open(args.blacklist) as fd:
421-
patterns = [x.strip() for x in fd.read().splitlines() if x.strip() and not
422-
x.startswith('#')]
477+
patterns = [x.strip() for x in fd.read().splitlines() if x.strip()
478+
and not x.startswith('#')]
423479
BLACKLIST_PATTERNS += patterns
424-
480+
425481
if args.whitelist:
426482
with open(args.whitelist) as fd:
427-
patterns = [x.strip() for x in fd.read().splitlines() if x.strip() and not
428-
x.startswith('#')]
483+
patterns = [x.strip() for x in fd.read().splitlines() if x.strip()
484+
and not x.startswith('#')]
429485
WHITELIST_PATTERNS += patterns
430486

431487
make_package(args)

0 commit comments

Comments
 (0)