def extract_thumbnail_number(text):
 pattr = re.compile('^\\s*#\\s*sphinx_gallery_thumbnail_number\\s*=\\s*([0-9]+)\\s*$', flags=re.MULTILINE)
 match = pattr.search(text)
 if (match is None):
  thumbnail_number = 1
 else:
  thumbnail_number = int(match.groups()[0])
 return thumbnail_number

def extract_thumbnail_number ( text ) : pattr = re . compile ( '^\\s*#\\s*sphinx_gallery_thumbnail_number\\s*=\\s*([0-9]+)\\s*$' , flags = re . MULTILINE ) match = pattr . search ( text ) if ( match is None ) : thumbnail_number = 1 else : thumbnail_number = int ( match . groups ( ) [ 0 ] ) return thumbnail_number
pull out the thumbnail image number specified in the docstring .