def _update_sample(data, socket, sample=None, project=None):
 if (sample is None):
  project = (project or socket.spiderspec.project)
  spiders = project.spiders
  spider = spiders[data['spider']]
  samples = spider.samples
  sample = samples[data['sample']]
  path = 'spiders/{}/{}/{{}}.html'.format(data['spider'], data['sample'])
 else:
  path = _html_path(sample)
 if hasattr(sample, 'dump'):
  sample = sample.dump()
 html_path = path.format
 for (name, type_) in (('original_body', 'raw'), ('rendered_body', None)):
  try:
   path = html_path(name)
   html = decode(socket.storage.open(path).read())
  except IOError:
   html = decoded_html(socket.tab, type_)
   socket.storage.save(path, ContentFile(html, path))
  sample[name] = html
 return sample

def _update_sample ( data , socket , sample = None , project = None ) : if ( sample is None ) : project = ( project or socket . spiderspec . project ) spiders = project . spiders spider = spiders [ data [ 'spider' ] ] samples = spider . samples sample = samples [ data [ 'sample' ] ] path = 'spiders/{}/{}/{{}}.html' . format ( data [ 'spider' ] , data [ 'sample' ] ) else : path = _html_path ( sample ) if hasattr ( sample , 'dump' ) : sample = sample . dump ( ) html_path = path . format for ( name , type_ ) in ( ( 'original_body' , 'raw' ) , ( 'rendered_body' , None ) ) : try : path = html_path ( name ) html = decode ( socket . storage . open ( path ) . read ( ) ) except IOError : html = decoded_html ( socket . tab , type_ ) socket . storage . save ( path , ContentFile ( html , path ) ) sample [ name ] = html return sample
recompile sample with latest annotations .