def __del__(self):
     """
     this function is automatically called by python when the object of this class goes out of scope
     we save the files we need in this function.
     """
     utils.Log.log("delete the IndexModule class object")
     Storage.save(self.inverted_index, self.file_mapping)
    def __init__(self, option=0):
        """
        initialize the inverted data structure and update it for the files in the folder name.
        """
        utils.Log.log("instantiate IndexModule class")
        # option: will decide whether index is used for folder/files or urls
        self.inverted_index = {}  # to contain the inverted index data structure
        self.file_mapping = {}    # to contain the mapping of document id of file with its path and metadata

        # Check is data is already present
        self.inverted_index, self.file_mapping = Storage.retrieve()
 def clean():
     # TODO need to be recorded
     utils.Log.enter()
     Storage.clean()
     utils.Log.exit()