a \`@sldZddlZddlZddlmZmZddlmZddZddZ d d Z d d Z d dZ ddZ ddZdS)zp oauthlib.utils ~~~~~~~~~~~~~~ This module contains utility methods used by various parts of the OAuth 2 spec. N)quoteurlparse) urldecodecCsJt|ts|dur|St|tttfr:ddd|DStd|dS)z5Convert a list of scopes to a space separated string.N cSsg|] }t|qSstr.0srrA/usr/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/utils.py z!list_to_scope..z8Invalid scope (%s), must be string, tuple, set, or list.) isinstancersettuplelistjoin ValueErrorscoperrr list_to_scopes rcCs<t|tttfrdd|DS|dur*dS|dSdS)z5Convert a space separated string to a list of scopes.cSsg|] }t|qSrrr rrr r rz!scope_to_list..Nr)rrrrstripsplitrrrr scope_to_lists rcCs.ttt|j}d|vr*t|d|d<|S)Nr)dictrrqueryr)uriparamsrrr params_from_uri"src CsNddd}t|\}}}}}}d|vr8|dd\}}n||}||fS)zuExtract hostname and port from URI. Will use default port for HTTP and HTTPS if none is present in the URI. Z80Z443)ZHTTPZHTTPS:)rrgetupper) rZ default_portsZschnetlocpathZparrZfraportrrr host_from_uri)sr'cCs$t|tstdt|dddS)ztEscape a string in an OAuth-compatible fashion. TODO: verify whether this can in fact be used for OAuth 2 z#Only unicode objects are escapable.zutf-8~)safe)rrrrencode)urrr escape<s r,cCs8tj|}|j|j|jdddd}t|S)z9Generate a age parameter for MAC authentication draft 00.ii@B)datetimeZnowZ microsecondsZsecondsZdaysr)Z issue_timeZtdZagerrr generate_ageGsr/cCstjdrdS|dS)zCheck if the uri is over ssl.ZOAUTHLIB_INSECURE_TRANSPORTTzhttps://)osenvironr"lower startswith)rrrr is_secure_transportOs r4)__doc__r.r0 urllib.parserrZoauthlib.commonrrrrr'r,r/r4rrrr s