Skip to content

Commit d771e26

Browse files
committed
FFF inline diff dir
Note we don't need to cacluylate this for autotags at all - saves some performance
1 parent 4082cf6 commit d771e26

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

Mopy/bash/basher/__init__.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@
7878
attrgetter_cache, deprint, dict_sort, fast_cached_property, \
7979
forward_compat_path_to_fn, round_size, str_to_sig, to_unix_newlines, \
8080
to_win_newlines, top_level_files
81-
from ..bosh import ModInfo, omods, DataStore, diff_tags, read_loot_tags, \
82-
read_dir_tags, save_tags_to_dir
81+
from ..bosh import ModInfo, omods, DataStore, read_loot_tags, read_dir_tags, \
82+
save_tags_to_dir
8383
from ..exception import BoltError, CancelError, SkipError, UnknownListener
8484
from ..gui import CENTER, BusyCursor, Button, CancelButton, CenteredSplash, \
8585
CheckListBox, Color, CopyOrMovePopup, DateAndTimeDialog, DropDown, \
@@ -1656,14 +1656,6 @@ def Execute(self):
16561656
_mod_details._refresh_tags()
16571657
# Copy tags to various places
16581658
bashTagsDesc = mod_info.getBashTagsDesc()
1659-
# We need to grab both the ones from the description and from LOOT,
1660-
# since we need to save a diff in case of Copy to BashTags
1661-
added_tags, deleted_tags = read_loot_tags(mod_info)
1662-
# Emulate the effects of applying the LOOT tags
1663-
old_tags = bashTagsDesc.copy()
1664-
old_tags |= added_tags
1665-
old_tags -= deleted_tags
1666-
dir_diff = diff_tags(mod_tags, old_tags)
16671659
class Tags_CopyTagList(AppendableLink, ItemLink):
16681660
_text = _('Copy Tag List')
16691661
_help = _('Copies a list of all bash tags for this game to the '
@@ -1681,10 +1673,16 @@ class Tags_CopyToBashTags(EnabledLink):
16811673
'description/LOOT tags to %(bashtags_path)s.') % {
16821674
'bashtags_path': mod_info.tags_path()}
16831675
def _enable(self):
1684-
return (not mod_info.mod_auto_bash_tags and
1685-
read_dir_tags(mod_info) != dir_diff)
1676+
if mod_info.mod_auto_bash_tags: return False
1677+
# We need to grab both the ones from the description and from
1678+
# LOOT, to calculate the diff with automatic tags
1679+
added_tags, deleted_tags = read_loot_tags(mod_info)
1680+
# Emulate the effects of applying the LOOT tags
1681+
auto_tags = (bashTagsDesc | added_tags) - deleted_tags
1682+
self._add_rem = mod_tags - auto_tags, auto_tags - mod_tags
1683+
return read_dir_tags(mod_info) != self._add_rem
16861684
def Execute(self):
1687-
save_tags_to_dir(mod_info, dir_diff)
1685+
save_tags_to_dir(mod_info, self._add_rem)
16881686
class Tags_CopyToDescription(EnabledLink):
16891687
"""Copy manually assigned bash tags into the mod description"""
16901688
_text = _('Copy to Description')

Mopy/bash/bosh/__init__.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,14 +293,12 @@ def read_dir_tags(mod_info, ci_bt_filenames=None):
293293
return *map(_process_tags, (added, removed)),
294294

295295
def save_tags_to_dir(mod_info, plugin_tag_diff): # one use!
296-
"""Compares plugin_tags to plugin_old_tags and saves the diff to
296+
"""Accepts the diff of current mod_info tags to what would be applied by
297+
its description and the LOOT masterlist / userlist and saves the diff to
297298
Data/BashTags/PLUGIN_NAME.txt.
298299
299300
:param mod_info: The plugin info to modify the tag file for.
300-
:param plugin_tag_diff: A tuple of two sets, as returned by diff_tags,
301-
representing a diff of all bash tags currently applied to the
302-
plugin in question vs. all bash tags applied to the plugin
303-
by its description and the LOOT masterlist / userlist.."""
301+
:param plugin_tag_diff: A tuple of two sets, (added_tags, removed_tags)."""
304302
bass.dirs['tag_files'].makedirs()
305303
tag_file = mod_info.tags_path()
306304
# Calculate the diff and ignore the minus when sorting the result
@@ -316,10 +314,6 @@ def save_tags_to_dir(mod_info, plugin_tag_diff): # one use!
316314
'wb_version': bass.AppVersion})
317315
out.write(', '.join(processed_diff) + '\n')
318316

319-
def diff_tags(plugin_new_tags, plugin_old_tags):
320-
"""Returns two sets, the first containing all added tags and the second all
321-
removed tags."""
322-
return plugin_new_tags - plugin_old_tags, plugin_old_tags - plugin_new_tags
323317
#------------------------------------------------------------------------------
324318
class _TabledInfo:
325319
"""Stores some of its attributes in a pickled dict. Most of the (hacky)

0 commit comments

Comments
 (0)