all repos — listfix @ 503fbf69b9001059b5eb6fd03306ecfa5da24e04

Postfix Mailing List Software; Maintained on behalf the of Agency Economy Incorporated NFP.

General code cleanup

	modified:   listfix/args.py
Brian Barto bartobrian@gmail.com
Wed, 30 Mar 2022 13:58:21 -0400
commit

503fbf69b9001059b5eb6fd03306ecfa5da24e04

parent

2044a2da03d78e4dcc1e90897231eb07c684e2b1

1 files changed, 5 insertions(+), 16 deletions(-)

jump to
M listfix/args.pylistfix/args.py

@@ -5,17 +5,12 @@

class Args: def __init__(self, args): - self.args = [] - self.command = None - - if (type(args) is list): - if (len(args) >= 2): - self.args = args - self.command = args[1] - else: - raise IndexError("Missing command argument.") - else: + if (type(args) is not list): raise TypeError("Arguments should be of list type.") + if (len(args) < 2): + raise IndexError("Missing command argument.") + self.args = args + self.command = args[1] def get_command(self): return self.command

@@ -23,30 +18,24 @@

def get_list_email(self): if (len(self.args) < 3): raise IndexError(f"Missing argument(s) for '{self.command}' command.") - if (not re_email_arg.match(self.args[2])): raise ValueError(f"Invalid argument value: {self.args[2]}") - return self.args[2] def get_list_name(self): if (len(self.args) < 4): raise IndexError(f"Missing argument(s) for '{self.command}' command.") - return self.args[3] def get_recipient_email(self): if (len(self.args) < 4): raise IndexError(f"Missing argument(s) for '{self.command}' command.") - if (not re_email_arg.match(self.args[3])): raise ValueError(f"Invalid argument value: {self.args[3]}") - return self.args[3] def get_recipient_name(self): if (len(self.args) < 5): raise IndexError(f"Missing argument(s) for '{self.command}' command.") - return self.args[4]