3 Pf2 @ s d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl m Z ddlmZ ej eZejdZd d ZG dd deZdS ) z7 The httplib2 algorithms ported for use with requests. N)parsedate_tz)CaseInsensitiveDict ) DictCache) Serializerz9^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?c C s0 t j| j }|d |d |d |d |d fS )zParses a URI using the regex given in Appendix B of RFC 3986. (scheme, authority, path, query, fragment) = parse_uri(uri) r )URImatchgroups)urir r /usr/lib/python3.6/controller.py parse_uri s r c @ s\ e Zd ZdZdddZedd Zedd Zd d Zdd Z dd Z dddZdd ZdS )CacheControllerz9An interface to see if request should cached or not. NTc C s" |pt | _|| _|pt | _d S )N)r cachecache_etagsr serializer)selfr r r r r r __init__! s zCacheController.__init__c C sl t |\}}}}}| s| r*td| |j }|j }|sBd}|rTdj||gpV|}|d | | }|S )z4Normalize the URL to create a safe key for the cachez(Only absolute URIs are allowed. uri = %s/?z://)r Exceptionlowerjoin) clsr schemeZ authoritypathZqueryZfragmentZrequest_uriZ defrag_urir r r _urlnorm&