|
# Python script that just writes the latest version in the meta.ini file of MO2 to version |
|
import sys |
|
from configparser import ConfigParser |
|
from pathlib import Path |
|
from typing import Literal |
|
|
|
|
|
def color(string: str, mode: Literal["green", "red", "yellow", "cyan"]): |
|
esc_char = "\033" |
|
color_reset = "[0m" |
|
colors = {"cyan": "[36m", "green": "[32m", "red": "[31m", "yellow": "[33m"} |
|
|
|
return f"{esc_char}{colors[mode]}{string}{esc_char}{color_reset}" |
|
|
|
|
|
def update_meta_version(dir: Path): |
|
config = ConfigParser() |
|
# This code is lint error, but it's code is correct. |
|
config.optionxform = str # Enable preserve case. |
|
|
|
print(f" DirName: {Path(dir).name}") |
|
|
|
try: |
|
config.read(f"{dir}/meta.ini", encoding="utf-8") |
|
except Exception: |
|
try: |
|
config.read( |
|
f"{dir}/meta.ini" |
|
) # In jp environment, default encoding is ShiftJS |
|
except Exception as e: |
|
print( |
|
color(" Error: Failed to read `meta.ini`.", "red"), |
|
e, |
|
end="\n\n", |
|
) |
|
return |
|
|
|
if "General" not in config.keys(): |
|
print(color(" Error: No General section.", "red"), end="\n\n") |
|
return |
|
|
|
if "version" not in config["General"].keys(): |
|
version = color("None.", "red") |
|
|
|
else: |
|
version = config["General"]["version"] |
|
|
|
# NOTE: This is the code to fix the error that version is not updated due to a flag error. |
|
# config["General"]["nexusFileStatus"] = "1" |
|
# with open(f"{dir}/meta.ini", "w", encoding="utf-8") as configfile: |
|
# config.write(configfile) |
|
# print(color(" Info: Writ file", "green")) |
|
|
|
latest_version = "" |
|
if "newestVersion" not in config["General"].keys(): |
|
latest_version = color("None", "red") |
|
else: |
|
latest_version = config["General"]["newestVersion"] |
|
|
|
print(f" Old version: {version}") |
|
print(f"Latest version: {latest_version}") |
|
|
|
if latest_version == "": |
|
print( |
|
color(" Warn: Skip update. Not found latest.", "yellow"), |
|
end="\n\n", |
|
) |
|
return |
|
|
|
if version != latest_version: |
|
config["General"]["version"] = latest_version |
|
with open(f"{dir}/meta.ini", "w", encoding="utf-8") as configfile: |
|
config.write(configfile) |
|
print(color(" Ok: Updated.", "green")) |
|
else: |
|
print(color(" Info: No need update. This is latest", "cyan")) |
|
|
|
|
|
def main(): |
|
default_path = "D:/GAME/ModOrganizer Skyrim SE/mods" |
|
search_path = Path(sys.argv[1] if len(sys.argv) > 1 else default_path) |
|
|
|
if not search_path.exists(): |
|
print(color(" Error: Specified path does not exist.", "red")) |
|
sys.exit(1) |
|
|
|
dirs = [x for x in search_path.iterdir() if x.is_dir()] |
|
|
|
for dir in dirs: |
|
# try: |
|
print("") |
|
update_meta_version(dir) |
|
# except Exception as e: |
|
# print(color(" Error:", "red"), e, end="\n\n") |
|
# continue |
|
|
|
|
|
if __name__ == "__main__": |
|
main() |
|
input("Press any key.") |
DAR(条件分岐でアニメーションが変化するSKSEplugin)とNemesis(アニメーション一元管理外部ツール)併用時
DAR, Nemesisを必要とするModをインストール、アンインストールした場合必ず以下を行う
Nemesisが実行できないとき
起動ファイルのパスが間違っている場合は実行ファイルの設定に行く
![2022-12-27 (2)](https://user-images.githubusercontent.com/68905624/209667791-57fdb2a6-58b3-4f76-a674-fe98d57f7203.png)
パスを修正する(デフォルトパス:
![2022-12-27 (3)](https://user-images.githubusercontent.com/68905624/209667913-b39b8a03-60af-4239-9ec2-7a7d69d0bc58.png)
ModOrganizer Skyrim SE\mods\Nemesis Unlimited Behavior Engine FINSに代わる新しいSkyrim挙動フレームワーク\Nemesis_Engine\Nemesis Unlimited Behavior Engine.exe
)