Remove unnecessary else/elif conditions after raise and return
`raise` and `return` interrupt the control flow, so `else` is unnecessary after them. The new code should be logically equivalent. This commit fixes the following pylint errors: - no-else-return (R1705) - no-else-raise (R1720) Signed-off-by: Fabian P. Schmidt <kerel@mailbox.org>merge-requests/799/head
parent
5679828e69
commit
ca35c99b83
|
@ -54,17 +54,18 @@ def get_transmitters_by_uuid_list(uuid_list):
|
|||
if not transmitter:
|
||||
raise ValueError('Invalid Transmitter UUID: {0}'.format(str(uuid_list[0])))
|
||||
return {transmitter[0]['uuid']: transmitter[0]}
|
||||
else:
|
||||
transmitters_list = get_transmitters()
|
||||
|
||||
transmitters = {t['uuid']: t for t in transmitters_list if t['uuid'] in uuid_list}
|
||||
invalid_transmitters = [
|
||||
str(uuid) for uuid in set(uuid_list).difference(set(transmitters.keys()))
|
||||
]
|
||||
if not invalid_transmitters:
|
||||
return transmitters
|
||||
else:
|
||||
if len(invalid_transmitters) == 1:
|
||||
raise ValueError('Invalid Transmitter UUID: {0}'.format(invalid_transmitters[0]))
|
||||
else:
|
||||
raise ValueError('Invalid Transmitter UUIDs: {0}'.format(invalid_transmitters))
|
||||
transmitters_list = get_transmitters()
|
||||
|
||||
transmitters = {t['uuid']: t for t in transmitters_list if t['uuid'] in uuid_list}
|
||||
invalid_transmitters = [
|
||||
str(uuid) for uuid in set(uuid_list).difference(set(transmitters.keys()))
|
||||
]
|
||||
|
||||
if not invalid_transmitters:
|
||||
return transmitters
|
||||
|
||||
if len(invalid_transmitters) == 1:
|
||||
raise ValueError('Invalid Transmitter UUID: {0}'.format(invalid_transmitters[0]))
|
||||
|
||||
raise ValueError('Invalid Transmitter UUIDs: {0}'.format(invalid_transmitters))
|
||||
|
|
|
@ -96,11 +96,10 @@ def check_schedule_perms_per_station(user, station_list):
|
|||
stations_without_permissions[0]
|
||||
)
|
||||
)
|
||||
else:
|
||||
raise UserNoPermissionError(
|
||||
'No permission to schedule observations on stations: {0}'.
|
||||
format(stations_without_permissions)
|
||||
)
|
||||
raise UserNoPermissionError(
|
||||
'No permission to schedule observations on stations: {0}'.
|
||||
format(stations_without_permissions)
|
||||
)
|
||||
|
||||
|
||||
def delete_perms(user, observation):
|
||||
|
|
|
@ -43,7 +43,7 @@ def max_altitude_in_window(observer, satellite, pass_tca, window_start, window_e
|
|||
# Observation window in the second half of the pass
|
||||
# Thus highest altitude right at the beginning of the window
|
||||
return get_altitude(observer, satellite, window_start)
|
||||
elif window_end < pass_tca:
|
||||
if window_end < pass_tca:
|
||||
# Observation window in the first half of the pass
|
||||
# Thus highest altitude right at the end of the window
|
||||
return get_altitude(observer, satellite, window_end)
|
||||
|
@ -128,7 +128,8 @@ def create_station_windows(scheduled_obs, overlapped, pass_params, observer, sat
|
|||
# Windows changed due to overlap, recalculate observation parameters
|
||||
if overlapped == 0:
|
||||
return []
|
||||
elif overlapped == 1:
|
||||
|
||||
if overlapped == 1:
|
||||
initial_duration = (pass_params['set_time'] - pass_params['rise_time']).total_seconds()
|
||||
for window_start, window_end in windows:
|
||||
altitude = max_altitude_in_window(
|
||||
|
|
|
@ -89,11 +89,10 @@ def check_transmitter_station_pairs(transmitter_station_list):
|
|||
'Transmitter out of station frequency range.'
|
||||
' Transmitter-Station pair: {0}'.format(out_of_range_pairs[0])
|
||||
)
|
||||
else:
|
||||
raise OutOfRangeError(
|
||||
'Transmitter out of station frequency range. '
|
||||
'Transmitter-Station pairs: {0}'.format(out_of_range_pairs)
|
||||
)
|
||||
raise OutOfRangeError(
|
||||
'Transmitter out of station frequency range. '
|
||||
'Transmitter-Station pairs: {0}'.format(out_of_range_pairs)
|
||||
)
|
||||
|
||||
|
||||
def check_overlaps(stations_dict):
|
||||
|
|
|
@ -381,8 +381,7 @@ def prediction_windows(request):
|
|||
if not transmitter:
|
||||
data = [{'error': 'You should select a valid Transmitter.'}]
|
||||
return JsonResponse(data, safe=False)
|
||||
else:
|
||||
downlink = transmitter[0]['downlink_low']
|
||||
downlink = transmitter[0]['downlink_low']
|
||||
except DBConnectionError as error:
|
||||
data = [{'error': error.message}]
|
||||
return JsonResponse(data, safe=False)
|
||||
|
@ -666,20 +665,18 @@ def scheduling_stations(request):
|
|||
if uuid is None:
|
||||
data = [{'error': 'You should select a Transmitter.'}]
|
||||
return JsonResponse(data, safe=False)
|
||||
else:
|
||||
try:
|
||||
transmitter = get_transmitter_by_uuid(uuid)
|
||||
if not transmitter:
|
||||
data = [{'error': 'You should select a valid Transmitter.'}]
|
||||
return JsonResponse(data, safe=False)
|
||||
else:
|
||||
downlink = transmitter[0]['downlink_low']
|
||||
if downlink is None:
|
||||
data = [{'error': 'You should select a valid Transmitter.'}]
|
||||
return JsonResponse(data, safe=False)
|
||||
except DBConnectionError as error:
|
||||
data = [{'error': error.message}]
|
||||
try:
|
||||
transmitter = get_transmitter_by_uuid(uuid)
|
||||
if not transmitter:
|
||||
data = [{'error': 'You should select a valid Transmitter.'}]
|
||||
return JsonResponse(data, safe=False)
|
||||
downlink = transmitter[0]['downlink_low']
|
||||
if downlink is None:
|
||||
data = [{'error': 'You should select a valid Transmitter.'}]
|
||||
return JsonResponse(data, safe=False)
|
||||
except DBConnectionError as error:
|
||||
data = [{'error': error.message}]
|
||||
return JsonResponse(data, safe=False)
|
||||
|
||||
stations = Station.objects.filter(status__gt=0).prefetch_related('antenna')
|
||||
available_stations = get_available_stations(stations, downlink, request.user)
|
||||
|
@ -818,23 +815,10 @@ def station_edit(request, station_id=None):
|
|||
form.save_m2m()
|
||||
messages.success(request, 'Ground Station saved successfully.')
|
||||
return redirect(reverse('base:station_view', kwargs={'station_id': station_form.id}))
|
||||
else:
|
||||
messages.error(
|
||||
request, ('Your Ground Station submission has some '
|
||||
'errors. {0}').format(form.errors)
|
||||
)
|
||||
return render(
|
||||
request, 'base/station_edit.html', {
|
||||
'form': form,
|
||||
'station': station,
|
||||
'antennas': antennas
|
||||
}
|
||||
)
|
||||
else:
|
||||
if station:
|
||||
form = StationForm(instance=station)
|
||||
else:
|
||||
form = StationForm()
|
||||
messages.error(
|
||||
request, ('Your Ground Station submission has some '
|
||||
'errors. {0}').format(form.errors)
|
||||
)
|
||||
return render(
|
||||
request, 'base/station_edit.html', {
|
||||
'form': form,
|
||||
|
@ -842,6 +826,17 @@ def station_edit(request, station_id=None):
|
|||
'antennas': antennas
|
||||
}
|
||||
)
|
||||
if station:
|
||||
form = StationForm(instance=station)
|
||||
else:
|
||||
form = StationForm()
|
||||
return render(
|
||||
request, 'base/station_edit.html', {
|
||||
'form': form,
|
||||
'station': station,
|
||||
'antennas': antennas
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
|
|
Loading…
Reference in New Issue