Modified get_path function in tools/subtitles.py
authorsaksham1115 <saksham115@gmail.com>
Wed, 13 Jul 2016 13:36:14 +0000 (13:36 +0000)
committersaksham1115 <saksham115@gmail.com>
Tue, 19 Jul 2016 17:29:09 +0000 (17:29 +0000)
mediagoblin/tools/subtitles.py

index 7fcf5f111c0a72e9c6be0fc8a573a1b29c4385d0..efafbeec809104c065e84ce774b1ec58c895a2c6 100644 (file)
@@ -1,23 +1,20 @@
 import os
 
 def get_path(path):
-       return eval(path)
-
-def open_subtitle(path):
        temp = ['user_dev','media','public']
-       path = list(get_path(path))
+       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):
-       temp = ['user_dev','media','public']
-       path = list(get_path(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)
+       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