/[wryebash]/branches/upstream-master/scripts/mktaglist.py
ViewVC logotype

Contents of /branches/upstream-master/scripts/mktaglist.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (show annotations) (download) (as text)
Mon Sep 19 03:20:26 2016 UTC (3 years, 9 months ago) by william
File MIME type: text/x-python
File size: 5443 byte(s)
add upstream git branches for dev and master
1 # -*- coding: utf-8 -*-
2 #
3 #===============================================================================
4 #
5 # Taglist Generator
6 #
7 # This script generates taglist.yaml files in Mopy\Bashed Patches\Oblivion and
8 # Mopy\Bashed Patches\Skyrim using the LOOT API and source masterlists. The
9 # masterlists must be named "masterlist.txt" or "masterlist.yaml" and put in the
10 # folders mentioned above, or be present in a LOOT install that was installed
11 # using its installer.
12 # To generate the taglist for a game, you must have the game installed. This
13 # script will generate taglists for all detected games.
14 #
15 # Usage:
16 # mktaglist.py
17 #
18 #===============================================================================
19
20 import sys
21 import os
22 import _winreg
23
24 sys.path.append('../Mopy/bash')
25
26 import loot
27
28 lootDir = u'../Mopy/bash/compiled'
29
30 # Detect games.
31 oblivionDir = None
32 skyrimDir = None
33 fallout3Dir = None
34 falloutNVDir = None
35
36 # Detect Oblivion.
37 try:
38 key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, u'Software\\Bethesda Softworks\\Oblivion', 0, _winreg.KEY_READ|_winreg.KEY_WOW64_32KEY)
39 value = _winreg.QueryValueEx(key,u'Installed Path')
40 if value[1] == _winreg.REG_SZ and os.path.exists(value[0]):
41 oblivionDir = value[0]
42 print u'Found Oblivion.'
43 except:
44 pass
45 #Detect Skyrim.
46 try:
47 key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, u'Software\\Bethesda Softworks\\Skyrim', 0, _winreg.KEY_READ|_winreg.KEY_WOW64_32KEY)
48 value = _winreg.QueryValueEx(key,u'Installed Path')
49 if value[1] == _winreg.REG_SZ and os.path.exists(value[0]):
50 skyrimDir = value[0]
51 print u'Found Skyrim.'
52 except:
53 pass
54
55 #Detect Fallout3.
56 try:
57 key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, u'Software\\Bethesda Softworks\\Fallout3', 0, _winreg.KEY_READ|_winreg.KEY_WOW64_32KEY)
58 value = _winreg.QueryValueEx(key,u'Installed Path')
59 if value[1] == _winreg.REG_SZ and os.path.exists(value[0]):
60 fallout3Dir = value[0]
61 print u'Found Fallout3.'
62 except:
63 pass
64
65 #Detect FalloutNV.
66 try:
67 key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, u'Software\\Bethesda Softworks\\FalloutNV', 0, _winreg.KEY_READ|_winreg.KEY_WOW64_32KEY)
68 value = _winreg.QueryValueEx(key,u'Installed Path')
69 if value[1] == _winreg.REG_SZ and os.path.exists(value[0]):
70 falloutNVDir = value[0]
71 print u'Found FalloutNV.'
72 except:
73 pass
74
75 # Masterlist paths
76 oblivionMlist = None
77 skyrimMlist = None
78 fallout3Mlist = None
79 falloutNVMlist = None
80
81 # Detect a LOOT install.
82 localAppData = os.path.join(os.environ["LOCALAPPDATA"], 'LOOT')
83 if os.path.exists(localAppData):
84 if oblivionDir and os.path.exists(os.path.join(localAppData, 'Oblivion')):
85 oblivionMlist = os.path.join(localAppData, 'Oblivion', 'masterlist.yaml')
86 if skyrimDir and os.path.exists(os.path.join(localAppData, 'Skyrim')):
87 skyrimMlist = os.path.join(localAppData, 'Skyrim', 'masterlist.yaml')
88 if fallout3Dir and os.path.exists(os.path.join(localAppData, 'Fallout3')):
89 fallout3Mlist = os.path.join(localAppData, 'Fallout3', 'masterlist.yaml')
90 if falloutNVDir and os.path.exists(os.path.join(localAppData, 'FalloutNV')):
91 falloutNVMlist = os.path.join(localAppData, 'FalloutNV', 'masterlist.yaml')
92 else:
93 raise Exception("No LOOT install found.")
94
95
96 # Load the LOOT API.
97 loot.Init(lootDir)
98 if loot.LootApi:
99 print u'Loaded the LOOT API from "%s", version %s.' % (lootDir, loot.version)
100 else:
101 raise Exception("Couldn't load LOOT API.")
102
103 if oblivionMlist:
104 # Convert Oblivion masterlist.
105 print u'Getting masterlist from %s' % oblivionMlist
106 taglistDir = u'../Mopy/Bash Patches/Oblivion/taglist.yaml'
107 if os.path.exists(oblivionMlist):
108 lootDb = loot.LootDb(oblivionDir,loot.loot_game_tes4)
109 lootDb.PlainLoad(oblivionMlist)
110 lootDb.DumpMinimal(taglistDir,True)
111 print u'Oblivion masterlist converted.'
112 else:
113 print u'Error: Oblivion masterlist not found.'
114
115 if skyrimMlist:
116 # Convert Skyrim masterlist.
117 print u'Getting masterlist from %s' % skyrimMlist
118 taglistDir = u'../Mopy/Bash Patches/Skyrim/taglist.yaml'
119 if os.path.exists(skyrimMlist):
120 lootDb = loot.LootDb(skyrimDir,loot.loot_game_tes5)
121 lootDb.PlainLoad(skyrimMlist)
122 lootDb.DumpMinimal(taglistDir,True)
123 print u'Skyrim masterlist converted.'
124 else:
125 print u'Error: Skyrim masterlist not found.'
126
127 if fallout3Mlist:
128 # Convert Fallout 3 masterlist.
129 print u'Getting masterlist from %s' % fallout3Mlist
130 taglistDir = u'../Mopy/Bash Patches/Fallout 3/taglist.yaml'
131 if os.path.exists(fallout3Mlist):
132 lootDb = loot.LootDb(fallout3Dir,loot.loot_game_fo3)
133 lootDb.PlainLoad(fallout3Mlist)
134 lootDb.DumpMinimal(taglistDir,True)
135 print u'Fallout 3 masterlist converted.'
136 else:
137 print u'Error: Fallout 3 masterlist not found.'
138
139 if falloutNVMlist:
140 # Convert Fallout New Vegas masterlist.
141 print u'Getting masterlist from %s' % falloutNVMlist
142 taglistDir = u'../Mopy/Bash Patches/Fallout New Vegas/taglist.yaml'
143 if os.path.exists(falloutNVMlist):
144 lootDb = loot.LootDb(falloutNVDir,loot.loot_game_fonv)
145 lootDb.PlainLoad(falloutNVMlist)
146 lootDb.DumpMinimal(taglistDir,True)
147 print u'Fallout New Vegas masterlist converted.'
148 else:
149 print u'Error: Fallout New Vegas masterlist not found.'
150
151 print u'Taglist generator finished.'

  ViewVC Help
Powered by ViewVC 1.1.22