| 71 | removed_in, details) |
| 72 | |
| 73 | def __str__(self): |
| 74 | # Use a defaultdict to give us the empty string |
| 75 | # when a part isn't included. |
| 76 | parts = collections.defaultdict(str) |
| 77 | parts["function"] = self.function |
| 78 | |
| 79 | if self.deprecated_in: |
| 80 | parts["deprecated"] = " as of %s" % self.deprecated_in |
| 81 | if self.removed_in: |
| 82 | parts["removed"] = " and will be removed {} {}".format("on" if isinstance(self.removed_in, date) else "in", |
| 83 | self.removed_in) |
| 84 | if any([self.deprecated_in, self.removed_in, self.details]): |
| 85 | parts["period"] = "." |
| 86 | if self.details: |
| 87 | parts["details"] = " %s" % self.details |
| 88 | |
| 89 | return ("%(function)s is deprecated%(deprecated)s%(removed)s" |
| 90 | "%(period)s%(details)s" % (parts)) |
| 91 | |
| 92 | |
| 93 | class UnsupportedWarning(DeprecatedWarning): |