Ensure unique segment names in the JPK driver.
authorW. Trevor King <wking@drexel.edu>
Wed, 8 Sep 2010 20:21:39 +0000 (16:21 -0400)
committerW. Trevor King <wking@drexel.edu>
Wed, 8 Sep 2010 20:21:39 +0000 (16:21 -0400)
hooke/driver/jpk.py

index 286766cb58c62a16153ef10e7f201db8462bcf5e..71af831b0be25e1872c807008344e7d210e18e19 100644 (file)
@@ -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):