def _thumbnail_div(subdir, full_dir, fname, snippet):
 thumb = os.path.join(full_dir, 'images', 'thumb', (fname[:(-3)] + '.png'))
 link_name = os.path.join(full_dir, fname).replace(os.path.sep, '_')
 ref_name = os.path.join(subdir, fname).replace(os.path.sep, '_')
 if ref_name.startswith('._'):
  ref_name = ref_name[2:]
 out = []
 out.append(('.. figure:: %s\n' % thumb))
 out.append('   :scale: 50\n')
 if link_name.startswith('._'):
  link_name = link_name[2:]
 if (full_dir != '.'):
  out.append(('   :target: ./%s/%s.html\n\n' % (full_dir, fname[:(-3)])))
 else:
  out.append(('   :target: ./%s.html\n\n' % link_name[:(-3)]))
 out.append(('   :ref:`example_%s`\n\n\n\n\n' % ref_name))
 return ''.join(out)

def _thumbnail_div ( subdir , full_dir , fname , snippet ) : thumb = os . path . join ( full_dir , 'images' , 'thumb' , ( fname [ : ( - 3 ) ] + '.png' ) ) link_name = os . path . join ( full_dir , fname ) . replace ( os . path . sep , '_' ) ref_name = os . path . join ( subdir , fname ) . replace ( os . path . sep , '_' ) if ref_name . startswith ( '._' ) : ref_name = ref_name [ 2 : ] out = [ ] out . append ( ( '.. figure:: %s\n' % thumb ) ) out . append ( '   :scale: 50\n' ) if link_name . startswith ( '._' ) : link_name = link_name [ 2 : ] if ( full_dir != '.' ) : out . append ( ( '   :target: ./%s/%s.html\n\n' % ( full_dir , fname [ : ( - 3 ) ] ) ) ) else : out . append ( ( '   :target: ./%s.html\n\n' % link_name [ : ( - 3 ) ] ) ) out . append ( ( '   :ref:`example_%s`\n\n\n\n\n' % ref_name ) ) return '' . join ( out )
generates rst to place a thumbnail in a gallery .