Server IP : 192.158.238.246 / Your IP : 18.222.94.214 Web Server : LiteSpeed System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64 User : jenniferflocom ( 1321) PHP Version : 8.1.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /opt/alt/python37/lib/python3.7/site-packages/paste/util/ |
Upload File : |
# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php import sys import os def find_package(dir): """ Given a directory, finds the equivalent package name. If it is directly in sys.path, returns ''. """ dir = os.path.abspath(dir) orig_dir = dir path = map(os.path.abspath, sys.path) packages = [] last_dir = None while 1: if dir in path: return '.'.join(packages) packages.insert(0, os.path.basename(dir)) dir = os.path.dirname(dir) if last_dir == dir: raise ValueError( "%s is not under any path found in sys.path" % orig_dir) last_dir = dir