Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def getLinkHeaderAbbreviatedTimeMap(urir, pivotDatetime):
s = surt.surt(urir, path_strip_trailing_slash_unless_empty=False)
indexPath = ipwbUtils.getIPWBReplayIndexPath()
cdxjLinesWithURIR = getCDXJLinesWithURIR(urir, indexPath)
hostAndPort = ipwbUtils.getIPWBReplayConfig()
tgURI = 'http://{0}:{1}/timegate/{2}'.format(
hostAndPort[0],
hostAndPort[1], urir)
tmURI = 'http://{0}:{1}/timemap/link/{2}'.format(
hostAndPort[0],
hostAndPort[1], urir)
tm = generateLinkTimeMapFromCDXJLines(cdxjLinesWithURIR, s, tmURI, tgURI)
# Fix base TM relation when viewing abbrev version in Link resp
tm = tm.replace('rel="self timemap"', 'rel="timemap"')
# Only one memento in TimeMap
if 'rel="first last memento"' in tm:
return tm.replace('\n', ' ').strip()
def showTimeMap(urir, format):
urir = getCompleteURI(urir)
s = surt.surt(urir, path_strip_trailing_slash_unless_empty=False)
indexPath = ipwbUtils.getIPWBReplayIndexPath()
cdxjLinesWithURIR = getCDXJLinesWithURIR(urir, indexPath)
tmContentType = ''
hostAndPort = ipwbUtils.getIPWBReplayConfig()
tgURI = 'http://{0}:{1}/timegate/{2}'.format(
hostAndPort[0],
hostAndPort[1], urir)
tm = '' # Initialize for usage beyond below conditionals
if format == 'link':
tm = generateLinkTimeMapFromCDXJLines(
cdxjLinesWithURIR, s, request.url, tgURI)
tmContentType = 'application/link-format'
elif format == 'cdxj':
tm = generateCDXJTimeMapFromCDXJLines(
cdxjLinesWithURIR, s, request.url, tgURI)
tmContentType = 'application/cdxj+ors'
resp = Response(tm)
def start(cdxjFilePath, proxy=None):
hostPort = ipwbUtils.getIPWBReplayConfig()
app.proxy = proxy
if not hostPort:
ipwbUtils.setIPWBReplayConfig(IPWBREPLAY_HOST, IPWBREPLAY_PORT)
if ipwbUtils.isDaemonAlive():
ipwbUtils.setIPWBReplayIndexPath(cdxjFilePath)
app.cdxjFilePath = cdxjFilePath
else:
print('Sample data not pulled from IPFS.')
print('Check that the IPFS daemon is running.')
# Perform checks for CDXJ file existence, TODO: reuse cached contents
app.cdxjFileContents = getIndexFileContents(cdxjFilePath)
try: