summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Lib/cgi.py
diff options
context:
space:
mode:
authorshadchin <[email protected]>2022-02-10 16:44:39 +0300
committerDaniil Cherednik <[email protected]>2022-02-10 16:44:39 +0300
commite9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch)
tree64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/tools/python3/src/Lib/cgi.py
parent2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff)
Restoring authorship annotation for <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Lib/cgi.py')
-rw-r--r--contrib/tools/python3/src/Lib/cgi.py52
1 files changed, 26 insertions, 26 deletions
diff --git a/contrib/tools/python3/src/Lib/cgi.py b/contrib/tools/python3/src/Lib/cgi.py
index 59d03c0ec02..1e880e51848 100644
--- a/contrib/tools/python3/src/Lib/cgi.py
+++ b/contrib/tools/python3/src/Lib/cgi.py
@@ -42,10 +42,10 @@ import html
import locale
import tempfile
-__all__ = ["MiniFieldStorage", "FieldStorage", "parse", "parse_multipart",
+__all__ = ["MiniFieldStorage", "FieldStorage", "parse", "parse_multipart",
"parse_header", "test", "print_exception", "print_environ",
"print_form", "print_directory", "print_arguments",
- "print_environ_usage"]
+ "print_environ_usage"]
# Logging support
# ===============
@@ -115,8 +115,8 @@ log = initlog # The current logging function
# 0 ==> unlimited input
maxlen = 0
-def parse(fp=None, environ=os.environ, keep_blank_values=0,
- strict_parsing=0, separator='&'):
+def parse(fp=None, environ=os.environ, keep_blank_values=0,
+ strict_parsing=0, separator='&'):
"""Parse a query in the environment or from a file (default stdin)
Arguments, all optional:
@@ -135,9 +135,9 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0,
strict_parsing: flag indicating what to do with parsing errors.
If false (the default), errors are silently ignored.
If true, errors raise a ValueError exception.
-
- separator: str. The symbol to use for separating the query arguments.
- Defaults to &.
+
+ separator: str. The symbol to use for separating the query arguments.
+ Defaults to &.
"""
if fp is None:
fp = sys.stdin
@@ -158,7 +158,7 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0,
if environ['REQUEST_METHOD'] == 'POST':
ctype, pdict = parse_header(environ['CONTENT_TYPE'])
if ctype == 'multipart/form-data':
- return parse_multipart(fp, pdict, separator=separator)
+ return parse_multipart(fp, pdict, separator=separator)
elif ctype == 'application/x-www-form-urlencoded':
clength = int(environ['CONTENT_LENGTH'])
if maxlen and clength > maxlen:
@@ -182,10 +182,10 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0,
qs = ""
environ['QUERY_STRING'] = qs # XXX Shouldn't, really
return urllib.parse.parse_qs(qs, keep_blank_values, strict_parsing,
- encoding=encoding, separator=separator)
+ encoding=encoding, separator=separator)
-def parse_multipart(fp, pdict, encoding="utf-8", errors="replace", separator='&'):
+def parse_multipart(fp, pdict, encoding="utf-8", errors="replace", separator='&'):
"""Parse multipart input.
Arguments:
@@ -204,12 +204,12 @@ def parse_multipart(fp, pdict, encoding="utf-8", errors="replace", separator='&'
ctype = "multipart/form-data; boundary={}".format(boundary)
headers = Message()
headers.set_type(ctype)
- try:
- headers['Content-Length'] = pdict['CONTENT-LENGTH']
- except KeyError:
- pass
+ try:
+ headers['Content-Length'] = pdict['CONTENT-LENGTH']
+ except KeyError:
+ pass
fs = FieldStorage(fp, headers=headers, encoding=encoding, errors=errors,
- environ={'REQUEST_METHOD': 'POST'}, separator=separator)
+ environ={'REQUEST_METHOD': 'POST'}, separator=separator)
return {k: fs.getlist(k) for k in fs}
def _parseparam(s):
@@ -319,7 +319,7 @@ class FieldStorage:
def __init__(self, fp=None, headers=None, outerboundary=b'',
environ=os.environ, keep_blank_values=0, strict_parsing=0,
limit=None, encoding='utf-8', errors='replace',
- max_num_fields=None, separator='&'):
+ max_num_fields=None, separator='&'):
"""Constructor. Read multipart/* until last part.
Arguments, all optional:
@@ -367,7 +367,7 @@ class FieldStorage:
self.keep_blank_values = keep_blank_values
self.strict_parsing = strict_parsing
self.max_num_fields = max_num_fields
- self.separator = separator
+ self.separator = separator
if 'REQUEST_METHOD' in environ:
method = environ['REQUEST_METHOD'].upper()
self.qs_on_post = None
@@ -469,7 +469,7 @@ class FieldStorage:
if maxlen and clen > maxlen:
raise ValueError('Maximum content length exceeded')
self.length = clen
- if self.limit is None and clen >= 0:
+ if self.limit is None and clen >= 0:
self.limit = clen
self.list = self.file = None
@@ -594,7 +594,7 @@ class FieldStorage:
query = urllib.parse.parse_qsl(
qs, self.keep_blank_values, self.strict_parsing,
encoding=self.encoding, errors=self.errors,
- max_num_fields=self.max_num_fields, separator=self.separator)
+ max_num_fields=self.max_num_fields, separator=self.separator)
self.list = [MiniFieldStorage(key, value) for key, value in query]
self.skip_lines()
@@ -610,7 +610,7 @@ class FieldStorage:
query = urllib.parse.parse_qsl(
self.qs_on_post, self.keep_blank_values, self.strict_parsing,
encoding=self.encoding, errors=self.errors,
- max_num_fields=self.max_num_fields, separator=self.separator)
+ max_num_fields=self.max_num_fields, separator=self.separator)
self.list.extend(MiniFieldStorage(key, value) for key, value in query)
klass = self.FieldStorageClass or self.__class__
@@ -650,11 +650,11 @@ class FieldStorage:
if 'content-length' in headers:
del headers['content-length']
- limit = None if self.limit is None \
- else self.limit - self.bytes_read
+ limit = None if self.limit is None \
+ else self.limit - self.bytes_read
part = klass(self.fp, headers, ib, environ, keep_blank_values,
- strict_parsing, limit,
- self.encoding, self.errors, max_num_fields, self.separator)
+ strict_parsing, limit,
+ self.encoding, self.errors, max_num_fields, self.separator)
if max_num_fields is not None:
max_num_fields -= 1
@@ -744,8 +744,8 @@ class FieldStorage:
last_line_lfend = True
_read = 0
while 1:
-
- if self.limit is not None and 0 <= self.limit <= _read:
+
+ if self.limit is not None and 0 <= self.limit <= _read:
break
line = self.fp.readline(1<<16) # bytes
self.bytes_read += len(line)