mirror of
https://github.com/gnh1201/caterpillar.git
synced 2025-11-27 10:00:40 +00:00
Update base.py
This commit is contained in:
parent
3360522dec
commit
6616832338
12
base.py
12
base.py
|
|
@ -15,6 +15,18 @@ import json
|
||||||
|
|
||||||
client_encoding = 'utf-8'
|
client_encoding = 'utf-8'
|
||||||
|
|
||||||
|
def extract_credentials(url):
|
||||||
|
pattern = re.compile(r'(?P<scheme>\w+://)?(?P<username>[^:/]+):(?P<password>[^@]+)@(?P<url>.+)')
|
||||||
|
match = pattern.match(url)
|
||||||
|
if match:
|
||||||
|
scheme = match.group('scheme') if match.group('scheme') else 'https://'
|
||||||
|
username = match.group('username')
|
||||||
|
password = match.group('password')
|
||||||
|
url = match.group('url')
|
||||||
|
return username, password, scheme + url
|
||||||
|
else:
|
||||||
|
return None, None, url
|
||||||
|
|
||||||
def jsonrpc2_create_id(data):
|
def jsonrpc2_create_id(data):
|
||||||
return hashlib.sha1(json.dumps(data).encode(client_encoding)).hexdigest()
|
return hashlib.sha1(json.dumps(data).encode(client_encoding)).hexdigest()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user