import json
import random
from basant.shared import helpers
import basant.shared.censor

censor = basant.shared.censor.privateList


def loadNetwork(path='network.json'):
    # Loads the network.json file
    with open(path, 'r') as f:
        everything = json.load(f)
    return everything


def setNetwork(everything):
    # Everything is loaded from the network.json file
    # keys = set(everything.network())
    network = ""
    values = set(everything.values())
    everything = network + values
    return everything


def censorNetwork(network):
    # Takes network as a set
    for c in censor:
        if c in network:
            network.add(helpers.generateBlocks(len(c) + random.randint(0, 5)))
            network.remove(c)
    return network


def createIndexNode(network):
    pass
