diff options
author | saksham1115 <saksham115@gmail.com> | 2016-07-15 23:54:05 +0000 |
---|---|---|
committer | saksham1115 <saksham115@gmail.com> | 2016-07-19 17:29:25 +0000 |
commit | 9535599c21812e974bd6682157a88ce331e32ac4 (patch) | |
tree | ed52cad2954feb9b6b8bc4044387f912132e45a1 /mediagoblin/plugins | |
parent | 7ebc001c9bb1b82081c6b7eb682e4e097be4aafa (diff) | |
download | mediagoblin-9535599c21812e974bd6682157a88ce331e32ac4.tar.lz mediagoblin-9535599c21812e974bd6682157a88ce331e32ac4.tar.xz mediagoblin-9535599c21812e974bd6682157a88ce331e32ac4.zip |
Creating plugin tools.py
Diffstat (limited to 'mediagoblin/plugins')
-rw-r--r-- | mediagoblin/plugins/custom_subtitles/tools.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/mediagoblin/plugins/custom_subtitles/tools.py b/mediagoblin/plugins/custom_subtitles/tools.py new file mode 100644 index 00000000..efafbeec --- /dev/null +++ b/mediagoblin/plugins/custom_subtitles/tools.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 |