Server IP : 103.119.228.120 / Your IP : 3.137.169.14 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/lib/mysqlsh/lib/python3.9/site-packages/setuptools/ |
Upload File : |
""" Helpers for normalization as expected in wheel/sdist/module file names and core metadata """ import re import packaging # https://packaging.python.org/en/latest/specifications/core-metadata/#name _VALID_NAME = re.compile(r"^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$", re.I) _UNSAFE_NAME_CHARS = re.compile(r"[^A-Z0-9._-]+", re.I) _NON_ALPHANUMERIC = re.compile(r"[^A-Z0-9]+", re.I) _PEP440_FALLBACK = re.compile(r"^v?(?P<safe>(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*)", re.I) def safe_identifier(name: str) -> str: """Make a string safe to be used as Python identifier. >>> safe_identifier("12abc") '_12abc' >>> safe_identifier("__editable__.myns.pkg-78.9.3_local") '__editable___myns_pkg_78_9_3_local' """ safe = re.sub(r'\W|^(?=\d)', '_', name) assert safe.isidentifier() return safe def safe_name(component: str) -> str: """Escape a component used as a project name according to Core Metadata. >>> safe_name("hello world") 'hello-world' >>> safe_name("hello?world") 'hello-world' >>> safe_name("hello_world") 'hello_world' """ # See pkg_resources.safe_name return _UNSAFE_NAME_CHARS.sub("-", component) def safe_version(version: str) -> str: """Convert an arbitrary string into a valid version string. Can still raise an ``InvalidVersion`` exception. To avoid exceptions use ``best_effort_version``. >>> safe_version("1988 12 25") '1988.12.25' >>> safe_version("v0.2.1") '0.2.1' >>> safe_version("v0.2?beta") '0.2b0' >>> safe_version("v0.2 beta") '0.2b0' >>> safe_version("ubuntu lts") Traceback (most recent call last): ... packaging.version.InvalidVersion: Invalid version: 'ubuntu.lts' """ v = version.replace(' ', '.') try: return str(packaging.version.Version(v)) except packaging.version.InvalidVersion: attempt = _UNSAFE_NAME_CHARS.sub("-", v) return str(packaging.version.Version(attempt)) def best_effort_version(version: str) -> str: """Convert an arbitrary string into a version-like string. Fallback when ``safe_version`` is not safe enough. >>> best_effort_version("v0.2 beta") '0.2b0' >>> best_effort_version("ubuntu lts") '0.dev0+sanitized.ubuntu.lts' >>> best_effort_version("0.23ubuntu1") '0.23.dev0+sanitized.ubuntu1' >>> best_effort_version("0.23-") '0.23.dev0+sanitized' >>> best_effort_version("0.-_") '0.dev0+sanitized' >>> best_effort_version("42.+?1") '42.dev0+sanitized.1' """ # See pkg_resources._forgiving_version try: return safe_version(version) except packaging.version.InvalidVersion: v = version.replace(' ', '.') match = _PEP440_FALLBACK.search(v) if match: safe = match["safe"] rest = v[len(safe) :] else: safe = "0" rest = version safe_rest = _NON_ALPHANUMERIC.sub(".", rest).strip(".") local = f"sanitized.{safe_rest}".strip(".") return safe_version(f"{safe}.dev0+{local}") def safe_extra(extra: str) -> str: """Normalize extra name according to PEP 685 >>> safe_extra("_FrIeNdLy-._.-bArD") 'friendly-bard' >>> safe_extra("FrIeNdLy-._.-bArD__._-") 'friendly-bard' """ return _NON_ALPHANUMERIC.sub("-", extra).strip("-").lower() def filename_component(value: str) -> str: """Normalize each component of a filename (e.g. distribution/version part of wheel) Note: ``value`` needs to be already normalized. >>> filename_component("my-pkg") 'my_pkg' """ return value.replace("-", "_").strip("_") def filename_component_broken(value: str) -> str: """ Produce the incorrect filename component for compatibility. See pypa/setuptools#4167 for detailed analysis. TODO: replace this with filename_component after pip 24 is nearly-ubiquitous. >>> filename_component_broken('foo_bar-baz') 'foo-bar-baz' """ return value.replace('_', '-') def safer_name(value: str) -> str: """Like ``safe_name`` but can be used as filename component for wheel""" # See bdist_wheel.safer_name return filename_component(safe_name(value)) def safer_best_effort_version(value: str) -> str: """Like ``best_effort_version`` but can be used as filename component for wheel""" # See bdist_wheel.safer_verion # TODO: Replace with only safe_version in the future (no need for best effort) return filename_component(best_effort_version(value))