Refactored rename header
Now will directly raise an exception, requiring one less if
This commit is contained in:
parent
1f7983309b
commit
e4158a3685
@ -194,8 +194,7 @@ class relation (object):
|
|||||||
newt.header = header(list(self.header.attributes))
|
newt.header = header(list(self.header.attributes))
|
||||||
|
|
||||||
for old, new in params.items():
|
for old, new in params.items():
|
||||||
if (newt.header.rename(old, new)) == False:
|
newt.header.rename(old, new)
|
||||||
raise Exception('Unable to find attribute: %s' % old)
|
|
||||||
|
|
||||||
newt.content = self.content
|
newt.content = self.content
|
||||||
newt._readonly = True
|
newt._readonly = True
|
||||||
@ -522,7 +521,7 @@ class header (object):
|
|||||||
|
|
||||||
def rename(self, old, new):
|
def rename(self, old, new):
|
||||||
'''Renames a field. Doesn't check if it is a duplicate.
|
'''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):
|
if not is_valid_relation_name(new):
|
||||||
raise Exception('%s is not a valid attribute name' % new)
|
raise Exception('%s is not a valid attribute name' % new)
|
||||||
@ -531,7 +530,7 @@ class header (object):
|
|||||||
id_ = self.attributes.index(old)
|
id_ = self.attributes.index(old)
|
||||||
self.attributes[id_] = new
|
self.attributes[id_] = new
|
||||||
except:
|
except:
|
||||||
return False
|
raise Exception('Field not found: %s' & old)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def sharedAttributes(self, other):
|
def sharedAttributes(self, other):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user