def __init__(self, jsonFileIn, desiredGenA, desiredGenB, maxIterations,
                 desiredMainSet, desiredHopperSet):
        #check to see if json file exists, otherwise safely create one
        #in the folder specified by desiredFilePath, with the name
        #specified by desiredFileName
        if jsonFileExists(jsonFileIn):
            #the json file must be formatted as a dictionary with
            #the following keys: generatorA, generatorB, mainSet, hopperSet
            #, currentIterations
            self.groupDictFromJson = jsonIO.importCacheFile(jsonFileIn)
            keyList = self.groupDictFromJson.keys()
            if "generatorA" in keyList:
                self.generatorA = self.groupDictFromJson["generatorA"]
                print("genA from file:", self.generatorA)
            else:
                self.generatorA = desiredGenA
            if "generatorB" in keyList:
                self.generatorB = self.groupDictFromJson["generatorB"]
                print("genB from file:", self.generatorB)
            else:
                self.generatorB = desiredGenB
            if "mainSet" in keyList:
                #Sets do not serialize to json files,
                #so we convert into a set for speedy membership checking
                #We must convert to a tuple first so  it can be hashed for the set
                self.mainSet = set(
                    tuple(
                        tuple(element)
                        for element in self.groupDictFromJson["mainSet"]))
            else:
                self.mainSet = desiredMainSet
            if "hopperSet" in keyList:
                self.hopperSet = set(
                    tuple(
                        tuple(element)
                        for element in self.groupDictFromJson["hopperSet"]))
            else:
                self.hopperSet = {
                    unnamedIteratorFunction(self.generatorA, self.generatorB)
                }
                print("groupyGroup.hopperSet:", self.hopperSet)
            self.currentIterations = 0

        else:
            with io.open(jsonFileIn, 'w') as jsonFile:
                self.currentJsonFile = jsonFile
                #Put the empty set in new json file to prevent a json null error
                json.dump("{}", jsonFile)
            self.generatorA = desiredGenA
            self.generatorB = desiredGenB
            self.mainSet = desiredMainSet
            self.hopperSet = {
                unnamedIteratorFunction(self.generatorA, self.generatorB)
            }
            print("groupyGroup.hopperSet:", self.hopperSet)
            self.currentIterations = 0

        self.maxIterations = maxIterations
 def __init__(self, jsonFile):
     #Check to see if named json file exists, if so import
     # its contained list of cyclic groups to cyclicGroupDict
     # if not, initialize cyclicGroupDict to the empty dictionary.
     if jsonFileExists(jsonFile):
         #the json file must be formatted as a dictionary with
         #the following keys: generatorA, generatorB, mainSet, hopperSet
         #, currentIterations
         self.cyclicGroupDict = jsonIO.importCacheFile(jsonFile)
     else:
         with io.open(jsonFile, 'w') as jsonFile:
             self.currentJsonFile = jsonFile
             #Put the empty set in new json file to prevent a json null error
             json.dump({}, jsonFile)
         self.cyclicGroupDict = {}
def main():
    if "--jsonFilePath" in sys.argv or "-j" in sys.argv:
        local_data_base_path = sys.argv[sys.argv.index("--jsonFilePath") + 1]
    else:
        local_data_base_path = 'twoism_post_counts.json'

    post_threshold = 10

    url = 'https://www.twoism.org/forum/viewforum.php?f=2&sid=603a39aa00d97c8f3546fc10b38bb8f8'

    page = requests.get(url)

    soup = BeautifulSoup(page.content, 'lxml')

    results = soup.body
    #print(results)

    contents = results.find(
        'div',
        id='wrap').find(id='page-body').find_all(class_='forumbg')[1].find_all(
            class_='topics')[0].find_all(class_='row')
    #print("contents:",contents)

    posts_by_topic = {}

    for topic in contents:

        # print("topic:", topic.dl.dd.contents[0])
        posts_by_topic[topic.dl.a.string] = int(topic.dl.dd.contents[0])

    if json_file_exists(local_data_base_path):
        dict_from_json = jsonIO.importCacheFile(local_data_base_path)
    else:
        dict_from_json = posts_by_topic
    print("posts_by_topic:", posts_by_topic)

    total_new_post_count = 0
    for topic_link in posts_by_topic:
        if topic_link in dict_from_json:
            total_new_post_count += posts_by_topic[
                topic_link] - dict_from_json[topic_link]

    #if total_new_post_count > post_threshold:
    # send_notification()
    jsonIO.exportCacheFile(local_data_base_path, posts_by_topic)
    print("total_new_post_count:", total_new_post_count)