mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-27 21:24:16 -04:00
switch .is_dir and .exists for os.access to avoid PermissionError on startup
This commit is contained in:
parent
c3dd0f22e5
commit
de2ab43f7f
22 changed files with 119 additions and 97 deletions
|
@ -3,7 +3,6 @@ __description__ = 'Plain Text'
|
|||
|
||||
from typing import IO, Iterable
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
from ..index.schema import Link
|
||||
from archivebox.misc.util import (
|
||||
|
@ -22,19 +21,20 @@ def parse_generic_txt_export(text_file: IO[str], **_kwargs) -> Iterable[Link]:
|
|||
if not line.strip():
|
||||
continue
|
||||
|
||||
# if the line is a local file path that resolves, then we can archive it
|
||||
try:
|
||||
if Path(line).exists():
|
||||
yield Link(
|
||||
url=line,
|
||||
timestamp=str(datetime.now(timezone.utc).timestamp()),
|
||||
title=None,
|
||||
tags=None,
|
||||
sources=[text_file.name],
|
||||
)
|
||||
except (OSError, PermissionError):
|
||||
# nvm, not a valid path...
|
||||
pass
|
||||
# # if the line is a local file path that resolves, then we can archive it
|
||||
# if line.startswith('file://'):
|
||||
# try:
|
||||
# if Path(line).exists():
|
||||
# yield Link(
|
||||
# url=line,
|
||||
# timestamp=str(datetime.now(timezone.utc).timestamp()),
|
||||
# title=None,
|
||||
# tags=None,
|
||||
# sources=[text_file.name],
|
||||
# )
|
||||
# except (OSError, PermissionError):
|
||||
# # nvm, not a valid path...
|
||||
# pass
|
||||
|
||||
# otherwise look for anything that looks like a URL in the line
|
||||
for url in find_all_urls(line):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue