From 878a57d142dfc94086bd82b5cdb65986efa9402e Mon Sep 17 00:00:00 2001 From: Kian-Meng Ang Date: Tue, 7 Feb 2023 15:13:35 +0800 Subject: [PATCH] Fix typos (#53) --- multipart/exceptions.py | 2 +- multipart/multipart.py | 28 ++++++++++++++-------------- multipart/tests/test_multipart.py | 7 +++---- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/multipart/exceptions.py b/multipart/exceptions.py index 3264b82..016e7f7 100644 --- a/multipart/exceptions.py +++ b/multipart/exceptions.py @@ -9,7 +9,7 @@ class ParseError(FormParserError): """ #: This is the offset in the input data chunk (*NOT* the overall stream) in - #: which the parse error occured. It will be -1 if not specified. + #: which the parse error occurred. It will be -1 if not specified. offset = -1 diff --git a/multipart/multipart.py b/multipart/multipart.py index df5d374..a9f1f9f 100644 --- a/multipart/multipart.py +++ b/multipart/multipart.py @@ -34,7 +34,7 @@ STATES = [ "START", - "START_BOUNDARY", "HEADER_FEILD_START", "HEADER_FIELD", "HEADER_VALUE_START", "HEADER_VALUE", + "START_BOUNDARY", "HEADER_FIELD_START", "HEADER_FIELD", "HEADER_VALUE_START", "HEADER_VALUE", "HEADER_VALUE_ALMOST_DONE", "HEADRES_ALMOST_DONE", "PART_DATA_START", "PART_DATA", "PART_DATA_END", "END" ] @@ -789,9 +789,9 @@ def _internal_write(self, data, length): # Depending on our state... if state == STATE_BEFORE_FIELD: # If the 'found_sep' flag is set, we've already encountered - # and skipped a single seperator. If so, we check our strict + # and skipped a single separator. If so, we check our strict # parsing flag and decide what to do. Otherwise, we haven't - # yet reached a seperator, and thus, if we do, we need to skip + # yet reached a separator, and thus, if we do, we need to skip # it as it will be the boundary between fields that's supposed # to be there. if ch == AMPERSAND or ch == SEMICOLON: @@ -809,7 +809,7 @@ def _internal_write(self, data, length): "semicolon at %d", i) else: # This case is when we're skipping the (first) - # seperator between fields, so we just set our flag + # separator between fields, so we just set our flag # and continue on. found_sep = True else: @@ -822,14 +822,14 @@ def _internal_write(self, data, length): found_sep = False elif state == STATE_FIELD_NAME: - # Try and find a seperator - we ensure that, if we do, we only + # Try and find a separator - we ensure that, if we do, we only # look for the equal sign before it. sep_pos = data.find(b'&', i) if sep_pos == -1: sep_pos = data.find(b';', i) # See if we can find an equals sign in the remaining data. If - # so, we can immedately emit the field name and jump to the + # so, we can immediately emit the field name and jump to the # data state. if sep_pos != -1: equals_pos = data.find(b'=', i, sep_pos) @@ -849,7 +849,7 @@ def _internal_write(self, data, length): # No equals sign found. if not strict_parsing: # See also comments in the STATE_FIELD_DATA case below. - # If we found the seperator, we emit the name and just + # If we found the separator, we emit the name and just # end - there's no data callback at all (not even with # a blank value). if sep_pos != -1: @@ -859,13 +859,13 @@ def _internal_write(self, data, length): i = sep_pos - 1 state = STATE_BEFORE_FIELD else: - # Otherwise, no seperator in this block, so the + # Otherwise, no separator in this block, so the # rest of this chunk must be a name. self.callback('field_name', data, i, length) i = length else: - # We're parsing strictly. If we find a seperator, + # We're parsing strictly. If we find a separator, # this is an error - we require an equals sign. if sep_pos != -1: e = QuerystringParseError( @@ -877,7 +877,7 @@ def _internal_write(self, data, length): e.offset = i raise e - # No seperator in the rest of this chunk, so it's just + # No separator in the rest of this chunk, so it's just # a field name. self.callback('field_name', data, i, length) i = length @@ -895,7 +895,7 @@ def _internal_write(self, data, length): self.callback('field_data', data, i, sep_pos) self.callback('field_end') - # Note that we go to the seperator, which brings us to the + # Note that we go to the separator, which brings us to the # "before field" state. This allows us to properly emit # "field_start" events only when we actually have data for # a field of some sort. @@ -1006,7 +1006,7 @@ def __init__(self, boundary, callbacks={}, max_size=float('inf')): self.max_size = max_size self._current_size = 0 - # Setup marks. These are used to track the state of data recieved. + # Setup marks. These are used to track the state of data received. self.marks = {} # TODO: Actually use this rather than the dumb version we currently use @@ -1500,7 +1500,7 @@ class FormParser: :class:`File`, but you can provide your own class if you wish to customize behaviour. The class will be instantiated as FileClass(file_name, field_name), and it - must provide the folllowing functions:: + must provide the following functions:: file_instance.write(data) file_instance.finalize() file_instance.close() @@ -1509,7 +1509,7 @@ class FormParser: :class:`Field`, but you can provide your own class if you wish to customize behaviour. The class will be instantiated as FieldClass(field_name), and it must - provide the folllowing functions:: + provide the following functions:: field_instance.write(data) field_instance.finalize() field_instance.close() diff --git a/multipart/tests/test_multipart.py b/multipart/tests/test_multipart.py index 8525227..089f451 100644 --- a/multipart/tests/test_multipart.py +++ b/multipart/tests/test_multipart.py @@ -391,7 +391,7 @@ def test_streaming_break(self): (b'asdf', b'baz') ) - def test_semicolon_seperator(self): + def test_semicolon_separator(self): self.p.write(b'foo=bar;asdf=baz') self.assert_fields( @@ -1070,7 +1070,7 @@ def on_file(f): f.write(b'1234') f.finalize() - # Assert that we only recieved a single file, with the right data, and that we're done. + # Assert that we only received a single file, with the right data, and that we're done. self.assertFalse(on_field.called) self.assertEqual(len(files), 1) self.assert_file_data(files[0], b'test1234') @@ -1094,7 +1094,7 @@ def simple_test(f): f.write(b'&test=asdf') f.finalize() - # Assert we only recieved 2 fields... + # Assert we only received 2 fields... self.assertFalse(on_file.called) self.assertEqual(len(fields), 2) @@ -1303,4 +1303,3 @@ def suite(): suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestHelperFunctions)) return suite -