mirror of
https://github.com/httpie/cli.git
synced 2025-06-26 12:31:47 +02:00
Cleanup
This commit is contained in:
parent
43f7b84a1e
commit
2078ece95a
@ -452,8 +452,8 @@ class KeyValueArgType(object):
|
|||||||
class Escaped(str):
|
class Escaped(str):
|
||||||
"""Represents an escaped character."""
|
"""Represents an escaped character."""
|
||||||
|
|
||||||
def tokenize(s):
|
def tokenize(string):
|
||||||
"""Tokenize `s`. There are only two token types - strings
|
"""Tokenize `string`. There are only two token types - strings
|
||||||
and escaped characters:
|
and escaped characters:
|
||||||
|
|
||||||
tokenize(r'foo\=bar\\baz')
|
tokenize(r'foo\=bar\\baz')
|
||||||
@ -462,16 +462,16 @@ class KeyValueArgType(object):
|
|||||||
"""
|
"""
|
||||||
backslash = '\\'
|
backslash = '\\'
|
||||||
tokens = ['']
|
tokens = ['']
|
||||||
s = iter(s)
|
characters = iter(string)
|
||||||
for c in s:
|
for char in characters:
|
||||||
if c == backslash:
|
if char == backslash:
|
||||||
nc = next(s, '')
|
next_char = next(characters, '')
|
||||||
if nc in self.special_characters:
|
if next_char in self.special_characters:
|
||||||
tokens.extend([Escaped(nc), ''])
|
tokens.extend([Escaped(next_char), ''])
|
||||||
else:
|
else:
|
||||||
tokens[-1] += c + nc
|
tokens[-1] += char + next_char
|
||||||
else:
|
else:
|
||||||
tokens[-1] += c
|
tokens[-1] += char
|
||||||
return tokens
|
return tokens
|
||||||
|
|
||||||
tokens = tokenize(string)
|
tokens = tokenize(string)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user