3 �gag � @ s� d Z ddlZddlZddlmZ ddlmZ ddlmZm Z m Z ddlmZ ddl mZ ddlmZmZ d d lmZ d dlmZmZ d dlmZ d Zee Zejd�ZddgZeee e edd�dd�ZG dd� de�Z dS )z( Persistent, JSON-serialized sessions. � N)�SimpleCookie)�Path)�Iterable�Optional�Union)�urlsplit)�AuthBase)�RequestsCookieJar� create_cookie� )�RequestHeadersDict)�BaseConfigDict�DEFAULT_CONFIG_DIR)�plugin_managerZsessionsz^[a-zA-Z0-9_.-]+$zContent-zIf-�Session)� config_dir�session_name�host�url�returnc C sp t jj|krt jj|�}nB|p0t|�jjd�d }|s:d}|jdd�}| t | |� d� }t |�}|j � |S )N�@r Z localhost�:�_z.json���)�os�path�sep� expanduserr Znetloc�split�replace�SESSIONS_DIR_NAMEr �load)r r r r r ZhostnameZsession� r"