1111
1212# History
1313# -------
14- #
14+ #
1515# Michael McLay started this module. Steve Majewski changed the
1616# interface to SvFormContentDict and FormContentDict. The multipart
1717# parsing was inspired by code submitted by Andreas Paepcke. Guido van
1818# Rossum rewrote, reformatted and documented the module and is currently
1919# responsible for its maintenance.
20- #
20+ #
2121
2222__version__ = "2.5"
2323
@@ -104,8 +104,8 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0):
104104 environ : environment dictionary; default: os.environ
105105
106106 keep_blank_values: flag indicating whether blank values in
107- URL encoded forms should be treated as blank strings.
108- A true value indicates that blanks should be retained as
107+ URL encoded forms should be treated as blank strings.
108+ A true value indicates that blanks should be retained as
109109 blank strings. The default false value indicates that
110110 blank values are to be ignored and treated as if they were
111111 not included.
@@ -129,10 +129,10 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0):
129129 qs = fp .read (clength )
130130 else :
131131 qs = '' # Unknown content-type
132- if environ .has_key ('QUERY_STRING' ):
132+ if environ .has_key ('QUERY_STRING' ):
133133 if qs : qs = qs + '&'
134134 qs = qs + environ ['QUERY_STRING' ]
135- elif sys .argv [1 :]:
135+ elif sys .argv [1 :]:
136136 if qs : qs = qs + '&'
137137 qs = qs + sys .argv [1 ]
138138 environ ['QUERY_STRING' ] = qs # XXX Shouldn't, really
@@ -155,8 +155,8 @@ def parse_qs(qs, keep_blank_values=0, strict_parsing=0):
155155 qs: URL-encoded query string to be parsed
156156
157157 keep_blank_values: flag indicating whether blank values in
158- URL encoded queries should be treated as blank strings.
159- A true value indicates that blanks should be retained as
158+ URL encoded queries should be treated as blank strings.
159+ A true value indicates that blanks should be retained as
160160 blank strings. The default false value indicates that
161161 blank values are to be ignored and treated as if they were
162162 not included.
@@ -188,7 +188,7 @@ def parse_qsl(qs, keep_blank_values=0, strict_parsing=0):
188188
189189 strict_parsing: flag indicating what to do with parsing errors. If
190190 false (the default), errors are silently ignored. If true,
191- errors raise a ValueError exception.
191+ errors raise a ValueError exception.
192192
193193 Returns a list, as G-d intended.
194194 """
@@ -215,17 +215,17 @@ def parse_multipart(fp, pdict):
215215 fp : input file
216216 pdict: dictionary containing other parameters of conten-type header
217217
218- Returns a dictionary just like parse_qs(): keys are the field names, each
219- value is a list of values for that field. This is easy to use but not
220- much good if you are expecting megabytes to be uploaded -- in that case,
221- use the FieldStorage class instead which is much more flexible. Note
222- that content-type is the raw, unparsed contents of the content-type
218+ Returns a dictionary just like parse_qs(): keys are the field names, each
219+ value is a list of values for that field. This is easy to use but not
220+ much good if you are expecting megabytes to be uploaded -- in that case,
221+ use the FieldStorage class instead which is much more flexible. Note
222+ that content-type is the raw, unparsed contents of the content-type
223223 header.
224-
225- XXX This does not parse nested multipart parts -- use FieldStorage for
224+
225+ XXX This does not parse nested multipart parts -- use FieldStorage for
226226 that.
227-
228- XXX This should really be subsumed by FieldStorage altogether -- no
227+
228+ XXX This should really be subsumed by FieldStorage altogether -- no
229229 point in having two implementations of the same parsing algorithm.
230230
231231 """
@@ -409,8 +409,8 @@ def __init__(self, fp=None, headers=None, outerboundary="",
409409 environ : environment dictionary; default: os.environ
410410
411411 keep_blank_values: flag indicating whether blank values in
412- URL encoded forms should be treated as blank strings.
413- A true value indicates that blanks should be retained as
412+ URL encoded forms should be treated as blank strings.
413+ A true value indicates that blanks should be retained as
414414 blank strings. The default false value indicates that
415415 blank values are to be ignored and treated as if they were
416416 not included.
@@ -707,7 +707,7 @@ def make_file(self, binary=None):
707707 """
708708 import tempfile
709709 return tempfile .TemporaryFile ("w+b" )
710-
710+
711711
712712
713713# Backwards Compatibility Classes
@@ -744,8 +744,8 @@ class SvFormContentDict(FormContentDict):
744744
745745 """
746746 def __getitem__ (self , key ):
747- if len (self .dict [key ]) > 1 :
748- raise IndexError , 'expecting a single value'
747+ if len (self .dict [key ]) > 1 :
748+ raise IndexError , 'expecting a single value'
749749 return self .dict [key ][0 ]
750750 def getlist (self , key ):
751751 return self .dict [key ]
@@ -766,7 +766,7 @@ def items(self):
766766
767767
768768class InterpFormContentDict (SvFormContentDict ):
769- """This class is present for backwards compatibility only."""
769+ """This class is present for backwards compatibility only."""
770770 def __getitem__ (self , key ):
771771 v = SvFormContentDict .__getitem__ (self , key )
772772 if v [0 ] in string .digits + '+-.' :
@@ -794,7 +794,7 @@ def items(self):
794794
795795
796796class FormContent (FormContentDict ):
797- """This class is present for backwards compatibility only."""
797+ """This class is present for backwards compatibility only."""
798798 def values (self , key ):
799799 if self .dict .has_key (key ) :return self .dict [key ]
800800 else : return None
@@ -882,7 +882,7 @@ def print_environ(environ=os.environ):
882882 print "<DL>"
883883 for key in keys :
884884 print "<DT>" , escape (key ), "<DD>" , escape (environ [key ])
885- print "</DL>"
885+ print "</DL>"
886886 print
887887
888888def print_form (form ):
@@ -982,5 +982,5 @@ def escape(s, quote=None):
982982# ===============
983983
984984# Call test() when this file is run as a script (not imported as a module)
985- if __name__ == '__main__' :
985+ if __name__ == '__main__' :
986986 test ()
0 commit comments