316bef69 |
1 | import ast,os |
2c36555b |
2 | |
3 | def get_path(path): |
4 | """ |
5 | Converting the path of the form |
6 | x = u'[ "A","B","C" ," D"]' |
7 | to |
8 | x = ["A", "B", "C", "D"] |
9 | """ |
316bef69 |
10 | return ast.literal_eval(path) |
11 | |
12 | def open_subtitle(path): |
13 | temp = ['user_dev','media','public'] |
14 | path = list(get_path(path)) |
15 | file_path = os.path.abspath(__file__).split('/') # Path of current file as dictionary |
16 | """ |
17 | Creating the absolute path for the subtitle file |
18 | """ |
19 | subtitle_path = file_path[:-3] + temp + path |
20 | subtitle_path = "/" + os.path.join(*subtitle_path) |
21 | """ |
22 | Opening the file using the absolute path |
23 | """ |
24 | subtitle = open(subtitle_path,"r") |
25 | text = subtitle.read() |
26 | return text |