3 fҐ @ s d Z dZddlmZmZmZ ddlmZ ddlZddl Z ddl Zddlm Z ddlmZ ddlmZ ddlZddlZddlZd d ddd ddddddddddgZdadadd Zdd Zdd Zdd Zeadade jddd!fd"dZd6d#dZ d7d$d Z!d%d Z"d&d' Z#d(d Z$G d)d d Z%G d*d d Z&e jfd+dZ'd8d,dZ(e jfd-dZ)d.d Z*d/d Z+d0d Z,d1d Z-d9d2dZ.d3d4 Z/e0d5kre' dS ):zSupport module for CGI (Common Gateway Interface) scripts. This module defines a number of utilities for use by CGI scripts written in Python. z2.6 )StringIOBytesIO TextIOWrapper)MappingN) FeedParser)Message)warnMiniFieldStorageFieldStorageparseparse_qs parse_qslparse_multipartparse_headertestprint_exception print_environ print_formprint_directoryprint_argumentsprint_environ_usageescape c G sH t r.t r.ytt daW n tk r, Y nX ts8tantat| dS )a Write a log message, if there is a log file. Even though this function is called initlog(), you should always use log(); log is a variable that is set either to initlog (initially), to dolog (once the log file has been opened), or to nolog (when logging is disabled). The first argument is a format string; the remaining arguments (if any) are arguments to the % operator, so e.g. log("%s: %s", "a", "b") will write "a: b" to the log file, followed by a newline. If the global logfp is not None, it should be a file object to which log data is written. If the global logfp is None, the global logfile may be a string giving a filename to open, in append mode. This file should be world writable!!! If the file can't be opened, logging is silently disabled (since there is no safe place where we could send an error message). aN)logfilelogfpopenOSErrornologlogdolog)allargs r" (/opt/alt/python36/lib64/python3.6/cgi.pyinitlog: s r$ c G s t j| | d dS )z=Write a log message to the log file. See initlog() for docs. N)r write)Zfmtargsr" r" r# r ] s r c G s dS )z9Dummy function, assigned to log when logging is disabled.Nr" )r! r" r" r# r a s r c C s da trtj datadS )zClose the log file.r N)r r closer$ r r" r" r" r# closeloge s r) &c C sZ | dkrt j} t| dr | j}nd}t| tr4| j} d|krDd|d<