Browse Source

Rename utis.open_dir -> utils.open_file

doc-issue-template
MrS0m30n3 8 years ago
parent
commit
de3dc09b57
2 changed files with 15 additions and 11 deletions
  1. 6
      youtube_dl_gui/mainframe.py
  2. 20
      youtube_dl_gui/utils.py

6
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']))

20
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

Loading…
Cancel
Save