| Server IP : 185.88.153.241 / Your IP : 216.73.217.115 Web Server : LiteSpeed System : Linux server312.bertina.biz 3.10.0-962.3.2.lve1.5.88.el7.x86_64 #1 SMP Fri Sep 26 14:06:42 UTC 2025 x86_64 User : ( 1405) PHP Version : 7.0.33 Disable Function : mail, apache_child_terminate, apache_setenv, define_syslog_variables, escapeshellarg, escapeshellcmd, exec, fp, highlight_file, ini_alter, ini_restore, inject_code, mysql_pconnect, openlog, passthru, phpAds_remoteInfo, phpAds_XmlRpc, phpAds_xmlrpcDecode, phpAds_xmlrpcEncode, popen, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, proc_close, proc_get_status, proc_nice, proc_open, proc_terminate, shell_exec, syslog, system, xmlrpc_entity_decode, show_source,dl,leak,crack_check,crack_closedict,crack_getlastmessage,crack_opendict,symlink,link,escapeshellarg,parse_ini_file, ln, show_source, pclose, parse_perms, mysql_list_dbs,stream_select,mysql_list_dbs,socket_select,socket_create,socket_create_listen,socket_create_pair,socket_listen,socket_accept,socket_bind,socket_strerror,socket_clear_error,socket_close,socket_connect,socket_get_option,socket_getpeername,socket_getsockname,socket_last_error,socket_read,socket_recv,socket_recvfrom,socket_send,socket_sendto,socket_set_block,socket_set_nonblock,socket_set_option,socket_shutdown,socket_write,readlink,pfsockopen,pcntl_exec,pcntl_fork,pcntl_signal,pcntl_waitpid,pcntl_wexitstatus, pcntl_wifexited, pcntl_wifsignaled, pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,fpassthru, posix_access, posix_ctermid, posix_errno, posix_get_last_error, posix_getcwd, posix_getgrnam, posix_getgroups, posix_getlogin, posix_getpgrp, posix_getpwnam, posix_getpwuid, posix_getrlimit, posix_getsid, posix_initgroups, posix_isatty, posix_mknod, posix_setegid, posix_seteuid, posix_strerror, posix_times, posix_ttyname, diskfreespace, disk_free_space, disk_total_space, sys_getloadavg,get_current_user MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /opt/alt/python27/lib/python2.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
"""
'imports' a string -- converts a string to a Python object, importing
any necessary modules and evaluating the expression. Everything
before the : in an import expression is the module path; everything
after is an expression to be evaluated in the namespace of that
module.
Alternately, if no : is present, then import the modules and get the
attributes as necessary. Arbitrary expressions are not allowed in
that case.
"""
def eval_import(s):
"""
Import a module, or import an object from a module.
A module name like ``foo.bar:baz()`` can be used, where
``foo.bar`` is the module, and ``baz()`` is an expression
evaluated in the context of that module. Note this is not safe on
arbitrary strings because of the eval.
"""
if ':' not in s:
return simple_import(s)
module_name, expr = s.split(':', 1)
module = import_module(module_name)
obj = eval(expr, module.__dict__)
return obj
def simple_import(s):
"""
Import a module, or import an object from a module.
A name like ``foo.bar.baz`` can be a module ``foo.bar.baz`` or a
module ``foo.bar`` with an object ``baz`` in it, or a module
``foo`` with an object ``bar`` with an attribute ``baz``.
"""
parts = s.split('.')
module = import_module(parts[0])
name = parts[0]
parts = parts[1:]
last_import_error = None
while parts:
name += '.' + parts[0]
try:
module = import_module(name)
parts = parts[1:]
except ImportError, e:
last_import_error = e
break
obj = module
while parts:
try:
obj = getattr(module, parts[0])
except AttributeError:
raise ImportError(
"Cannot find %s in module %r (stopped importing modules with error %s)" % (parts[0], module, last_import_error))
parts = parts[1:]
return obj
def import_module(s):
"""
Import a module.
"""
mod = __import__(s)
parts = s.split('.')
for part in parts[1:]:
mod = getattr(mod, part)
return mod
def try_import_module(module_name):
"""
Imports a module, but catches import errors. Only catches errors
when that module doesn't exist; if that module itself has an
import error it will still get raised. Returns None if the module
doesn't exist.
"""
try:
return import_module(module_name)
except ImportError, e:
if not getattr(e, 'args', None):
raise
desc = e.args[0]
if not desc.startswith('No module named '):
raise
desc = desc[len('No module named '):]
# If you import foo.bar.baz, the bad import could be any
# of foo.bar.baz, bar.baz, or baz; we'll test them all:
parts = module_name.split('.')
for i in range(len(parts)):
if desc == '.'.join(parts[i:]):
return None
raise