Esempio n. 1
0
    def onMenuHelpTips(self, evt):
        sTips = r'''Copy a directory path and open CellRename to start in that directory.

In Replace, for case-insensitive matching type "i:" before your query.

In Replace, to use regex, type "r:" before your query. Groups work, so "r:(\w+),(\w+)" to "\2,\1" will turn "first,second" into "second,first". '''
        wxutil.alertDialog(self,sTips,'Tips')
Esempio n. 2
0
 def onMenuEditNumber(self, evt):
     sFirst = wxutil.inputDialog(self, 'Rename into a sequence like 01, 02, 03, and so on. Please enter the first entry of the sequence (e.g. "1", or "001", or "42").','001')
     if not sFirst: return
     self.grid.writeToModel(self.data)
     ret = self.data.transformAppendNumber(sFirst)
     self.grid.loadFromModel(self.data)
     if ret!=True and ret: wxutil.alertDialog(self, str(ret))
Esempio n. 3
0
    def onMenuHelpAbout(self, evt):
        wxutil.alertDialog(
            self, '''cellrename: renaming files with a spreadsheet-like UI.
        
Ben Fisher, 2008, GPL
https://github.com/moltenform/labs_youthful_projects/tree/master/src/cellrename
https://moltenform.com/page/cellrename/doc/''', 'About')
Esempio n. 4
0
 def onSuffixOrPrefix(self, bPrefix):
     sAdded = wxutil.inputDialog(self, 'Add a '+('prefix' if bPrefix else 'suffix')+'.','')
     if not sAdded: return
     
     self.grid.writeToModel(self.data)
     ret = self.data.transformSuffixOrPrefix(bPrefix, sAdded)
     self.grid.loadFromModel(self.data)
     if ret!=True and ret: wxutil.alertDialog(self, str(ret))
Esempio n. 5
0
 def onMenuEditPattern(self, evt):
     sPattern = wxutil.inputDialog(self, 'Enter a naming pattern. The following can be used:/n/n/t%n=padded number (i.e. 001, 002)/n/t%N=number/n/t%f=file name/n/t%U=uppercase name/n/t%u=lowercase name'.
         replace('/n',os.linesep).replace('/t','     '),'%f')
     if not sPattern: return
     self.grid.writeToModel(self.data)
     ret = self.data.transformWithPattern(sPattern)
     self.grid.loadFromModel(self.data)
     if ret!=True and ret: wxutil.alertDialog(self, str(ret))
Esempio n. 6
0
 def alertRepair(self):
     wxutil.alertDialog(
         self,
         'It looks like renaming was not successful. When you click OK, the previous filenames will be placed in the clipboard. Please rename back to normal filenames before continuing, and then restart CellRename.',
         'Error')
     if self.undo_history and self.undo_history[1]:
         afrom = self.undo_history[1]
         s = os.linesep.join(afrom)
         wxutil.setClipboardText(s)
Esempio n. 7
0
    def onMenuHelpTips(self, evt):
        sTips = r'''Copy a directory path and open CellRename to start in that directory.

When replacing with regex, capture groups work:
replacing "(\w+),(\w+)" with "\2,\1" will turn "first,second" into "second,first". 

See also, the documentation at
https://github.com/moltenjs/labs_youthful_projects/tree/master/cellrename
'''
        wxutil.alertDialog(self, sTips, 'Tips')
Esempio n. 8
0
    def onSuffixOrPrefix(self, bPrefix):
        sAdded = wxutil.inputDialog(
            self, 'Add a ' + ('prefix' if bPrefix else 'suffix') + '.', '')
        if not sAdded:
            return

        self.grid.writeToModel(self.data)
        ret = self.data.transformSuffixOrPrefix(bPrefix, sAdded)
        self.grid.loadFromModel(self.data)
        if ret != True and ret:
            wxutil.alertDialog(self, str(ret))
Esempio n. 9
0
 def onMenuEditUndo(self, evt):
     # attempt to undo last rename
     if not self.undo_history:
         return
     sPrevdir, ato, afrom = self.undo_history # note reverse order, because rename to from
     if sPrevdir!=self.data.directory:
         wxutil.alertDialog(self, 'Cannot undo, first return to the directory.')
         return
     if not wxutil.alertDialog(self, 'Undo renaming these files?', 'Confirm', wx.OK|wx.CANCEL):
         return
     self.performRename(afrom, ato)
     self.menuobj_undo.Enable(False)
Esempio n. 10
0
    def onMenuHelpTips(self, evt):
        sTips = r'''Tips

Copy a directory path and open CellRename to start in that directory.

When replacing with regex, capture groups work:
replacing "(\w+),(\w+)" with "\2,\1" will turn "first,second" into "second,first". 

See also, the documentation at
https://github.com/moltenform/labs_youthful_projects/tree/master/src/cellrename
'''
        wxutil.alertDialog(self, sTips, 'Tips')
Esempio n. 11
0
    def onMenuEditPattern(self, evt):
        sPattern = wxutil.inputDialog(
            self,
            'Enter a naming pattern. The following can be used:/n/n/t%n=padded number (i.e. 001, 002)/n/t%N=number/n/t%f=file name/n/t%U=uppercase name/n/t%u=lowercase name/n/t%t=titlecase name'
            .replace('/n', os.linesep).replace('/t', '     '), '%f')
        if not sPattern:
            return

        self.grid.writeToModel(self.data)
        ret = self.data.transformWithPattern(sPattern)
        self.grid.loadFromModel(self.data)
        if ret != True and ret:
            wxutil.alertDialog(self, str(ret))
Esempio n. 12
0
    def onMenuEditNumber(self, evt):
        sFirst = wxutil.inputDialog(
            self,
            'Rename into a sequence like 01, 02, 03, and so on. Please enter the first entry of the sequence (e.g. "1", or "001", or "42").',
            '001')
        if not sFirst:
            return

        self.grid.writeToModel(self.data)
        ret = self.data.transformAppendNumber(sFirst)
        self.grid.loadFromModel(self.data)
        if ret != True and ret:
            wxutil.alertDialog(self, str(ret))
Esempio n. 13
0
 def performRename(self, afrom, ato):
     result = False
     try:
         result = cellrename_engine.renameFiles(self.data.directory, afrom, ato)
     except Exception:
         wxutil.alertDialog(self, 'Exception occurred: '+str(sys.exc_info()[0]))
         return
     
     if result != True:
         wxutil.alertDialog(self, str(result))
         self.writeStatus("")
         return
     
     self.undo_history = self.data.directory, afrom, ato
     self.menuobj_undo.Enable(True)
     self.onMenuFileRefresh()
     self.writeStatus( str(self.data.getLength())+' files renamed.')
Esempio n. 14
0
    def onMenuEditUndo(self, evt):
        # attempt to undo last rename
        if not self.undo_history:
            return

        sPrevdir, ato, afrom = self.undo_history  # note reverse order, because rename to from
        if sPrevdir != self.data.directory:
            wxutil.alertDialog(self,
                               'Cannot undo, first return to the directory.')
            return

        if not wxutil.alertDialog(self, 'Undo renaming these files?',
                                  'Confirm', wx.OK | wx.CANCEL):
            return

        self.performRename(afrom, ato)
        self.menuobj_undo.Enable(False)
Esempio n. 15
0
 def onMenuEditReplace(self, evt):
     sSearch = wxutil.inputDialog(self, 'Search for string: ')
     if not sSearch: return
     sReplace = wxutil.inputDialog(self, 'And replace with: ')
     if sReplace==None: return
     
     self.grid.writeToModel(self.data)
     # regex replace, or regex case-insensitive replace (as documented in 'tips')
     if sSearch.startswith('r:'):
         ret = self.data.transformRegexReplace(sSearch[len('r:'):], sReplace,True,True)
     elif sSearch.startswith('ri:'):
         ret = self.data.transformRegexReplace(sSearch[len('ri:'):], sReplace,True,False)
     elif sSearch.startswith('i:'):
         ret = self.data.transformRegexReplace(sSearch[len('i:'):], sReplace,False,False)
     else:
         ret = self.data.transformReplace(sSearch, sReplace)
     self.grid.loadFromModel(self.data)
     if ret!=True and ret: wxutil.alertDialog(self, str(ret))
Esempio n. 16
0
    def performRename(self, afrom, ato):
        result = False
        try:
            result = cellrename_engine.renameFiles(self.data.directory, afrom,
                                                   ato)
        except Exception:
            wxutil.alertDialog(self,
                               'Exception occurred: ' + str(sys.exc_info()[0]))
            return

        if result != True:
            wxutil.alertDialog(self, str(result))
            self.writeStatus("")
            return

        self.undo_history = self.data.directory, afrom, ato
        self.menuobj_undo.Enable(True)
        self.onMenuFileRefresh()
        self.writeStatus(str(self.data.getLength()) + ' files renamed.')
Esempio n. 17
0
 def onDoReplace(self, bRegex):
     sSearch = askWithHistory(self, 'regexsearch' if bRegex else 'search', 'Search for regex pattern: ' if bRegex else 'Search for string: ')
     if not sSearch:
         return
     
     sReplace = askWithHistory(self, 'regexrepl' if bRegex else 'repl', 'And replace with: ')
     if sReplace == None:
         return
     
     self.grid.writeToModel(self.data)
     
     if bRegex:
         ret = self.data.transformRegexReplace(sSearch, sReplace, True, True)
     else:
         ret = self.data.transformReplace(sSearch, sReplace)
     
     self.grid.loadFromModel(self.data)
     if ret != True and ret:
         wxutil.alertDialog(self, str(ret))
Esempio n. 18
0
    def onDoReplace(self, bRegex):
        sSearch = askWithHistory(
            self, 'regexsearch' if bRegex else 'search',
            'Search for regex pattern: ' if bRegex else 'Search for string: ')
        if not sSearch:
            return

        sReplace = askWithHistory(self, 'regexrepl' if bRegex else 'repl',
                                  'And replace with: ')
        if sReplace == None:
            return

        self.grid.writeToModel(self.data)

        if bRegex:
            ret = self.data.transformRegexReplace(sSearch, sReplace, True,
                                                  True)
        else:
            ret = self.data.transformReplace(sSearch, sReplace)

        self.grid.loadFromModel(self.data)
        if ret != True and ret:
            wxutil.alertDialog(self, str(ret))
Esempio n. 19
0
    def OnKeyDown(self, evt):
        # implement multi-cell copy and paste.
        if evt.GetKeyCode() == ord("U") and evt.ControlDown() and evt.ShiftDown():
            wxutil.alertDialog(self, "running unit tests")
            try:
                unittests.runall()
            except Exception:
                wxutil.alertDialog(self, "e:" + str(sys.exc_info()[0]))
            else:
                wxutil.alertDialog(self, "all tests pass")

        # respond to key event
        dictEditableColumns = {COL_NEWNAME: 1}
        ret = cellrename_gridclipboard.handle_keyboard_events(self, evt, dictEditableColumns)
        if not ret:
            evt.Skip()  # if we didn't handle the event, pass it upwards
    def OnKeyDown(self, evt):
        # implement multi-cell copy and paste.
        if evt.GetKeyCode() == ord(
                'U') and evt.ControlDown() and evt.ShiftDown():
            wxutil.alertDialog(self, 'running unit tests')
            try:
                unittests.runall()
            except Exception:
                wxutil.alertDialog(self, 'e:' + str(sys.exc_info()[0]))
            else:
                wxutil.alertDialog(self, 'all tests pass')

        # respond to key event
        dictEditableColumns = {COL_NEWNAME: 1}
        ret = cellrename_gridclipboard.handle_keyboard_events(
            self, evt, dictEditableColumns)
        if not ret:
            evt.Skip()  # if we didn't handle the event, pass it upwards
Esempio n. 21
0
 def alertRepair(self):
     wxutil.alertDialog(self, 'It looks like renaming was not successful. When you click OK, the previous filenames will be placed in the clipboard. Please rename back to normal filenames before continuing, and then restart CellRename.','Error')
     if self.undo_history and self.undo_history[1]:
         afrom = self.undo_history[1]
         s = os.linesep.join(afrom)
         wxutil.setClipboardText(s)
Esempio n. 22
0
    def onMenuHelpAbout(self, evt):
        wxutil.alertDialog(self, '''cellrename: renaming files with a spreadsheet-like UI.
        
Ben Fisher, 2008, GPL
https://github.com/moltenjs/labs_youthful_projects/tree/master/cellrename
https://moltenjs.com/articles/cellrename/''', 'About')
Esempio n. 23
0
    def onMenuHelpAbout(self, evt):
        wxutil.alertDialog(self,'''cellrename: renaming files with a spreadsheet-like UI.
        
Ben Fisher, 2008, GPL
http://github.com/downpoured/cellrename
http://halfhourhacks.blogspot.com''','About')