コード例 #1
0
def makeModFile(co: str, cocap: str, 
                wash: bool, vers: bool,
                modFilePan: str):
    """ make the .md file for the mod """
    w = ("w" if wash else "")
    v = ("v" if vers else "")
    washVersStr = w + v
    if washVersStr:
        washVersStr = "_" + washVersStr
    cowv = co + washVersStr  
    washNot = (" " if wash else "not ")
    versNot = (" " if vers else "not ")
    
    TREATY_STRS = {
        "":    "No treaties",    
        "_w": "Washington Treaty",    
        "_v": "Versailles Treaty",    
        "_wv": "Washington+Versailles Treaties",           
    } 
    wPlusV = TREATY_STRS[washVersStr]
    modFileData = form(MOD_FILE_TEMPLATE,
        cowv = cowv,
        cocap = cocap,
        wPlusV = wPlusV,
        washNot = washNot,
        versNot = versNot,
    )    
    prn("Writing <{}>...", modFilePan)
    butil.writeFile(modFilePan, modFileData)
コード例 #2
0
def readModLog() -> ModLog:
    """ read the modlog file """
    if butil.fileExists(MODLOG_PN):
        mlStr = butil.readFile(MODLOG_PN)
        ml = json.loads(mlStr)
        return ml
    else:
        prn("Mod log file <%s> doe not exist.", MODLOG_PN)
        return []
コード例 #3
0
def makeMod(co: str, cocap: str, wash: bool, vers: bool):
    """ make a modiification 
    co = country name (all lower case)
    cocap = country name, capitalised
    wash = is Washington Naval Treaty in force?
    vers = os Versailles Treaty in force?
    """
    washVersStr = (""
        + ("w" if wash else "")
        + ("v" if vers else ""))
    if washVersStr:
        washVersStr = "_" + washVersStr
        
    fnStub = "hist1922_" + co + washVersStr
    fn = fnStub + ".md"
    prn("{}: making file <{}>", cocap, fn)
    modFilePan = butil.join(MODS_DIR, fn)
    if butil.fileExists(modFilePan):
        prn("**** File <{}> exists, aborting ****", modFilePan)
        return
    
    makeModFile(co, cocap, wash, vers, modFilePan)
    makeModDir(fnStub)
コード例 #4
0
def makeModDir(fnStub):
    """ make the top directory of the mod """
    modDir = butil.join(MODS_DIR, fnStub, "Save")
    prn("Creating dir <{}/>...", modDir)
    butil.createDir(modDir)
コード例 #5
0
def main():
    prn("mk1922mods = make mods for 1922 start")
    for co, cocap in COUNTRIES:
        for wash in [False, True]:
            for vers in [False, True]:
                makeMod(co, cocap, wash, vers)