Created
March 22, 2015 20:44
-
-
Save pnw/eec67c1a3868acf838f5 to your computer and use it in GitHub Desktop.
Script to automatically unpack Civ 5 mods on Macs
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
""" | |
Simply automates the process of converting the raw steam downloads into unzipped directories. | |
See: http://forums.civfanatics.com/showthread.php?t=477763 | |
Requirements: p7zip | |
Installing p7zip: http://superuser.com/questions/548349/how-can-i-install-7zip-so-i-can-run-it-from-terminal-on-os-x | |
""" | |
import os | |
from subprocess import call | |
homedir = os.path.expanduser('~') | |
userdata_path = os.path.join(homedir, 'Library', 'Application Support', 'Steam', 'userdata') | |
if not os.path.isdir(userdata_path): | |
raise RuntimeError('Could not find the userdata directory') | |
modsdir = os.path.join(homedir, 'Documents', 'Aspyr', 'Sid Meier\'s Civilization 5', 'MODS') | |
if not os.path.isdir(modsdir): | |
raise RuntimeError('Invalid MODS dir') | |
def main(): | |
# find all the mods in the userdata directory | |
for path, dirs, files in os.walk(userdata_path): | |
for fname in files: | |
modname, ext = os.path.splitext(fname) | |
if ext == '.civ5mod': | |
# We have a mod file! | |
moddir = os.path.join(modsdir, modname) | |
if not os.path.exists(moddir): | |
absfname = os.path.join(path, fname) | |
call(['7z', 'x', absfname, '-o%s' % moddir]) | |
else: | |
print 'Mod already exists: ', modname | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment