def find_dir_item_metadata_by_name(dir, name):
 meta_stream = None
 try:
  mfile = dir.metadata_file()
  if mfile:
   meta_stream = mfile.open()
   meta = metadata.Metadata.read(meta_stream)
   if (name == ''):
    return meta
   for sub in dir:
    if stat.S_ISDIR(sub.mode):
     meta = find_dir_item_metadata_by_name(sub, '')
    else:
     meta = metadata.Metadata.read(meta_stream)
    if (sub.name == name):
     return meta
 finally:
  if meta_stream:
   meta_stream.close()

def find_dir_item_metadata_by_name ( dir , name ) : meta_stream = None try : mfile = dir . metadata_file ( ) if mfile : meta_stream = mfile . open ( ) meta = metadata . Metadata . read ( meta_stream ) if ( name == '' ) : return meta for sub in dir : if stat . S_ISDIR ( sub . mode ) : meta = find_dir_item_metadata_by_name ( sub , '' ) else : meta = metadata . Metadata . read ( meta_stream ) if ( sub . name == name ) : return meta finally : if meta_stream : meta_stream . close ( )
find metadata in dir for an item with the given name .