MCPcopy Create free account
hub / github.com/apache/madlib / parseConnectionStr

Function parseConnectionStr

src/madpack/madpack.py:868–888  ·  view source on GitHub ↗

@brief Parse connection strings of the form [username[/password]@][hostname][:port][/database] Separation characters (/@:) and the backslash (\) need to be escaped. @returns A tuple (username, password, hostname, port, database). Field not specified wil

(connectionStr)

Source from the content-addressed store, hash-verified

866
867
868def parseConnectionStr(connectionStr):
869 """
870 @brief Parse connection strings of the form
871 <tt>[username[/password]@][hostname][:port][/database]</tt>
872
873 Separation characters (/@:) and the backslash (\) need to be escaped.
874 @returns A tuple (username, password, hostname, port, database). Field not
875 specified will be None.
876 """
877 match = re.search(
878 r'((?P<user>([^/@:\\]|\\/|\\@|\\:|\\\\)+)' +
879 r'(/(?P<password>([^/@:\\]|\\/|\\@|\\:|\\\\)*))?@)?' +
880 r'(?P<host>([^/@:\\]|\\/|\\@|\\:|\\\\)+)?' +
881 r'(:(?P<port>[0-9]+))?' +
882 r'(/(?P<database>([^/@:\\]|\\/|\\@|\\:|\\\\)+))?', connectionStr)
883 return (
884 unescape(match.group('user')),
885 unescape(match.group('password')),
886 unescape(match.group('host')),
887 match.group('port'),
888 unescape(match.group('database')))
889# ------------------------------------------------------------------------------
890
891

Callers 1

mainFunction · 0.85

Calls 2

unescapeFunction · 0.85
searchMethod · 0.80

Tested by

no test coverage detected