예제 #1
0
def check_for_unused_OOB(path, output_file):
    originalpath = path
    #this creates a dict of all the oobs that exist
    oobdict = {}
    newoobdict = {}
    linedict = {}
    filedict = {}
    searchstrings = ['OOB = ', 'load_oob = ', 'oob = ']
    filterstrings = []
    thingstripped = 'oob'
    path = os.path.join(path, 'history', 'countries')
    finaldict = actually_check_for_unused_oob(originalpath, newoobdict)
    oobdict, linedict, filedict = create_search_dict(oobdict, linedict,
                                                     filedict, path,
                                                     searchstrings,
                                                     filterstrings,
                                                     thingstripped)
    path = os.path.join(originalpath, 'common', 'technologies')
    oobdict, linedict, filedict = create_search_dict(oobdict, linedict,
                                                     filedict, path,
                                                     searchstrings,
                                                     filterstrings,
                                                     thingstripped)
    oobdict, linedict, filedict = search_effects(oobdict, linedict, filedict,
                                                 originalpath, searchstrings,
                                                 filterstrings, thingstripped)
    for key in oobdict:
        #print(key)
        finaldict[key] = True
    for key in finaldict:
        if finaldict[key] == False:
            result = "The oob " + key + " is not used by anything.\n"
            #print(result)
            output_file.write(result)
예제 #2
0
def check_for_missing_OOB(path, output_file):
    originalpath = path
    #this creates a dict of all the oobs that are referenced
    oobdict = {}
    linedict = {}
    filedict = {}
    searchstrings = ['OOB = ', 'load_oob = ', 'oob = ']
    filterstrings = []
    thingstripped = 'oob'
    path = os.path.join(path, 'history', 'countries')
    oobdict, linedict, filedict = create_search_dict(oobdict, linedict,
                                                     filedict, path,
                                                     searchstrings,
                                                     filterstrings,
                                                     thingstripped)
    oobdict, linedict, filedict = search_effects(oobdict, linedict, filedict,
                                                 originalpath, searchstrings,
                                                 filterstrings, thingstripped)
    finaldict = actually_check_for_missing_oob(originalpath, oobdict)
    for key in finaldict:
        if finaldict[key] == False:
            result = "The oob " + key + " referenced in file " + filedict[
                key] + " on line " + str(linedict[key]) + " does not exist.\n"
            #print(result)
            output_file.write(result)
def check_ideologies(path, usesvanilla, output_file):
    debug = False
    ideologydict = {}
    linedict = {}
    filedict = {}
    defaultideologies = ['democratic', 'communism', 'fascism', 'neutrality']
    filterstrings = []
    thingstripped = 'ideology'
    searchstrings = ['ideology = ', 'has_government =', 'ruling_party = ']
    ideologydict, linedict, filedict = search_effects(ideologydict, linedict,
                                                      filedict, path,
                                                      searchstrings,
                                                      filterstrings,
                                                      thingstripped)
    ideologypath = os.path.join(path, 'common', 'ideologies')
    file = open_file(os.path.join(ideologypath, '00_ideologies.txt'))
    line = file.readline()
    depth = 0
    istypes = False
    ideologydict['ROOT'] = True
    if usesvanilla:
        for each in defaultideologies:
            ideologydict[each] = True
    while line:
        line = file.readline()
        if depth == 1 and '= {' in line:
            ideology = line.split(' = {')[0].strip()
            if debug is True:
                print(ideology)
            if ideology in ideologydict:
                ideologydict[ideology] = True
        if depth == 2 and 'types = {' in line:
            istypes = True
        if depth == 3 and '= {}' in line and istypes:
            ideology = line.split('= {}')[0].strip()
            if debug is True:
                print(ideology)
            if ideology in ideologydict:
                ideologydict[ideology] = True

        if '{' in line:
            depth = depth + 1
        if '}' in line:
            depth = depth - 1
        if depth == 2 and istypes:
            istypes = False
    for item in ideologydict:
        if ideologydict[item] is False:
            result = "The ideology " + item + " referenced in " + filedict[
                item] + " on line " + str(linedict[item]) + " is not defined"
            if debug is True:
                print(result)
            output_file.write(result)
예제 #4
0
def check_states(path, output_file):
    originalpath = path
    #this creates a dict of all the oobs that exist
    statedict = {}
    linedict = {}
    filedict = {}
    searchstrings = ['add_state_claim = ', 'owns_state = ', 'controls_state = ', 'transfer_state = ', 'add_state_core = ', 'state = ']
    filterstrings = []
    thingstripped = 'states'
    statedict, linedict, filedict =search_effects(statedict, linedict, filedict, originalpath, searchstrings, filterstrings, thingstripped)
    finaldict = create_state_dict(originalpath, statedict, output_file)
    for key in finaldict:
        if finaldict[key] == False:
            result = "State " + key + " referenced in " + filedict[key] + " on line " + str(linedict[key]) + " does not exist"
            #print(result)
            output_file.write(result)
예제 #5
0
def check_for_missing_General(path, output_file):
    originalpath = path
    #this creates a dict of all the generals that are referenced
    generaldict = {}
    linedict = {}
    filedict = {}
    searchstrings = ['has_unit_leader = ', 'remove_unit_leader =']
    filterstrings = []
    thingstripped = 'general'
    generaldict, linedict, filedict = search_effects(generaldict, linedict,
                                                     filedict, originalpath,
                                                     searchstrings,
                                                     filterstrings,
                                                     thingstripped)
    finaldict = actually_check_for_missing_general(originalpath, generaldict)
    for key in finaldict:
        if finaldict[key] == False:
            result = "The leader " + key + " referenced in file " + filedict[
                key] + " on line " + str(linedict[key]) + " does not exist.\n"
            #print(result)
            output_file.write(result)