Last active
December 2, 2020 20:44
-
-
Save treeherder/f909dcab32dc20643c77a71716a65746 to your computer and use it in GitHub Desktop.
first draft of a tool for working on steam workshop mods without having to sort through them by hand.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob, argparse, re | |
from collections import Counter | |
from pathlib import Path | |
class Mod_Checker: | |
def __init__(self): | |
arg_par = argparse.ArgumentParser(description='Print the names and corresponding file paths for mods in your workshop folder.') | |
arg_par.add_argument('path', metavar='P', type=str, | |
help='The filepath of the desired workshop folder.') | |
arg_par.add_argument('--name', dest='term', type=str, help='Search mods by name or partial match.') | |
arg_par.add_argument('--server', dest='dest_path', type=str, help='The directory where the dayz server runs.') | |
self.args = arg_par.parse_args() | |
realpath = Path(self.args.path) | |
self.metafiles = realpath.glob('**/meta.cpp') | |
self.list_of_mods = [] | |
def search_mod_names_and_IDs(self): | |
for metafile in self.metafiles: | |
with open(str.format('{0}', metafile)) as metacpp: | |
lines = metacpp.readlines() | |
workshop_ID = lines[1].split(';')[0].split('=')[-1] | |
workshop_name = lines[2].split(';')[0].split('=')[-1] | |
mod_listing = {'name':workshop_name, 'id':workshop_ID} | |
self.list_of_mods.append(mod_listing) | |
def query_list(self): | |
self.search_mod_names_and_IDs() | |
all_installed_mods = {item['name']:item['id'] for item in self.list_of_mods} | |
if self.args.term: | |
for mod_metas in all_installed_mods.items(): | |
if self.args.term.lower() in mod_metas[0].lower(): | |
print(mod_metas) | |
m = Mod_Checker() | |
m.query_list() | |
# E:/SteamLibrary/steamapps/workshop/content/221100/ | |
#change path to point from SteamLibrary directory level | |
#todo: create pipeline for checking upadates and moving / renaming files to the game server directory | |
#allow selection of mod from list returned by term search? | |
# flag for copying files | |
# copy keys | |
# daemon mode? | |
# --> | |
#find workshop files by searching the extant mod folders in the server directory | |
Author
treeherder
commented
Dec 2, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment