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