Skip to content

Commit

Permalink
Corrections in renaming markers:
Browse files Browse the repository at this point in the history
See:
http://forums.bethsoft.com/topic/1604190-wrye-bash-thread-110/page-3#entry25188212

- allow arbitrary characters in marker names
- drop "extension" processing in marker names

Under #259.
  • Loading branch information
Utumno committed Sep 10, 2016
1 parent 560435c commit 4a5c1dd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
32 changes: 12 additions & 20 deletions Mopy/bash/basher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2143,18 +2143,10 @@ def set_item_format(self, item, item_format):

def OnBeginEditLabel(self,event):
"""Start renaming installers"""
to_rename = self.GetSelected()
#--Only rename multiple items of the same type
firstItem = self.data_store[self.GetSelected()[0]]
if isinstance(firstItem,bosh.InstallerMarker):
installer_type = bosh.InstallerMarker
elif isinstance(firstItem,bosh.InstallerArchive):
installer_type = bosh.InstallerArchive
elif isinstance(firstItem,bosh.InstallerProject):
installer_type = bosh.InstallerProject
else:
event.Veto()
return
for item in self.GetSelected():
installer_type = type(self.data_store[to_rename[0]])
for item in to_rename[1:]:
if not isinstance(self.data_store[item], installer_type):
event.Veto()
return
Expand All @@ -2176,26 +2168,26 @@ def OnEditLabelChar(self, event):
"""For pressing F2 on the edit box for renaming"""
if event.GetKeyCode() == wx.WXK_F2:
editbox = self._gList.GetEditControl()
selection = editbox.GetSelection()
# (start, stop), if start==stop there is no selection
selection_span = editbox.GetSelection()
text = editbox.GetValue()
lenWithExt = len(text)
if selection[0] != 0:
selection = (0,lenWithExt)
selectedText = GPath(text[selection[0]:selection[1]])
if selection_span[0] != 0:
selection_span = (0,lenWithExt)
selectedText = GPath(text[selection_span[0]:selection_span[1]])
textNextLower = selectedText.body
if textNextLower == selectedText:
lenNextLower = lenWithExt
else:
lenNextLower = len(textNextLower.s)

selected = self.data_store[self.GetSelected()[0]]
if isinstance(selected, bosh.InstallerArchive):
selection = (0, lenNextLower)
selection_span = (0, lenNextLower)
elif isinstance(selected, bosh.InstallerMarker):
selection = (2, lenWithExt-2)
selection_span = (2, lenWithExt - 2)
else:
selection = (0, lenWithExt)
editbox.SetSelection(*selection)
selection_span = (0, lenWithExt)
editbox.SetSelection(*selection_span)
else:
event.Skip()

Expand Down
4 changes: 2 additions & 2 deletions Mopy/bash/bosh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5348,6 +5348,7 @@ class InstallerMarker(Installer):
Currently only used for the '==Last==' marker"""
__slots__ = tuple() #--No new slots
type_string = _(u'Marker')
reValidNamePattern = re.compile(ur'^(.+?)(\d*)$', re.I | re.U)

def __init__(self,archive):
Installer.__init__(self,archive)
Expand All @@ -5373,8 +5374,7 @@ def install(self,name,destFiles,data_sizeCrcDate,progress=None):

def renameInstaller(self, archive, root, numStr, data):
installer = data[archive]
newName = GPath(
u'==' + root.strip(u'=') + numStr + archive.ext + u'==')
newName = GPath(u'==' + root.strip(u'=') + numStr + u'==')
if newName == archive:
return False
#--Add the marker to Bash and remove old one
Expand Down

0 comments on commit 4a5c1dd

Please sign in to comment.