From 9535599c21812e974bd6682157a88ce331e32ac4 Mon Sep 17 00:00:00 2001 From: saksham1115 Date: Fri, 15 Jul 2016 23:54:05 +0000 Subject: [PATCH] Creating plugin tools.py --- mediagoblin/plugins/custom_subtitles/tools.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 mediagoblin/plugins/custom_subtitles/tools.py diff --git a/mediagoblin/plugins/custom_subtitles/tools.py b/mediagoblin/plugins/custom_subtitles/tools.py new file mode 100644 index 00000000..efafbeec --- /dev/null +++ b/mediagoblin/plugins/custom_subtitles/tools.py @@ -0,0 +1,20 @@ +import os + +def get_path(path): + temp = ['user_dev','media','public'] + path = list(eval(path)) + file_path = os.path.abspath(__file__).split('/') # Path of current file as dictionary + subtitle_path = file_path[:-3] + temp + path # Creating the absolute path for the subtitle file + subtitle_path = "/" + os.path.join(*subtitle_path) + return subtitle_path + +def open_subtitle(path): + subtitle_path = get_path(path) + subtitle = open(subtitle_path,"r") # Opening the file using the absolute path + text = subtitle.read() + return text + +def save_subtitle(path,text): + subtitle_path = get_path(path) + subtitle = open(subtitle_path,"w") # Opening the file using the absolute path + subtitle.write(text) \ No newline at end of file -- 2.25.1