Omkar008 commited on
Commit
1db5498
1 Parent(s): 0f18465

Update get_gmail_data.py

Browse files
Files changed (1) hide show
  1. get_gmail_data.py +7 -4
get_gmail_data.py CHANGED
@@ -159,9 +159,9 @@ class GmailDataExtractor:
159
 
160
  if data:
161
  # Save only the first 10 characters of the attachment data
162
- return subject,body , links , {filename:data}
163
 
164
- return subject, body, links , None
165
 
166
  def extract_text_and_links(html_content: str) -> tuple:
167
  """
@@ -200,7 +200,7 @@ class GmailDataExtractor:
200
 
201
  Returns:
202
  dict: A dictionary containing the extracted messages with their subjects, bodies, links, and attachment statuses.
203
- format:{"results":[{"subjec":"test subject" , "body":"it would be text" , "attachment_data":{"filename":base64URL format}},{second message with same content of subject , body , attachment_data}]}
204
 
205
  """
206
  messages = self.__fetch_messages()
@@ -213,6 +213,9 @@ class GmailDataExtractor:
213
  body = body if body is not None else ""
214
  attachment_data = attachment_data if attachment_data is not None else {}
215
 
216
- results.append({"subject": subject, "body": body, "attachment_data": attachment_data})
 
 
 
217
 
218
  return {"results": results}
 
159
 
160
  if data:
161
  # Save only the first 10 characters of the attachment data
162
+ return subject,body ,{"filename":filename , "base64URLData":data}
163
 
164
+ return subject, body,None
165
 
166
  def extract_text_and_links(html_content: str) -> tuple:
167
  """
 
200
 
201
  Returns:
202
  dict: A dictionary containing the extracted messages with their subjects, bodies, links, and attachment statuses.
203
+ format:{"results":[{"subjec":"test subject" , "body":"it would be text" , "attachment_data":{"filename":filename,"base64URLData":data}},{second message with same content of subject , body , attachment_data}]}
204
 
205
  """
206
  messages = self.__fetch_messages()
 
213
  body = body if body is not None else ""
214
  attachment_data = attachment_data if attachment_data is not None else {}
215
 
216
+ if attachment_data: # Check if attachment_data is present
217
+ results.append({"attachment_data": attachment_data})
218
+ elif body: # If attachment_data is absent, append body only if it's not empty
219
+ results.append({"body": body})
220
 
221
  return {"results": results}