# Path: ipwb/indexer.py
# DEBUG = False
#     DEBUG = debug
# def s2b(s):  # Convert str to bytes, cross-py
# def push_to_ipfs(hstr, payload):
# def encrypt(hstr, payload, encryption_key):
# def create_ipfs_temp_path():
# def index_file_at(warc_paths, encryption_key=None,
#                   compression_level=None, encrypt_then_compress=True,
#                   quiet=False, outfile=None, debug=False):
# def sanitize_cdxj_line(cdxj_line):
# def cdx_cdxj_lines_from_file(warc_path, **enc_comp_opts):
# def generate_cdxj_metadata(cdxj_lines=None):
# def ask_user_for_encryption_key():
# def verify_daemon_is_alive(host_and_port):
# def verify_file_exists(warc_path):
# def show_progress(msg, i, n):
# def log_error(err_in, end='\n'):
# def pull_from_ipfs(hash_in):
# def push_bytes_to_ipfs(bytes_in):
# def write_file(filename, content):


import pytest
import os
import sys
import json
from ipwb import indexer
from . import testUtil as ipwb_test




def is_valid_surt(surt):
    return True  # The surt library does not yet have a way to check this


def is_valid_datetime(dt):
    return len(dt) == 14 and dt.isdigit()


def is_valid_json(jsonIn):
    try:
        j = json.loads(json.dumps(jsonIn))
    except ValueError:
        return False
    return True


def check_cdxj_fields(cdxjEntry):
    (surt, dt, json) = cdxjEntry.split(' ', 2)
    valid_surt = is_valid_surt(surt)
    valid_dt = is_valid_datetime(dt)
    valid_json = is_valid_json(json)

    return valid_surt and valid_dt and valid_json



# Path: ipwb/indexer.py
# DEBUG = False
#     DEBUG = debug
# def s2b(s):  # Convert str to bytes, cross-py
# def push_to_ipfs(hstr, payload):
# def encrypt(hstr, payload, encryption_key):
# def create_ipfs_temp_path():
# def index_file_at(warc_paths, encryption_key=None,
#                   compression_level=None, encrypt_then_compress=True,
#                   quiet=False, outfile=None, debug=False):
# def sanitize_cdxj_line(cdxj_line):
# def cdx_cdxj_lines_from_file(warc_path, **enc_comp_opts):
# def generate_cdxj_metadata(cdxj_lines=None):
# def ask_user_for_encryption_key():
# def verify_daemon_is_alive(host_and_port):
# def verify_file_exists(warc_path):
# def show_progress(msg, i, n):
# def log_error(err_in, end='\n'):
# def pull_from_ipfs(hash_in):
# def push_bytes_to_ipfs(bytes_in):
# def write_file(filename, content):


# Path: tests/test_randomized_add.py
import pytest
import os
import sys
import json
from ipwb import indexer
from . import testUtil as ipwb_test





def is_valid_surt(surt):
    return True  # The surt library does not yet have a way to check this


def is_valid_datetime(dt):
    return len(dt) == 14 and dt.isdigit()


def is_valid_json(jsonIn):
    try:
        j = json.loads(json.dumps(jsonIn))
    except ValueError:
        return False
    return True


def check_cdxj_fields(cdxjEntry):
    (surt, dt, json) = cdxjEntry.split(' ', 2)
    valid_surt = is_valid_surt(surt)
    valid_dt = is_valid_datetime(dt)
    valid_json = is_valid_json(json)

    return valid_surt and valid_dt and valid_json



def check_ipwb_json_field_presence(jsonStr):