1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-23 06:32:24 +01:00
pywb/webagg/test/testutils.py
2016-03-09 14:29:14 -08:00

17 lines
430 B
Python

import json
import os
def json_list(cdxlist, fields=['timestamp', 'load_url', 'filename', 'source']):
return list([json.loads(cdx.to_json(fields)) for cdx in cdxlist])
def key_ts_res(cdxlist, extra='filename'):
return '\n'.join([cdx['urlkey'] + ' ' + cdx['timestamp'] + ' ' + cdx[extra] for cdx in cdxlist])
def to_path(path):
if os.path.sep != '/':
path = path.replace('/', os.path.sep)
return path