a
    lHªhA  ã                   @   sD   d dl mZ d dlZd dlZd dlZdd„ Zdd„ Zedd„ ƒZdS )	é    )ÚcontextmanagerNc                  C   sž   t j t j t j t¡¡¡} t j | dd¡}t ¡ }| |¡ d|d d  	¡ |d d  	¡ |d d  	¡ |d d  	¡ |d d	  	¡ |d d
  	¡ dœ}|S )NZconfzpinguinite.confÚ	localhostÚDEFAULTZMySQLDatabaseZMySQLIDZMySQLPWÚHomeURLDomainÚAdminDirectoryÚOutMailServer)ÚhostÚdatabaseÚuserÚpasswordr   r   r   )
ÚosÚpathÚdirnameÚabspathÚ__file__ÚjoinÚconfigparserÚConfigParserÚreadÚstrip)ZBASE_DIRZ	CONF_PATHÚconfigZ	ping_conf© r   ú*/wd/v2025.freedom4um.com/utils/pingdata.pyÚget_pingconf_vars   s    
ù	r   c                    s&   ‡ fdd„dD ƒ}d|d< d|d< |S )Nc                    s   i | ]}|ˆ | “qS r   r   )Ú.0Úk©ÚPingConfr   r   Ú
<dictcomp>   ó    z#get_mysql_creds.<locals>.<dictcomp>)r   r	   r
   r   Úutf8mb4ÚcharsetZutf8mb4_unicode_ciZ	collationr   )r   Úmysql_credsr   r   r   Úget_mysql_creds   s    r#   c                 c   sD   d| vrd| d< t jjf i | ¤Ž}z|V  W | ¡  n
| ¡  0 d S )Nr!   r    )ÚmysqlZ	connectorÚconnectÚclose)Z
mysqlcredsÚconnr   r   r   Ú
open_mysql!   s    r(   )	Ú
contextlibr   r   r   Zmysql.connectorr$   r   r#   r(   r   r   r   r   Ú<module>   s   