Advertisement
Guest User

Loading and using of multiple versions of the Python module with the same name.

a guest
Jun 27th, 2021
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 13.15 KB | None | 0 0
  1. #!/bin/sh
  2. # This is a shell archive (produced by GNU sharutils 4.15.2).
  3. # To extract the files from this archive, save it to some FILE, remove
  4. # everything before the '#!/bin/sh' line above, then type 'sh FILE'.
  5. #
  6. lock_dir=_sh130097
  7. # Made on 2021-06-28 01:53 CEST by <wzab@wzab>.
  8. # Source directory was '/tmp/demo'.
  9. #
  10. # Existing files will *not* be overwritten, unless '-c' is specified.
  11. #
  12. # This shar contains:
  13. # length mode       name
  14. # ------ ---------- ------------------------------------------
  15. #    603 -rw-r--r-- load_demo.py
  16. #     40 -rw-r--r-- t2/agwb/agwb.py
  17. #     15 -rw-r--r-- t2/agwb/top_const.py
  18. #     79 -rw-r--r-- t2/agwb/__init__.py
  19. #    209 -rw-r--r-- t2/agwb/top_v0.py
  20. #     40 -rw-r--r-- t1/agwb/agwb.py
  21. #     15 -rw-r--r-- t1/agwb/top_const.py
  22. #     79 -rw-r--r-- t1/agwb/__init__.py
  23. #    210 -rw-r--r-- t1/agwb/top_v0.py
  24. #
  25. MD5SUM=${MD5SUM-md5sum}
  26. f=`${MD5SUM} --version | egrep '^md5sum .*(core|text)utils'`
  27. test -n "${f}" && md5check=true || md5check=false
  28. ${md5check} || \
  29.   echo 'Note: not verifying md5sums.  Consider installing GNU coreutils.'
  30. if test "X$1" = "X-c"
  31. then keep_file=''
  32. else keep_file=true
  33. fi
  34. echo=echo
  35. save_IFS="${IFS}"
  36. IFS="${IFS}:"
  37. gettext_dir=
  38. locale_dir=
  39. set_echo=false
  40.  
  41. for dir in $PATH
  42. do
  43.   if test -f $dir/gettext \
  44.      && ($dir/gettext --version >/dev/null 2>&1)
  45.   then
  46.     case `$dir/gettext --version 2>&1 | sed 1q` in
  47.       *GNU*) gettext_dir=$dir
  48.       set_echo=true
  49.       break ;;
  50.     esac
  51.   fi
  52. done
  53.  
  54. if ${set_echo}
  55. then
  56.   set_echo=false
  57.   for dir in $PATH
  58.   do
  59.     if test -f $dir/shar \
  60.        && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
  61.     then
  62.       locale_dir=`$dir/shar --print-text-domain-dir`
  63.       set_echo=true
  64.       break
  65.     fi
  66.   done
  67.  
  68.   if ${set_echo}
  69.   then
  70.     TEXTDOMAINDIR=$locale_dir
  71.     export TEXTDOMAINDIR
  72.     TEXTDOMAIN=sharutils
  73.     export TEXTDOMAIN
  74.     echo="$gettext_dir/gettext -s"
  75.   fi
  76. fi
  77. IFS="$save_IFS"
  78. if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null
  79. then if (echo -n test; echo 1,2,3) | grep n >/dev/null
  80.      then shar_n= shar_c='
  81. '
  82.      else shar_n=-n shar_c= ; fi
  83. else shar_n= shar_c='\c' ; fi
  84. f=shar-touch.$$
  85. st1=200112312359.59
  86. st2=123123592001.59
  87. st2tr=123123592001.5 # old SysV 14-char limit
  88. st3=1231235901
  89.  
  90. if   touch -am -t ${st1} ${f} >/dev/null 2>&1 && \
  91.      test ! -f ${st1} && test -f ${f}; then
  92.   shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"'
  93.  
  94. elif touch -am ${st2} ${f} >/dev/null 2>&1 && \
  95.      test ! -f ${st2} && test ! -f ${st2tr} && test -f ${f}; then
  96.   shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"'
  97.  
  98. elif touch -am ${st3} ${f} >/dev/null 2>&1 && \
  99.      test ! -f ${st3} && test -f ${f}; then
  100.   shar_touch='touch -am $3$4$5$6$2 "$8"'
  101.  
  102. else
  103.   shar_touch=:
  104.   echo
  105.   ${echo} 'WARNING: not restoring timestamps.  Consider getting and
  106. installing GNU '\''touch'\'', distributed in GNU coreutils...'
  107.   echo
  108. fi
  109. rm -f ${st1} ${st2} ${st2tr} ${st3} ${f}
  110. #
  111. if test ! -d ${lock_dir} ; then :
  112. else ${echo} "lock directory ${lock_dir} exists"
  113.      exit 1
  114. fi
  115. if mkdir ${lock_dir}
  116. then ${echo} "x - created lock directory ${lock_dir}."
  117. else ${echo} "x - failed to create lock directory ${lock_dir}."
  118.      exit 1
  119. fi
  120. # ============= load_demo.py ==============
  121. if test -n "${keep_file}" && test -f 'load_demo.py'
  122. then
  123. ${echo} "x - SKIPPING load_demo.py (file already exists)"
  124.  
  125. else
  126. ${echo} "x - extracting load_demo.py (text)"
  127.   sed 's/^X//' << 'SHAR_EOF' > 'load_demo.py' &&
  128. import sys
  129. import importlib
  130. X
  131. def load_agwb(lddir,top):
  132. X    sys.path.insert(0,lddir)
  133. X    importlib.import_module('agwb')
  134. X    # Get the class for the top entity
  135. X    res = getattr(sys.modules['agwb'],top)()
  136. X    sys.path.remove(lddir)
  137. X    sys.modules.pop('agwb')
  138. X    mods_to_remove = []
  139. X    for mod in sys.modules.keys():
  140. X        if mod.find('agwb.') == 0:
  141. X            mods_to_remove.append(mod)
  142. X    for mod in mods_to_remove:
  143. X        sys.modules.pop(mod)
  144. X    return res
  145. X
  146. at1 = load_agwb('./t1','top_v0')
  147. at2 = load_agwb('./t2','top_v0')
  148. print("Call at1.show")
  149. at1.show()
  150. print("Call at2.show")
  151. at2.show()
  152. X
  153. SHAR_EOF
  154.   (set 20 21 06 28 00 47 32 'load_demo.py'
  155.    eval "${shar_touch}") && \
  156.   chmod 0644 'load_demo.py'
  157. if test $? -ne 0
  158. then ${echo} "restore of load_demo.py failed"
  159. fi
  160.   if ${md5check}
  161.   then (
  162.        ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'load_demo.py': 'MD5 check failed'
  163.        ) << \SHAR_EOF
  164. 76ae500f29f46a431c78dbd36919cb0f  load_demo.py
  165. SHAR_EOF
  166.  
  167. else
  168. test `LC_ALL=C wc -c < 'load_demo.py'` -ne 603 && \
  169.   ${echo} "restoration warning:  size of 'load_demo.py' is not 603"
  170.   fi
  171. fi
  172. # ============= t2/agwb/agwb.py ==============
  173. if test ! -d 't2'; then
  174.   mkdir 't2'
  175. if test $? -eq 0
  176. then ${echo} "x - created directory t2."
  177. else ${echo} "x - failed to create directory t2."
  178.      exit 1
  179. fi
  180. fi
  181. if test ! -d 't2/agwb'; then
  182.   mkdir 't2/agwb'
  183. if test $? -eq 0
  184. then ${echo} "x - created directory t2/agwb."
  185. else ${echo} "x - failed to create directory t2/agwb."
  186.      exit 1
  187. fi
  188. fi
  189. if test -n "${keep_file}" && test -f 't2/agwb/agwb.py'
  190. then
  191. ${echo} "x - SKIPPING t2/agwb/agwb.py (file already exists)"
  192.  
  193. else
  194. ${echo} "x - extracting t2/agwb/agwb.py (text)"
  195.   sed 's/^X//' << 'SHAR_EOF' > 't2/agwb/agwb.py' &&
  196. desc="That's version from directory t2"
  197. SHAR_EOF
  198.   (set 20 21 06 28 00 42 33 't2/agwb/agwb.py'
  199.    eval "${shar_touch}") && \
  200.   chmod 0644 't2/agwb/agwb.py'
  201. if test $? -ne 0
  202. then ${echo} "restore of t2/agwb/agwb.py failed"
  203. fi
  204.   if ${md5check}
  205.   then (
  206.        ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 't2/agwb/agwb.py': 'MD5 check failed'
  207.        ) << \SHAR_EOF
  208. 4a1737fdf0a063cb6a40e763fd85245a  t2/agwb/agwb.py
  209. SHAR_EOF
  210.  
  211. else
  212. test `LC_ALL=C wc -c < 't2/agwb/agwb.py'` -ne 40 && \
  213.   ${echo} "restoration warning:  size of 't2/agwb/agwb.py' is not 40"
  214.   fi
  215. fi
  216. # ============= t2/agwb/top_const.py ==============
  217. if test ! -d 't2/agwb'; then
  218.   mkdir 't2/agwb'
  219. if test $? -eq 0
  220. then ${echo} "x - created directory t2/agwb."
  221. else ${echo} "x - failed to create directory t2/agwb."
  222.      exit 1
  223. fi
  224. fi
  225. if test -n "${keep_file}" && test -f 't2/agwb/top_const.py'
  226. then
  227. ${echo} "x - SKIPPING t2/agwb/top_const.py (file already exists)"
  228.  
  229. else
  230. ${echo} "x - extracting t2/agwb/top_const.py (text)"
  231.   sed 's/^X//' << 'SHAR_EOF' > 't2/agwb/top_const.py' &&
  232. C_TYPE_ID=2222
  233. SHAR_EOF
  234.   (set 20 21 06 28 00 42 40 't2/agwb/top_const.py'
  235.    eval "${shar_touch}") && \
  236.   chmod 0644 't2/agwb/top_const.py'
  237. if test $? -ne 0
  238. then ${echo} "restore of t2/agwb/top_const.py failed"
  239. fi
  240.   if ${md5check}
  241.   then (
  242.        ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 't2/agwb/top_const.py': 'MD5 check failed'
  243.        ) << \SHAR_EOF
  244. e32dd05b8c4a7f38d1a0f48d0473073c  t2/agwb/top_const.py
  245. SHAR_EOF
  246.  
  247. else
  248. test `LC_ALL=C wc -c < 't2/agwb/top_const.py'` -ne 15 && \
  249.   ${echo} "restoration warning:  size of 't2/agwb/top_const.py' is not 15"
  250.   fi
  251. fi
  252. # ============= t2/agwb/__init__.py ==============
  253. if test -n "${keep_file}" && test -f 't2/agwb/__init__.py'
  254. then
  255. ${echo} "x - SKIPPING t2/agwb/__init__.py (file already exists)"
  256.  
  257. else
  258. ${echo} "x - extracting t2/agwb/__init__.py (text)"
  259.   sed 's/^X//' << 'SHAR_EOF' > 't2/agwb/__init__.py' &&
  260. from .agwb import *
  261. from .top_const import *
  262. from .top_v0 import top as top_v0
  263. SHAR_EOF
  264.   (set 20 21 06 28 00 46 48 't2/agwb/__init__.py'
  265.    eval "${shar_touch}") && \
  266.   chmod 0644 't2/agwb/__init__.py'
  267. if test $? -ne 0
  268. then ${echo} "restore of t2/agwb/__init__.py failed"
  269. fi
  270.   if ${md5check}
  271.   then (
  272.        ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 't2/agwb/__init__.py': 'MD5 check failed'
  273.        ) << \SHAR_EOF
  274. ce4aeea94e7d02e4175bee763e16f351  t2/agwb/__init__.py
  275. SHAR_EOF
  276.  
  277. else
  278. test `LC_ALL=C wc -c < 't2/agwb/__init__.py'` -ne 79 && \
  279.   ${echo} "restoration warning:  size of 't2/agwb/__init__.py' is not 79"
  280.   fi
  281. fi
  282. # ============= t2/agwb/top_v0.py ==============
  283. if test -n "${keep_file}" && test -f 't2/agwb/top_v0.py'
  284. then
  285. ${echo} "x - SKIPPING t2/agwb/top_v0.py (file already exists)"
  286.  
  287. else
  288. ${echo} "x - extracting t2/agwb/top_v0.py (text)"
  289.   sed 's/^X//' << 'SHAR_EOF' > 't2/agwb/top_v0.py' &&
  290. from . import agwb
  291. from .top_const import *
  292. class top():
  293. X    def __init__(self):
  294. X       self.rr = agwb.desc
  295. X    def show(self):
  296. X       print("object from t2, desc=",self.rr)
  297. X       print("type ID=",C_TYPE_ID)
  298. SHAR_EOF
  299.   (set 20 21 06 28 00 53 12 't2/agwb/top_v0.py'
  300.    eval "${shar_touch}") && \
  301.   chmod 0644 't2/agwb/top_v0.py'
  302. if test $? -ne 0
  303. then ${echo} "restore of t2/agwb/top_v0.py failed"
  304. fi
  305.   if ${md5check}
  306.   then (
  307.        ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 't2/agwb/top_v0.py': 'MD5 check failed'
  308.        ) << \SHAR_EOF
  309. a9df0ac7641bcbd58ff0bbf61f560e16  t2/agwb/top_v0.py
  310. SHAR_EOF
  311.  
  312. else
  313. test `LC_ALL=C wc -c < 't2/agwb/top_v0.py'` -ne 209 && \
  314.   ${echo} "restoration warning:  size of 't2/agwb/top_v0.py' is not 209"
  315.   fi
  316. fi
  317. # ============= t1/agwb/agwb.py ==============
  318. if test ! -d 't1'; then
  319.   mkdir 't1'
  320. if test $? -eq 0
  321. then ${echo} "x - created directory t1."
  322. else ${echo} "x - failed to create directory t1."
  323.      exit 1
  324. fi
  325. fi
  326. if test ! -d 't1/agwb'; then
  327.   mkdir 't1/agwb'
  328. if test $? -eq 0
  329. then ${echo} "x - created directory t1/agwb."
  330. else ${echo} "x - failed to create directory t1/agwb."
  331.      exit 1
  332. fi
  333. fi
  334. if test -n "${keep_file}" && test -f 't1/agwb/agwb.py'
  335. then
  336. ${echo} "x - SKIPPING t1/agwb/agwb.py (file already exists)"
  337.  
  338. else
  339. ${echo} "x - extracting t1/agwb/agwb.py (text)"
  340.   sed 's/^X//' << 'SHAR_EOF' > 't1/agwb/agwb.py' &&
  341. desc="That's version from directory t1"
  342. SHAR_EOF
  343.   (set 20 21 06 28 00 37 53 't1/agwb/agwb.py'
  344.    eval "${shar_touch}") && \
  345.   chmod 0644 't1/agwb/agwb.py'
  346. if test $? -ne 0
  347. then ${echo} "restore of t1/agwb/agwb.py failed"
  348. fi
  349.   if ${md5check}
  350.   then (
  351.        ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 't1/agwb/agwb.py': 'MD5 check failed'
  352.        ) << \SHAR_EOF
  353. 034b71c5fe1062ac88a80783dbcd9169  t1/agwb/agwb.py
  354. SHAR_EOF
  355.  
  356. else
  357. test `LC_ALL=C wc -c < 't1/agwb/agwb.py'` -ne 40 && \
  358.   ${echo} "restoration warning:  size of 't1/agwb/agwb.py' is not 40"
  359.   fi
  360. fi
  361. # ============= t1/agwb/top_const.py ==============
  362. if test ! -d 't1/agwb'; then
  363.   mkdir 't1/agwb'
  364. if test $? -eq 0
  365. then ${echo} "x - created directory t1/agwb."
  366. else ${echo} "x - failed to create directory t1/agwb."
  367.      exit 1
  368. fi
  369. fi
  370. if test -n "${keep_file}" && test -f 't1/agwb/top_const.py'
  371. then
  372. ${echo} "x - SKIPPING t1/agwb/top_const.py (file already exists)"
  373.  
  374. else
  375. ${echo} "x - extracting t1/agwb/top_const.py (text)"
  376.   sed 's/^X//' << 'SHAR_EOF' > 't1/agwb/top_const.py' &&
  377. C_TYPE_ID=1111
  378. SHAR_EOF
  379.   (set 20 21 06 28 00 38 30 't1/agwb/top_const.py'
  380.    eval "${shar_touch}") && \
  381.   chmod 0644 't1/agwb/top_const.py'
  382. if test $? -ne 0
  383. then ${echo} "restore of t1/agwb/top_const.py failed"
  384. fi
  385.   if ${md5check}
  386.   then (
  387.        ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 't1/agwb/top_const.py': 'MD5 check failed'
  388.        ) << \SHAR_EOF
  389. 0ab74f53f6cd78d10d350d28ac06ecd8  t1/agwb/top_const.py
  390. SHAR_EOF
  391.  
  392. else
  393. test `LC_ALL=C wc -c < 't1/agwb/top_const.py'` -ne 15 && \
  394.   ${echo} "restoration warning:  size of 't1/agwb/top_const.py' is not 15"
  395.   fi
  396. fi
  397. # ============= t1/agwb/__init__.py ==============
  398. if test -n "${keep_file}" && test -f 't1/agwb/__init__.py'
  399. then
  400. ${echo} "x - SKIPPING t1/agwb/__init__.py (file already exists)"
  401.  
  402. else
  403. ${echo} "x - extracting t1/agwb/__init__.py (text)"
  404.   sed 's/^X//' << 'SHAR_EOF' > 't1/agwb/__init__.py' &&
  405. from .agwb import *
  406. from .top_const import *
  407. from .top_v0 import top as top_v0
  408. SHAR_EOF
  409.   (set 20 21 06 28 00 46 37 't1/agwb/__init__.py'
  410.    eval "${shar_touch}") && \
  411.   chmod 0644 't1/agwb/__init__.py'
  412. if test $? -ne 0
  413. then ${echo} "restore of t1/agwb/__init__.py failed"
  414. fi
  415.   if ${md5check}
  416.   then (
  417.        ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 't1/agwb/__init__.py': 'MD5 check failed'
  418.        ) << \SHAR_EOF
  419. ce4aeea94e7d02e4175bee763e16f351  t1/agwb/__init__.py
  420. SHAR_EOF
  421.  
  422. else
  423. test `LC_ALL=C wc -c < 't1/agwb/__init__.py'` -ne 79 && \
  424.   ${echo} "restoration warning:  size of 't1/agwb/__init__.py' is not 79"
  425.   fi
  426. fi
  427. # ============= t1/agwb/top_v0.py ==============
  428. if test -n "${keep_file}" && test -f 't1/agwb/top_v0.py'
  429. then
  430. ${echo} "x - SKIPPING t1/agwb/top_v0.py (file already exists)"
  431.  
  432. else
  433. ${echo} "x - extracting t1/agwb/top_v0.py (text)"
  434.   sed 's/^X//' << 'SHAR_EOF' > 't1/agwb/top_v0.py' &&
  435. from . import agwb
  436. from .top_const import *
  437. X
  438. class top():
  439. X    def __init__(self):
  440. X       self.rr = agwb.desc
  441. X    def show(self):
  442. X       print("object from t1, desc=",self.rr)
  443. X       print("type ID=",C_TYPE_ID)
  444. SHAR_EOF
  445.   (set 20 21 06 28 00 54 18 't1/agwb/top_v0.py'
  446.    eval "${shar_touch}") && \
  447.   chmod 0644 't1/agwb/top_v0.py'
  448. if test $? -ne 0
  449. then ${echo} "restore of t1/agwb/top_v0.py failed"
  450. fi
  451.   if ${md5check}
  452.   then (
  453.        ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 't1/agwb/top_v0.py': 'MD5 check failed'
  454.        ) << \SHAR_EOF
  455. 87d0a95a860020fdfddee13d383b8149  t1/agwb/top_v0.py
  456. SHAR_EOF
  457.  
  458. else
  459. test `LC_ALL=C wc -c < 't1/agwb/top_v0.py'` -ne 210 && \
  460.   ${echo} "restoration warning:  size of 't1/agwb/top_v0.py' is not 210"
  461.   fi
  462. fi
  463. if rm -fr ${lock_dir}
  464. then ${echo} "x - removed lock directory ${lock_dir}."
  465. else ${echo} "x - failed to remove lock directory ${lock_dir}."
  466.      exit 1
  467. fi
  468. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement