diff options
| author | uvok | 2025-01-19 15:13:54 +0100 | 
|---|---|---|
| committer | uvok | 2025-01-19 15:13:54 +0100 | 
| commit | fa8795206b4f70422c5eec38c5def0bc7426e8d1 (patch) | |
| tree | 69c25321aad0e3c1a4695766afddb32cc29821d2 | |
| parent | ba49c8558029ef76225beb78172e0b7968771ee4 (diff) | |
Add datetime
| -rw-r--r-- | hello-fusepy.py | 10 | 
1 files changed, 8 insertions, 2 deletions
diff --git a/hello-fusepy.py b/hello-fusepy.py index 7fc86c1..010ef9d 100644 --- a/hello-fusepy.py +++ b/hello-fusepy.py @@ -3,6 +3,7 @@ import errno  import stat  import logging  import requests +from datetime import datetime as dtp  from fuse import (      FUSE,      Operations, @@ -16,9 +17,10 @@ api_url = "https://furry.engineer/users/uvok/outbox?min_id=0&page=true"  class Status(object): -    def __init__(self, id: str, content: str): +    def __init__(self, id: str, content: str, published: str):          self.id = id          self.content = content +        self.published = published  class HelloWorld(Operations, LoggingMixIn): @@ -37,11 +39,15 @@ class HelloWorld(Operations, LoggingMixIn):              }          found = next((s for s in self.statuses if "/" + s.id == path), None)          if found: +            published_dt = dtp.fromisoformat(found.published) +            pubunix = published_dt.timestamp()              return {                  "st_mode": (stat.S_IFREG | 0o400),                  "st_size": len(found.content.encode("utf8")),                  "st_uid": uid,                  "st_gid": gid, +                "st_ctime": pubunix, +                "st_mtime": pubunix,              }          raise FuseOSError(errno.ENOENT) @@ -51,7 +57,7 @@ class HelloWorld(Operations, LoggingMixIn):          stats = res.json()          logging.debug(f"Status: ${stats['id']}")          self.statuses = [ -            Status(s["object"]["id"].split("/")[-1], s["object"]["content"]) +            Status(s["object"]["id"].split("/")[-1], s["object"]["content"], s["object"]["published"])              for s in stats["orderedItems"]          ]          pass  | 
