def load_external_templates(spec_base, spider_name):
 spider_dir = join(spec_base, spider_name)
 if (not isdir(spider_dir)):
  raise StopIteration
 for name in os.listdir(spider_dir):
  if (not name.endswith('.json')):
   continue
  path = join(spider_dir, name)
  with open(path) as f:
   sample = json.load(f)
   sample_dir = path[:(- len('.json'))]
   if isdir(sample_dir):
    for fname in os.listdir(sample_dir):
     if fname.endswith('.html'):
      with open(join(sample_dir, fname)) as f:
       attr = fname[:(- len('.html'))]
       sample[attr] = read(f)
    version = sample.get('version', '')
    (yield _build_sample(sample, legacy=(version < '0.13.0')))

def load_external_templates ( spec_base , spider_name ) : spider_dir = join ( spec_base , spider_name ) if ( not isdir ( spider_dir ) ) : raise StopIteration for name in os . listdir ( spider_dir ) : if ( not name . endswith ( '.json' ) ) : continue path = join ( spider_dir , name ) with open ( path ) as f : sample = json . load ( f ) sample_dir = path [ : ( - len ( '.json' ) ) ] if isdir ( sample_dir ) : for fname in os . listdir ( sample_dir ) : if fname . endswith ( '.html' ) : with open ( join ( sample_dir , fname ) ) as f : attr = fname [ : ( - len ( '.html' ) ) ] sample [ attr ] = read ( f ) version = sample . get ( 'version' , '' ) ( yield _build_sample ( sample , legacy = ( version < '0.13.0' ) ) )
a generator yielding the content of all passed template_names for spider_name .