Skip to content

Commit

Permalink
Refactor redundant code into function
Browse files Browse the repository at this point in the history
  • Loading branch information
samj1912 committed Jan 11, 2017
1 parent 99a7f5a commit 2ed88a8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions picard/ui/filebrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,21 @@ def _restore_state(self):
self.expand(index)
self.scrollTo(index, scrolltype)

def _get_destination_from_path(self, path):
destination = os.path.normpath(unicode(path))
if not os.path.isdir(destination):
destination = os.path.dirname(destination)
return destination

def move_files_here(self):
indexes = self.selectedIndexes()
if not indexes:
return
path = self.model.filePath(indexes[0])
destination = os.path.normpath(unicode(path))
if not os.path.isdir(destination):
destination = os.path.dirname(destination)
config.setting["move_files_to"] = destination
config.setting["move_files_to"] = self._get_destination_from_path(path)

def set_as_starting_directory(self):
indexes = self.selectedIndexes()
if indexes:
path = self.model.filePath(indexes[0])
destination = os.path.normpath(unicode(path))
if not os.path.isdir(destination):
destination = os.path.dirname(destination)
config.setting["starting_directory_path"] = destination
config.setting["starting_directory_path"] = self._get_destination_from_path(path)

0 comments on commit 2ed88a8

Please sign in to comment.