Modified get_path function in tools/subtitles.py
[mediagoblin.git] / mediagoblin / tools / subtitles.py
CommitLineData
1ba4556b 1import os
2c36555b 2
3def get_path(path):
316bef69 4 temp = ['user_dev','media','public']
4292c6aa 5 path = list(eval(path))
316bef69 6 file_path = os.path.abspath(__file__).split('/') # Path of current file as dictionary
1ba4556b 7 subtitle_path = file_path[:-3] + temp + path # Creating the absolute path for the subtitle file
316bef69 8 subtitle_path = "/" + os.path.join(*subtitle_path)
4292c6aa 9 return subtitle_path
10
11def open_subtitle(path):
12 subtitle_path = get_path(path)
1ba4556b 13 subtitle = open(subtitle_path,"r") # Opening the file using the absolute path
316bef69 14 text = subtitle.read()
a8902a5e 15 return text
16
17def save_subtitle(path,text):
4292c6aa 18 subtitle_path = get_path(path)
a8902a5e 19 subtitle = open(subtitle_path,"w") # Opening the file using the absolute path
20 subtitle.write(text)