Skip to content

Commit

Permalink
Fix typos (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
kianmeng authored Feb 7, 2023
1 parent 3e4db8e commit 878a57d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion multipart/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
28 changes: 14 additions & 14 deletions multipart/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]

Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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)
Expand All @@ -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:
Expand All @@ -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(
Expand All @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down
7 changes: 3 additions & 4 deletions multipart/tests/test_multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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')
Expand All @@ -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)

Expand Down Expand Up @@ -1303,4 +1303,3 @@ def suite():
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestHelperFunctions))

return suite

0 comments on commit 878a57d

Please sign in to comment.