Add the script used to deprecate sys.path hacks

This commit is contained in:
Calen Pennington
2020-09-21 15:58:11 -04:00
committed by Calen Pennington
parent 7cbfc8de40
commit 3ebba52cf7

17
sys_path_hacks/un_sys_path.sh Executable file
View File

@@ -0,0 +1,17 @@
#! /bin/sh
export TARGET=$1
for path in $(find ${TARGET}/djangoapps/ -name '*.py' | grep -v migrations); do
export new_path=$(echo $path | sed "s#${TARGET}/djangoapps/#sys_path_hacks/${TARGET}/#")
export python_path=$(echo $path | sed "s#/#.#g" | sed "s#.py##" | sed "s#.__init__##")
export old_python_path=$(echo $python_path | sed "s#${TARGET}.djangoapps.##")
mkdir -p $(dirname $new_path)
echo > $new_path <<SCRIPT
import warnings
import textwrap
warnings.warn(textwrap.dedent("""\
Importing $old_python_path instead of $python_path is deprecated. See https://github.com/edx/edx-platform/blob/master/docs/decisions/0007-sys-path-modification-removal.rst.
""", stacklevel=2)
from $python_path import *
SCRIPT
done