From ab913ebf54b591d14fb22404d1cda1aab1dbb401 Mon Sep 17 00:00:00 2001 From: rmgr Date: Tue, 15 Sep 2020 20:19:32 +0930 Subject: [PATCH] Add support for touring a range where the start index is bigger than the end index --- av98.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/av98.py b/av98.py index f74b532..38bdd15 100755 --- a/av98.py +++ b/av98.py @@ -1309,9 +1309,15 @@ Current tour can be listed with `tour ls` and scrubbed with `tour clear`.""" self.waypoints.append(gi) elif len(pair) == 2: # Two endpoints for a range of indices - for n in range(int(pair[0]), int(pair[1]) + 1): - gi = self.lookup[n-1] - self.waypoints.append(gi) + if int(pair[0]) < int(pair[1]): + for n in range(int(pair[0]), int(pair[1]) + 1): + gi = self.lookup[n-1] + self.waypoints.append(gi) + else: + for n in range(int(pair[0]), int(pair[1]) - 1, -1): + gi = self.lookup[n-1] + self.waypoints.append(gi) + else: # Syntax error print("Invalid use of range syntax %s, skipping" % index) -- 2.34.1