From de3dc09b57ef7c6d8d10606ac00035538d794ea6 Mon Sep 17 00:00:00 2001 From: MrS0m30n3 Date: Sat, 24 Sep 2016 21:12:34 +0300 Subject: [PATCH] Rename utis.open_dir -> utils.open_file --- youtube_dl_gui/mainframe.py | 6 +++--- youtube_dl_gui/utils.py | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/youtube_dl_gui/mainframe.py b/youtube_dl_gui/mainframe.py index 2254195..1faf1e5 100644 --- a/youtube_dl_gui/mainframe.py +++ b/youtube_dl_gui/mainframe.py @@ -44,8 +44,8 @@ from .utils import ( json_store, json_load, to_string, - get_time, - open_dir + open_file, + get_time ) from .info import ( @@ -593,7 +593,7 @@ class MainFrame(wx.Frame): else: self._create_popup(self.DL_COMPLETED_MSG, self.INFO_LABEL, wx.OK | wx.ICON_INFORMATION) if self.opt_manager.options['open_dl_dir']: - success = open_dir(self.opt_manager.options['save_path']) + success = open_file(self.opt_manager.options['save_path']) if not success: self._status_bar_write(self.OPEN_DIR_ERR.format(dir=self.opt_manager.options['save_path'])) diff --git a/youtube_dl_gui/utils.py b/youtube_dl_gui/utils.py index f19f330..1088829 100644 --- a/youtube_dl_gui/utils.py +++ b/youtube_dl_gui/utils.py @@ -123,18 +123,22 @@ def absolute_path(filename): return os_path_dirname(os_path_realpath(os_path_abspath(filename))) -def open_dir(path): - """Open path using default file navigator. - Return True if path exists else False. """ - path = remove_shortcuts(path) +def open_file(file_path): + """Open file in file_path using the default OS application. - if not os_path_exists(path): + Returns: + True on success else False. + + """ + file_path = remove_shortcuts(file_path) + + if not os_path_exists(file_path): return False - if os.name == 'nt': - os_startfile(path) + if os.name == "nt": + os_startfile(file_path) else: - subprocess.call(('xdg-open', path)) + subprocess.call(("xdg-open", file_path)) return True