def iter_filename_info(dir_name):
 pattern = re.compile('^((.+)__(.+)__([^-]+))\\.png')
 for t in os.walk(dir_name):
  for filename in t[2]:
   if filename.endswith('.png'):
    m = pattern.match(filename)
    if (m is None):
     (yield {'error': 'png filename not following screenshot pattern: {}'.format(filename)})
    else:
     d = m.group(2).replace('__', sep)
     (yield {'dunder': m.group(1), 'dir': d, 'file': m.group(3), 'ext': m.group(4), 'source': slash(d, ((m.group(3) + '.') + m.group(4)))})

def iter_filename_info ( dir_name ) : pattern = re . compile ( '^((.+)__(.+)__([^-]+))\\.png' ) for t in os . walk ( dir_name ) : for filename in t [ 2 ] : if filename . endswith ( '.png' ) : m = pattern . match ( filename ) if ( m is None ) : ( yield { 'error' : 'png filename not following screenshot pattern: {}' . format ( filename ) } ) else : d = m . group ( 2 ) . replace ( '__' , sep ) ( yield { 'dunder' : m . group ( 1 ) , 'dir' : d , 'file' : m . group ( 3 ) , 'ext' : m . group ( 4 ) , 'source' : slash ( d , ( ( m . group ( 3 ) + '.' ) + m . group ( 4 ) ) ) } )
yield info of each matching screenshot found walking the directory dir_name .