From 0ca529913941a8d0e4c3323febabd9a856655348 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 8 Sep 2010 16:21:39 -0400 Subject: [PATCH] Ensure unique segment names in the JPK driver. --- hooke/driver/jpk.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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): -- 2.26.2