[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31110] branches/soc-2010-leifandersen: Did some reasearch on python hashtables, realized that the prefered method is just to use dictionaries.
Leif Andersen
leif.a.andersen at gmail.com
Fri Aug 6 18:18:18 CEST 2010
Revision: 31110
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31110
Author: leifandersen
Date: 2010-08-06 18:18:18 +0200 (Fri, 06 Aug 2010)
Log Message:
-----------
Did some reasearch on python hashtables, realized that the prefered method is just to use dictionaries. Which means I've now implemented it in all of the hash tests (previously I was using an almost identicle technique, except using tuples instead of dictionaries).
Modified Paths:
--------------
branches/soc-2010-leifandersen/release/scripts/op/tests_hash.py
branches/soc-2010-leifandersen/tests/hash_compare.py
branches/soc-2010-leifandersen/tests/python/Armature_example2.py
branches/soc-2010-leifandersen/tests/python/BGL_example.py
branches/soc-2010-leifandersen/tests/python/Camera_example.py
branches/soc-2010-leifandersen/tests/python/Constraint_example1.py
branches/soc-2010-leifandersen/tests/python/Constraint_example2.py
branches/soc-2010-leifandersen/tests/python/Draw_example.py
branches/soc-2010-leifandersen/tests/python/Font_example.py
branches/soc-2010-leifandersen/tests/python/Group_example2.py
branches/soc-2010-leifandersen/tests/python/MeshPrimitives_example.py
branches/soc-2010-leifandersen/tests/python/Mesh_example.py
branches/soc-2010-leifandersen/tests/python/MetaBall_example.py
branches/soc-2010-leifandersen/tests/python/Modifier_example.py
branches/soc-2010-leifandersen/tests/python/NMesh_example.py
branches/soc-2010-leifandersen/tests/python/Object_example.py
branches/soc-2010-leifandersen/tests/python/Radio_example.py
branches/soc-2010-leifandersen/tests/python/Render_example.py
branches/soc-2010-leifandersen/tests/python/Scene_example.py
branches/soc-2010-leifandersen/tests/python/Sound_example.py
branches/soc-2010-leifandersen/tests/python/Text3d_example.py
branches/soc-2010-leifandersen/tests/python/Text_example.py
branches/soc-2010-leifandersen/tests/python/Timeline.py
branches/soc-2010-leifandersen/tests/python/Types_example.py
branches/soc-2010-leifandersen/tests/python/Window_example1.py
branches/soc-2010-leifandersen/tests/python/World_example1.py
branches/soc-2010-leifandersen/tests/python/World_example2.py
branches/soc-2010-leifandersen/tests/python/effect_example.py
branches/soc-2010-leifandersen/tests/python/image_example.py
branches/soc-2010-leifandersen/tests/python/lamp_modes_example.py
Modified: branches/soc-2010-leifandersen/release/scripts/op/tests_hash.py
===================================================================
--- branches/soc-2010-leifandersen/release/scripts/op/tests_hash.py 2010-08-06 16:11:17 UTC (rev 31109)
+++ branches/soc-2010-leifandersen/release/scripts/op/tests_hash.py 2010-08-06 16:18:18 UTC (rev 31110)
@@ -438,8 +438,8 @@
def execute(self, context):
file = open(self.properties.filepath, 'w')
- for tuple in tests.hashfile.data:
- file.write(tuple[0] + " = " + str(tuple[1]) + "\n")
+ for element in tests.hashfile.data:
+ file.write(element + " = " + tests.hashfile.data[element] + "\n")
file.close()
return {'FINISHED'}
@@ -465,13 +465,14 @@
file = open(self.properties.filepath, 'r')
try:
line = file.readline()
- tests.data = []
+ data = []
while line != "":
while line.strip().startswith('#') or line.startswith("\n") or line.isspace():
line = file.readline()
split = line.split()
- tests.hashfile.data.append([split[0],int(split[2])])
+ data.append((split[0],int(split[2])))
line = file.readline()
+ tests.hashfile.data = dict(data)
file.close()
return {'FINISHED'}
except:
Modified: branches/soc-2010-leifandersen/tests/hash_compare.py
===================================================================
--- branches/soc-2010-leifandersen/tests/hash_compare.py 2010-08-06 16:11:17 UTC (rev 31109)
+++ branches/soc-2010-leifandersen/tests/hash_compare.py 2010-08-06 16:18:18 UTC (rev 31110)
@@ -12,9 +12,7 @@
hash = 0
def setUp(self):
- for hashpair in data:
- if hashpair[0] == os.path.split(bpy.data.filepath)[1]:
- self.hash = hashpair[1]
+ self.hash = data[os.path.split(bpy.data.filepath)[1]]
def test_case(self):
bpy.ops.tests.hash()
@@ -29,4 +27,4 @@
print(bpy.ops.tests.read_hashfile(filepath=os.path.join(os.path.split(sys.argv[0])[0], 'hashfile.txt')))
data = tests.hashfile.data
unittest.TextTestRunner(verbosity=2).run(suite())
- bpy.ops.wm.exit_blender()
\ No newline at end of file
+ bpy.ops.wm.exit_blender()
Modified: branches/soc-2010-leifandersen/tests/python/Armature_example2.py
===================================================================
--- branches/soc-2010-leifandersen/tests/python/Armature_example2.py 2010-08-06 16:11:17 UTC (rev 31109)
+++ branches/soc-2010-leifandersen/tests/python/Armature_example2.py 2010-08-06 16:18:18 UTC (rev 31110)
@@ -16,11 +16,8 @@
hash_end = 0
def setUp(self):
- for hashpair in data:
- if hashpair[0] == os.path.split(bpy.data.filepath)[1] + '_start':
- self.hash_start = hashpair[1]
- if hashpair[0] == os.path.split(bpy.data.filepath)[1] + '_end':
- self.hash_end = hashpair[1]
+ self.hash_start = data[os.path.split(bpy.data.filepath)[1] + '_start']
+ self.hash_end = data[os.path.split(bpy.data.filepath)[1] + '_end']
def test_all_quads(self):
bpy.ops.tests.hash()
Modified: branches/soc-2010-leifandersen/tests/python/BGL_example.py
===================================================================
--- branches/soc-2010-leifandersen/tests/python/BGL_example.py 2010-08-06 16:11:17 UTC (rev 31109)
+++ branches/soc-2010-leifandersen/tests/python/BGL_example.py 2010-08-06 16:18:18 UTC (rev 31110)
@@ -13,11 +13,8 @@
hash_end = 0
def setUp(self):
- for hashpair in data:
- if hashpair[0] == os.path.split(bpy.data.filepath)[1] + '_start':
- self.hash_start = hashpair[1]
- if hashpair[0] == os.path.split(bpy.data.filepath)[1] + '_end':
- self.hash_end = hashpair[1]
+ self.hash_start = data[os.path.split(bpy.data.filepath)[1] + '_start']
+ self.hash_end = data[os.path.split(bpy.data.filepath)[1] + '_end']
def test_all_quads(self):
bpy.ops.tests.hash()
Modified: branches/soc-2010-leifandersen/tests/python/Camera_example.py
===================================================================
--- branches/soc-2010-leifandersen/tests/python/Camera_example.py 2010-08-06 16:11:17 UTC (rev 31109)
+++ branches/soc-2010-leifandersen/tests/python/Camera_example.py 2010-08-06 16:18:18 UTC (rev 31110)
@@ -13,11 +13,8 @@
hash_end = 0
def setUp(self):
- for hashpair in data:
- if hashpair[0] == os.path.split(bpy.data.filepath)[1] + '_start':
- self.hash_start = hashpair[1]
- if hashpair[0] == os.path.split(bpy.data.filepath)[1] + '_end':
- self.hash_end = hashpair[1]
+ self.hash_start = data[os.path.split(bpy.data.filepath)[1] + '_start']
+ self.hash_end = data[os.path.split(bpy.data.filepath)[1] + '_end']
def test_all_quads(self):
bpy.ops.tests.hash()
Modified: branches/soc-2010-leifandersen/tests/python/Constraint_example1.py
===================================================================
--- branches/soc-2010-leifandersen/tests/python/Constraint_example1.py 2010-08-06 16:11:17 UTC (rev 31109)
+++ branches/soc-2010-leifandersen/tests/python/Constraint_example1.py 2010-08-06 16:18:18 UTC (rev 31110)
@@ -13,11 +13,8 @@
hash_end = 0
def setUp(self):
- for hashpair in data:
- if hashpair[0] == os.path.split(bpy.data.filepath)[1] + '_start':
- self.hash_start = hashpair[1]
- if hashpair[0] == os.path.split(bpy.data.filepath)[1] + '_end':
- self.hash_end = hashpair[1]
+ self.hash_start = data[os.path.split(bpy.data.filepath)[1] + '_start']
+ self.hash_end = data[os.path.split(bpy.data.filepath)[1] + '_end']
def test_all_quads(self):
bpy.ops.tests.hash()
Modified: branches/soc-2010-leifandersen/tests/python/Constraint_example2.py
===================================================================
--- branches/soc-2010-leifandersen/tests/python/Constraint_example2.py 2010-08-06 16:11:17 UTC (rev 31109)
+++ branches/soc-2010-leifandersen/tests/python/Constraint_example2.py 2010-08-06 16:18:18 UTC (rev 31110)
@@ -13,11 +13,8 @@
hash_end = 0
def setUp(self):
- for hashpair in data:
- if hashpair[0] == os.path.split(bpy.data.filepath)[1] + '_start':
- self.hash_start = hashpair[1]
- if hashpair[0] == os.path.split(bpy.data.filepath)[1] + '_end':
- self.hash_end = hashpair[1]
+ self.hash_start = data[os.path.split(bpy.data.filepath)[1] + '_start']
+ self.hash_end = data[os.path.split(bpy.data.filepath)[1] + '_end']
def test_all_quads(self):
bpy.ops.tests.hash()
Modified: branches/soc-2010-leifandersen/tests/python/Draw_example.py
===================================================================
--- branches/soc-2010-leifandersen/tests/python/Draw_example.py 2010-08-06 16:11:17 UTC (rev 31109)
+++ branches/soc-2010-leifandersen/tests/python/Draw_example.py 2010-08-06 16:18:18 UTC (rev 31110)
@@ -13,11 +13,8 @@
hash_end = 0
def setUp(self):
- for hashpair in data:
- if hashpair[0] == os.path.split(bpy.data.filepath)[1] + '_start':
- self.hash_start = hashpair[1]
- if hashpair[0] == os.path.split(bpy.data.filepath)[1] + '_end':
- self.hash_end = hashpair[1]
+ self.hash_start = data[os.path.split(bpy.data.filepath)[1] + '_start']
+ self.hash_end = data[os.path.split(bpy.data.filepath)[1] + '_end']
def test_all_quads(self):
bpy.ops.tests.hash()
Modified: branches/soc-2010-leifandersen/tests/python/Font_example.py
===================================================================
--- branches/soc-2010-leifandersen/tests/python/Font_example.py 2010-08-06 16:11:17 UTC (rev 31109)
+++ branches/soc-2010-leifandersen/tests/python/Font_example.py 2010-08-06 16:18:18 UTC (rev 31110)
@@ -13,11 +13,8 @@
hash_end = 0
def setUp(self):
- for hashpair in data:
- if hashpair[0] == os.path.split(bpy.data.filepath)[1] + '_start':
- self.hash_start = hashpair[1]
- if hashpair[0] == os.path.split(bpy.data.filepath)[1] + '_end':
- self.hash_end = hashpair[1]
+ self.hash_start = data[os.path.split(bpy.data.filepath)[1] + '_start']
+ self.hash_end = data[os.path.split(bpy.data.filepath)[1] + '_end']
def test_all_quads(self):
bpy.ops.tests.hash()
Modified: branches/soc-2010-leifandersen/tests/python/Group_example2.py
===================================================================
--- branches/soc-2010-leifandersen/tests/python/Group_example2.py 2010-08-06 16:11:17 UTC (rev 31109)
+++ branches/soc-2010-leifandersen/tests/python/Group_example2.py 2010-08-06 16:18:18 UTC (rev 31110)
@@ -13,11 +13,8 @@
hash_end = 0
def setUp(self):
- for hashpair in data:
- if hashpair[0] == os.path.split(bpy.data.filepath)[1] + '_start':
- self.hash_start = hashpair[1]
- if hashpair[0] == os.path.split(bpy.data.filepath)[1] + '_end':
- self.hash_end = hashpair[1]
+ self.hash_start = data[os.path.split(bpy.data.filepath)[1] + '_start']
+ self.hash_end = data[os.path.split(bpy.data.filepath)[1] + '_end']
def test_all_quads(self):
bpy.ops.tests.hash()
Modified: branches/soc-2010-leifandersen/tests/python/MeshPrimitives_example.py
===================================================================
--- branches/soc-2010-leifandersen/tests/python/MeshPrimitives_example.py 2010-08-06 16:11:17 UTC (rev 31109)
+++ branches/soc-2010-leifandersen/tests/python/MeshPrimitives_example.py 2010-08-06 16:18:18 UTC (rev 31110)
@@ -13,11 +13,8 @@
hash_end = 0
def setUp(self):
- for hashpair in data:
- if hashpair[0] == os.path.split(bpy.data.filepath)[1] + '_start':
- self.hash_start = hashpair[1]
- if hashpair[0] == os.path.split(bpy.data.filepath)[1] + '_end':
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list