Skip to content

Commit 29e404c

Browse files
InfernioSharlikran
authored andcommitted
WIP: Use FileInfo.get_masters() where possible
Note: This relies on the cosaves rework, specifically the 'cosaves.py - beta' commit and the 'correct save masters' commit. Much easier to find the definition and search usages for than the previous '.header.masters' code, which is now only used where necessary. Will also allow us to be much more flexible in the future if masters become more complex than that. Obviously touches a ton of places, so WIP, but it shouldn't have any functional impacts.
1 parent f13ded3 commit 29e404c

8 files changed

Lines changed: 29 additions & 29 deletions

File tree

Mopy/bash/basher/mod_links.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def Execute(self):
114114
to_refresh = []
115115
# creates esp files - so place them correctly after the last esm
116116
previous_master = bosh.modInfos.cached_lo_last_esm()
117-
for master in self._selected_info.header.masters:
117+
for master in self._selected_info.get_masters():
118118
if master in bosh.modInfos:
119119
continue
120120
# Missing master, create a dummy plugin for it
@@ -713,7 +713,7 @@ def Execute(self):
713713
loOrder = lambda tup: load_order.cached_lo_index_or_max(tup[0])
714714
text_list = u''
715715
for mod, info in sorted(modInfos.items(), key=loOrder):
716-
if self._selected_item in info.header.masters:
716+
if self._selected_item in info.get_masters():
717717
hexIndex = modInfos.hexIndexString(mod)
718718
if hexIndex:
719719
prefix = bul + hexIndex
@@ -985,7 +985,7 @@ def _Execute(self):
985985
delinquent = collections.defaultdict(list)
986986
for mod in load_order.cached_active_tuple():
987987
if mod == self._selected_item: break
988-
for master in bosh.modInfos[mod].header.masters:
988+
for master in bosh.modInfos[mod].get_masters():
989989
if not load_order.cached_is_active(master):
990990
missing[mod].append(master)
991991
elif master not in previousMods:
@@ -1448,7 +1448,7 @@ def Execute(self):
14481448
return self._showError(_(
14491449
u"File must be selected from %s Data Files directory.")
14501450
% bush.game.fsName)
1451-
if name in self._selected_info.header.masters:
1451+
if name in self._selected_info.get_masters():
14521452
return self._showError(_(u"%s is already a master!") % name.s)
14531453
names.append(name)
14541454
# actually do the modification
@@ -1681,7 +1681,7 @@ def _initData(self, window, selection,
16811681
__reEspExt=re.compile(ur'\.esp(.ghost)?$', re.I | re.U)):
16821682
super(Mod_FlipMasters, self)._initData(window, selection)
16831683
self._text = _(u'Esmify Masters')
1684-
masters = self._selected_info.header.masters
1684+
masters = self._selected_info.get_masters()
16851685
enable = len(selection) == 1 and len(masters) > 1
16861686
self.espMasters = [master for master in masters
16871687
if __reEspExt.search(master.s)] if enable else []
@@ -2620,7 +2620,7 @@ def Execute(self):
26202620
return self._showError(_(
26212621
u"File must be selected from %s Data Files directory.")
26222622
% bush.game.fsName)
2623-
if name in modInfo.header.masters:
2623+
if name in modInfo.get_masters():
26242624
return self._showError(
26252625
name.s + u' ' + _(u"is already a master."))
26262626
names.append(name)

Mopy/bash/bosh/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ def hasActiveTimeConflict(self):
690690
def hasBadMasterNames(self):
691691
"""True if has a master with un unencodable name in cp1252."""
692692
try:
693-
for x in self.header.masters: x.s.encode('cp1252')
693+
for x in self.get_masters(): x.s.encode('cp1252')
694694
return False
695695
except UnicodeEncodeError:
696696
return True
@@ -1026,7 +1026,7 @@ def write_masters(self):
10261026
self.abs_path.untemp()
10271027
#--Cosaves
10281028
master_map = dict((x.s, y.s) for x, y in
1029-
zip(oldMasters, self.header.masters) if x != y)
1029+
zip(oldMasters, self.get_masters()) if x != y)
10301030
if master_map:
10311031
#--Pluggy cosave?
10321032
if bush.game.has_standalone_pluggy:
@@ -2140,7 +2140,7 @@ def getModList(self,showCRC=False,showVersion=True,fileInfo=None,wtxt=False):
21402140
_(u'----> Delinquent MASTER: '),
21412141
u'**')
21422142
if fileInfo:
2143-
masters = set(fileInfo.header.masters)
2143+
masters = set(fileInfo.get_masters())
21442144
missing = sorted([x for x in masters if x not in self])
21452145
log.setHeader(head+_(u'Missing Masters for %s: ') % fileInfo.name.s)
21462146
for mod in missing:
@@ -2175,7 +2175,7 @@ def getModList(self,showCRC=False,showVersion=True,fileInfo=None,wtxt=False):
21752175
text +=_(u' [CRC: %s]') % (self[name].crc_string())
21762176
log(text)
21772177
if name in masters:
2178-
for master2 in self[name].header.masters:
2178+
for master2 in self[name].get_masters():
21792179
if master2 not in self:
21802180
log(sMissing+master2.s)
21812181
elif load_order.get_ordered((name, master2))[1] == master2:
@@ -2266,7 +2266,7 @@ def lo_activate(self, fileName, doSave=True, _modSet=None, _children=None,
22662266
# Disabled for now
22672267
##if self[fileName].hasBadMasterNames():
22682268
## return
2269-
for master in self[fileName].header.masters:
2269+
for master in self[fileName].get_masters():
22702270
if master in _modSet: self.lo_activate(master, False, _modSet,
22712271
_children, _activated)
22722272
#--Select in plugins
@@ -2293,7 +2293,7 @@ def lo_deactivate(self, fileName, doSave=True):
22932293
def _children(parent):
22942294
for selFile in sel:
22952295
if selFile in children: continue # if no more => no more in sel
2296-
for master in self[selFile].header.masters:
2296+
for master in self[selFile].get_masters():
22972297
if master == parent:
22982298
children.add(selFile)
22992299
break

Mopy/bash/bosh/_mergeability.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def isPBashMergeable(modInfo, minfos, reasons):
112112
break
113113
if newblocks: reasons.append(_(u'New record(s) in block(s): ')+u', '.join(sorted(newblocks))+u'.')
114114
dependent = [name.s for name, info in minfos.iteritems()
115-
if not info.isBP() and modInfo.name in info.header.masters]
115+
if not info.isBP() and modInfo.name in info.get_masters()]
116116
if dependent:
117117
if not verbose: return False
118118
reasons.append(_(u'Is a master of mod(s): ')+u', '.join(sorted(dependent))+u'.')
@@ -197,7 +197,7 @@ def _modIsMergeableLoad(modInfo, minfos, reasons):
197197
reasons.append(_(u'New record(s) in block(s): %s.') % u', '.join(sorted(newblocks)))
198198
# dependent mods mergeability should be determined BEFORE their masters
199199
dependent = [name.s for name, info in minfos.iteritems() if
200-
not info.isBP() and modInfo.name in info.header.masters
200+
not info.isBP() and modInfo.name in info.get_masters()
201201
and name not in minfos.mergeable]
202202
if dependent:
203203
if not verbose: return False

Mopy/bash/bosh/mods_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ def checkMods(self, showModList=False, showRuleSets=False, showNotes=False,
515515
previousMods = set()
516516
for mod in load_order.cached_active_tuple():
517517
loggedMod = False
518-
for master in modInfos[mod].header.masters:
518+
for master in modInfos[mod].get_masters():
519519
if master not in active:
520520
label = _(u'MISSING')
521521
elif master not in previousMods:

Mopy/bash/parsers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def __init__(self,aliases=None):
6464
def readFactionEids(self,modInfo):
6565
"""Extracts faction editor ids from modInfo and its masters."""
6666
loadFactory = LoadFactory(False,MreRecord.type_class['FACT'])
67-
for modName in (modInfo.header.masters + [modInfo.name]):
67+
for modName in (modInfo.get_masters() + [modInfo.name]):
6868
if modName in self.gotFactions: continue
6969
modFile = ModFile(bosh.modInfos[modName],loadFactory)
7070
modFile.load(True)
@@ -304,7 +304,7 @@ def readFromMod(self,modInfo):
304304
"""Imports actor level data from the specified mod and its masters."""
305305
mod_id_levels, gotLevels = self.mod_id_levels, self.gotLevels
306306
loadFactory = LoadFactory(False,MreRecord.type_class['NPC_'])
307-
for modName in (modInfo.header.masters + [modInfo.name]):
307+
for modName in (modInfo.get_masters() + [modInfo.name]):
308308
if modName in gotLevels: continue
309309
modFile = ModFile(bosh.modInfos[modName],loadFactory)
310310
modFile.load(True)
@@ -823,7 +823,7 @@ def __init__(self,aliases=None):
823823
def readFactionEids(self,modInfo):
824824
"""Extracts faction editor ids from modInfo and its masters."""
825825
loadFactory = LoadFactory(False,MreRecord.type_class['FACT'])
826-
for modName in (modInfo.header.masters + [modInfo.name]):
826+
for modName in (modInfo.get_masters() + [modInfo.name]):
827827
if modName in self.gotFactions: continue
828828
modFile = ModFile(bosh.modInfos[modName],loadFactory)
829829
modFile.load(True)

Mopy/bash/patcher/patchers/importers.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def initData(self, progress):
8686
if srcMod not in bosh.modInfos: continue
8787
srcInfo = bosh.modInfos[srcMod]
8888
srcFile = ModFile(srcInfo,loadFactory)
89-
masters = srcInfo.header.masters
89+
masters = srcInfo.get_masters()
9090
srcFile.load(True)
9191
srcFile.convertToLongFids(longTypes)
9292
mapper = srcFile.getLongMapper()
@@ -334,7 +334,7 @@ def checkMasterCellBlockData(cellBlock):
334334
srcFile.load(True)
335335
srcFile.convertToLongFids(('CELL','WRLD'))
336336
cachedMasters[srcMod] = srcFile
337-
masters = srcInfo.header.masters
337+
masters = srcInfo.get_masters()
338338
bashTags = srcInfo.getBashTags()
339339
# print bashTags
340340
tags = bashTags & set(self.recAttrs)
@@ -818,7 +818,7 @@ def initData(self,progress):
818818
if srcMod not in bosh.modInfos: continue
819819
srcInfo = bosh.modInfos[srcMod]
820820
srcFile = ModFile(srcInfo,loadFactory)
821-
masters = srcInfo.header.masters
821+
masters = srcInfo.get_masters()
822822
srcFile.load(True)
823823
srcFile.convertToLongFids(longTypes)
824824
mapper = srcFile.getLongMapper()
@@ -1077,7 +1077,7 @@ def initData(self,progress):
10771077
if srcMod not in bosh.modInfos: continue
10781078
srcInfo = bosh.modInfos[srcMod]
10791079
srcFile = ModFile(srcInfo,loadFactory)
1080-
masters = srcInfo.header.masters
1080+
masters = srcInfo.get_masters()
10811081
bashTags = srcInfo.getBashTags()
10821082
srcFile.load(True)
10831083
srcFile.convertToLongFids(longTypes)
@@ -1746,7 +1746,7 @@ def initPatchFile(self, patchFile):
17461746
self.isActive = bool(self.srcs)
17471747
self.masters = set()
17481748
for srcMod in self.srcs:
1749-
self.masters |= set(bosh.modInfos[srcMod].header.masters)
1749+
self.masters |= set(bosh.modInfos[srcMod].get_masters())
17501750
self.allMods = self.masters | set(self.srcs)
17511751
self.mod_id_entries = {}
17521752
self.touched = set()
@@ -1980,7 +1980,7 @@ def initData(self,progress):
19801980
if srcMod not in bosh.modInfos: continue
19811981
srcInfo = bosh.modInfos[srcMod]
19821982
srcFile = ModFile(srcInfo,loadFactory)
1983-
masters = srcInfo.header.masters
1983+
masters = srcInfo.get_masters()
19841984
bashTags = srcInfo.getBashTags()
19851985
srcFile.load(True)
19861986
srcFile.convertToLongFids(longTypes)
@@ -2370,7 +2370,7 @@ def initData(self,progress):
23702370
temp_faceData = {}
23712371
faceInfo = bosh.modInfos[faceMod]
23722372
faceFile = ModFile(faceInfo,loadFactory)
2373-
masters = faceInfo.header.masters
2373+
masters = faceInfo.get_masters()
23742374
bashTags = faceInfo.getBashTags()
23752375
faceFile.load(True)
23762376
faceFile.convertToLongFids(('NPC_',))
@@ -3049,7 +3049,7 @@ def initData(self,progress):
30493049
if srcMod not in bosh.modInfos: continue
30503050
srcInfo = bosh.modInfos[srcMod]
30513051
srcFile = ModFile(srcInfo,loadFactory)
3052-
masters = srcInfo.header.masters
3052+
masters = srcInfo.get_masters()
30533053
srcFile.load(True)
30543054
srcFile.convertToLongFids(longTypes)
30553055
mapper = srcFile.getLongMapper()

Mopy/bash/patcher/patchers/races_multitweaks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ def initData(self,progress):
721721
srcInfo = bosh.modInfos[srcMod]
722722
srcFile = ModFile(srcInfo,loadFactory)
723723
srcFile.load(True)
724-
masters = srcInfo.header.masters
724+
masters = srcInfo.get_masters()
725725
bashTags = srcInfo.getBashTags()
726726
if 'RACE' not in srcFile.tops: continue
727727
srcFile.convertToLongFids(('RACE',))

Mopy/bash/patcher/patchers/special.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def scanModFile(self, modFile, progress):
126126
leveler in self.patchFile.allSet]
127127
self.delevMasters = set()
128128
for leveler in self.levelers:
129-
self.delevMasters.update(bosh.modInfos[leveler].header.masters)
129+
self.delevMasters.update(bosh.modInfos[leveler].get_masters())
130130
#--Begin regular scan
131131
modName = modFile.fileInfo.name
132132
modFile.convertToLongFids(self.listTypes)
@@ -536,7 +536,7 @@ def scanModFile(self, modFile, progress):
536536
leveler in self.patchFile.allSet]
537537
self.deflstMasters = set()
538538
for leveler in self.levelers:
539-
self.deflstMasters.update(bosh.modInfos[leveler].header.masters)
539+
self.deflstMasters.update(bosh.modInfos[leveler].get_masters())
540540
#--Begin regular scan
541541
modName = modFile.fileInfo.name
542542
modFile.convertToLongFids(self.listTypes)

0 commit comments

Comments
 (0)