def fetch_or_load(spec_path):
 headers = {}
 try:
  modified = datetime.utcfromtimestamp(os.path.getmtime(spec_path))
  date = modified.strftime('%a, %d %b %Y %I:%M:%S UTC')
  headers['If-Modified-Since'] = date
 except OSError as error:
  if (error.errno != errno.ENOENT):
   raise
 request = urllib.Request(VALIDATION_SPEC, headers=headers)
 response = urllib.urlopen(request)
 if (response.code == 200):
  with open(spec_path, 'w+b') as spec:
   spec.writelines(response)
   spec.seek(0)
   return html.parse(spec)
 with open(spec_path) as spec:
  return html.parse(spec)

def fetch_or_load ( spec_path ) : headers = { } try : modified = datetime . utcfromtimestamp ( os . path . getmtime ( spec_path ) ) date = modified . strftime ( '%a, %d %b %Y %I:%M:%S UTC' ) headers [ 'If-Modified-Since' ] = date except OSError as error : if ( error . errno != errno . ENOENT ) : raise request = urllib . Request ( VALIDATION_SPEC , headers = headers ) response = urllib . urlopen ( request ) if ( response . code == 200 ) : with open ( spec_path , 'w+b' ) as spec : spec . writelines ( response ) spec . seek ( 0 ) return html . parse ( spec ) with open ( spec_path ) as spec : return html . parse ( spec )
fetch a new specification or use the cache if its current .