diff options
author | Boris Bobrov <breton@cynicmansion.ru> | 2018-07-10 18:29:30 +0200 |
---|---|---|
committer | Boris Bobrov <breton@cynicmansion.ru> | 2018-07-10 18:29:30 +0200 |
commit | e08de70757b6f973bc2955f1b3292d383a19b21d (patch) | |
tree | f60ad20e55538e1945cbc61284b09540dd601975 /mediagoblin/tools/subtitles.py | |
parent | 588162b861f4993ee8412b14601b215505134bfc (diff) | |
parent | 7ab18019782b285a5bf9fc79227e0d0d4896398a (diff) | |
download | mediagoblin-e08de70757b6f973bc2955f1b3292d383a19b21d.tar.lz mediagoblin-e08de70757b6f973bc2955f1b3292d383a19b21d.tar.xz mediagoblin-e08de70757b6f973bc2955f1b3292d383a19b21d.zip |
Merge remote-tracking branch 'gsoc2016/Subtitle-1'
Diffstat (limited to 'mediagoblin/tools/subtitles.py')
-rw-r--r-- | mediagoblin/tools/subtitles.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/mediagoblin/tools/subtitles.py b/mediagoblin/tools/subtitles.py new file mode 100644 index 00000000..efafbeec --- /dev/null +++ b/mediagoblin/tools/subtitles.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 |