diff options
author | Barry Warsaw <barry@python.org> | 2002-09-28 20:44:58 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2002-09-28 20:44:58 (GMT) |
commit | e03e8f09eb135c7470850320792e90f8cd73fec3 (patch) | |
tree | 04e6edd16548de569c9cbc400d1dcbe190eba7cf | |
parent | 4ece778bbc5bbb2408bc7494bf58924039d5eaa4 (diff) | |
download | cpython-e03e8f09eb135c7470850320792e90f8cd73fec3.zip cpython-e03e8f09eb135c7470850320792e90f8cd73fec3.tar.gz cpython-e03e8f09eb135c7470850320792e90f8cd73fec3.tar.bz2 |
Use True/False everywhere.
-rw-r--r-- | Lib/email/Parser.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Lib/email/Parser.py b/Lib/email/Parser.py index 869ef16..98d20c3 100644 --- a/Lib/email/Parser.py +++ b/Lib/email/Parser.py @@ -14,9 +14,16 @@ from email import Message EMPTYSTRING = '' NL = '\n' +try: + True, False +except NameError: + True = 1 + False = 0 + + class Parser: - def __init__(self, _class=Message.Message, strict=0): + def __init__(self, _class=Message.Message, strict=False): """Parser of RFC 2822 and MIME email messages. Creates an in-memory object tree representing the email message, which @@ -41,14 +48,14 @@ class Parser: self._class = _class self._strict = strict - def parse(self, fp, headersonly=0): + def parse(self, fp, headersonly=False): root = self._class() self._parseheaders(root, fp) if not headersonly: self._parsebody(root, fp) return root - def parsestr(self, text, headersonly=0): + def parsestr(self, text, headersonly=False): return self.parse(StringIO(text), headersonly=headersonly) def _parseheaders(self, container, fp): @@ -57,7 +64,7 @@ class Parser: lastheader = '' lastvalue = [] lineno = 0 - while 1: + while True: # Don't strip the line before we test for the end condition, # because whitespace-only header lines are RFC compliant # continuation lines. @@ -216,7 +223,7 @@ class Parser: # by a blank line. We'll represent each header block as a # separate Message object blocks = [] - while 1: + while True: blockmsg = self._class() self._parseheaders(blockmsg, fp) if not len(blockmsg): |