Skip to content

Commit 6f3ae31

Browse files
committed
Refactor foregroundServiceType option parsing in build.py
1 parent 188c666 commit 6f3ae31

File tree

1 file changed

+8
-10
lines changed
  • pythonforandroid/bootstraps/common/build

1 file changed

+8
-10
lines changed

pythonforandroid/bootstraps/common/build/build.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -477,17 +477,15 @@ def make_package(args):
477477
foreground = 'foreground' in options
478478
sticky = 'sticky' in options
479479
foreground_type_option = next((s for s in options if s.startswith('foregroundServiceType')), None)
480+
foreground_type = None
480481
if foreground_type_option:
481-
try:
482-
foreground_type = foreground_type_option.split('=')[1]
483-
if not foreground_type:
484-
raise ValueError('Missing value for `foregroundServiceType` option. '
485-
'Expected format: foregroundServiceType=location')
486-
except IndexError:
487-
raise ValueError('Missing value for `foregroundServiceType` option. '
488-
'Expected format: foregroundServiceType=location')
489-
else:
490-
foreground_type = None
482+
parts = foreground_type_option.split('=', 1)
483+
if len(parts) != 2 or not parts[1]:
484+
raise ValueError(
485+
'Missing value for `foregroundServiceType` option. '
486+
'Expected format: foregroundServiceType=location'
487+
)
488+
foreground_type = parts[1]
491489

492490
service_data.append((name, foreground_type))
493491
service_target_path =\

0 commit comments

Comments
 (0)