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":
|
elif args.mode == "ingest-db":
|
||||||
args.infile = utils.abspath(args.infile)
|
args.infile = utils.abspath(args.infile)
|
||||||
elif args.mode == "ingest-ls":
|
elif args.mode == "ingest-ls":
|
||||||
config.hostname = None
|
config.hostname = ""
|
||||||
elif args.mode == "ingest-rclone-json":
|
elif args.mode == "ingest-rclone-json":
|
||||||
config.hostname = None
|
config.hostname = ""
|
||||||
args.remote_base = args.remote_base[0]
|
args.remote_base = args.remote_base[0]
|
||||||
elif args.mode is None:
|
elif args.mode is None:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,15 @@ asdict = asdict
|
||||||
StatType = Literal["d", "f", "l", "-"]
|
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
|
@dataclass
|
||||||
class File:
|
class File:
|
||||||
id: int
|
id: "int | None"
|
||||||
parent_id: int
|
parent_id: "int | None"
|
||||||
added: datetime
|
added: datetime
|
||||||
updated: datetime
|
updated: datetime
|
||||||
location: str
|
location: str
|
||||||
|
|
@ -35,6 +40,8 @@ class File:
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
pstat = entry.stat(follow_symlinks=False)
|
pstat = entry.stat(follow_symlinks=False)
|
||||||
return cls(
|
return cls(
|
||||||
|
id=None,
|
||||||
|
parent_id=None,
|
||||||
added=now,
|
added=now,
|
||||||
updated=now,
|
updated=now,
|
||||||
location=entry.path,
|
location=entry.path,
|
||||||
|
|
@ -42,7 +49,7 @@ class File:
|
||||||
stat_bytes=pstat.st_size,
|
stat_bytes=pstat.st_size,
|
||||||
# stat_changed=datetime.fromtimestamp(pstat.st_ctime),
|
# stat_changed=datetime.fromtimestamp(pstat.st_ctime),
|
||||||
stat_modified=datetime.fromtimestamp(pstat.st_mtime),
|
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
|
@classmethod
|
||||||
|
|
@ -50,6 +57,8 @@ class File:
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
pstat = os.stat(path, follow_symlinks=False)
|
pstat = os.stat(path, follow_symlinks=False)
|
||||||
return cls(
|
return cls(
|
||||||
|
id=None,
|
||||||
|
parent_id=None,
|
||||||
added=now,
|
added=now,
|
||||||
updated=now,
|
updated=now,
|
||||||
location=os.path.abspath(path),
|
location=os.path.abspath(path),
|
||||||
|
|
@ -57,7 +66,7 @@ class File:
|
||||||
stat_bytes=pstat.st_size,
|
stat_bytes=pstat.st_size,
|
||||||
# stat_changed=datetime.fromtimestamp(pstat.st_ctime),
|
# stat_changed=datetime.fromtimestamp(pstat.st_ctime),
|
||||||
stat_modified=datetime.fromtimestamp(pstat.st_mtime),
|
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
|
@staticmethod
|
||||||
|
|
@ -82,5 +91,5 @@ class File:
|
||||||
hostname=config.hostname,
|
hostname=config.hostname,
|
||||||
stat_bytes=pstat.st_size,
|
stat_bytes=pstat.st_size,
|
||||||
stat_modified=datetime.fromtimestamp(pstat.st_mtime),
|
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