- if len(self.tpl) not in [0, 1, 2]:
- raise CommandError('length not in [0, 1, 2]')
- for index in self.tpl:
- try:
- index = int(index)
- except (TypeError, ValueError) as err:
- raise CommandError('Not a tuple of int') from err
+ if len(self.tpl) == 0:
+ return
+ if len(self.tpl) == 1:
+ self.lower = self._check_element(self.tpl[0])
+ return
+ if len(self.tpl) != 2:
+ raise CommandError('Range wrong size (0, 1 or 2 allowed)')
+ self.lower = self._check_element(self.tpl[0])
+ self.upper = self._check_element(self.tpl[1])
+ if self.lower == '' and self.upper != '':
+ raise CommandError(f'Integer expected to start the range: {self.tpl}')
+ if self.upper.isdigit() and self.lower.isdigit():
+ if int(self.lower) > int(self.upper):
+ raise CommandError(f'Wrong range: {self.lower} > {self.upper}')