From e4158a368565979f7cba0e82daeba635e3e8ba21 Mon Sep 17 00:00:00 2001 From: Salvo 'LtWorf' Tomaselli Date: Mon, 1 Jun 2015 08:58:54 +0200 Subject: [PATCH] Refactored rename header Now will directly raise an exception, requiring one less if --- relational/relation.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/relational/relation.py b/relational/relation.py index b07ba0d..82ce1e9 100644 --- a/relational/relation.py +++ b/relational/relation.py @@ -194,8 +194,7 @@ class relation (object): newt.header = header(list(self.header.attributes)) for old, new in params.items(): - if (newt.header.rename(old, new)) == False: - raise Exception('Unable to find attribute: %s' % old) + newt.header.rename(old, new) newt.content = self.content newt._readonly = True @@ -522,7 +521,7 @@ class header (object): def rename(self, old, new): '''Renames a field. Doesn't check if it is a duplicate. - Returns True if the field was renamed, False otherwise''' + Returns True''' if not is_valid_relation_name(new): raise Exception('%s is not a valid attribute name' % new) @@ -531,7 +530,7 @@ class header (object): id_ = self.attributes.index(old) self.attributes[id_] = new except: - return False + raise Exception('Field not found: %s' & old) return True def sharedAttributes(self, other):