From 581ed2987bd456d2894637a30bb5a14a4caa5f9b Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 14 Dec 2016 13:40:57 -0800 Subject: Fix values to methods in __main__ several of these don't take a self argument. In one case self is needed, in the others decorating them as static methods fixes the behavior. --- alot/__main__.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'alot/__main__.py') diff --git a/alot/__main__.py b/alot/__main__.py index 6bdd129c..34c36b52 100644 --- a/alot/__main__.py +++ b/alot/__main__.py @@ -60,8 +60,8 @@ class ComposeOptions(SubcommandOptions): class SearchOptions(SubcommandOptions): accepted = ['oldest_first', 'newest_first', 'message_id', 'unsorted'] - def colourint(val): - if val not in accepted: + def colourint(self, val): + if val not in self.accepted: raise ValueError("Unknown sort order") return val colourint.coerceDoc = "Must be one of " + str(accepted) @@ -73,14 +73,18 @@ class SearchOptions(SubcommandOptions): class Options(usage.Options): optFlags = [["read-only", "r", 'open db in read only mode'], ] - def colourint(val): + # Should be static method, except static methods are slotted and cannot + # have arbitrary attributes attached + def colourint(self, val): val = int(val) if val not in [1, 16, 256]: raise ValueError("Not in range") return val colourint.coerceDoc = "Must be 1, 16 or 256" - def debuglogstring(val): + # Should be static method, except static methods are slotted and cannot + # have arbitrary attributes attached + def debuglogstring(self, val): if val not in ['error', 'debug', 'info', 'warning']: raise ValueError("Not in range") return val -- cgit v1.2.3