from __future__ import (
    unicode_literals,
    absolute_import,
    print_function,
    division,
    )

import os
from aaf2.file import AAFFile

base = os.path.join(os.path.dirname(os.path.abspath(__file__)))
test_dir = os.path.join(base, 'results')
if not os.path.exists(test_dir):
    os.makedirs(test_dir)

test_files = os.path.join(base, 'test_files')

if __name__ == "__main__":
    import logging
    # logging.basicConfig(level=logging.DEBUG)

    test_file = os.path.join(test_files, "test_file_01.aaf")
    # test_file = os.path.join(test_files, "empty.aaf")
    with AAFFile(test_file) as f:
        pass
        # test = f.read_object("/Header-2/Content-3b03/Mobs-1901{a0}")
        # print test['MobID'].value
        # test = f.read_object("/Header-2/Content-3b03/Mobs-1901{27}/Slots-4403{1}/Segment-4803/Components-1001{0}")
        f.dump()
        # for root, storage, stream in f.cfb.walk():
        #     print root.path()

        # for item in f.root.walk_references(topdown=True):
        #     space = " " * len(item.dir.path().split("/"))
        #     print space, item

@@ -112,16 +112,32 @@
 port os%0A
+import unittest%0A
 from aaf
@@ -157,16 +157,44 @@
  AAFFile
+%0Afrom aaf2 import properties
 %0A%0Abase =
@@ -403,335 +403,422 @@
 ')%0A%0A
-if __name__ == %22__main__%22:%0A    import logging%0A    # logging.basicConfig(level=logging.DEBUG)%0A%0A    test_file = os.path.join(test_files, %22test_file_01.aaf%22)%0A    # test_file = os.path.join(test_files, %22empty.aaf%22)%0A    with AAFFile(test_file) as f:%0A        pass%0A        # test = f.read_object(%22/Header-2/Content-3b03/Mobs-1901%7Ba0%7D%22
+%0Adef walk(root, space=%22%22, func=None):%0A    indent = %22  %22%0A%0A    for p in root.properties():%0A        if isinstance(p, properties.StrongRefProperty):%0A            func(space, p.name, p.typedef)%0A            walk(p.value, space + indent, func)%0A%0A        if isinstance(p, properties.StrongRefVectorProperty):%0A            func(space, p.name, p.typedef)%0A            for obj in p.value:%0A                func(space + indent, obj
 )%0A  
@@ -827,219 +827,209 @@
     
+ 
-# print test%5B'MobID'%5D.value%0A        # test = f.read_object(%22/Header-2/Content-3b03/Mobs-1901%7B27%7D/Slots-4403%7B1%7D/Segment-4803/Components-1001%7B0%7D%22)%0A        f.dump()%0A        # for root, storage, stream in f.cfb.walk
+       walk(obj, space + indent*2, func)%0A            continue%0A%0A        if isinstance(p, properties.StrongRefSetProperty):%0A            func(space, p.name, p.typedef)%0A            for key, obj in p.items
 ():%0A
@@ -1040,152 +1040,406 @@
     
+ 
-#
+  
      
-print root.path()%0A%0A        # for item in f.root.walk_references(topdown=Tru
+func(space + indent, obj)%0A                walk(obj, space + indent*2, func)%0A%0A            continue%0A%0A        func(space, p.name, p.typedef, p.value)%0A%0A%0Adef procces(*args):%0A    line = %22 %22.join(%5Bstr(item) for item in args%5D)%0A%0A%0Aclass AAFTests(unittest.TestCas
 e):%0A
+%0A%0A
     
- 
+def test_wall_all(self):%0A%0A
    
-#
      
-space = %22 %22 * len(item.dir.path().split(%22/%22))
+test_file = os.path.join(test_files, %22test_file_01.aaf%22)%0A        with AAFFile(test_file) as f:
 %0A   
@@ -1447,28 +1447,153 @@
     
-#
     
- print space, item
+walk(f.root, '', func=procces)%0A%0Aif __name__ == %22__main__%22:%0A    import logging%0A    # logging.basicConfig(level=logging.DEBUG)%0A    unittest.main()
 %0A

make into unit test