Rename Message.add() to Message._parse_line()
This commit is contained in:
parent
3a878eb975
commit
a3b6969349
1 changed files with 25 additions and 30 deletions
|
@ -96,7 +96,31 @@ class Message(DatabaseTable):
|
||||||
self.content
|
self.content
|
||||||
)
|
)
|
||||||
|
|
||||||
def add(self, line: str):
|
def header(self, key: str):
|
||||||
|
return self.headers.get(key.lower())
|
||||||
|
|
||||||
|
def unique_id(self) -> str:
|
||||||
|
return self.header('Message-ID')
|
||||||
|
|
||||||
|
def parent_id(self) -> str:
|
||||||
|
return self.header('References')
|
||||||
|
|
||||||
|
def date(self):
|
||||||
|
try:
|
||||||
|
return search_dates(self.headers['date'])[0][1]
|
||||||
|
except:
|
||||||
|
return datetime.datetime.fromtimestamp(0)
|
||||||
|
|
||||||
|
def sender(self):
|
||||||
|
return self.headers.get('from', 'Unknown')
|
||||||
|
|
||||||
|
def subject(self):
|
||||||
|
return self.headers.get('subject', '(no subject)')
|
||||||
|
|
||||||
|
def is_first_line(self):
|
||||||
|
return len(self.headers) == 1 and (self.body == '' or self.body is None)
|
||||||
|
|
||||||
|
def _parse_line(self, line: str):
|
||||||
if self.line is not None:
|
if self.line is not None:
|
||||||
self.content += self.line
|
self.content += self.line
|
||||||
|
|
||||||
|
@ -123,35 +147,6 @@ class Message(DatabaseTable):
|
||||||
|
|
||||||
self.line = line
|
self.line = line
|
||||||
|
|
||||||
def header(self, key: str):
|
|
||||||
return self.headers.get(key.lower())
|
|
||||||
|
|
||||||
def unique_id(self) -> str:
|
|
||||||
return self.header('Message-ID')
|
|
||||||
|
|
||||||
def parent_id(self) -> str:
|
|
||||||
return self.header('References')
|
|
||||||
|
|
||||||
def date(self):
|
|
||||||
try:
|
|
||||||
return search_dates(self.headers['date'])[0][1]
|
|
||||||
except:
|
|
||||||
return datetime.datetime.fromtimestamp(0)
|
|
||||||
|
|
||||||
def sender(self):
|
|
||||||
return self.headers.get('from', 'Unknown')
|
|
||||||
|
|
||||||
def subject(self):
|
|
||||||
return self.headers.get('subject', '(no subject)')
|
|
||||||
|
|
||||||
def is_first_line(self):
|
|
||||||
return len(self.headers) == 1 and (self.body == '' or self.body is None)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse(text: str):
|
def parse(text: str):
|
||||||
message = Message()
|
message = Message()
|
||||||
|
|
Loading…
Add table
Reference in a new issue