From 40dba847c1a59a92a3f908ac736f40d48b207b15 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Sat, 27 Feb 2021 18:30:20 +1100 Subject: [PATCH] moved SymlinkName into shared --- shared.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/shared.py b/shared.py index a20c477..3e94ad6 100644 --- a/shared.py +++ b/shared.py @@ -1,4 +1,5 @@ import socket +import os hostname = socket.gethostname() PROD_HOST="pa_web" @@ -27,3 +28,16 @@ def CreateSelect(name, selected, list, js=""): str += f'>{el}' str += '' return str + +def SymlinkName(path, file): + sig_bit=file.replace(path, "") + last_dir=os.path.basename(path[0:-1]) + + if sig_bit[-1] == '/': + last_bit = os.path.dirname(sig_bit)[0:-1] + else: + last_bit = os.path.dirname(sig_bit) + symlink = 'static/'+last_dir+'/'+last_bit + if symlink[-1] == '/': + symlink=symlink[0:-1] + return symlink