| 388 | """ % (self.OutputString(attrs).replace('"', r'\"')) |
| 389 | |
| 390 | def OutputString(self, attrs=None): |
| 391 | # Build up our result |
| 392 | # |
| 393 | result = [] |
| 394 | append = result.append |
| 395 | |
| 396 | # First, the key=value pair |
| 397 | append("%s=%s" % (self.key, self.coded_value)) |
| 398 | |
| 399 | # Now add any defined attributes |
| 400 | if attrs is None: |
| 401 | attrs = self._reserved |
| 402 | items = sorted(self.items()) |
| 403 | for key, value in items: |
| 404 | if value == "": |
| 405 | continue |
| 406 | if key not in attrs: |
| 407 | continue |
| 408 | if key == "expires" and isinstance(value, int): |
| 409 | append("%s=%s" % (self._reserved[key], _getdate(value))) |
| 410 | elif key == "max-age" and isinstance(value, int): |
| 411 | append("%s=%d" % (self._reserved[key], value)) |
| 412 | elif key == "comment" and isinstance(value, str): |
| 413 | append("%s=%s" % (self._reserved[key], _quote(value))) |
| 414 | elif key in self._flags: |
| 415 | if value: |
| 416 | append(str(self._reserved[key])) |
| 417 | else: |
| 418 | append("%s=%s" % (self._reserved[key], value)) |
| 419 | |
| 420 | # Return the result |
| 421 | return _semispacejoin(result) |
| 422 | |
| 423 | __class_getitem__ = classmethod(types.GenericAlias) |
| 424 | |