def discover_sourcemap(result):
 sourcemap = result.headers.get('sourcemap', result.headers.get('x-sourcemap'))
 if (not sourcemap):
  parsed_body = result.body.split('\n')
  if (len(parsed_body) > 10):
   possibilities = (parsed_body[:5] + parsed_body[(-5):])
  else:
   possibilities = parsed_body
  for line in possibilities:
   if (line[:21] in ('//# sourceMappingURL=', '//@ sourceMappingURL=')):
    sourcemap = line[21:].rstrip()
 if sourcemap:
  if (('/*' in sourcemap) and (sourcemap[(-2):] == '*/')):
   index = sourcemap.index('/*')
   if (index == 0):
    raise AssertionError(('react-native comment found at bad location: %d, %r' % (index, sourcemap)))
   sourcemap = sourcemap[:index]
  sourcemap = urljoin(result.url, sourcemap)
 return sourcemap

def discover_sourcemap ( result ) : sourcemap = result . headers . get ( 'sourcemap' , result . headers . get ( 'x-sourcemap' ) ) if ( not sourcemap ) : parsed_body = result . body . split ( '\n' ) if ( len ( parsed_body ) > 10 ) : possibilities = ( parsed_body [ : 5 ] + parsed_body [ ( - 5 ) : ] ) else : possibilities = parsed_body for line in possibilities : if ( line [ : 21 ] in ( '//# sourceMappingURL=' , '//@ sourceMappingURL=' ) ) : sourcemap = line [ 21 : ] . rstrip ( ) if sourcemap : if ( ( '/*' in sourcemap ) and ( sourcemap [ ( - 2 ) : ] == '*/' ) ) : index = sourcemap . index ( '/*' ) if ( index == 0 ) : raise AssertionError ( ( 'react-native comment found at bad location: %d, %r' % ( index , sourcemap ) ) ) sourcemap = sourcemap [ : index ] sourcemap = urljoin ( result . url , sourcemap ) return sourcemap
given a urlresult object .