32 @param key key for the item |
32 @param key key for the item |
33 @param value value of the item |
33 @param value value of the item |
34 """ |
34 """ |
35 if key in self: |
35 if key in self: |
36 raise DuplicateParamError(key) |
36 raise DuplicateParamError(key) |
37 super(UniqueNamespace, self).__setitem__(key, value) |
37 super().__setitem__(key, value) |
38 |
38 |
39 # RFC 2616 |
39 # RFC 2616 |
40 separator_chars = "()<>@,;:\\\"/[]?={} \t" # __IGNORE_WARNING_M613__ |
40 separator_chars = "()<>@,;:\\\"/[]?={} \t" # __IGNORE_WARNING_M613__ |
41 ctl_chars = ''.join(chr(i) for i in range(32)) + chr(127) |
41 ctl_chars = ''.join(chr(i) for i in range(32)) + chr(127) |
42 nontoken_chars = separator_chars + ctl_chars |
42 nontoken_chars = separator_chars + ctl_chars |
81 A quoted string (RFC 2616, Section 2.2). |
81 A quoted string (RFC 2616, Section 2.2). |
82 """ |
82 """ |
83 grammar = re.compile(r'"({0}|{1})+"'.format(quoted_pair_re, qdtext_re)) |
83 grammar = re.compile(r'"({0}|{1})+"'.format(quoted_pair_re, qdtext_re)) |
84 |
84 |
85 def __str__(self): |
85 def __str__(self): |
86 s = super(QuotedString, self).__str__() |
86 s = super().__str__() |
87 s = s[1:-1] # remove quotes |
87 s = s[1:-1] # remove quotes |
88 s = re.sub(r'\\(.)', r'\1', s) # drop backslashes |
88 s = re.sub(r'\\(.)', r'\1', s) # drop backslashes |
89 return s |
89 return s |
90 |
90 |
91 class Value(str): |
91 class Value(str): |
135 A token introducing an extended value (RFC 6266, Section 4.1). |
135 A token introducing an extended value (RFC 6266, Section 4.1). |
136 """ |
136 """ |
137 regex = re.compile(token_re + r'\*') |
137 regex = re.compile(token_re + r'\*') |
138 |
138 |
139 def __str__(self): |
139 def __str__(self): |
140 return super(ExtToken, self).__str__().lower() |
140 return super().__str__().lower() |
141 |
141 |
142 class NoExtToken(peg.Symbol): |
142 class NoExtToken(peg.Symbol): |
143 """ |
143 """ |
144 A token introducing a normal value (RFC 6266, Section 4.1). |
144 A token introducing a normal value (RFC 6266, Section 4.1). |
145 """ |
145 """ |
146 regex = re.compile(token_re + r'(?<!\*)') |
146 regex = re.compile(token_re + r'(?<!\*)') |
147 |
147 |
148 def __str__(self): |
148 def __str__(self): |
149 return super(NoExtToken, self).__str__().lower() |
149 return super().__str__().lower() |
150 |
150 |
151 class DispositionParm(str): |
151 class DispositionParm(str): |
152 """ |
152 """ |
153 A parameter for the Disposition-Type header (RFC6266, Section 4.1). |
153 A parameter for the Disposition-Type header (RFC6266, Section 4.1). |
154 """ |
154 """ |