From: W. Trevor King Date: Wed, 8 Sep 2010 20:21:39 +0000 (-0400) Subject: Ensure unique segment names in the JPK driver. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0ca529913941a8d0e4c3323febabd9a856655348;p=hooke.git Ensure unique segment names in the JPK driver. --- diff --git a/hooke/driver/jpk.py b/hooke/driver/jpk.py index 286766c..71af831 100644 --- a/hooke/driver/jpk.py +++ b/hooke/driver/jpk.py @@ -90,7 +90,15 @@ class JPKDriver (Driver): if key in curve_info: segment.info['spring constant (N/m)'] = \ curve_info['spring constant (N/m)'] - + names = [segment.info['name'] for segment in segments] + for name in set(names): # ensure unique names + count = names.count(name) + if count > 1: + i = 0 + for j,n in enumerate(names): + if n == name: + segments[j].info['name'] += '-%d' % i + i += 1 return (segments, curve_info) def _zip_info(self, zipfile):