Skip to content

Commit

Permalink
BugFix
Browse files Browse the repository at this point in the history
  • Loading branch information
helviojunior committed May 18, 2024
1 parent 006be59 commit 5fa2afe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions filecrawler/libs/containerfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from typing import Optional
from filecrawler.libs.file import File
from filecrawler.libs.process import Process
from filecrawler.util.tools import Tools
import shutil


Expand Down Expand Up @@ -102,11 +101,12 @@ def extract_eml(self) -> bool:
import email
from email import policy
from email.parser import HeaderParser
from filecrawler.util.tools import Tools

with open(str(self._file.path), "r") as f:
msg = email.message_from_file(f, policy=policy.default)
msg_data = None
msg_epoch = Tools.to_epoch(Tools.get_email_date(msg))
msg_data = None

full_name = os.path.join(str(self._temp_path), f"header.txt")
try:
Expand Down
6 changes: 3 additions & 3 deletions filecrawler/util/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ def get_git_version():

@staticmethod
def to_datetime(epoch: [int, float]) -> datetime.datetime:
return datetime.datetime(1970, 1, 1, 0, 0, 0) + datetime.timedelta(seconds=int(epoch))
return datetime.datetime(1970, 1, 1, 0, 0, 0) + datetime.timedelta(seconds=epoch)

@staticmethod
def to_epoch(date: datetime.datetime) -> int:
return (date - datetime.datetime(1970, 1, 1, 0, 0, 0)).seconds
def to_epoch(date: datetime.datetime) -> float:
return (date - datetime.datetime(1970, 1, 1, 0, 0, 0)).total_seconds()

@staticmethod
def to_boolean(text: [str, bool]) -> bool:
Expand Down

0 comments on commit 5fa2afe

Please sign in to comment.