def _mergetreejinja(src, dst, context):
 for item in os.listdir(src):
  s = os.path.join(src, item)
  d = os.path.join(dst, item)
  if os.path.isdir(s):
   log.info('Copying folder {0} to {1}'.format(s, d))
   if os.path.exists(d):
    _mergetreejinja(s, d, context)
   else:
    os.mkdir(d)
    _mergetreejinja(s, d, context)
  elif (item != TEMPLATE_FILE_NAME):
   d = Template(d).render(context)
   log.info('Copying file {0} to {1}'.format(s, d))
   with salt.utils.fopen(s, 'r') as source_file:
    src_contents = source_file.read()
    dest_contents = Template(src_contents).render(context)
   with salt.utils.fopen(d, 'w') as dest_file:
    dest_file.write(dest_contents)

def _mergetreejinja ( src , dst , context ) : for item in os . listdir ( src ) : s = os . path . join ( src , item ) d = os . path . join ( dst , item ) if os . path . isdir ( s ) : log . info ( 'Copying folder {0} to {1}' . format ( s , d ) ) if os . path . exists ( d ) : _mergetreejinja ( s , d , context ) else : os . mkdir ( d ) _mergetreejinja ( s , d , context ) elif ( item != TEMPLATE_FILE_NAME ) : d = Template ( d ) . render ( context ) log . info ( 'Copying file {0} to {1}' . format ( s , d ) ) with salt . utils . fopen ( s , 'r' ) as source_file : src_contents = source_file . read ( ) dest_contents = Template ( src_contents ) . render ( context ) with salt . utils . fopen ( d , 'w' ) as dest_file : dest_file . write ( dest_contents )
merge directory a to directory b .