| Server IP : 101.53.144.229 / Your IP : 216.73.216.181 Web Server : Apache System : Linux host.gdigitalindia.in 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : digitalshiksha ( 1179) PHP Version : 5.6.40 Disable Function : eval,show_source,system,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,dl,show_source,curl_multi_exechellcmd, ini_restore,apache_get_modules,get_cfg_var,passthru, exec ,proc_get_status,fpassthru,c999_buff_prepare,c999_sess_put,c99_buff_prepare,c99_sess_put,proc_close,ini_alter,dl,symlink,link,proc_close,ini_alter,dl,symlink,link,mail MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/self/cwd/c1/1/opt/alt/python38/lib64/python3.8/site-packages/pycares/ |
Upload File : |
try:
import idna as idna2008
except ImportError:
idna2008 = None
def ascii_bytes(data):
if isinstance(data, str):
return data.encode('ascii')
if isinstance(data, bytes):
return data
raise TypeError('only str (ascii encoding) and bytes are supported')
def maybe_str(data):
if isinstance(data, str):
return data
if isinstance(data, bytes):
try:
return data.decode('ascii')
except UnicodeDecodeError:
return data
raise TypeError('only str (ascii encoding) and bytes are supported')
def is_all_ascii(text):
for c in text:
if ord(c) > 0x7f:
return False
return True
def parse_name_idna2008(name):
parts = name.split('.')
r = []
for part in parts:
if is_all_ascii(part):
r.append(part.encode('ascii'))
else:
r.append(idna2008.encode(part))
return b'.'.join(r)
def parse_name(name):
if isinstance(name, str):
if is_all_ascii(name):
return name.encode('ascii')
if idna2008 is not None:
return parse_name_idna2008(name)
return name.encode('idna')
if isinstance(name, bytes):
return name
raise TypeError('only str and bytes are supported')
__all__ = ['ascii_bytes', 'maybe_str', 'parse_name']