fix typing issue
This commit is contained in:
parent
398736c4ad
commit
22ef62202a
2 changed files with 16 additions and 7 deletions
|
|
@ -201,9 +201,9 @@ def getargs() -> argparse.Namespace:
|
|||
elif args.mode == "ingest-db":
|
||||
args.infile = utils.abspath(args.infile)
|
||||
elif args.mode == "ingest-ls":
|
||||
config.hostname = None
|
||||
config.hostname = ""
|
||||
elif args.mode == "ingest-rclone-json":
|
||||
config.hostname = None
|
||||
config.hostname = ""
|
||||
args.remote_base = args.remote_base[0]
|
||||
elif args.mode is None:
|
||||
parser.print_help()
|
||||
|
|
|
|||
|
|
@ -17,10 +17,15 @@ asdict = asdict
|
|||
StatType = Literal["d", "f", "l", "-"]
|
||||
|
||||
|
||||
def _mode(st_mode: int) -> StatType:
|
||||
mode: StatType = _modes.get(S_IFMT(st_mode), "-") # type: ignore[assignment]
|
||||
return mode
|
||||
|
||||
|
||||
@dataclass
|
||||
class File:
|
||||
id: int
|
||||
parent_id: int
|
||||
id: "int | None"
|
||||
parent_id: "int | None"
|
||||
added: datetime
|
||||
updated: datetime
|
||||
location: str
|
||||
|
|
@ -35,6 +40,8 @@ class File:
|
|||
now = datetime.now()
|
||||
pstat = entry.stat(follow_symlinks=False)
|
||||
return cls(
|
||||
id=None,
|
||||
parent_id=None,
|
||||
added=now,
|
||||
updated=now,
|
||||
location=entry.path,
|
||||
|
|
@ -42,7 +49,7 @@ class File:
|
|||
stat_bytes=pstat.st_size,
|
||||
# stat_changed=datetime.fromtimestamp(pstat.st_ctime),
|
||||
stat_modified=datetime.fromtimestamp(pstat.st_mtime),
|
||||
stat_type=_modes.get(S_IFMT(pstat.st_mode), "-"), # type: ignore
|
||||
stat_type=_mode(pstat.st_mode),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
|
@ -50,6 +57,8 @@ class File:
|
|||
now = datetime.now()
|
||||
pstat = os.stat(path, follow_symlinks=False)
|
||||
return cls(
|
||||
id=None,
|
||||
parent_id=None,
|
||||
added=now,
|
||||
updated=now,
|
||||
location=os.path.abspath(path),
|
||||
|
|
@ -57,7 +66,7 @@ class File:
|
|||
stat_bytes=pstat.st_size,
|
||||
# stat_changed=datetime.fromtimestamp(pstat.st_ctime),
|
||||
stat_modified=datetime.fromtimestamp(pstat.st_mtime),
|
||||
stat_type=_modes.get(S_IFMT(pstat.st_mode), "-"), # type: ignore
|
||||
stat_type=_mode(pstat.st_mode),
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
|
|
@ -82,5 +91,5 @@ class File:
|
|||
hostname=config.hostname,
|
||||
stat_bytes=pstat.st_size,
|
||||
stat_modified=datetime.fromtimestamp(pstat.st_mtime),
|
||||
stat_type=_modes.get(S_IFMT(pstat.st_mode), "-"),
|
||||
stat_type=_mode(pstat.st_mode),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue